summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-09-29 19:06:49 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-09-29 19:06:49 +0700
commit1e40f3b647d6825779503858bb2ed2d0f8a4b184 (patch)
tree79085120f46c7563b8f9c1623a894f3e17889f8e /indoteknik_custom/models/purchase_order.py
parent156507bd6de73802ae9ef32d344c59184e6f923a (diff)
Update purchase_order.py, purchase_order_line.py, and 2 more files...
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index d51115f8..54ef60af 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -12,7 +12,6 @@ class PurchaseOrder(models.Model):
('pengajuan2', 'Approval Pimpinan'), #akbar - 7 temporary not used
('approved', 'Approved'),
], 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',
@@ -26,6 +25,7 @@ class PurchaseOrder(models.Model):
total_so_percent_margin = fields.Float(
'SO Margin%', compute='compute_total_margin',
help="Total % Margin in Sales Order Header")
+ amount_total_without_service = fields.Float('AmtTotalWithoutService', compute='compute_amt_total_without_service')
def get_procurement_status(self):
for purchase_order in self:
@@ -64,16 +64,16 @@ class PurchaseOrder(models.Model):
}
self.env['purchase.order.line'].sudo().create(values)
- def compute_count_line_product(self):
- for order in self:
- count = 0
- for line in order.order_line:
- if line.product_id.type == 'product':
- count += 1
- if count == 0:
- order.count_line_product = 1
- else:
- order.count_line_product = count
+ # def compute_count_line_product(self):
+ # for order in self:
+ # count = 0
+ # for line in order.order_line:
+ # if line.product_id.type == 'product':
+ # count += 1
+ # if count == 0:
+ # order.count_line_product = 1
+ # else:
+ # order.count_line_product = count
def compute_delivery_amount(self):
for order in self:
@@ -171,11 +171,11 @@ class PurchaseOrder(models.Model):
sum_so_margin += sale_order_line.item_margin
sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty
if sale_order_line.order_id.shipping_cost_covered == 'indoteknik':
- sales_price -= round((sale_order_line.order_id.delivery_amt / sale_order_line.order_id.count_line_product), 2)
+ sales_price -= sale_order_line.delivery_amt_line
sum_sales_price += sales_price
purchase_price = line.price_subtotal
if line.order_id.delivery_amount > 0:
- purchase_price += round((line.order_id.delivery_amount / line.order_id.count_line_product), 2)
+ purchase_price += line.delivery_amt_line
real_item_margin = sales_price - purchase_price
sum_margin += real_item_margin
@@ -197,3 +197,11 @@ class PurchaseOrder(models.Model):
# return
# for line in self.order_line:
# line.compute_item_margin()
+
+ def compute_amt_total_without_service(self):
+ for order in self:
+ sum_price_total = 0
+ for line in order.order_line:
+ if line.product_id.type == 'product':
+ sum_price_total += line.price_total
+ order.amount_total_without_service = sum_price_total