diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-02 14:07:43 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2024-02-02 14:07:43 +0700 |
| commit | c26ea43e1d8c3c5bfffb94bc1432589a9f2815c9 (patch) | |
| tree | 86b02e1b4d362617b168f4cb0a5777be483d07fb | |
| parent | 8bc43445f1d0b70d54d0a45830e04d0fcc406fbe (diff) | |
| parent | f5edc62d22c9a3973261ad289a11e189f0866f52 (diff) | |
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/commision.py | 17 | ||||
| -rw-r--r-- | indoteknik_custom/models/logbook_sj.py | 117 | ||||
| -rw-r--r-- | indoteknik_custom/models/po_multi_cancel.py | 22 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 23 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 28 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_pricelist.py | 27 | ||||
| -rw-r--r-- | indoteknik_custom/models/report_logbook_sj.py | 34 | ||||
| -rw-r--r-- | indoteknik_custom/models/requisition.py | 303 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 7 | ||||
| -rw-r--r-- | indoteknik_custom/views/logbook_sj.xml | 52 | ||||
| -rw-r--r-- | indoteknik_custom/views/po_multi_cancel.xml | 31 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 13 | ||||
| -rw-r--r-- | indoteknik_custom/views/report_logbook_sj.xml | 90 |
15 files changed, 594 insertions, 176 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index c7e65b37..b8a5f6f8 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -107,6 +107,9 @@ 'views/purchase_order_multi_update.xml', 'views/purchase_order_multi_confirm.xml', 'views/invoice_reklas_penjualan.xml', + 'views/po_multi_cancel.xml', + 'views/logbook_sj.xml', + 'views/report_logbook_sj.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 76387ff8..49e3567c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -98,3 +98,6 @@ from . import purchase_order_multi_update from . import invoice_reklas_penjualan from . import purchase_order_multi_confirm from . import stock_quant +from . import po_multi_cancel +from . import logbook_sj +from . import report_logbook_sj diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index a9ad624c..955d1634 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -159,12 +159,14 @@ class CustomerCommision(models.Model): @api.constrains('commision_percent') def _onchange_commision_percent(self): print('masuk onchange commision percent') - self.commision_amt = self.commision_percent * self.total_dpp // 100 + if self.commision_amt == 0: + self.commision_amt = self.commision_percent * self.total_dpp // 100 - # @api.constrains('commision_amt') - # def _onchange_commision_amt(self): - # print('masuk onchange commision amt') - # self.commision_percent = (self.commision_amt / self.grand_total * 100) + @api.constrains('commision_amt') + def _onchange_commision_amt(self): + print('masuk onchange commision amt') + if self.commision_percent == 0: + self.commision_percent = (self.commision_amt / self.total_dpp * 100) def _compute_total_dpp(self): for data in self: @@ -176,6 +178,11 @@ class CustomerCommision(models.Model): @api.model def create(self, vals): vals['number'] = self.env['ir.sequence'].next_by_code('customer.commision') or '0' + # if vals['commision_amt'] > 0: + # commision_amt = vals['commision_amt'] + # total_dpp = vals['total_dpp'] + # commision_percent = commision_amt / total_dpp * 100 + # vals['commision_percent'] = commision_percent result = super(CustomerCommision, self).create(vals) return result diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py new file mode 100644 index 00000000..567f1ae3 --- /dev/null +++ b/indoteknik_custom/models/logbook_sj.py @@ -0,0 +1,117 @@ +from odoo import models, fields, api, _ +from odoo.exceptions import UserError +from pytz import timezone +from datetime import datetime + +class LogbookSJ(models.TransientModel): + _name = 'logbook.sj' + + name = fields.Char(string='Name', default='Logbook SJ') + logbook_sj_line = fields.One2many( + comodel_name='logbook.sj.line', + inverse_name='logbook_sj_id', + string='Logbook SJ Line' + ) + + def create_logbook_sj(self): + logbook_line = self.logbook_sj_line + + current_time = datetime.utcnow() + report_logbook_ids = [] + for line in logbook_line: + nomor_sj = line.name + picking = self.env['stock.picking'].search([ + ('picking_code', '=', nomor_sj), + ]) + parameters_header = { + 'name': nomor_sj, + 'date': current_time, + 'name_picking': picking.name, + 'partner_id': picking.partner_id.id, + } + + report_logbook = self.env['report.logbook.sj'].create([parameters_header]) + + + for stock in picking.move_line_ids_without_package: + data = { + 'product_id': stock.product_id.id, + 'location_id': stock.location_id.id, + 'product_uom_qty': stock.product_uom_qty, + 'qty_done': stock.qty_done, + 'product_uom_id': stock.product_uom_id.id, + 'report_logbook_sj_id': report_logbook.id + } + self.env['report.logbook.sj.line'].create([data]) + + report_logbook_ids.append(report_logbook.id) + line.unlink() + + self.unlink() + return { + 'name': _('Report Logbook SJ'), + 'view_mode': 'tree,form', + 'res_model': 'report.logbook.sj', + 'target': 'current', + 'type': 'ir.actions.act_window', + 'domain': [('id', 'in', report_logbook_ids)], + } + +class LogbookSJLine(models.TransientModel): + _name = 'logbook.sj.line' + + name = fields.Char(string='SJ Number') + driver_id = fields.Many2one(comodel_name='res.users', string='Driver') + departure_date = fields.Char(string='Departure Date') + arrival_date = fields.Char(string='Arrival Date') + carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method') + tracking_no = fields.Char(string='Tracking No') + logbook_sj_id = fields.Many2one('logbook.sj', string='Logbook SJ') + partner_id = fields.Many2one('res.partner', string='Customer') + + @api.onchange('name') + def onchange_name(self): + current_time = datetime.now(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') + + if self.name: + if len(self.name) == 13: + self.name = self.name[:-1] + picking = self.env['stock.picking'].search([('picking_code', '=', self.name)], limit=1) + if picking: + if picking.driver_id: + self.driver_id = picking.driver_id + else: + self.driver_id = self.env.uid + + sale_order = False + if picking.origin: + sale_order = self.env['sale.order'].search([('name', '=', picking.origin)], limit=1) + + if sale_order.carrier_id: + self.carrier_id = sale_order.carrier_id + + self.tracking_no = picking.delivery_tracking_no + + self.partner_id = picking.partner_id + + delivery_type = self.get_delivery_type(picking.driver_departure_date, picking.driver_arrival_date) + if delivery_type != 'departure': + self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') + + if delivery_type == 'departure': + self.departure_date = current_time + elif delivery_type == 'arrival': + self.arrival_date = current_time + else: + self.arrival_date = picking.driver_arrival_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') + else: + raise UserError('Nomor DO tidak ditemukan') + + def get_delivery_type(self, driver_departure_date, driver_arrival_date): + delivery_type = 'departure' + if driver_departure_date: + delivery_type = 'arrival' + if driver_arrival_date: + delivery_type = False + + return delivery_type diff --git a/indoteknik_custom/models/po_multi_cancel.py b/indoteknik_custom/models/po_multi_cancel.py new file mode 100644 index 00000000..52c156b5 --- /dev/null +++ b/indoteknik_custom/models/po_multi_cancel.py @@ -0,0 +1,22 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class PoMultiCancel(models.TransientModel): + _name = 'po.multi.cancel' + + def save_multi_cancel_po(self): + purchase_ids = self._context['purchase_ids'] + purchase = self.env['purchase.order'].browse(purchase_ids) + purchase.button_cancel() + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'Status berhasil diubah', + 'next': {'type': 'ir.actions.act_window_close'}, + } + }
\ No newline at end of file diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index ebadff06..dc654196 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -53,10 +53,29 @@ class PurchaseOrder(models.Model): status_paid_cbd = fields.Boolean(string='Paid Status', tracking=3, help='Field ini diisi secara manual oleh Finance AP dan hanya untuk status PO CBD') revisi_po = fields.Boolean(string='Revisi', tracking=3) + @api.model + def action_multi_cancel(self): + for purchase in self: + purchase.update({ + 'state': 'cancel', + }) + + if purchase.state == 'cancel': + purchase.update({ + 'approval_status': False, + }) + + def open_form_multi_cancel(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_po_multi_cancel') + action['context'] = { + 'purchase_ids': [x.id for x in self] + } + return action + def delete_line(self): - lines_to_delete = self.order_line.filtered(lambda line: line.delete_line) + lines_to_delete = self.order_line.filtered(lambda line: line.suggest == 'masih cukup') if not lines_to_delete: - raise UserError('Tidak ada item yang dipilih') + raise UserError('Tidak ada item yang masih cukup') lines_to_delete.unlink() def open_form_multi_confirm_po(self): diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 465944d5..f1881942 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -36,6 +36,34 @@ class PurchaseOrderLine(models.Model): note = fields.Char(string='Note') qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') delete_line = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') + is_edit_product_qty = fields.Boolean(string='Is Edit Product Qty', compute='_compute_is_edit_product_qty') + + def _compute_is_edit_product_qty(self): + for line in self: + + if line.order_id.state in ['draft']: + is_valid = True + else: + is_valid = False + + line.is_edit_product_qty = is_valid + + # @api.constrains('product_qty') + # def change_qty_po_and_qty_demand(self): + # for line in self: + # if line.order_id.state in ['draft', 'cancel'] and len(line.order_id.picking_ids) == 0: + # continue + + # for stock_picking in line.order_id.picking_ids: + # picking = self.env['stock.move'].search([ + # ('picking_id.purchase_id', '=', line.order_id.id), + # ('product_id', '=', line.product_id.id) + # ]) + + # if picking: + # picking.write({ + # 'product_uom_qty': line.product_qty + # }) def _compute_qty_reserved(self): for line in self: diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 805ebc89..67b22e4c 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -39,8 +39,7 @@ class PurchasePricelist(models.Model): if price_unit == 0: self.include_price = 0 return - # taxes = self.taxes_system_id or self.taxes_product_id - # price_unit = self.system_price or self.product_price + tax_include = taxes.price_include if taxes: if tax_include: @@ -53,18 +52,20 @@ class PurchasePricelist(models.Model): self.include_price = price_unit def _get_valid_price(self): - p_price = 0 - taxes = False + purchase_price = self + price = 0 + taxes = None + human_last_update = purchase_price.human_last_update or datetime.min + system_last_update = purchase_price.system_last_update or datetime.min - if self.system_price > 0: - if self.product_price > 0 and self.human_last_update > self.system_last_update: - p_price, taxes = self.product_price, self.taxes_product_id - else: - p_price, taxes = self.system_price, self.taxes_system_id - elif self.product_price > 0: - p_price, taxes = self.product_price, self.taxes_product_id - - return p_price, taxes + if system_last_update > human_last_update: + price = purchase_price.system_price + taxes = purchase_price.taxes_system_id + else: + price = purchase_price.product_price + taxes = purchase_price.taxes_product_id + + return price, taxes @api.constrains('vendor_id', 'product_id') def _check_duplicate_purchase_pricelist(self): diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py new file mode 100644 index 00000000..d2008608 --- /dev/null +++ b/indoteknik_custom/models/report_logbook_sj.py @@ -0,0 +1,34 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError +from pytz import timezone +from datetime import datetime + +class ReportLogbookSJ(models.Model): + _name = 'report.logbook.sj' + + name = fields.Char(string='Nomor SJ', default='Logbook SJ') + date = fields.Datetime(string='Date') + name_picking = fields.Char(string='Picking Name') + partner_id = fields.Many2one('res.partner', string='Customer') + approve_by_finance = fields.Boolean(string='Approve By Finance') + report_logbook_sj_line = fields.One2many( + comodel_name='report.logbook.sj.line', + inverse_name='report_logbook_sj_id', + string='Logbook SJ Line' + ) + + def approve(self): + if self.env.user.is_accounting: + self.approve_by_finance = True + else: + raise UserError('Hanya Accounting yang bisa Approve') + +class ReportLogbookSJLine(models.Model): + _name = 'report.logbook.sj.line' + + product_id = fields.Many2one(comodel_name='product.product', string='Product') + location_id = fields.Many2one(comodel_name='stock.location', string='From') + product_uom_qty = fields.Float(string='Reserved') + qty_done = fields.Float(string='Done') + product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure') + report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ')
\ No newline at end of file diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 7ceff6e5..2b148c96 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -1,6 +1,7 @@ -from odoo import models, fields, api +from odoo import models, fields, api, _ from odoo.exceptions import UserError from datetime import datetime +import math import logging _logger = logging.getLogger(__name__) @@ -28,121 +29,40 @@ class Requisition(models.Model): result = super(Requisition, self).create(vals) return result - # def create_requisition_from_sales_with_price(self): - # if self.requisition_lines: - # raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') - # if not self.sale_order_id: - # raise UserError('Sale Order harus diisi') - # if self.is_po: - # raise UserError('Sudah jadi PO, tidak bisa di create ulang PO nya') - - # count = 0 - # for order_line in self.sale_order_id.order_line: - # # get purchase price altama, if nothing, then get other cheaper, if nothing then last po - # purchase_price = order_line.purchase_price - # vendor_id = order_line.vendor_id.id - - # # get qty available bandengan - # qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty - # suggest = 'harus beli' - # if qty_available > order_line.product_qty: - # suggest = 'masih cukup' - - # self.env['requisition.line'].create([{ - # 'requisition_id': self.id, - # 'partner_id': vendor_id, - # 'brand_id': order_line.product_id.product_tmpl_id.x_manufacture.id, - # 'product_id': order_line.product_id.id, - # 'qty_purchase': order_line.product_uom_qty, - # 'tax_id': order_line.purchase_tax_id.id, - # 'price_unit': purchase_price, - # 'subtotal': purchase_price * order_line.product_uom_qty, - # 'source': 'sales', - # 'qty_available_store': qty_available, - # 'suggest': suggest, - # }]) - # count+=1 - # _logger.info('Create Requisition %s' % order_line.product_id.name) - # self.notification = "Requisition Created %s lines" % count - - # def create_requisition_from_sales(self): - # if self.requisition_lines: - # raise UserError('Sudah digenerate sebelumnya, hapus line terlebih dahulu') - # if not self.sale_order_id: - # raise UserError('Sale Order harus diisi') - # if self.is_po: - # raise UserError('Sudah jadi PO, tidak bisa di create ulang PO nya') - - # # old_requisition = self.env['requisition'].search([('sale_order_id', '=', self.sale_order_id.id)], limit=1) - # # if old_requisition: - # # raise UserError('Sudah pernah jadi Requisition') - - # count = 0 - # for order_line in self.sale_order_id.order_line: - # # get purchase price altama, if nothing, then get other cheaper, if nothing then last po - # purchase_price = 0 - # vendor_id = 0 - - # # get qty available bandengan - # qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty - # suggest = 'harus beli' - # if qty_available > order_line.product_qty: - # suggest = 'masih cukup' - - # purchase_pricelist = self.env['purchase.pricelist'].search([ - # ('product_id.id', '=', order_line.product_id.id), - # ('vendor_id.id', '=', 5571) - # ], order='product_price asc', limit=1) - # purchase_price = purchase_pricelist.product_price - # vendor_id = purchase_pricelist.vendor_id.id - # source = 'PriceList' - - # if not purchase_price or purchase_price <= 0: - # purchase_pricelist = self.env['purchase.pricelist'].search([('product_id', '=', order_line.product_id.id)], order='product_price asc', limit=1) - # purchase_price = purchase_pricelist.product_price - # vendor_id = purchase_pricelist.vendor_id.id - # source = 'PriceList' - - # if not purchase_price or purchase_price <= 0: - # last_po_line = self.env['purchase.order.line'].search([('product_id', '=', order_line.product_id.id), ('order_id.state', '=', 'done')], order='id desc', limit=1) - # purchase_price = last_po_line.price_unit - # vendor_id = last_po_line.order_id.partner_id.id - # source = 'LastPO' - - # if not purchase_price or purchase_price <= 0: - # purchase_price = 0 - # vendor_id = 5571 - # source = 'Nothing' - - # self.env['requisition.line'].create([{ - # 'requisition_id': self.id, - # 'partner_id': vendor_id, - # 'brand_id': order_line.product_id.product_tmpl_id.x_manufacture.id, - # 'product_id': order_line.product_id.id, - # 'qty_purchase': order_line.product_uom_qty, - # 'tax_id': order_line.purchase_tax_id.id, - # 'price_unit': purchase_price, - # 'subtotal': purchase_price * order_line.product_uom_qty, - # 'source': source, - # 'qty_available_store': qty_available, - # 'suggest': suggest, - # }]) - # count+=1 - # _logger.info('Create Requisition %s' % order_line.product_id.name) - # self.notification = "Requisition Created %s lines" % count - + def create_po_from_requisition(self): if not self.requisition_lines: raise UserError('Tidak ada Lines, belum bisa create PO') if self.is_po: raise UserError('Sudah pernah di create PO') - current_time = datetime.now() - vendor_ids = self.env['requisition.line'].read_group([('requisition_id', '=', self.id), ('partner_id', '!=', False)], fields=['partner_id'], groupby=['partner_id']) - counter_po_number = 0 + vendor_ids = self.env['requisition.line'].read_group([ + ('requisition_id', '=', self.id), + ('partner_id', '!=', False) + ], fields=['partner_id'], groupby=['partner_id']) + + po_ids = [] for vendor in vendor_ids: - param_header = { - 'partner_id': vendor['partner_id'][0], + result_po = self.create_po_by_vendor(vendor['partner_id'][0]) + po_ids += result_po + return { + 'name': _('Purchase Order'), + 'view_mode': 'tree,form', + 'res_model': 'purchase.order', + 'target': 'current', + 'type': 'ir.actions.act_window', + 'domain': [('id', 'in', po_ids)], + } + + def create_po_by_vendor(self, vendor_id): + current_time = datetime.now() + + PRODUCT_PER_PO = 20 + + requisition_line = self.env['requisition.line'] + + param_header = { + 'partner_id': vendor_id, # 'partner_ref': self.sale_order_id.name, 'currency_id': 12, 'user_id': self.env.user.id, @@ -152,54 +72,131 @@ class Requisition(models.Model): 'sale_order_id': self.sale_order_id.id, 'note_description': 'from Purchase Requisition' } - # new_po = self.env['purchase.order'].create([param_header]) - products_vendors = self.env['requisition.line'].search([ - ('requisition_id', '=', self.id), - ('partner_id', '=', vendor['partner_id'][0]), - ('qty_purchase', '>', 0) - ], order='brand_id') - count = brand_id = 0 - - for product in products_vendors: - if count == 200 or brand_id != product.brand_id.id: - count = 0 - counter_po_number += 1 - new_po = self.env['purchase.order'].create([param_header]) - new_po.name = new_po.name + "/R/"+str(counter_po_number) - self.env['requisition.purchase.match'].create([{ - 'requisition_id': self.id, - 'order_id': new_po.id - }]) - self.env.cr.commit() - # else: - # new_po = self.env['purchase.order'].create([param_header]) - brand_id = product.brand_id.id - count += 10 - - # qty_available = product.product_id.qty_onhand_bandengan + product.product_id.qty_incoming_bandengan - product.product_id.outgoing_qty - # suggest = 'harus beli' - # if qty_available > product.qty_purchase: - # suggest = 'masih cukup' - - tax = [22] + domain = [ + ('requisition_id', '=', self.id), + ('partner_id', '=', vendor_id), + ('qty_purchase', '>', 0) + ] + + products_len = requisition_line.search_count(domain) + page = math.ceil(products_len / PRODUCT_PER_PO) + po_ids = [] + # i start from zero (0) + for i in range(page): + new_po = self.env['purchase.order'].create([param_header]) + new_po.name = new_po.name + "/R/" + str(i + 1) + po_ids.append(new_po.id) + lines = requisition_line.search( + domain, + offset=i * PRODUCT_PER_PO, + limit=PRODUCT_PER_PO + ) + tax = [22] + + for line in lines: + product = line.product_id param_line = { - 'order_id': new_po.id, - 'sequence': count, - 'product_id': product.product_id.id, - 'product_qty': product.qty_purchase, - 'product_uom_qty': product.qty_purchase, - 'price_unit': product.price_unit, + 'order_id' : new_po.id, + 'product_id': product.id, + 'product_qty': line.qty_purchase, + 'product_uom_qty': line.qty_purchase, + 'name': product.name, + 'price_unit': line.price_unit, 'taxes_id': tax, - # 'qty_available_store': qty_available, - # 'suggest': suggest, } - new_line = self.env['purchase.order.line'].create([param_line]) - product.current_po_id = new_po.id - product.current_po_line_id = new_line.id - _logger.info('Create PO Line %s' % product.product_id.name) - # self.notification = self.notification + ' %s' % new_po.name - self.is_po = True + new_po_line = self.env['purchase.order.line'].create([param_line]) + line.current_po_id = new_po.id + line.current_po_line_id = new_po_line.id + return po_ids + + # def create_po_from_requisition(self): + # if not self.requisition_lines: + # raise UserError('Tidak ada Lines, belum bisa create PO') + # if self.is_po: + # raise UserError('Sudah pernah di create PO') + # current_time = datetime.now() + # vendor_ids = self.env['requisition.line'].read_group([('requisition_id', '=', self.id), ('partner_id', '!=', False)], fields=['partner_id'], groupby=['partner_id']) + + # counter_po_number = 0 + # po_ids = [] + # for vendor in vendor_ids: + # param_header = { + # 'partner_id': vendor['partner_id'][0], + # # 'partner_ref': self.sale_order_id.name, + # 'currency_id': 12, + # 'user_id': self.env.user.id, + # 'company_id': 1, # indoteknik dotcom gemilang + # 'picking_type_id': 28, # indoteknik bandengan receipts + # 'date_order': current_time, + # 'sale_order_id': self.sale_order_id.id, + # 'note_description': 'from Purchase Requisition' + # } + # param_requisition_line = [ + # ('requisition_id', '=', self.id), + # ('partner_id', '=', vendor['partner_id'][0]), + # ('qty_purchase', '>', 0) + # ] + # # new_po = self.env['purchase.order'].create([param_header]) + # products_vendors = self.env['requisition.line'].search(, order='brand_id') + # count = brand_id = 0 + + # for product in products_vendors: + # if count > 200 or brand_id != product.brand_id.id: + # continue + + # count = 0 + # counter_po_number += 1 + # new_po = self.env['purchase.order'].create([param_header]) + # new_po.name = new_po.name + "/R/"+str(counter_po_number) + # self.env['requisition.purchase.match'].create([{ + # 'requisition_id': self.id, + # 'order_id': new_po.id + # }]) + # po_ids.append(new_po.id) + # self.env.cr.commit() + # # else: + # # new_po = self.env['purchase.order'].create([param_header]) + # brand_id = product.brand_id.id + # count += 10 + + # # qty_available = product.product_id.qty_onhand_bandengan + product.product_id.qty_incoming_bandengan - product.product_id.outgoing_qty + # # suggest = 'harus beli' + # # if qty_available > product.qty_purchase: + # # suggest = 'masih cukup' + + # tax = [22] + + # param_line = { + + # 'sequence': count, + # 'product_id': product.product_id.id, + # 'product_qty': product.qty_purchase, + # 'product_uom_qty': product.qty_purchase, + # 'price_unit': product.price_unit, + # 'taxes_id': tax, + # # 'qty_available_store': qty_available, + # # 'suggest': suggest, + # } + # new_line = self.env['purchase.order.line'].create([param_line]) + # if new_po: + # new_line.write({ + # 'order_id': new_po.id, + # }) + # product.current_po_id = new_po.id + # product.current_po_line_id = new_line.id + # _logger.info('Create PO Line %s' % product.product_id.name) + # # self.notification = self.notification + ' %s' % new_po.name + # self.is_po = True + # if po_ids: + # return { + # 'name': _('Purchase Order'), + # 'view_mode': 'tree,form', + # 'res_model': 'purchase.order', + # 'target': 'current', + # 'type': 'ir.actions.act_window', + # 'domain': [('id', 'in', po_ids)], + # } class RequisitionLine(models.Model): _name = 'requisition.line' diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 8d014b69..31503dbe 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -88,4 +88,9 @@ access_sale_advance_payment_inv,access.sale.advance.payment.inv,model_sale_advan access_purchase_order_multi_update,access.purchase.order.multi_update,model_purchase_order_multi_update,,1,1,1,1 access_invoice_reklas_penjualan,access.invoice.reklas.penjualan,model_invoice_reklas_penjualan,,1,1,1,1 access_invoice_reklas_penjualan_line,access.invoice.reklas.penjualan.line,model_invoice_reklas_penjualan_line,,1,1,1,1 -access_purchase_order_multi_confirm,access.purchase.order.multi_confirm,model_purchase_order_multi_confirm,,1,1,1,1
\ No newline at end of file +access_purchase_order_multi_confirm,access.purchase.order.multi_confirm,model_purchase_order_multi_confirm,,1,1,1,1 +access_po_multi_cancel,access.po.multi.cancel,model_po_multi_cancel,,1,1,1,1 +access_logbook_sj,access.logbook.sj,model_logbook_sj,,1,1,1,1 +access_logbook_sj_line,access.logbook.sj.line,model_logbook_sj_line,,1,1,1,1 +access_report_logbook_sj,access.report.logbook.sj,model_report_logbook_sj,,1,1,1,1 +access_report_logbook_sj_line,access.report.logbook.sj.line,model_report_logbook_sj_line,,1,1,1,1 diff --git a/indoteknik_custom/views/logbook_sj.xml b/indoteknik_custom/views/logbook_sj.xml new file mode 100644 index 00000000..9eb9aa12 --- /dev/null +++ b/indoteknik_custom/views/logbook_sj.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record id="view_logbook_sj_form" model="ir.ui.view"> + <field name="name">Logbook SJ</field> + <field name="model">logbook.sj</field> + <field name="arch" type="xml"> + <form> + <sheet> + <field name="name" invisible="1"/> + <field + name="logbook_sj_line" + mode="tree" + > + <tree editable="bottom"> + <control> + <create name="add_logbook_sj_line_control" string="Add a logbook"/> + </control> + <field name="name" required="1"/> + <field name="driver_id" readonly="1"/> + <field name="departure_date" readonly="1"/> + <field name="arrival_date" readonly="1"/> + <field name="carrier_id" readonly="1"/> + <field name="tracking_no" readonly="1"/> + <field name="partner_id" readonly="1"/> + </tree> + </field> + </sheet> + <footer> + <button name="create_logbook_sj" string="Submit" type="object" default_focus="1" class="oe_highlight"/> + <button string="Cancel" class="btn btn-secondary" special="cancel" /> + </footer> + </form> + </field> + </record> + + <record id="action_logbook_sj" model="ir.actions.act_window"> + <field name="name">Logbook SJ</field> + <field name="res_model">logbook.sj</field> + <field name="type">ir.actions.act_window</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_logbook_sj_form"/> + <field name="target">new</field> + </record> + + <menuitem + action="action_logbook_sj" + id="logbook_sj" + parent="stock.menu_stock_warehouse_mgmt" + name="Logbook SJ" + sequence="1" + /> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/po_multi_cancel.xml b/indoteknik_custom/views/po_multi_cancel.xml new file mode 100644 index 00000000..c17fc5a7 --- /dev/null +++ b/indoteknik_custom/views/po_multi_cancel.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="view_po_multi_cancel_form" model="ir.ui.view"> + <field name="name">PO Multi Cancel</field> + <field name="model">po.multi.cancel</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <span>Apakah Anda Yakin Ingin Mengubah Status Menjadi Cancel?</span> + </group> + </sheet> + <footer> + <button name="save_multi_cancel_po" string="Update" type="object" default_focus="1" class="oe_highlight"/> + <button string="Cancel" class="btn btn-secondary" special="cancel" /> + </footer> + </form> + </field> + </record> + + <record id="action_po_multi_cancel" model="ir.actions.act_window"> + <field name="name">PO Multi Cancel</field> + <field name="res_model">po.multi.cancel</field> + <field name="type">ir.actions.act_window</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_po_multi_cancel_form"/> + <field name="target">new</field> + </record> + </data> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 48443057..a6f28ffa 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -52,12 +52,12 @@ </field> <field name="product_id" position="before"> <field name="line_no" attrs="{'readonly': 1}" optional="hide"/> - <field name="delete_line"/> </field> <field name="product_id" position="attributes"> <attribute name="options">{'no_create': True}</attribute> </field> <field name="product_qty" position="before"> + <field name="is_edit_product_qty" readonly="1" optional="hide"/> <field name="qty_onhand" readonly="1" optional="hide"/> <field name="qty_incoming" readonly="1" optional="hide"/> <field name="qty_outgoing" readonly="1" optional="hide"/> @@ -102,7 +102,7 @@ </xpath> <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_qty']" position="attributes"> - <attribute name="attrs">{'readonly': [], 'required': True}</attribute> + <attribute name="attrs">{'readonly': [('is_edit_product_qty', '=', False)], 'required': True}</attribute> </xpath> <xpath expr="//form/sheet/notebook/page[@name='purchase_delivery_invoice']" position="before"> @@ -213,4 +213,13 @@ <field name="code">action = records.open_form_multi_confirm_po()</field> </record> </data> + <data> + <record id="purchase_order_multi_cancel_ir_actions_server" model="ir.actions.server"> + <field name="name">Cancel PO</field> + <field name="model_id" ref="purchase.model_purchase_order"/> + <field name="binding_model_id" ref="purchase.model_purchase_order"/> + <field name="state">code</field> + <field name="code">action = records.open_form_multi_cancel()</field> + </record> + </data> </odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml new file mode 100644 index 00000000..52e00d17 --- /dev/null +++ b/indoteknik_custom/views/report_logbook_sj.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="report_logbook_sj_tree" model="ir.ui.view"> + <field name="name">report.logbook.sj.tree</field> + <field name="model">report.logbook.sj</field> + <field name="arch" type="xml"> + <tree create="0"> + <field name="name"/> + <field name="date"/> + <field name="name_picking"/> + <field name="approve_by_finance"/> + <field name="partner_id"/> + </tree> + </field> + </record> + + <record id="report_logbook_sj_line_tree" model="ir.ui.view"> + <field name="name">report.logbook.sj.line.tree</field> + <field name="model">report.logbook.sj.line</field> + <field name="arch" type="xml"> + <tree> + <field name="product_id"/> + <field name="location_id"/> + <field name="product_uom_qty"/> + <field name="qty_done"/> + <field name="product_uom_id"/> + </tree> + </field> + </record> + + <record id="report_logbook_sj_form" model="ir.ui.view"> + <field name="name">report.logbook.sj.form</field> + <field name="model">report.logbook.sj</field> + <field name="arch" type="xml"> + <form> + <header> + <button name="approve" + string="Approve" + type="object" + /> + </header> + <sheet string="Report logbook SJ"> + <div class="oe_button_box" name="button_box"/> + <group> + <group> + <field name="name" readonly="1"/> + <field name="date" readonly="1"/> + </group> + <group> + <field name="name_picking" readonly="1"/> + <field name="partner_id" readonly="1"/> + <field name="approve_by_finance" readonly="1"/> + </group> + </group> + <notebook> + <page string="Line"> + <field name="report_logbook_sj_line"/> + </page> + </notebook> + </sheet> + </form> + </field> + </record> +<!-- + <record id="view_report_logbook_sj_filter" model="ir.ui.view"> + <field name="name">report.logbook.sj.list.select</field> + <field name="model">report.logbook.sj</field> + <field name="priority" eval="15"/> + <field name="arch" type="xml"> + <search string="Search Report Logbook SJ"> + <field name="number"/> + <field name="partner_id"/> + <field name="dunning_line" string="Invoice" filter_domain="[('dunning_line.invoice_id', 'ilike', self)]"/> + </search> + </field> + </record> --> + + <record id="report_logbook_sj_action" model="ir.actions.act_window"> + <field name="name">Report Logbook SJ</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">report.logbook.sj</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem id="menu_report_logbook_sj" + name="Report Logbook SJ" + action="report_logbook_sj_action" + parent="account.menu_finance_reports" + sequence="200"/> +</odoo>
\ No newline at end of file |
