From 6b41dbf6831517523d47ef31a48558613d86a741 Mon Sep 17 00:00:00 2001 From: yhu-odoo Date: Mon, 6 Apr 2020 10:27:55 +0000 Subject: [PATCH] [IMP] purchase: use product cost when no pricelist Before the commit, when there is no pricelist, we set the unit price to be 0 on the PO. After the commit, when in the same situation, we use the cost set on the product form. Task 2072560 PR #49067 Signed-off-by: Simon Lejeune (sle) --- addons/purchase/models/purchase.py | 3 +-- addons/stock_landed_costs/tests/test_stockvaluationlayer.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 28bde993e43..86011139988 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -864,8 +864,7 @@ class PurchaseOrderLine(models.Model): self.date_planned = self._get_date_planned(seller).strftime(DEFAULT_SERVER_DATETIME_FORMAT) if not seller: - if self.product_id.seller_ids.filtered(lambda s: s.name.id == self.partner_id.id): - self.price_unit = 0.0 + self.price_unit = self.product_id.standard_price return price_unit = self.env['account.tax']._fix_tax_included_price_company(seller.price, self.product_id.supplier_taxes_id, self.taxes_id, self.company_id) if seller else 0.0 diff --git a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py index d0401bab47a..b0f0d37c0dc 100644 --- a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py +++ b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py @@ -257,8 +257,8 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon): with rfq.order_line.new() as po_line: po_line.product_id = self.product1 - po_line.price_unit = 10 po_line.product_qty = 10 + po_line.price_unit = 10 po_line.taxes_id.clear() rfq = rfq.save() @@ -344,8 +344,8 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon): with rfq.order_line.new() as po_line: po_line.product_id = self.product1 - po_line.price_unit = 10 po_line.product_qty = 10 + po_line.price_unit = 10 po_line.taxes_id.clear() rfq = rfq.save() @@ -397,8 +397,8 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon): with rfq.order_line.new() as po_line: po_line.product_id = self.product1 - po_line.price_unit = 10 po_line.product_qty = 10 + po_line.price_unit = 10 po_line.taxes_id.clear() rfq = rfq.save()