Commit Graph
78 Commits
Author SHA1 Message Date
Victor Feyens 594ccdcbf4 [FIX] *: typos and english incoherences
Mainly transifex issues but also some errors found through 'grep' checks.

Fix typos and obscure english strings in xml contents, fields strings/helps, some docstrings, ...
ensuring correct translations base (and fallback when translations isn't available).

closes odoo/odoo#57276

X-original-commit: 4214f05d454bca2b60fda3a288d529c098e84f77
Related: odoo/enterprise#13053
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-09-08 18:12:26 +00:00
Raphael Collet 1f48130d2b [REF] core: _name_search() now returns a list of ids
This provides a better API to search for records by name without the
formatting part (`display_name`).

This also simplifies all the overridings of `_name_search` that no
longer need to call `name_get()`.  The call to `name_get()` is done in
method `name_search` in a generic way.
2020-08-18 13:02:41 +00:00
qdp-odoo 847889b497 [FIX] analytic, account: multi company fixes
added _check_company_auto and check_company attributes on relevant objects

Was task 2206523

closes odoo/odoo#46586

Related: odoo/enterprise#8986
Related: odoo/upgrade#993
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-03-26 13:22:58 +00:00
Nicolas Martinelli fbb73734f9 [FIX] analytic: partner without name
Do not crash if the commercial partner doesn't have a name.

opw-2158809

closes odoo/odoo#43533

X-original-commit: 90b55325894a248b0386d2f8c4b8568d278963f9
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-01-20 08:46:04 +00:00
Victor Feyens eae9055f49 [FIX] analytic: wrong domain creation
Leftover typo from #36804 .

closes odoo/odoo#40478

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2019-11-19 10:09:46 +00:00
Victor Feyens 37b1689be7 [FIX] account, analytic: remove company_ids context key mechanism 2019-11-18 12:25:05 +00:00
Xavier ALT bea0a9edfe [FIX] base, *: ensure name_search() returns lazy name_get() result
To avoid slowing down search like "{relational_field}" contains "{value}"
we always need to return the lazy name_get() for each [_]name_search method

closes odoo/odoo#36735

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-09-11 17:11:33 +00:00
jem-odoo 7c5ce75aeb [FIX] analytic: missing depends
This commit adds a missing `depends` on the `debit` and `credit` computed
field on analytic account model. Indeed, without that, the recompute is not
done when accessing thoses fields after adding lines in the same
transaction (like in tests).

Task-1911581
2019-08-21 11:22:58 +00:00
Prakash Prajapati c058562d73 [IMP] various: Add multi company domains on views
When the many2xxx field relates to a model where company_id is required, set
this  domain [('company_id','=',company_id.id)]

When the company_id field of the related model is not required, set this domain
['|',('company_id','=',company_id.id),('company_id','=',False)]

When setting the domain on a field which is in the treeview of a xxx2many field
evaluate against the company_id of the 'parent'.

Some constraints have been added on sereval models. Take a look at the complete
specification for more details.

TaskID: 2024446
Closes: #35266

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-08-16 11:17:28 +00:00
Priyanka Kakadiya 65613f5f83 [REF] account,hr_expense,sale: enforce uom domain
Enforce the domain of the UOM not by an onchange but by a domain.

Example of an issue if the domain is enforced by an onchange:
- create a order
- add an order line
- select the product
- select an uom
> the uom presented are the one from the product category.
-Save
- edit
- select an uom
> all UOM are presented even the ones of other categories

This commit enforce this new logic at most places.

task - 2003959

closes odoo/odoo#33741

Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2019-07-22 08:07:31 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Yannick Tivisse f5dfe4727c [IMP] api.py: Rename company_id/company_ids into company/companies
The goal is to be coherent with the user property.

Actually, company_id and company_ids on the environment are no fields.

Calling env.company_id returns a browse record, not an id.
2019-05-29 08:09:15 +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 71faa19af0 [MERGE] forward port branch saas-12.1 up to 2b3296bbf8 2019-03-11 14:42:34 +01:00
Toufik Ben Jaa 5805c032a4 [FIX] analytic: name_search return no results
- Since the commit 5fcf891e07 an issue has
  been introduced in the `analytic.account.analytic` name_search method.

  In some cases searching through analytic accounts will return no
  results when it should.

  The issue is due to a bug in `expression.py` that doesn't correctly
  handle the fields in `auto_join`.

  The issue is described here https://github.com/odoo/odoo/issues/25175
  and will be fixed by the ORM team.

closes odoo/odoo#31628

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-06 12:15:35 +00:00
RomainLibert 5fcf891e07 [IMP] various: optimize _name_search
In the overrides of _name_search we should avoid creating domains with
huge lists of ids as it is inefficient.
We can also make sure that we optimize the empty search as in this case
the custom domain doesn't make sense, we can simply search on an empty
domain and, thanks to the limit argument, still keep a fast query.

Linked to task 1918906

Thanks to @odony and @nseinlet

closes odoo/odoo#30155

closes odoo/odoo#30887
2019-02-06 13:26:33 +00:00
RomainLibert 6dbdfb9bf7 [IMP] various: optimize _name_search
In the overrides of _name_search we should avoid creating domains with
huge lists of ids as it is inefficient.
We can also make sure that we optimize the empty search as in this case
the custom domain doesn't make sense, we can simply search on an empty
domain and, thanks to the limit argument, still keep a fast query.

Linked to task 1918906

Thanks to @odony and @nseinlet

closes odoo/odoo#30155
2019-02-05 11:44:21 +00:00
Thibault Delavallée b8197ff178 [REF] various: update tracking parameters
Purpose is to clean the use of tracking parameters on fields. Parameters are
merged and is now tracking=<int> or tracking=True.

This commit is linked to task ID 1903814 and PR #28430.
2019-01-04 11:46:14 +00:00
Adrian Torres 3f4f77fd9d [REF] *: adapt code to new related default behaviour
This commit adapts the business code to changes introduced by
the parent commit in order to keep the same behaviour as before.

All readonly=False fields will have to be checked afterwards to confirm
that the business case requires write access to the source field.
2018-09-27 12:10:23 +02:00
Nimesh Jethva 7246170de6 [IMP]account_*: Improvement in model description
Purpose of this commit is to give description more "business oriented"
because those descriptions appears in Odoo Studio which is supposed to be used by end users, not only by developers.

Related Task ID : 37311
2018-09-21 11:45:14 +02:00
Christophe Simonis 86ff929ad6 [MERGE] forward port branch saas-11.4 up to 1199451606 2018-09-10 17:06:18 +02:00
Yannick Tivisse 7978d4ba0f Revert "[IMP] *: Define groups on res.users models"
This reverts commit 99f497b390.
2018-09-10 14:23:42 +02:00
jem-odoo 8db463d124 [MOV] analytic: move uom field from account to analytic 2018-08-13 14:39:50 +02:00
Christophe Simonis 2ab7ad8361 [MERGE] forward port branch saas-11.3 up to c00df14654 2018-06-07 11:43:07 +02:00
Christophe Simonis 969eb3fa2f [MERGE] forward port branch saas-11.2 up to c834c0f587 2018-06-06 15:46:36 +02:00
Nicolas Martinelli 21e233cba5 [FIX] analytic: read_group
Oversight of forward-port 9001a75f23

opw-1853068
2018-05-31 08:20:46 +02:00
Christophe Simonis f36e6917bd [MERGE] forward port branch saas-11.3 up to 37eed7c509 2018-05-29 17:34:43 +02:00
Christophe Simonis 37eed7c509 [MERGE] forward port branch saas-11.2 up to 58e3552246 2018-05-25 14:34:18 +02:00
Christophe Simonis 2bc6ea1b37 [MERGE] forward port branch 11.0 up to 02ee3fd88e 2018-05-23 19:33:40 +02:00
Yannick Tivisse 473c74f636 [IMP] various: Override _(name_)search instead of (name_)search
Purpose
=======
The method _name_search and _search add support to search as another user.

All the overrides of name_search and search redefine the behavior of the search.

This bring inconsistencies as the result of a call to _name_search and name_search
could differ on certain modules, which is not acceptable.

Specification
=============

Example:
~~~~~~~~

If the name_search method is overridden to search also on the driver name,
then calling name_search with a label 'JF' will return all the cars with a name containing
'JF' or all the cars with a driver name containing 'JF'. Let's say that we have a ir.rule
preventing a user to read the cars of another company. Then the call to name search only returns
the cars satisfying the previous condition AND belonging to his company.

Now, we want to overpass this constraint. We call _name_search with the attribute name_get_uid=1.
Then the call to _name_search returns all the cars from all the companies with a name like 'JF',
but nothing is done about the driver_name.

Example of wrong search redefinition on a model
-----------------------------------------------

    @api.model
    def name_search(self, name, args=None, operator='ilike', limit=100):
        domain = args or []
        domain = expression.AND([domain, [('name', 'ilike', name)]])
        partners = self.env['res.partner'].search([('name', operator, name)])
        if partners and name:
            domain = expression.OR([domain, ['|', ('driver_id', 'in', partners.ids), ('driver_id', '=', False)]])
        rec = self.search(domain, limit=limit)
        return rec.name_get()

Example of correct search redefinition on a model
-------------------------------------------------

    @api.model
    def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
        domain = args or []
        domain = expression.AND([domain, [('name', operator, name)]])
        partner_ids = self.env['res.partner']._search([('name', operator, name)], access_rights_uid=name_get_uid)
        if partner_ids:
            domain = expression.OR([domain, ['|', ('driver_id', 'in', partner_ids), ('driver_id', '=', False)]])
        rec = self._search(domain, limit=limit, access_rights_uid=name_get_uid)
        return self.browse(rec).name_get()

The same logic should be applied on the overrides of the search method.
2018-05-23 11:15:46 +02:00
Christophe Simonis 8383181b8f [MERGE] forward port branch saas-15 up to 021d0e6a98 2018-05-18 18:59:06 +02:00
Christophe Simonis 021d0e6a98 [MERGE] forward port branch saas-14 up to cabe0951af 2018-05-18 18:54:26 +02:00
Carlos Dauden 9001a75f23 [IMP] analytic: Performance on _compute_debit_credit_balance
Courtesy of Carlos Dauden.
Was PR #24660
2018-05-18 17:39:00 +02:00
Yannick Tivisse 99f497b390 [IMP] *: Define groups on res.users models
The reified view on the res users will be dropped in the following commit.

The previous commit adds support to define each group as a computed field on the res users.

This commit defines:
- A boolean field for each 'isolated' res.group, i.e. a group in the hidden category.
- A selection field for each 'Application' res.group, i.e. a group in a application category.

Example:
- The group to manage pricelist in sales becomes a boolean field
- The groups project user/manager become a selection field
2018-04-26 15:13:38 +02:00
Yannick Tivisse 7a282c9965 [IMP] *: Replace all occurences of 'compute' by '_convert' 2018-04-13 16:54:28 +02:00
Nicolas Martinelli 3b158b65c1 [FIX] analytic, hr_timesheet: recompute order
When creating a timesheet, several fields need to be recomputed:
- `currency_id`
- `group_id`
- `department_id`
- `is_timesheet`
- `validated`

When `validated` is computed before the other fields, the recomputation
will lead to an `AccessError` because of the rule
`hr_timesheet.timesheet_line_rule_user`.

Since the test `test_timesheet_validation_user` expects an
`AccessError`, the test succeeds. However, from time to time,
`validated` is computed last => the `AccessError` is not raised.

Actually, a `ValidationError` should be raised in this case (from the
`create` override in `timesheet_grid`).

This commit is a cherry-pick of 802339c12d
and dcca2e8b9d
2018-04-13 10:47:11 +02:00
Nicolas Martinelli 802339c12d [FIX] analytic, hr_timesheet: recompute order
When creating a timesheet, several fields need to be recomputed:
- `currency_id`
- `group_id`
- `department_id`
- `is_timesheet`
- `validated`

When `validated` is computed before the other fields, the recomputation
will lead to an `AccessError` because of the rule
`hr_timesheet.timesheet_line_rule_user`.

Since the test `test_timesheet_validation_user` expects an
`AccessError`, the test succeeds. However, from time to time,
`validated` is computed last => the `AccessError` is not raised.

Actually, a `ValidationError` should be raised in this case (from the
`create` override in `timesheet_grid`).
2018-04-03 08:30:30 +02:00
Raphael Collet e724858d50 [REF] models: use parent_path to implement parent_store
This replaces the former modified preorder tree traversal (MPTT) with the
fields `parent_left`/`parent_right`.  Each record is associated to a string
`parent_path`, that represents the path from its root node to itself.  The path
is made of the node ids suffixed with a slash:

              a                 node | id | parent_path
             / \                  a  | 42 | 42/
           ...  b                 b  | 63 | 42/63/
               / \                c  | 84 | 42/63/84/
              c   d               d  | 85 | 42/63/85/

This field provides an efficient implementation for parent_of/child_of queries:
the nodes in the subtree of record are the ones where `parent_path` starts with
the `parent_path` of record.  It is also more efficient to maintain than the
MPTT fields, and less sensitive to concurrent updates, because the value of
`parent_path` does not depend on sibling nodes.
2018-02-28 10:33:44 +01:00
rmu-odoo ccaea94a66 [IMP] anlaytic: display total of balance/credit/debit on group_by
Purpose
=======

User not able to see his total balance per customer if user has several projects with same customer..

see here : https://www.odoo.com/web/content/3287924

Specification
=============

User should be able to see the sum of the debit, credit and balance when group by partner

The difficulty here is that debit,credit and balance are non-stored computed fields depending on the company and the date passed with the context. As these parameters depend on the user and the current date, we can't store the field. The simplest way to achieve this is to override the read_group method and compute the sum by hand when the values are aggregated (means when a group_by is applied).
2018-02-05 10:11:56 +01:00
Joren Van Onder 079a13a349 [IMP] analytic: in-depth refactoring
* analytic accounts can be shared among companies
* amount on analytic lines always refer to amount in company currency of which it belongs to
* add analytic groups (hierarchical way to classify analytic accounts)
* analytic tags:
- only present on analytic lines, not anymore on analytic accounts
- can be used to distribue/split an analytic lines among several analytic accounts
- enabled by a dedicated res.group
- added on several objects (vouchers, expenses, analytic defaults...) as well as in bank statement reconciliation widget (manual counterpart and account.reconcile.model)

* bunch of fixes made related to analytic

Was PR #22124. Was task 32386. Original work by tbe.
2018-01-31 15:53:04 +01:00
Alexandre Kühn 23e6dd36d7 [IMP] web: hide in kanban tag's color (#20815)
New feature:

   - New Transparent tag visual (grey border & text, white bg),
   - By default, newly created kanban tags are transparent,
   - Tag's colorpicker has now a 'Hide in Kanban' checkbox,
     to select the transparent color.

Toggling off 'Hide in Kanban' sets the color of the tag as follow:

   - Previous color, if 'Hide in Kanban' was toggled on on the
     same formview session.
   - Color 1 (dark orange), otherwise.
2017-11-20 10:47:43 +01:00
ptr-odoo 276f080638 [IMP] account: allow to archive journal, account.tag and analytic.tag
Currently there is no option to Archive / Unarchive Journal + Accounting Tag + Analytic Account Tag

task: https://www.odoo.com/web#id=27447&view_type=form&model=project.task&menu_id=4720
PR: #12864
2017-08-29 12:38:10 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Fabien Pinckaers b33228cb49 [IMP] *: color index - avoid lots of grey tags on kanban 2017-01-07 23:34:38 -08:00
fwi-odoo 4f9c1c25f4 [MOV][IMP] analytic: reorganize addon, remove openerp tags and rename python classes 2016-08-02 09:54:37 +02:00
Kinjal Mehta 16d993a134 [IMP] account_budget,analytic,project: Some display improvements
1/ An empty notebook was created in analytic and filled in account_budget
   That way, we had a horizontal line while the module wasn't installed yet
2/ The fields use_task and use_issue displayed on the account.analytic.account
   are just redundant information. The probable use case is to go on the project
   select the issues management on it, and it will be activated on the related
   analytic account. I don't think that anybody will come on the analytic account
   to activate the issues. So we hide them in group_no_one
3/ On the analytic account form view, display the title label only in edit mode
2016-03-23 16:35:34 +01:00
Kinjal Mehta a57592abe4 [IMP] analytic: Replaced account_type field by active field
Currently there is a selection field 'account_type' on the
account.analytic.account model with 2 values : Active or Archived

Let's use an active field instead and add a Archive stat button on the
form. That way, we can remove all the domain ('account_type','=','normal')
which are implicit with the generic active field behavior
2016-03-23 16:35:34 +01:00
Damien Bouvy 150d74b6ea [IMP] analytic: add tracking of customer in chatter 2016-03-01 17:12:25 +01:00
Olivier Dony 1e729c7c5a [FIX] analytic: name_search with negative operators
The algorithm for matching analytic accounts based
on search term is only meant to be used for
simple, positive operators.
In other cases the results will not be what the user
expects. Falling back to the default name_search
behavior will be more useful.
2016-02-17 10:49:00 +01:00
Goffin Simon c090d9992a [FIX] analytic: _default_user
The "user_id" linked to the employee_id set on the sheet must be used
when editing a sheet.

opw:659647
2015-12-16 16:48:20 +01:00