1# coding: utf-8 2from odoo import api, models 3from odoo.addons.website.models import ir_http 4 5 6class IrRule(models.Model): 7 _inherit = 'ir.rule' 8 9 @api.model 10 def _eval_context(self): 11 res = super(IrRule, self)._eval_context() 12 13 # We need is_frontend to avoid showing website's company items in backend 14 # (that could be different than current company). We can't use 15 # `get_current_website(falback=False)` as it could also return a website 16 # in backend (if domain set & match).. 17 is_frontend = ir_http.get_request_website() 18 Website = self.env['website'] 19 res['website'] = is_frontend and Website.get_current_website() or Website 20 return res 21 22 def _compute_domain_keys(self): 23 """ Return the list of context keys to use for caching ``_compute_domain``. """ 24 return super(IrRule, self)._compute_domain_keys() + ['website_id'] 25