summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_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/sale_order.py
parent156507bd6de73802ae9ef32d344c59184e6f923a (diff)
Update purchase_order.py, purchase_order_line.py, and 2 more files...
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 5c868c67..fda76ebb 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -21,7 +21,6 @@ class SaleOrder(models.Model):
carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method')
have_visit_service = fields.Boolean(string='Have Visit Service', help='To compute is customer get visit service',
compute='_compute_have_visit_service')
- count_line_product = fields.Float('Count Line Product', compute='compute_count_line_product')
delivery_amt = fields.Float('Delivery Amt')
shipping_cost_covered = fields.Selection([
('indoteknik', 'Indoteknik'),
@@ -162,6 +161,7 @@ class SaleOrderLine(models.Model):
purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0)
purchase_tax_id = fields.Many2one('account.tax', string='Tax',
domain=['|', ('active', '=', False), ('active', '=', True)])
+ delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line')
def compute_item_margin(self):
for line in self:
@@ -175,7 +175,8 @@ class SaleOrderLine(models.Model):
sales_price = line.price_reduce_taxexcl * line.product_uom_qty
# minus with delivery if covered by indoteknik
if line.order_id.shipping_cost_covered == 'indoteknik':
- sales_price -= round((line.order_id.delivery_amt / line.order_id.count_line_product), 2)
+ sales_price -= line.delivery_amt_line
+ # sales_price -= round((line.order_id.delivery_amt / line.order_id.count_line_product), 2)
purchase_price = line.purchase_price
if line.purchase_tax_id.price_include:
@@ -205,3 +206,9 @@ class SaleOrderLine(models.Model):
[('product_id', '=', self.product_id.id)], limit=1, order='product_price ASC')
line.vendor_id = purchase_price.vendor_id
line.tax_id = line.order_id.sales_tax_id
+
+ def compute_delivery_amt_line(self):
+ for line in self:
+ contribution = round((line.price_total / line.order_id.amount_total), 2)
+ delivery_amt = line.order_id.delivery_amt
+ line.delivery_amt_line = delivery_amt * contribution