From 1371df38b6818960e6e9520ae783f041694209d8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 11 Sep 2024 13:39:13 +0700 Subject: ongkos kirim po --- indoteknik_custom/models/purchase_order.py | 13 +++++++++++++ indoteknik_custom/views/purchase_order.xml | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 83e401b7..edcbbb19 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -31,6 +31,7 @@ class PurchaseOrder(models.Model): ('approved', 'Approved'), ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) delivery_amount = fields.Float('Delivery Amount', compute='compute_delivery_amount') + delivery_amt = fields.Float('Delivery Amt') total_margin = fields.Float( 'Margin', compute='compute_total_margin', help="Total Margin in Sales Order Header") @@ -67,6 +68,14 @@ class PurchaseOrder(models.Model): ], string='Printed?', copy=False, tracking=True) date_done_picking = fields.Datetime(string='Date Done Picking', compute='get_date_done') bills_dp_id = fields.Many2one('account.move', string='Bills DP') + grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total') + + def _compute_grand_total(self): + for order in self: + if order.delivery_amt: + order.grand_total = order.delivery_amt + order.amount_total + else: + order.grand_total = order.amount_total def create_bill_dp(self): if not self.env.user.is_accounting: @@ -671,6 +680,8 @@ class PurchaseOrder(models.Model): purchase_price = line.price_subtotal if line.order_id.delivery_amount > 0: purchase_price += line.delivery_amt_line + if line.order_id.delivery_amt > 0: + purchase_price += line.order_id.delivery_amt real_item_margin = sales_price - purchase_price sum_margin += real_item_margin @@ -713,6 +724,8 @@ class PurchaseOrder(models.Model): purchase_price = po_line.price_subtotal / po_line.product_qty * line.qty_po if line.purchase_order_id.delivery_amount > 0: purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po + if line.purchase_order_id.delivery_amt > 0: + purchase_price += line.purchase_order_id.delivery_amt real_item_margin = sales_price - purchase_price sum_margin += real_item_margin diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 9ded8308..6bc97bbf 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -37,7 +37,10 @@ - + + + + @@ -45,6 +48,7 @@ + -- cgit v1.2.3