summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order_line.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-25 08:47:36 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-25 08:47:36 +0700
commit9fa80c62cdffec5b91aaf2a2899d70d0f507c2e4 (patch)
tree93ae8d82f774345f650bc8d072dea759c6e33363 /indoteknik_custom/models/sale_order_line.py
parenta21c5fe37529b2d2259d3b86d8e98730b2bc8513 (diff)
parenta7be93f4825967807f12e6bfbebcf090af8500fa (diff)
Merge branch 'production' into iman/switch-account
# Conflicts: # indoteknik_api/controllers/api_v1/user.py # indoteknik_custom/models/user_company_request.py
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 ''