diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/website/models/ir_rule.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website/models/ir_rule.py')
| -rw-r--r-- | addons/website/models/ir_rule.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/addons/website/models/ir_rule.py b/addons/website/models/ir_rule.py new file mode 100644 index 00000000..a11ddef1 --- /dev/null +++ b/addons/website/models/ir_rule.py @@ -0,0 +1,24 @@ +# 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'] |
