summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-11 13:39:13 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-11 13:39:13 +0700
commit1371df38b6818960e6e9520ae783f041694209d8 (patch)
tree01ac51459bf52bbbfd4b3f8605c904f4e3917031 /indoteknik_custom/models
parentb61d191e9d5663acb81338de133789fd0c43bdf0 (diff)
ongkos kirim po
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py13
1 files changed, 13 insertions, 0 deletions
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