diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-20 17:02:27 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-20 17:02:27 +0700 |
| commit | 4b26288b29d738f37b7e5eba0c88ab19f24b5c1f (patch) | |
| tree | cea0d927e694ff3a37bd0bd029201fb9dd9967ed | |
| parent | 69679a78e128f22e0568c2b3e40b61f6065bf785 (diff) | |
| parent | fe7087deb15d6dfa0d815c2e391cce9e753fd3cf (diff) | |
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 509e3d1c..d362d573 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -110,9 +110,13 @@ class SaleOrderLine(models.Model): elif self.product_id.categ_id.id == 34: # finish good / manufacturing only cost = self.product_id.standard_price self.purchase_price = cost + elif self.product_id.x_manufacture.override_vendor_id: + purchase_price = self.env['purchase.pricelist'].search( + [('vendor_id', '=', self.product_id.x_manufacture.override_vendor_id.id), + ('product_id', '=', self.product_id.id)], + limit=1, order='count_trx_po desc, count_trx_po_vendor desc') + self.purchase_price = self._get_valid_purchase_price(purchase_price) else: - # purchase_price = self.env['purchase.pricelist'].search( - # [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1) purchase_price = self.env['purchase.pricelist'].search( [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1, order='count_trx_po desc, count_trx_po_vendor desc') @@ -136,11 +140,15 @@ class SaleOrderLine(models.Model): super(SaleOrderLine, self).product_id_change() for line in self: if line.product_id and line.product_id.type == 'product': + query = [('product_id', '=', line.product_id.id)] + if line.product_id.x_manufacture.override_vendor_id: + query = [('product_id', '=', line.product_id.id), + ('vendor_id', '=', line.product_id.x_manufacture.override_vendor_id.id)] purchase_price = self.env['purchase.pricelist'].search( - [('product_id', '=', self.product_id.id)], limit=1, order='count_trx_po desc, count_trx_po_vendor desc') + query, limit=1, order='count_trx_po desc, count_trx_po_vendor desc') line.vendor_id = purchase_price.vendor_id line.tax_id = line.order_id.sales_tax_id - line.purchase_price = self._get_valid_purchase_price(purchase_price) + line.purchase_price = line._get_valid_purchase_price(purchase_price) line_name = ('[' + line.product_id.default_code + ']' if line.product_id.default_code else '') + ' ' + (line.product_id.name if line.product_id.name else '') + ' ' + \ ('(' + line.product_id.product_template_attribute_value_ids.name + ')' if line.product_id.product_template_attribute_value_ids.name else '') + ' ' + \ |
