From 121512a8232e62b32557161bdf40e41e294f47a8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 1 Apr 2024 15:41:24 +0700 Subject: feedback purchasing job --- indoteknik_custom/models/automatic_purchase.py | 1 + indoteknik_custom/models/purchase_order.py | 16 ++++++++++++++-- indoteknik_custom/models/purchase_order_sales_match.py | 3 ++- indoteknik_custom/models/purchasing_job_multi_update.py | 6 +++--- indoteknik_custom/views/purchase_order.xml | 8 ++++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 6acc8424..2e080bcf 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -244,6 +244,7 @@ class AutomaticPurchase(models.Model): 'product_id': sale_order.product_id.id, 'qty_so': sale_order.qty_so, 'qty_po': sale_order.qty_po, + 'margin_so': sale_order.sale_line_id.item_percent_margin } po_matches_so_line = self.env['purchase.order.sales.match'].create([matches_so_line]) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 1cdf5094..49e121e4 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -54,6 +54,16 @@ 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) from_apo = fields.Boolean(string='From APO') + approval_edit_line = fields.Boolean(string='Approval Edit Line') + + def approve_edit_line(self): + self.approval_edit_line = True + + @api.constrains('order_line') + def constrains_order_line(self): + for purchase in self: + if purchase.from_apo and not purchase.approval_edit_line: + raise UserError('Harus approve edit line terlebih dahulu, minta ke purchasing manager') @api.model def action_multi_cancel(self): @@ -325,8 +335,10 @@ class PurchaseOrder(models.Model): if self.total_percent_margin < self.total_so_percent_margin and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: raise UserError("Beda Margin dengan Sales, harus approval Manager") - if not self.sale_order_id and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: - raise UserError("Tidak ada link dengan SO, harus approval Manager") + if not self.from_apo: + if not self.sale_order_id and not self.env.user.is_purchasing_manager and not self.env.user.is_leader: + raise UserError("Tidak ada link dengan SO, harus approval Manager") + send_email = False self.add_product_to_pricelist() for line in self.order_line: diff --git a/indoteknik_custom/models/purchase_order_sales_match.py b/indoteknik_custom/models/purchase_order_sales_match.py index 02c19b1f..d8b11481 100644 --- a/indoteknik_custom/models/purchase_order_sales_match.py +++ b/indoteknik_custom/models/purchase_order_sales_match.py @@ -19,4 +19,5 @@ class PurchaseOrderSalesMatch(models.Model): salesperson_id = fields.Many2one('res.users', string='Sales') product_id = fields.Many2one('product.product', string='Product') qty_so = fields.Float(string='Qty SO') - qty_po = fields.Float(string='Qty PO') \ No newline at end of file + qty_po = fields.Float(string='Qty PO') + margin_so = fields.Float(string='Margin SO') \ No newline at end of file diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py index e7f19e50..f3d07597 100644 --- a/indoteknik_custom/models/purchasing_job_multi_update.py +++ b/indoteknik_custom/models/purchasing_job_multi_update.py @@ -12,14 +12,14 @@ class PurchasingJobMultiUpdate(models.TransientModel): product_ids = self._context['product_ids'] products = self.env['v.purchasing.job'].browse(product_ids) for product in products: - if product.status_apo == 'apo': - raise UserError('Ada Purchase Order yang statusnya APO, proses dulu') - + # if product.status_apo == 'apo': + # raise UserError('Ada Purchase Order yang statusnya APO, proses dulu') purchasing_job_state = self.env['purchasing.job.state'] purchasing_job_state.create({ 'purchasing_job_id': product.id, 'status_apo': 'apo', }) + apo = products.generate_request_po() return { 'name': _('Automatic Purchase'), diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index baff620c..68622a8e 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -20,6 +20,11 @@ type="object" attrs="{'invisible': [('approval_status', '=', 'approved')]}" /> + @@ -87,6 +92,8 @@ + + @@ -217,6 +224,7 @@ + -- cgit v1.2.3