summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/sale_order_line.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py
index 5e01067a..f218757b 100644
--- a/indoteknik_custom/models/sale_order_line.py
+++ b/indoteknik_custom/models/sale_order_line.py
@@ -251,12 +251,9 @@ class SaleOrderLine(models.Model):
# purchase_price = self.env['purchase.pricelist'].search(
# query, limit=1, order='count_trx_po desc, count_trx_po_vendor desc')
price, taxes, vendor_id = self._get_purchase_price(line.product_id)
- line.vendor_md_id = vendor_id
line.vendor_id = vendor_id
- line.margin_md = line.item_percent_margin
line.tax_id = line.order_id.sales_tax_id
# price, taxes = line._get_valid_purchase_price(purchase_price)
- line.purchase_price_md = price
line.purchase_price = price
line.purchase_tax_id = taxes
@@ -270,6 +267,14 @@ class SaleOrderLine(models.Model):
line.name = line_name
line.weight = line.product_id.weight
+ @api.constrains('vendor_id')
+ def _check_vendor_id(self):
+ for line in self:
+ price, taxes, vendor_id = self._get_purchase_price(line.product_id)
+ line.vendor_md_id = vendor_id
+ line.margin_md = line.item_percent_margin
+ line.purchase_price_md = price
+
def compute_delivery_amt_line(self):
for line in self:
try: