Files
odoo_source/addons/website/models/ir_rule.py
T
Romain Derie a5a5a57e48 [FIX] website(_sale): allow to use and access website pricelist
Before this commit, if the website's company was different than the user
company, the ecommerce would use the user's company instead of its own
pricelists.

Step to reproduce:
  - Set company2 to website1
  - Create a pricelist1 for company1 and a pricelist2 for company2
  - With an user from company1, visit the website1.
  - The pricelist used will be the one from the user, pricelist1 and not the
    pricelist2 from company2 which is the website1 company.
2019-03-14 10:28:02 +00:00

25 lines
915 B
Python

# coding: utf-8
from odoo import api, models
from odoo.addons.website.models import ir_http
class IrRule(models.Model):
_inherit = 'ir.rule'
@api.model
def _eval_context(self):
res = super(IrRule, self)._eval_context()
# We need is_frontend to avoid showing website's company items in backend
# (that could be different than current company). We can't use
# `get_current_website(falback=False)` as it could also return a website
# in backend (if domain set & match)..
is_frontend = ir_http.get_request_website()
Website = self.env['website']
res['website'] = is_frontend and Website.get_current_website() or Website
return res
def _compute_domain_keys(self):
""" Return the list of context keys to use for caching ``_compute_domain``. """
return super(IrRule, self)._compute_domain_keys() + ['website_id']