summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-09-26 14:37:00 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-09-26 14:37:00 +0700
commit98d8bb612184f5354c076f52143afcfad4e05e6f (patch)
tree275018b3282fb56a8e8da04705d062597041b83d
parent0b48304775255b09de9c2aeba55cd958a860954c (diff)
Update sale_order.py
-rwxr-xr-xindoteknik_custom/models/sale_order.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index ad50712f..e317fb8e 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -156,3 +156,13 @@ class SaleOrderLine(models.Model):
line.item_margin = margin_per_item
# if sales_price > 0:
line.item_percent_margin = round((margin_per_item / sales_price), 2) * 100
+
+ @api.onchange('vendor_id')
+ def onchange_vendor_id(self):
+ if not self.product_id or self.product_id.type == 'service':
+ return
+ test1 = self.vendor_id.id
+ test2 = self.product_id.id
+ purchase_price = self.env['purchase.pricelist'].search(
+ [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1)
+ self.purchase_price = purchase_price.product_price