diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-10-15 12:18:34 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-10-15 12:18:34 +0700 |
| commit | ee6d5d4433a397ca5cdf3474f29bcbd0b2553736 (patch) | |
| tree | ae85ed3eedd2f76fcec722e4ccaeb5b941885782 | |
| parent | b6bf4c8b58b9311c6a6cf7f745cb42b025159759 (diff) | |
<Miqdad> SO line onchange vendor id
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index bd2600ae..1df1a058 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -247,29 +247,29 @@ class SaleOrderLine(models.Model): margin_per_item = sales_price - purchase_price line.item_before_margin = margin_per_item - @api.onchange('vendor_id') - def onchange_vendor_id(self): - # TODO : need to change this logic @stephan - if not self.product_id or self.product_id.type == 'service': - return - 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') - price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) - self.purchase_price = price - self.purchase_tax_id = taxes - # else: - # 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') - # price, taxes = self._get_valid_purchase_price(purchase_price) - # self.purchase_price = price - # self.purchase_tax_id = taxes + # @api.onchange('vendor_id') + # def onchange_vendor_id(self): + # # TODO : need to change this logic @stephan + # if not self.product_id or self.product_id.type == 'service': + # return + # 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') + # price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) + # self.purchase_price = price + # self.purchase_tax_id = taxes + # # else: + # # 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') + # # price, taxes = self._get_valid_purchase_price(purchase_price) + # # self.purchase_price = price + # # self.purchase_tax_id = taxes # def _calculate_selling_price(self): # rec_purchase_price, rec_taxes, rec_vendor_id = self._get_purchase_price(self.product_id) @@ -523,7 +523,7 @@ class SaleOrderLine(models.Model): if self.product_id.categ_id.id == 34: self.purchase_price = self.product_id.standard_price - self.purchase_tax_id = False # reset + self.purchase_tax_id = False elif self.product_id.x_manufacture.override_vendor_id: price, taxes, vendor_id = self._get_purchase_price_by_vendor(self.product_id, self.vendor_id) self.purchase_price = price |
