summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSwapnesh Shah <swapneshshah111@gmail.com>2020-05-06 17:34:08 +0000
committerSwapnesh Shah <swapneshshah111@gmail.com>2020-11-25 18:51:32 +0000
commitcb514b2a6cd788be15ce82dc3659061d19e0baf1 (patch)
treea9a8c80773f18588b0d24864292af56409a317b1
parentdfeb55f3d6c720530398a8f76676a4fe86376c81 (diff)
FIX] website_sale: prevent website with no pricelist in multi company
Followup on 911ada2d02b24778435fd9174441a6834da2effa When modifying the company_id of a pricelist, the check to ensure a website has a pricelist available wasn't triggered. This commits ensures the Each website has Valid Pricelist with Correct or Empty company. Fixes #50707 closes odoo/odoo#62358 X-original-commit: f196430baa8c5e2ce403808adc26d90fe84665fa Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
-rw-r--r--addons/website_sale/models/product.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py
index 79a5ebb02de..b1e440f3698 100644
--- a/addons/website_sale/models/product.py
+++ b/addons/website_sale/models/product.py
@@ -91,6 +91,7 @@ class ProductPricelist(models.Model):
- Have its `website_id` set to current website (specific pricelist).
- Have no `website_id` set and should be `selectable` (generic pricelist)
or should have a `code` (generic promotion).
+ - Have no `company_id` or a `company_id` matching its website one.
Note: A pricelist without a website_id, not selectable and without a
code is a backend pricelist.
@@ -98,13 +99,17 @@ class ProductPricelist(models.Model):
Change in this method should be reflected in `_get_website_pricelists_domain`.
"""
self.ensure_one()
+ if self.company_id and self.company_id != self.env["website"].browse(website_id).company_id:
+ return False
return self.website_id.id == website_id or (not self.website_id and (self.selectable or self.sudo().code))
def _get_website_pricelists_domain(self, website_id):
''' Check above `_is_available_on_website` for explanation.
Change in this method should be reflected in `_is_available_on_website`.
'''
+ company_id = self.env["website"].browse(website_id).company_id.id
return [
+ '&', ('company_id', 'in', [False, company_id]),
'|', ('website_id', '=', website_id),
'&', ('website_id', '=', False),
'|', ('selectable', '=', True), ('code', '!=', False),