Commit Graph
28 Commits
Author SHA1 Message Date
Victor Feyens a3ded9043d [IMP] *: declare ir.rule in noupdate
ir.rule are default values but can be customized based on the
company's policy and needs.
This is typically a record that is in noupdate as should be
customization-friendly.
2020-03-20 16:21:25 +01:00
Victor Feyens 532c083cbb [IMP] *: remove global field definition in ir rules xml
It is a computed field, there is no need to manually set its value.
2020-03-20 16:15:40 +01:00
Martin Trigaux 65530dfd6a [ADD] *: add ir.model.access on all transient models
Following changes needing ir.model.access on transient models too.
Remove groups declaration on the action to move it to ir.model.access
when possible.
Rules are strict by default with no unlink access by default and high
priviledge asked. Adaptations may be needed later.
Write access is given as a wizard may need to be modified in case the
action triggers an error and the user has to correct a value

account*: use account.group_account_user for all transient by default
	  remove account.print.journal relic
stock*: use stock.group_stock_user by default
survey: survey user can send invitations
mail: allow any employee to execute wizards
      additional verifications are made to ensure they are executed
      only on the documents the user has access to you
      give portal access to mail.compose.message as portal still does
      some actions like posting messages on the forum
      add ir.rule to avoid reading somebody else messages
      increase the query count because of undeterminist count
crm: saleman for lead2opp, manager for massmailing
     partner manager for actions linked to partners
     avoid a write in test_lead_lost
sms: any employee can send sms
mrp: mrp user can execute wizards
     give unlink access as making write during do_produce operation
base_import: employees can import files
delivery: stock user can deliver
event_sale: sale user can configure the wizards
	    event user inherit from  sale rights
gamification: employee can give badge
google_service: resolve FIXME
hr: add specific rights
    manager can set a plan according to group on button
    anyone who can write on an employee can register a departure
hr_expense: set rights based on buttons
hr_holidays: an approver can make a summary report
hr_recruitment: recruiter can refuse a candidate
hr_timesheet: can use the wizard if can create a timesheet
l10n_eu_service: managers can create fiscal positions
mass_mailing: same group as on mass.mailing.list
membership: accountant can create invoice from membership
payment: accountant can create a link
	 as the source is an account.move
	 keep the payment.acquirer.onboarding.wizard to system user
	 only as it is called during company configuration
point_of_sale: PoS manager only can use wizards
	       never create closing_balance_confirm_wizard records
product_expiry: stock user has rights on stock.picking
product_margin: access from accounting menus
repair: same rules as for above models
sale: set ir.rule for self wizard only
      add rule from model introduced in payment to add salesman group
sale_crm: saleman can create a quotation from a lead
sale_coupon: any saleman can generate coupon
	     add self ir.rule
sale_product_configurator: salesman can select product variants
snailmail: employee can send letters
website: designers can write on website
website_crm_partner_assign: same rule as group on action
website_sale: sale ACL as for payment.acquirer.onboarding.wizard
website_slides: anyone can send invitation

base: base.language.*: allow employee (cf lang_install)
      change.password.user: can not read change password wizard of
      other users
      test.*: no access is needed

Courtesy of Damien Bouvy, William Andre and Antoine Prieëls for review
of acl
2020-02-04 17:54:18 +01:00
Hetashree Chauhan 421b9dfe21 [IMP] delivery, product, sale(_management): make company consistence
Purpose of the commit is to make the multi company consistence with product,
sale order and order template.

So the Common Product Catalog setting is removed from generel settings
because its behavior wasn't really clean from a technical point of view
(disabling the rule on products access) and wouldn't work as well with
new multi-company logic.
The default logic of sharing products will be kept, but when someone
wants to limit products sharing, he will do so product by product, by
setting the company_id.

Also the default company_id on product will be blank so default product
will be a sharable by multi company.
and added company_id on sale templates so user can select his/her own
company or the templates which are common.

task-2025168
Closes: #34342
2019-07-22 05:17:00 +00:00
Yannick Tivisse a5b6f31cf2 [IMP] base: Contextualize the multi company
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>
2019-05-13 08:57:49 +00:00
Christophe Simonis 9db108c106 [FIX] delivery: remove extra unsourced file 2018-03-07 18:49:05 +01:00
Christophe Simonis d67b410dfc [MERGE] forward port branch saas-15 up to cb87388d72 2018-03-07 17:42:02 +01:00
Nicolas Martinelli 037cfc9f67 [FIX] delivery: products not shared
- Define 2 companies A and B. Delivery methods are linked to products in
  company A
- Deactivate 'Share product to all companies'
- Create a user B in Company B only
- As user B, create a SO and open the drop-down list for delivery
  methods

An access error is raised.

Delivery methods should follow the same record rules than the products
they are linked to.

opw-1815490
2018-03-06 10:02:44 +01:00
Jaykishan Solanki 6999d054fc [ADD] delivery: delivery.carrier must follow the same multi-company rules than the products they reference 2017-07-20 15:32:20 +02:00
Yannick Tivisse 9e57185449 [IMP] base,sales_team: Move res_groups and menuitems to sales_team
Purpose:
Having the res_group defined in base and sales_team auto installed
with mail doens't make sense.

