Multi-website support in Security Rules
by IT-Projects LLC https://twitter.com/OdooFree , Ildar Nasyrov https://twitter.com/OdooFree
Odoo
$ 20.47
Required Apps |
Website Builder (website)
|
Included Dependencies | Show |
Lines of code | 725 |
Technical Name |
ir_rule_website |
License | See License tab |
Website | https://itpp.dev |
Also available in version | v 13.0 v 10.0 v 12.0 |
Multi-website support in Security Rules
Make website-dependent access to pages, products, etc.
Version: v11.0.1.3.2
Tested and maintained by
IT Projects Labs
Assitance: apps@itpp.dev
Technical module that allows implementing different features. For example:
- Show a blog on specific websites only
- Show an event on specific websites only
- Show a product on specific websites only
Let our expertise work for you!
(Doors and windows below are clickable)
/itpp-labs-1100.jpg)
/itpp-labs-930.jpg)
/itpp-labs-690.jpg)
Multi-website support in Security Rules
Installation
- Install this module in a usual way
Configuration
- There is a new setting in each rule now - it is relevant only for website rules with special website_id parameter in them
- As usual open [[ Settings ]] >> Technical >> Security >> Record Rules to create a new rule or edit existing one
- You should see on rule form a new group named Multi-website extension with the Backend behaviour setting in it
- Leave this field empty if your rule has nothing to do with websites
- Select Grant access if you want to give access to model from backend, or Deny access - if you want to restrict
- Note: if you leave this fields empty for a rule that is using website_id parameter - you may have this kind of error when trying to configure your product's website_ids field from odoo backend:
The requested operation cannot be completed due to security restrictions. Please contact your system administrator. (Document type: product.template, Operation: read)
from web-interface, or
INFO rw odoo.models: The requested operation cannot be completed due to record rules: Document type: product.template, Operation: read, Records: 47, User: 5
in odoo logs
This is so because in backend rules work in non-website context. In other words the setting is mandatory for website rules.
Usage
- If you have a model accessible through a website (by means of controller methods) - specify this module into the "depends" section of your manifest file
- Now you can create security rules using website_id in domain_force fields. For example,
<?xml version="1.0" encoding="utf-8"?> <odoo> <record id="blog_rule_all" model="ir.rule"> <field name="name">Blogs available only for specifed websites</field> <field name="model_id" ref="model_blog_blog"/> <field name="domain_force">[('website_ids', 'in', [website_id])]</field> <field name="backend_behaviour">true</field> </record> </odoo>
The MIT License (MIT) Copyright 2020 IT-Projects Labs Copyright 2015-2020 IT-Projects LLC Copyright 2014-2015 Ivan Yelizariev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module