diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-01 15:41:24 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-01 15:41:24 +0700 |
| commit | 121512a8232e62b32557161bdf40e41e294f47a8 (patch) | |
| tree | e39ccddee46b7d5d8312b3975265fbf0b2382257 | |
| parent | ac526d1dbdabc894c47e28bc3689bf6893bc1dea (diff) | |
feedback purchasing job
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 16 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchase_order_sales_match.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchasing_job_multi_update.py | 6 | ||||
| -rwxr-xr-x | 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')]}" /> + <button name="approve_edit_line" + string="Approve Edit" + type="object" + attrs="{'invisible': [('from_apo', '=', False), ('approval_edit_line', '=', True)]}" + /> <button name="indoteknik_custom.action_view_uangmuka_pembelian" string="UangMuka" type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/> </button> @@ -87,6 +92,8 @@ <field name="has_active_invoice" invisible="1" /> <field name="responsible_ids" widget="many2many_tags"/> <field name="status_paid_cbd"/> + <field name="from_apo"/> + <field name="approval_edit_line"/> </field> <field name="order_line" position="attributes"> @@ -217,6 +224,7 @@ <field name="product_id" readonly="1"/> <field name="qty_so" readonly="1"/> <field name="qty_po" readonly="1"/> + <field name="margin_so" readonly="1"/> </tree> </field> </record> |
