summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-09-28 16:25:01 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-09-28 16:25:01 +0700
commit597d6458234a14bd20e7fba8a0ceb07168423d2a (patch)
treed3af413c17daa60486fa52ed63d582e3ac66e5da /indoteknik_custom/models/purchase_order.py
parent009be5919cb5835f98f5882f69b3a7652e8ec658 (diff)
Update purchase_order.py, purchase_order_line.py, and 3 more files...
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index acc737e8..60121919 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -14,6 +14,18 @@ class PurchaseOrder(models.Model):
], string='Approval Status', readonly=True, copy=False, index=True, tracking=3)
count_line_product = fields.Float('Count Line Product', compute='compute_count_line_product')
delivery_amount = fields.Float('Delivery Amount', compute='compute_delivery_amount')
+ total_margin = fields.Float(
+ 'Margin', compute='compute_total_margin',
+ help="Total Margin in Sales Order Header")
+ total_percent_margin = fields.Float(
+ 'Margin%', compute='compute_total_margin',
+ help="Total % Margin in Sales Order Header")
+ total_so_margin = fields.Float(
+ 'SO Margin', compute='compute_total_margin',
+ help="Total Margin in Sales Order Header")
+ total_so_percent_margin = fields.Float(
+ 'SO Margin%', compute='compute_total_margin',
+ help="Total % Margin in Sales Order Header")
def get_procurement_status(self):
for purchase_order in self:
@@ -136,3 +148,13 @@ class PurchaseOrder(models.Model):
res = super(PurchaseOrder, self).button_cancel()
self.approval_status = False
return res
+
+ def compute_total_margin(self):
+ if not self.order_line:
+ self.total_margin = 0
+ self.total_percent_margin = 0
+ self.total_so_margin = 0
+ self.total_so_percent_margin = 0
+ return
+ for line in self.order_line:
+ line.compute_item_margin()