Skip to content
Snippets Groups Projects
Commit f196430b authored by Swapnesh Shah's avatar Swapnesh Shah
Browse files

FIX] website_sale: prevent website with no pricelist in multi company


Followup on 911ada2d

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#50785

Signed-off-by: default avatarRomain Derie <rdeodoo@users.noreply.github.com>
parent fd211958
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,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.
......@@ -96,13 +97,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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment