-
Notifications
You must be signed in to change notification settings - Fork 30.1k
[IMP] web: add companies infos to the evaluation context #190218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] web: add companies infos to the evaluation context #190218
Conversation
8dca9ae
to
831d63e
Compare
be0fc90
to
819eb3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should try to remove these two (in another PR is fine)
addons/web/static/src/model/relational_model/relational_model.js
Outdated
Show resolved
Hide resolved
41062c4
to
2e4a2fd
Compare
5d71a26
to
c02ee08
Compare
odoo/tools/view_validation.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we depreciate these two values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we will do it in a follow-up PR
0f85e2c
to
e5779d1
Compare
e5779d1
to
8db80ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robodoo rebase-ff r+
Merge method set to rebase and fast-forward. |
This commit adds a new object with the information of the companies, to the evaluation context of Python expressions. The object contains: - multi_company: A boolean indicating whether the user has access to multiple companies. - allowed_ids : The list of company IDs the user is allowed to connect to. - active_ids: The list of company IDs the user is connected to (selected in the company switcher dropdown). - active_id: The ID of the main company selected (the one highlighted in the company switcher dropdown and displayed in the navbar of the webclient). - has(id|ids, 'property', value) : returns a boolean indicating whether there's a company with id in `ids` for which `field` matches the given `value`. Note that the properties of the companies are those sent by the server in the session info. If a new property is needed, the company function `_get_session_info` can be overridden. For example, the following code will add the `company_code` property: ```py def _get_session_info(self, allowed_company_ids): res = super()._get_session_info(allowed_company_ids) res.update({ 'country_code': self.country_id.code }) return res ``` Some usage examples: - In this case, the field 'foo' will be visible if the user has access to more than one company: ```xml <field name="foo" invisible="not companies.multi_company"/> ``` - In this case, the filed 'foo' will be visible if the user has activated one company with the country code 'PE': ```xml <field name="foo" invisible="not companies.has(companies.active_ids, 'country_code', 'PE')"/> ``` - In this case, the field 'float_field' will be visible if the main company (the one show on the top bar), has the country code 'PE': ```xml <field name="float_field" invisible="not companies.has(companies.active_id, 'country_code', 'PE')"/> ``` - In this case, the field 'child_ids' will be visible if the company of the current record has the country code 'PE'. Note that, to evaluate correctly this expression, the 'company_id' field should be in the view: ```xml <field name="child_ids" invisible="not companies.has(company_id, 'country_code', 'PE')"/> ``` part-of task-id 4250356
This commit removes the display_switch_company_menu from the session, and uses the company service. Note that, the company service already has the information about the allowed companies. part-of task-id 2224776
8db80ec
to
dca22fa
Compare
robodoo r+ |
This commit adds a new object with the information of the companies, to the evaluation context of Python expressions. The object contains: - multi_company: A boolean indicating whether the user has access to multiple companies. - allowed_ids : The list of company IDs the user is allowed to connect to. - active_ids: The list of company IDs the user is connected to (selected in the company switcher dropdown). - active_id: The ID of the main company selected (the one highlighted in the company switcher dropdown and displayed in the navbar of the webclient). - has(id|ids, 'property', value) : returns a boolean indicating whether there's a company with id in `ids` for which `field` matches the given `value`. Note that the properties of the companies are those sent by the server in the session info. If a new property is needed, the company function `_get_session_info` can be overridden. For example, the following code will add the `company_code` property: ```py def _get_session_info(self, allowed_company_ids): res = super()._get_session_info(allowed_company_ids) res.update({ 'country_code': self.country_id.code }) return res ``` Some usage examples: - In this case, the field 'foo' will be visible if the user has access to more than one company: ```xml <field name="foo" invisible="not companies.multi_company"/> ``` - In this case, the filed 'foo' will be visible if the user has activated one company with the country code 'PE': ```xml <field name="foo" invisible="not companies.has(companies.active_ids, 'country_code', 'PE')"/> ``` - In this case, the field 'float_field' will be visible if the main company (the one show on the top bar), has the country code 'PE': ```xml <field name="float_field" invisible="not companies.has(companies.active_id, 'country_code', 'PE')"/> ``` - In this case, the field 'child_ids' will be visible if the company of the current record has the country code 'PE'. Note that, to evaluate correctly this expression, the 'company_id' field should be in the view: ```xml <field name="child_ids" invisible="not companies.has(company_id, 'country_code', 'PE')"/> ``` part-of task-id 4250356 Part-of: #190218 Related: odoo/enterprise#75836 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit removes the display_switch_company_menu from the session, and uses the company service. Note that, the company service already has the information about the allowed companies. part-of task-id 2224776 closes #190218 Related: odoo/enterprise#75836 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This adapts the server-side form to the changes made in odoo#190218. The `companies` object contains: - multi_company: A boolean indicating whether the user has access to multiple companies. - allowed_ids : The list of company IDs the user is allowed to connect to. - active_ids: The list of company IDs the user is connected to (selected in the company switcher dropdown). - active_id: The ID of the main company selected (the one highlighted in the company switcher dropdown and displayed in the navbar of the webclient). - has(id|ids, 'property', value) : returns a boolean indicating whether there's a company with id in `ids` for which `field` matches the given `value`.
This adapts the server-side form to the changes made in #190218. The `companies` object contains: - multi_company: A boolean indicating whether the user has access to multiple companies. - allowed_ids : The list of company IDs the user is allowed to connect to. - active_ids: The list of company IDs the user is connected to (selected in the company switcher dropdown). - active_id: The ID of the main company selected (the one highlighted in the company switcher dropdown and displayed in the navbar of the webclient). - has(id|ids, 'property', value) : returns a boolean indicating whether there's a company with id in `ids` for which `field` matches the given `value`. closes #195707 Signed-off-by: Raphael Collet <rco@odoo.com>
This commit adds a new object with the information of the companies, to
the evaluation context of Python expressions.
The object contains:
ids
for whichfield
matches the givenvalue
. Note that the properties of the companies are those sent by the server in the session info. If a new property is needed, the company function_get_session_info
can be overridden. For example, the following code will add thecompany_code
property:Some usage examples:
In this case, the field 'foo' will be visible if the user has access
to more than one company:
In this case, the filed 'foo' will be visible if the user has
activated one company with the country code 'PE':
In this case, the field 'float_field' will be visible if the main
company (the one show on the top bar), has the country code 'PE':
In this case, the field 'child_ids' will be visible if the company of
the current record has the country code 'PE'. Note that, to
evaluate correctly this expression, the 'company_id' field
should be in the view:
part-of task-id 4250356