summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order_line.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/sale_order_line.py')
-rw-r--r--indoteknik_custom/models/sale_order_line.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py
index d1dcd0af..5e01067a 100644
--- a/indoteknik_custom/models/sale_order_line.py
+++ b/indoteknik_custom/models/sale_order_line.py
@@ -14,7 +14,9 @@ class SaleOrderLine(models.Model):
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]"
)
+ vendor_md_id = fields.Many2one('res.partner', string='MD Vendor')
purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0)
+ purchase_price_md = fields.Float('MD Purchase')
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')
fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0)
@@ -32,6 +34,8 @@ class SaleOrderLine(models.Model):
reserved_from = fields.Char(string='Reserved From', copy=False)
item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction')
weight = fields.Float(string='Weight')
+ md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True)
+ margin_md = fields.Float(string='Margin MD')
@api.constrains('note_procurement')
def note_procurement_to_apo(self):
@@ -125,6 +129,9 @@ class SaleOrderLine(models.Model):
else:
line.item_percent_margin = 0
+ if not line.margin_md:
+ line.margin_md = line.item_percent_margin
+
@api.onchange('vendor_id')
def onchange_vendor_id(self):
# TODO : need to change this logic @stephan
@@ -244,11 +251,14 @@ 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
+ line.purchase_tax_id = taxes
attribute_values = line.product_id.product_template_attribute_value_ids.mapped('name')
attribute_values_str = ', '.join(attribute_values) if attribute_values else ''