From 4e5b9507417e0d8e32824fc1cc1625bab2db4d07 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Wed, 31 Jul 2019 10:38:50 +0000 Subject: [PATCH] [FIX] product: pricelist item cannot be without a pricelist ref --- addons/product/models/product_pricelist.py | 2 +- .../sale/tests/test_sale_product_attribute_value_config.py | 5 ++--- .../test_website_sale_product_attribute_value_config.py | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/product/models/product_pricelist.py b/addons/product/models/product_pricelist.py index 8711fddfa1e..6c879cce7dd 100644 --- a/addons/product/models/product_pricelist.py +++ b/addons/product/models/product_pricelist.py @@ -416,7 +416,7 @@ class PricelistItem(models.Model): 'Cost Price : The base price will be the cost price.\n' 'Other Pricelist : Computation of the base price based on another Pricelist.') base_pricelist_id = fields.Many2one('product.pricelist', 'Other Pricelist') - pricelist_id = fields.Many2one('product.pricelist', 'Pricelist', index=True, ondelete='cascade') + pricelist_id = fields.Many2one('product.pricelist', 'Pricelist', index=True, ondelete='cascade', required=True) price_surcharge = fields.Float( 'Price Surcharge', digits='Product Price', help='Specify the fixed amount to add or substract(if negative) to the amount calculated with the discount.') diff --git a/addons/sale/tests/test_sale_product_attribute_value_config.py b/addons/sale/tests/test_sale_product_attribute_value_config.py index 792e3f8f3d6..105c0ee3bbe 100644 --- a/addons/sale/tests/test_sale_product_attribute_value_config.py +++ b/addons/sale/tests/test_sale_product_attribute_value_config.py @@ -71,11 +71,10 @@ class TestSaleProductAttributeValueConfig(TestSaleProductAttributeValueSetup): pricelist_item = self.env['product.pricelist.item'].create({ 'min_quantity': 2, 'compute_price': 'percentage', - 'percent_price': discount + 'percent_price': discount, + 'pricelist_id': pricelist.id, }) - pricelist.item_ids += pricelist_item - return (pricelist, pricelist_item, currency_ratio, 1 - discount / 100) def test_01_is_combination_possible_archived(self): diff --git a/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py b/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py index 89fc591b8e5..5f2cd506632 100644 --- a/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py +++ b/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py @@ -15,9 +15,10 @@ class TestWebsiteSaleProductAttributeValueConfig(TestSaleProductAttributeValueSe self.computer = self.computer.with_context(website_id=current_website.id) # make sure the pricelist has a 10% discount - pricelist.item_ids = self.env['product.pricelist.item'].create({ + self.env['product.pricelist.item'].create({ 'price_discount': 10, 'compute_price': 'formula', + 'pricelist_id': pricelist.id, }) discount_rate = 0.9