Purpose
=======
Allow the user to select the allowed companies for which he wants to see records
on top of selecting his current company.
It is confusing for users to see the records from the company he is connected to
and the records of the children companies.
Instead of using the hierarchy of companies to access records across companies,
the user can now select (from his set of allowed companies) the companies for
which he wants to access records.
/!\ This means that the user will interact with records from company A when in
company B.
Example: a SO has been created and confirmed in A. When in B, I create the
invoice from it.
Specifications
==============
1/ Deprecate the parent/children hierarchy on the res.company model. The fields are
kept on the res.company model to ensure the retro-compatibility, but won't be used
accross the standard code anymore. The only functional usage for this mechanism
was to allow to see records from several companies by creating a virtual parent
company, which will be possible with the new mechanism.
2/ By default, a user will only see the records of the company he is connected
to (or records without a company). (It is still editable by the user if needed).
For that, put this information in the user context, to allow having different
configurations on different browser tabs. Instead of having domains like
['|',
('company_id', '=', False),
('company_id', 'child_of', user.company_id.id)]
you'll have something like
['|',
('company_id', '=', False),
('company_id', 'in', company_ids)]
Note that the 'company_ids' is a value that is passed in the evaluation
context on the record rule, as we already have user, or time.
company_ids is a list of the ids of all the enabled companies in the
user's context.
3/ Out of the generic improvements brought by this task, this will illustrate
issues that could exist since several versions. For example, it should not be
possible to create a scrap order for the company A with a package of the company
B, or it should not be possible to create an invoice on the company A with
payment terms from the company B. Before the version 12.0, it was easy to
encounter this kind of issues as the admin was the SUPERUSER_ID. A positive side
effect of the fact that the SUPERUSER_ID has become an inactive user was to
make it more difficult to introduce mismatch on the records, but haven't solved
the issue, as it was still possible to do it with parent companies
configuration. Some of these issues have been fixed in this commit, but all the
business flows should be re-tested to check if an ir.rule should be introduced
(eg: a multi company rule for stock.quand.package), if the company of a record
is correctly transfered to another record created from the first record (eg:
From a SO, create an invoice and a payment, the company of the sales order
should be transfered on the invoice and the payment, even if the company of the
sales order is A and I'm logged into the company B with the company A enabled.
4/ Currently, if I click on a button on a notification email (example 'View
Task'), I face a traceback if I'm not logged into the company of the record.
Now, if you click on a button and if you have access to the record, the correct
company will be automatically set.
5/ If I display a kanban view with several records from several companies (and
an image), all the images should be displayed.
6/ Currently if you copy paste an url, this will crash if you're not in the
correct company. This won't be fixed because it's quite impossible to do it in
a clean way. This task brings a workaround. Copy/Paste -> Traceback -> Log into
the correct company, re-copy/paste -> Ok.
7/ 2 property methods have been added on the environment to retrieve the company
on which the user is logged in and the companies the user enabled, on a specific
tab.
That way, when creating a record, instead of doing
default=lambda self: self.env.user.company_id
do
default=lambda self: self.env.company_id
On the other hand, to retrieve the enabled companies, do
companies = self.env.company_ids
8/ Modify the Company Switcher widget to allow to log into another company
WITHOUT writing on the res.users (and thus bringing cache invalidation issues
and so on). Also allow to enable several companies and see records from several
companies, and independantly of the other browser's tabs.
9/ When focusing on a tab, save the current company configuration on the local
storage. That way, when doing 'CTRL+T' or a middle click, the context is
propagated to the new tab.
10/ Improve the error message in case of multi company access errors. Now, when
the user is in debug mode, display the related names of the records and the name
of the user who brings the issue.
11/ Remove the context erasing when writing on a res.users
This is probably coming from the migration to new API of the base module.
The context was not propagated at this moment, which was a common mistake at
that time. When migrating the module, probably by using the 'black box' method,
as the context was not propagated, it was erased on the new version. This is
now an issue because the context (i.e. the enabled companies) was erased when
writing on a res.users, leading to tracebacks.
See: https://github.com/odoo/odoo/commit/7eab8e26d3d46c53f4be924d6a34e80a66e74960#diff-4c2e738ee8f64f11806c889ea097b5e7R624
12/ Fix the crash manager on redirect warnings. The issue is the following
- Create an invoice on a company without a configured CoA.
- Set a partner
- On the onchange_partner_id, a redirect warning is raised to propose you
to configure a CoA
- Click on 'Go to the configuration panel'
- A generic warning says something like 'Do you want to discard your changes?'
- Click on yes, the page refreshes, but not on the redirect action.
Now, set correctly the action on the hash, and reload instead. The breadcrumb is
lost for example, but you reach the correct action at least.
13/ Introduce a res.group to enable/disable the multi company per tab
feature.
14/ To help the users to know which tab is in which company, add the
possibility to have a favicon per company. When creating a company,
the classical 'O' icon is colored by default in a random color.
15/ Remove the company switcher on the frontend. This was mainly there
to allow a user to swicth to the company linked to the website.
This behavior is now transparent to the user. If the website A is
activated, then the company set on the context is the company of the
website.
16/ Deprecated the _company_default_get method on the res.company
model. Remove the method _get_company on the res.users model.
17/ Add 'allowed_company_ids' and 'current_company_id' on the pyeval
context. You can now use those variables on domains in the views to
access directly to the activated company.ies on the current tab.
TaskID: 1960971
closes odoo/odoo#32341
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
377 lines
26 KiB
XML
377 lines
26 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<odoo>
|
||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||
<field name="name">res.config.settings.view.form.inherit.website</field>
|
||
<field name="model">res.config.settings</field>
|
||
<field name="priority" eval="20"/>
|
||
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
|
||
<field name="arch" type="xml">
|
||
<xpath expr="//div[hasclass('settings')]" position="inside">
|
||
<div class="app_settings_block" data-string="Website" string="Website" data-key="website" groups="website.group_website_designer">
|
||
<h2 groups="website.group_multi_website">Select the Website to Configure</h2>
|
||
<div class="row mt16 o_settings_container" id="website_selection_settings" groups="website.group_multi_website">
|
||
<div class="col-xs-12 col-md-6 o_setting_box" id="website">
|
||
<div class="o_setting_right_pane">
|
||
<label string="Website" for="website_id"/>
|
||
<div class="text-muted">
|
||
Settings on this page will apply to this website
|
||
</div>
|
||
<div class="mt16">
|
||
<field name="website_id" widget="selection"/>
|
||
</div>
|
||
<div>
|
||
<button name="action_website_create_new" type="object" string="Create a New Website" class="btn-secondary" icon="fa-arrow-right"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<h2>Website <button name="action_website_create_new" type="object" string="New" class="ml-2 btn btn-link" icon="fa-plus" groups="!website.group_multi_website"/></h2>
|
||
<div class="row mt16 o_settings_container" id="website_settings">
|
||
<div class="col-12 o_setting_box" id="website_action_setting">
|
||
<button name="website_go_to" type="object" string="Go to Website" class="btn btn-primary" icon="fa-globe"/>
|
||
<button name="%(website.action_website_add_features)d" type="action" string="Add features" class="ml-2 btn btn-secondary" icon="fa-plus"/>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="domain_setting">
|
||
<div class="o_setting_right_pane">
|
||
<label for="website_name" string="Website Title"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Name and favicon of your website
|
||
</div>
|
||
<div class="content-group">
|
||
<div class="row mt16">
|
||
<label class="col-lg-3 o_light_label" string="Name" for="website_name"/>
|
||
<field name="website_name" attrs="{'required': [('website_id', '!=', False)] }"/>
|
||
</div>
|
||
<div class="row">
|
||
<label class="col-lg-3 o_light_label" for="favicon" />
|
||
<field name="favicon" widget="image" class="float-left oe_avatar"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="company_settings" groups="base.group_multi_company">
|
||
<div class="o_setting_right_pane">
|
||
<label string="Company" for="website_company_id"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
The company this website belongs to
|
||
</div>
|
||
<field name="website_company_id"/>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="languages_setting">
|
||
<div class="o_setting_right_pane">
|
||
<label for="language_ids"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Languages available on your website
|
||
</div>
|
||
<div class="content-group">
|
||
<div class="mt16">
|
||
<field name="language_ids" widget="many2many_tags" options="{'no_create': True, 'no_open': True}"
|
||
attrs="{'required': [('website_id', '!=', False)]}"/>
|
||
</div>
|
||
<field name="language_count" invisible="1"/>
|
||
<div class="mt8" attrs="{'invisible':[('language_count', '<', 2)]}">
|
||
<label class="o_light_label mr8" string="Default" for="website_default_lang_id"/>
|
||
<field name="website_default_lang_id" widget="selection" attrs="{'required': [('website_id', '!=', False)]}"/>
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<button type="action" name="%(base.action_view_base_language_install)d" string="Install new language" class="btn-link" icon="fa-arrow-right"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="domain_settings" groups="website.group_multi_website">
|
||
<div class="o_setting_right_pane">
|
||
<label string="Domain" for="website_domain"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Display this website when users visit this domain
|
||
</div>
|
||
<div class="mt8">
|
||
<field name="website_domain" placeholder="www.odoo.com"/>
|
||
</div>
|
||
<div class="mt8 text-muted" title="You can have 2 websites with same domain AND a condition on country group to select wich website use.">
|
||
Once the selection of available websites by domain is done, you can filter by country group.
|
||
</div>
|
||
<div class="mt8">
|
||
<field name="website_country_group_ids" widget="many2many_tags"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="auth_signup_uninvited_setting"
|
||
title=" To send invitations in B2B mode, open a contact or select several ones in list view and click on 'Portal Access Management' option in the dropdown menu *Action*.">
|
||
<div class="o_setting_left_pane">
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label for="auth_signup_uninvited"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Let your customers log in to see their documents
|
||
</div>
|
||
<div class="mt8">
|
||
<field name="auth_signup_uninvited" class="o_light_label" widget="radio" required="True"/>
|
||
</div>
|
||
<div class="content-group">
|
||
<button type="object" name="open_template_user" string="Default Access Rights" icon="fa-arrow-right" class="btn-link"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-offset-6 col-lg-6 o_setting_box" id="google_analytics_setting">
|
||
<div class="o_setting_left_pane">
|
||
<field name="has_google_analytics"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label for="has_google_analytics"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Track visits in Google Analytics
|
||
</div>
|
||
<div class="content-group" attrs="{'invisible': [('has_google_analytics', '=', False)]}">
|
||
<div class="row mt16">
|
||
<label class="col-lg-3 o_light_label" string="Tracking ID" for="google_analytics_key"/>
|
||
<field name="google_analytics_key" placeholder="UA-XXXXXXXX-Y"
|
||
attrs="{'required': [('has_google_analytics', '=', True)]}"/>
|
||
</div>
|
||
</div>
|
||
<div attrs="{'invisible': [('has_google_analytics', '=', False)]}">
|
||
<a href="https://www.odoo.com/documentation/user/12.0/website/optimize/google_analytics.html"
|
||
class="oe_link" target="_blank">
|
||
<i class="fa fa-arrow-right"/>
|
||
How to get my Tracking ID
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="google_analytics_dashboard_setting" attrs="{'invisible': [('has_google_analytics', '=', False)]}">
|
||
<div class="o_setting_left_pane">
|
||
<field name="has_google_analytics_dashboard"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label for="has_google_analytics_dashboard"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Follow your website traffic in Odoo.
|
||
</div>
|
||
<div class="content-group" attrs="{'invisible': [('has_google_analytics_dashboard', '=', False)]}">
|
||
<div class="row mt16">
|
||
<label class="col-lg-3 o_light_label" string="Client ID" for="google_management_client_id"/>
|
||
<field name="google_management_client_id" attrs="{'required': [('has_google_analytics_dashboard', '=', True)]}"/>
|
||
</div>
|
||
<div class="row">
|
||
<label class="col-lg-3 o_light_label" string="Client Secret" for="google_management_client_secret"/>
|
||
<field name="google_management_client_secret" attrs="{'required': [('has_google_analytics_dashboard', '=', True)]}"/>
|
||
</div>
|
||
</div>
|
||
<div attrs="{'invisible': [('has_google_analytics_dashboard', '=', False)]}">
|
||
<a href="https://www.odoo.com/documentation/user/online/website/optimize/google_analytics_dashboard.html"
|
||
class="oe_link" target="_blank">
|
||
<i class="fa fa-arrow-right"/>
|
||
How to get my Client ID
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" groups="website.group_multi_website">
|
||
<div class="o_setting_left_pane">
|
||
<field name="specific_user_account"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label for="specific_user_account"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Force your user to create an account per website
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-12 col-lg-6 o_setting_box" id="cdn_setting" title="A CDN helps you serve your website’s content with high availability and high performance to any visitor wherever they are located." groups="base.group_no_one">
|
||
<div class="o_setting_left_pane">
|
||
<field name="cdn_activated"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label for="cdn_activated"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Use a CDN to optimize the availability of your website's content
|
||
</div>
|
||
<div class="content-group" attrs="{'invisible': [('cdn_activated', '=', False)]}">
|
||
<div class="row mt16">
|
||
<label class="col-lg-3 o_light_label" for="cdn_url"/>
|
||
<field name="cdn_url"
|
||
attrs="{'required': [('cdn_activated', '=', True)]}"
|
||
placeholder="//mycompany.mycdn.com/"
|
||
t-translation="off"/>
|
||
</div>
|
||
<div class="row" >
|
||
<label class="col-lg-3 o_light_label" for="cdn_filters"/>
|
||
<field name="cdn_filters" class="oe_inline"
|
||
attrs="{'required': [('cdn_activated', '=', True)]}"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box">
|
||
<div class="o_setting_left_pane">
|
||
<field name="has_social_network"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label string="Social Media" for="has_social_network"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Add links to social media on your website
|
||
</div>
|
||
<div class="content-group" attrs="{'invisible': [('has_social_network', '=', False)]}">
|
||
<div class="row">
|
||
<label for="social_twitter" string="Twitter" class="col-md-3 o_light_label"/>
|
||
<field name="social_twitter"/>
|
||
</div>
|
||
<div class="row">
|
||
<label for="social_facebook" string="Facebook" class="col-md-3 o_light_label"/>
|
||
<field name="social_facebook"/>
|
||
</div>
|
||
<div class="row">
|
||
<label for="social_github" string="GitHub" class="col-md-3 o_light_label"/>
|
||
<field name="social_github"/>
|
||
</div>
|
||
<div class="row">
|
||
<label for="social_linkedin" string="LinkedIn" class="col-md-3 o_light_label"/>
|
||
<field name="social_linkedin"/>
|
||
</div>
|
||
<div class="row">
|
||
<label for="social_youtube" string="YouTube" class="col-md-3 o_light_label"/>
|
||
<field name="social_youtube"/>
|
||
</div>
|
||
<div class="row">
|
||
<label for="social_googleplus" string="Google Plus" class="col-md-3 o_light_label"/>
|
||
<field name="social_googleplus"/>
|
||
</div>
|
||
<div class="row">
|
||
<label for="social_instagram" string="Instagram" class="col-md-3 o_light_label"/>
|
||
<field name="social_instagram"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="social_default_image_setting">
|
||
<div class="o_setting_right_pane">
|
||
<label string="Default Social Share Image" for="social_default_image"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
If set, replaces the company logo as the default social share image.
|
||
</div>
|
||
<field name="social_default_image" widget="image" class="w-25 mt-2"/>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<h2>Features</h2>
|
||
<div class="row mt16 o_settings_container" id="webmaster_settings">
|
||
<div id="multi_website" class="col-12 col-md-6 o_setting_box">
|
||
<div class="o_setting_left_pane">
|
||
<field name="group_multi_website"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label string="Multi-Websites" for="group_multi_website"/>
|
||
<div class="text-muted">
|
||
Manage multiple websites
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="google_maps_setting">
|
||
<div class="o_setting_left_pane">
|
||
<field name="has_google_maps"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label for="has_google_maps"/>
|
||
<span class="fa fa-lg fa-globe" title="Values set here are website-specific." groups="website.group_multi_website"/>
|
||
<div class="text-muted">
|
||
Use Google Map on your website (<a href="/contactus">Contact Us</a> page, snippets, ...)
|
||
</div>
|
||
<div class="content-group" attrs="{'invisible': [('has_google_maps', '=', False)]}">
|
||
<div class="row mt16">
|
||
<label class="col-lg-3 o_light_label" string="API Key" for="google_maps_api_key"/>
|
||
<field name="google_maps_api_key" attrs="{'required': [('has_google_maps', '=', True)]}" />
|
||
</div>
|
||
</div>
|
||
<div attrs="{'invisible': [('has_google_maps', '=', False)]}">
|
||
<a role="button" class="btn-link" target="_blank"
|
||
href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true">
|
||
<i class="fa fa-arrow-right"/>
|
||
Create a Google Project and Get a Key
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-12 col-lg-6 o_setting_box" id="utm_tracker_settings" title="Analyze the efficiency of your marketing campaigns by using trackable UTM trackers (campaigns, medium, sources). Create trackers and follow clicks from the Promote menu of your website. Those trackers can be used in Google Analytics or in Odoo reports where you can see the opportunities and sales revenue generated thanks to your links.">
|
||
<div class="o_setting_left_pane">
|
||
<field name="module_website_links"/>
|
||
</div>
|
||
<div class="o_setting_right_pane">
|
||
<label for="module_website_links"/>
|
||
<div class="text-muted">
|
||
Track clicks on UTM links
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</xpath>
|
||
</field>
|
||
</record>
|
||
|
||
<record id="action_website_configuration" model="ir.actions.act_window">
|
||
<field name="name">Settings</field>
|
||
<field name="type">ir.actions.act_window</field>
|
||
<field name="res_model">res.config.settings</field>
|
||
<field name="view_mode">form</field>
|
||
<field name="target">inline</field>
|
||
<field name="context">{'module' : 'website'}</field>
|
||
</record>
|
||
|
||
<menuitem id="menu_website_global_configuration" parent="menu_website_configuration"
|
||
sequence="100" name="Configuration" groups="base.group_system"/>
|
||
|
||
<menuitem name="Settings"
|
||
id="menu_website_website_settings"
|
||
action="action_website_configuration"
|
||
parent="menu_website_global_configuration"
|
||
groups="base.group_system"
|
||
sequence="10"/>
|
||
|
||
<menuitem id="menu_website_add_features" parent="website.menu_website_global_configuration"
|
||
sequence="20" groups="base.group_system" action="action_website_add_features"/>
|
||
|
||
<menuitem name="Websites"
|
||
id="menu_website_websites_list"
|
||
action="action_website_list"
|
||
parent="menu_website_global_configuration"
|
||
groups="base.group_no_one"
|
||
sequence="10"
|
||
/>
|
||
|
||
<menuitem name="Pages"
|
||
id="menu_website_pages_list"
|
||
action="action_website_pages_list"
|
||
parent="menu_website_global_configuration"
|
||
sequence="30"
|
||
/>
|
||
|
||
<menuitem name="Redirects"
|
||
id="menu_website_redirect_list"
|
||
action="action_website_redirect_list"
|
||
parent="menu_website_global_configuration"
|
||
sequence="40"
|
||
/>
|
||
|
||
<menuitem name="Menus"
|
||
id="menu_website_menu_list"
|
||
action="action_website_menu"
|
||
parent="menu_website_global_configuration"
|
||
sequence="45"
|
||
groups="base.group_no_one"/>
|
||
|
||
</odoo>
|