- Move the empty res_config class and the related view from
  base_setup to sales_team (base_setup only contains the 'General Settings'
  model and views
- Move the 'sale' related content from product to sale module (Access rights,
  menuitems,...)
- Set sales_team at autoinstall False. The module is installed when needed by
  crm or sale for example
- Set sales_team as a dependency of voip. (Access rights defined for configuration
  purpose)
- Set sales_team ad a dependency of subscription (Access rights issue too)

[FIX] account: move some ir.model.access to sale module
[FIX] payment: Move some ir.rule to website_sale
[FIX] stock: move some ir.model.access rule to sale_stock
[FIX] project: Move some ir.model.access rules to crm_project_issue
[FIX] mrp: Move some ir.model.access rules to sale_mrp
[FIX] calendar: move some ir.model.access rules to crm

Rename xmlids accordingly. Example: 'base.group_sale_manager' becomes
sales_team.group_sale_manager.

[ADD] sales_team: See own documents => See only his sales team
Moved the "User: Own Leads Only", "User: All Leads" and "Manager" groups from sale and crm
into sales_team module. Add the record rules so that user can see only his Own Sales Team
if "See Own Leads" is sales right and can see all sales teams if he is having sales rights
of "See All Leads" or manager.
2016-06-09 16:05:25 +02:00
Yannick Tivisse ccdb5cbfc0 Revert "[IMP] base,sales_team: Move res_groups and menuitems to sales_team"
This branch need more testing instead of doing 10 fixes. A lot of issues are occuring
when installing modules in different orders.

This reverts commit fa6e415cdb.
2016-06-06 17:26:30 +02:00
Yannick Tivisse fa6e415cdb [IMP] base,sales_team: Move res_groups and menuitems to sales_team
Purpose:
Having the res_group defined in base and sales_team auto installed
with mail doens't make sense.

- Move the empty res_config class and the related view from
  base_setup to sales_team (base_setup only contains the 'General Settings'
  model and views
- Move the 'sale' related content from product to sale module (Access rights,
  menuitems,...)
- Set sales_team at autoinstall False. The module is installed when needed by
  crm or sale for example
- Set sales_team as a dependency of voip. (Access rights defined for configuration
  purpose)
- Set sales_team ad a dependency of subscription (Access rights issue too)

Rename xmlids accordingly. Example: 'base.group_sale_manager' becomes
sales_team.group_sale_manager.
2016-06-06 15:46:52 +02:00
Mahendra barad a223111b92 [IMP] delivery, website_sale_delivery: refactoring and usability
* migration to new API
* removed delivery.grid object, has been merged with delivery.carrier
* change view of delivery.carrier (price rules, etc.)
* tests from yml to py
* website : restrict the list of countries for delivery address in the shop
2015-09-01 08:14:16 +02:00
Christophe Simonis fe92deaa1d [MERGE] forward port of branch 8.0 up to 2de301d 2015-07-07 18:13:57 +02:00
Lionel Sausin cdd023f8fc [FIX] delivery: grant stock workers permission to list carriers
Otherwise sotck users are not allowed to list the available carriers (e.g. when
creating a picking).

Closes #7299
2015-07-06 17:09:10 +02:00
jpa-odoo de331d5aae [IMP] website_sale : onboarding. Allow user to print saleorder when confirm its command, display delivery method menu in sale and in warehouse (with access right stock.group_stock_manager and base.group_sale_manager) and improve quantity ui widget. 2015-01-26 17:06:00 +01:00
Fabien Pinckaers f27318c8af [IMP] Security Rule: removed duplicates due to inheritancies of groups
bzr revid: fp@tinyerp.com-20111212181113-mhnnbps3ip8ls6pp
2011-12-12 19:11:13 +01:00
Fabien Pinckaers fe9500c14e [IMP] access rights cleaning
bzr revid: fp@tinyerp.com-20101016164709-8w551aaosqx0dufu
2010-10-16 18:47:09 +02:00
Vir (Open ERP) b92dca2fce [MOD] stock_*, delivery : Modifications in access rights
bzr revid: vir@tinyerp.com-20100806105011-y4nnkgw377i4kkly
2010-08-06 16:20:11 +05:30
AMP (OpenERP) 39d1c31b49 [MOD] usability improvement and changes in access rights
bzr revid: amp@tinyerp.com-20100730130247-1hvssj5z0f9gvd3a
2010-07-30 18:32:47 +05:30
AMP (OpenERP) 7e0180c254 [MOD] usability improvement in access rights
bzr revid: amp@tinyerp.com-20100729133057-gdhqqohzpkdnq8vl
2010-07-29 19:00:57 +05:30
AMP (OpenERP) 086f180c80 [MOD] usability improvement in access rights
bzr revid: amp@tinyerp.com-20100726051551-i1udiuboxtn4vfve
2010-07-26 10:45:51 +05:30
AMP (OpenERP) 6eb86abda3 [MOD] usability improvement in access rights
bzr revid: amp@tinyerp.com-20100723072243-kpex4cdgckhga46d
2010-07-23 12:52:43 +05:30
UCO (OpenERP) 3217cf7e4c [REM]: Removed access rules for OSV memory objects
bzr revid: rpa@tinyerp.com-20100628134938-23kiccr4355jfhmg
2010-06-28 19:19:38 +05:30
Rvo (Open ERP) 5fd39ca156 [ADD]: access rights for osv_memory and osv_osv objects
bzr revid: rvo@tinyerp.co.in-20100421111435-v4u8cemnfir19kh0
2010-04-21 16:44:35 +05:30
Christophe Simonis 1a138e1454 fix and complete access rules
bzr revid: christophe@tinyerp.com-20081017162038-kzsgroivk73t0vyx
2008-10-17 18:20:38 +02:00
Fabien Pinckaers 51f8c2b263 Better Security Rules
bzr revid: fp@tinyerp.com-20080903224650-u1oadqv9x75atmyl
2008-09-04 00:46:50 +02:00
Fabien Pinckaers b4d6690794 Improved Security
bzr revid: fp@tinyerp.com-20080903180400-df7l6wxg1zpirmmi
2008-09-03 20:04:00 +02:00