The previous commit introduced an optimization to reduce the number of
queries and fields fetched when we call `name_search`. But it works much
better when the dependencies of `display_name` contain field names used
in the calculation (on the same record/model).
Then, to improve the performance and the cache coherency, add `depends`
and `depends_context` depending on the custom `_compute_display_name`.
Add only the first level of dependencies (never traverse relational
field) because only these have a positive impact on the previous
optimization and the cost is very low (see `modified`).
About `depends_context`, we don't include `lang` because (when `_` is
used by example) it is unlikely to get the same display_name in the same
request with two different lang.
closesodoo/odoo#122085
Related: odoo/documentation#4639
Related: odoo/enterprise#42599
Related: odoo/upgrade#4780
Signed-off-by: Raphael Collet <rco@odoo.com>
Rationale
=========
Since v8, the `display_name` field is present on all models. By default,
`display_name` uses `name_get` which has pretty much the same purpose
(return record name used by the web client). Gradually, many (backend)
developers (and the ORM: https://github.com/odoo/odoo/commit/6da1c3ac4c036eac289597602976538e243cb939)
started using `display_name` (more convenient than
`record.name_get()[0][1]`) but it still had the `name_get` override.
It becomes more complex than necessary and poeple start to misunderstand
the two (and sometimes override both, leading to inconstiencies between
`display_name`/`name_get`).
To simplify the ORM and the API, we decided to keep only one of them,
the `display_name` field:
- It is much more convenient from a backend point of view
(`record.name_get()[0][1]` vs `record.display_name`)
- It is cached during the same transaction (and invalidated if
its dependencies change)
- It can be overridden like any other compute field (override
`_compute_display_name` with any extra dependencies)
- `name_get` is replaced by `read(['display_name'])`
(API perceptive), which can actually be more efficient
(if `display_name`'s depends are correct, the ORM will only fetch the
fields it needs instead of every prefetchable field)
Changes
=======
- Deprecates `name_get` for the v17 and based the method on
`display_name` (the opposite of before)
- Converts all usage of `name_get`
- Overrides of `name_get` are now overrides of `_compute_display_name`
- For `res.partner`, rename the field store `display_name` into
`complete_name` because `display_name` context-dependent and it makes
no sense to have a compute store that is context-dependent.
- Previously, it was possible to return multiple names for the same
record with `name_get`, but it was tricky and most of the usage of
this `name_get` didn't take this into account. The only example of
this is the `name_get` of `product.product`
(now use `", ".join(<names>)`).
Part-of: odoo/odoo#122085
Latams need more fields for VAT and Odoo Milk broke
how these fields are displayed.
opw-3382698
closesodoo/odoo#126461
X-original-commit: 960d47ccc9db2ae69836a5f1ed7bff163b051a42
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
THese are rarely intended for all users but often intended only for
employees.
account:
account.incoterms: only used within internal business models
account.journal.group: same as account.journal, add sudo in computed field
account_edi: need access to accounting objects
base_address_extended:
res.city: only employees should access address data
board: only employees uses this (old) module
crm:
crm.stage: internal users business object
hr_recruitment: employees can read
im_livechat: apply same as for the steps
l10n_ar: used on partner, not only invoices
l10n_ec: accessed only through account.move
l10n_latam: accessed on res.partner
mail:
publisher.warrenty.contract: no data, only static models
mail.channel: group_user has already his own rule
mail.group: group_user has already his own rule
mail.message.subtype: group_user has already his own rule
mail.message.all: remove, already has a portal and employee rule
partner_autocomplete: no interaction with public
project:
project.tags: only needed for project sharing
sale_management:
sale.order.option: same as sale.order
utm: employee already has write access
web_editor: test models that have nothing to do here
web_tour: only employees uses tours
website_sale:
product.ribbon: add sudo for access
base:
ir.default: only employees uses set (could probably be converted to group_system)
ir.ui.view.custom: same as ir.ui.view, add sudo when needed
report.*: portal users don't configure reports
res.users.log: create in sudo, no access needed (adapt test to use another model)
res.lang: still needed for public
closesodoo/odoo#118701
Related: odoo/enterprise#41285
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Currently, only stable releases see their translations updated. This has
resulted in master accumulating outdated stuff for years, which can be
confusing for users testing master on runbot.
This one-shot commit resynchronizes master translations based on the
content from 16.0 and removes empty PO files (i.e. no longer containing
translations).
closesodoo/odoo#121629
Related: odoo/enterprise#41171
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
According to Wiktionary, French spacing is "the archaic practice (though
still current in French) of inserting a space around colons, semicolons,
question marks, and exclamation marks". This is not standard practice in
English and most languages of the world.
The purpose of this commit is to start purging the code from this typo,
as it may reflect poorly on the software for some people.
closesodoo/odoo#116167
Related: odoo/enterprise#38542
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
This is mostly a cleaning/refactoring change.
The current API for init hooks (pre, post, uninstall) is to pass
`cr, registry`.
But the first thing which was done by most
post init and uninstall hooks was to create an env using
the cr passed
e.g.
`env = api.Environment(cr, SUPERUSER_ID, {})`
and the `registry` argument was unused in all these hooks,
completely.
By changing the API of hooks to pass `env` instead
of `cr, registry`, we gain in average two lines in every
hooks:
- the line creating the env `env = api.Environment(cr, SUPERUSER_ID, {})`
- the line importing `api` and `SUPERUSER_ID`
Therefore removing ~250 lines of repeated code lines accross odoo/odoo and
odoo/enterprise.
In addition to these lines removed,
it also ease the API of init hooks for Odoo developers,
who are used to that `env` and not so much how to create an `env`
from a cursor.
Part-of: odoo/odoo#108254
Before this PR, all this localisation was written in spanish, but all the localisation have to be written in english and then translated back in the native language. This PR correct that.
closesodoo/odoo#109147
Task-id: 3119934
Signed-off-by: Laurent Smet <las@odoo.com>
Remove most values uselessly specified because giving the same value as
the default one (see _DEFAULT_MANIFEST in odoo/modules/module.py)
* auto_install is Falsy by default
* author is Odoo SA by default
* summary & description are empty strings by default
* application is False by default
* test, demo, depends and data are empty lists by default
This will reduce noise/inconsistencies between manifests specifications,
simplify analysis of manifests content, ...
closesodoo/odoo#90209
Related: odoo/enterprise#26807
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
The possible index names have been renamed "btree", "btree_not_null"
(instead of "not null") and "trigram" (instead of "gin").
Task 2742526
Part-of: odoo/odoo#83274
Three supported types:
- btree (default for index=True)
- btree not null (when >90% of the data are null)
- gin trigram search (for char fields)
Review of indexes on all objects.
closesodoo/odoo#83015
Signed-off-by: Fabien Pinckaers <fp@odoo.com>
The license is missing in most enterprise manifest so
the decision was taken to make it explicit in all cases.
When not defined, a warning will be triggered starting from
14.0 when falling back on the default LGPL-3.
closesodoo/odoo#74245
Related: odoo/design-themes#48
Related: odoo/enterprise#19862
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This revision solves two things:
- On installation of `l10n_latam_base`,
`l10n_latam_base` is set as default as `l10n_latam_identification_type_id`
for all partners in the database.
The ORM method `write` was used to do so.
With a database having a large number of partners,
such as multiple hundred of thousands,
this leaded to performance issues when `l10n_latam_base`
got installed.
I checked compute methods that could depends on this field,
and the only one I found is `_compute_l10n_ar_vat`,
which is not yet `installed/loaded` when this posthook takes place,
as it's in the module `l10n_ar` which depends on `l10n_latam_base`
and therefore is loaded after. So, it was already not executed/computed
when using the ORM `write` method before this revision.
Therefore, the use of plain SQL can be used to speed up the performance.
- Also, the ORM `write` triggered unexpected compute fields
which could raise exceptions, because of the `commercial_partner_id`
synchronization.
For instance:
```
Traceback (most recent call last):
File "/home/odoo/src/odoo/14.0/odoo/service/server.py", line 1198, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/home/odoo/src/odoo/14.0/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/odoo/src/odoo/14.0/odoo/modules/loading.py", line 455, in load_modules
loaded_modules, update_module, models_to_check)
File "/home/odoo/src/odoo/14.0/odoo/modules/loading.py", line 348, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/home/odoo/src/odoo/14.0/odoo/modules/loading.py", line 239, in load_module_graph
getattr(py_module, post_init)(cr, registry)
File "/home/odoo/src/odoo/14.0/addons/l10n_latam_base/__init__.py", line 8, in _set_default_identification_type
env['res.partner'].search([]).write({'l10n_latam_identification_type_id': env.ref('l10n_latam_base.it_vat').id})
File "/home/odoo/src/odoo/14.0/addons/base_vat/models/res_partner.py", line 538, in write
return super(ResPartner, self).write(values)
File "/home/odoo/src/odoo/14.0/addons/snailmail/models/res_partner.py", line 26, in write
return super(ResPartner, self).write(vals)
File "/home/odoo/src/odoo/14.0/addons/partner_autocomplete/models/res_partner.py", line 199, in write
res = super(ResPartner, self).write(values)
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/res_partner.py", line 550, in write
partner._fields_sync(vals)
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/res_partner.py", line 469, in _fields_sync
self._children_sync(values)
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/res_partner.py", line 478, in _children_sync
self._commercial_sync_to_children()
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/res_partner.py", line 452, in _commercial_sync_to_children
sync_children._compute_commercial_partner()
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/res_partner.py", line 297, in _compute_commercial_partner
partner.commercial_partner_id = partner.parent_id.commercial_partner_id
File "/home/odoo/src/odoo/14.0/odoo/fields.py", line 1127, in __set__
records.write({self.name: write_value})
File "/home/odoo/src/odoo/14.0/addons/base_vat/models/res_partner.py", line 538, in write
return super(ResPartner, self).write(values)
File "/home/odoo/src/odoo/14.0/addons/snailmail/models/res_partner.py", line 26, in write
return super(ResPartner, self).write(vals)
File "/home/odoo/src/odoo/14.0/addons/partner_autocomplete/models/res_partner.py", line 199, in write
res = super(ResPartner, self).write(values)
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/res_partner.py", line 546, in write
result = result and super(Partner, self).write(vals)
File "/home/odoo/src/odoo/14.0/addons/mail/models/mail_activity.py", line 766, in write
return super(MailActivityMixin, self).write(vals)
File "/home/odoo/src/odoo/14.0/addons/mail/models/mail_thread.py", line 322, in write
result = super(MailThread, self).write(values)
File "/home/odoo/src/odoo/14.0/addons/website/models/mixins.py", line 182, in write
return super(WebsitePublishedMixin, self).write(values)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 3640, in write
self.modified(relational_names, before=True)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5786, in modified
tocompute = list(tocompute)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5862, in _modified_triggers
yield from records._modified_triggers(val)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5858, in _modified_triggers
records |= model.search([(key.name, 'in', real_records.ids)], order='id')
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 1708, in search
res = self._search(args, offset=offset, limit=limit, order=order, count=count)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 4492, in _search
self._flush_search(args, order=order)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 4470, in _flush_search
self.env[model_name].flush(field_names)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5442, in flush
self.recompute(fnames, records=records)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5908, in recompute
process(field)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 5879, in process
field.recompute(recs)
File "/home/odoo/src/odoo/14.0/odoo/fields.py", line 1145, in recompute
self.compute_value(record)
File "/home/odoo/src/odoo/14.0/odoo/fields.py", line 1175, in compute_value
records._compute_field_value(self)
File "/home/odoo/src/odoo/14.0/addons/mail/models/mail_thread.py", line 410, in _compute_field_value
return super()._compute_field_value(field)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 4068, in _compute_field_value
self.filtered('id')._validate_fields(fnames)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 1260, in _validate_fields
check(self)
File "/home/odoo/src/odoo/14.0/addons/sale_project/models/project.py", line 70, in _check_sale_line_type
product_id=task.sale_line_id.product_id.display_name,
odoo.exceptions.ValidationError: You cannot link the order item SO/2019/11374 - [COMOD2H] Servicio de Correctivo dos Horas to this task because it is a re-invoiced expense.
```
upg-11324
closesodoo/odoo#69958
X-original-commit: 680bd481412823b66fcf45c9312a59c7029e200b
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
Before, account_fiscal_country_id was only use for tax operations; and country_id was used for all the other accounting stuff. Now, with the new ability to use foreign tax reports (with foreign VAT fiscal positions), we can generalize the fiscal country, sot that it is the one that needs to be used for the whole accounting. Since foreign tax reports were not supported before, account_fiscal_country_id is already set on existing database as the country for the "main" accounting, so the impact of this change is small.
closesodoo/odoo#68349
Related: odoo/upgrade#2322
Related: odoo/enterprise#17299
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Identification type was always been overwrite by the _onchange_country even when just opening the contact form, this was always setting the is_vat identification type as default without taking into account if the user has defined their own default.:
* If Identification type is set and it is compatible with the country then we leave it as it is (this is the case the identification type has been set by a default).
* If Identification type is set but is not compatible with the country then compute and set the Identification type that is is_vat True for the country
Where country is the one set in the partner record, if not set will use the country of the move's company, if not defined then will use the country of the environment company
closesodoo/odoo#67628
X-original-commit: 8e9b1c404a71c0a7dce37c7f5f6ecef1396e0a1a
Signed-off-by: Josse Colpaert <jco@openerp.com>
limit identification type search result in one
record to avoid apparent singleton error
closesodoo/odoo#50380
X-original-commit: fe62fbc520a7daee8006d2b453d0b2f2459ce1ad
Signed-off-by: Josse Colpaert <jco@openerp.com>
Purpose
=======
The current kanban view is messy. It is difficult to identify which
apps are installed or not. The user can completely miss a module
that might have interested him. A search panel would make things way
more readable.
closesodoo/odoo#44401
Taskid: 2181557
Related: odoo/enterprise#8144
Related: odoo/upgrade#879
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Followup of a425695e
The terms were back in 12.0
Courtesy of Juan José Scarafía
closesodoo/odoo#41624
X-original-commit: 85d0c7001a997748d7691205bbb8d066597591a5
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
l10n_latam_base:
* update translations
* extend manifest
* update manifest, delete new menus/fields/models from manifest
l10n_latam_invoice_document:
* update translations
* remove filter journals for recipts
* make method private
* extend manifest
* update manifest, delete new menus/fields/models from manifest
* misspelling error in ValidationError
* fixup missing change apply before merge/rebase
l10n_ar:
* make method private
* update translations
* catch error when stdnum.ar.format
* fiscal position with criteria diff from Responsibility
* Install AR CoA now set properly the company values.
* add meaning of CUIT when mentioned in code.
* unse a simplier elif and less conditions to evaluate
* only get concept for invoice lines that are not section/note
* remove TODO comments, this will be not implemented in this version
* update to sincular al the AFIP POS System options
* return match responsability type directly
* improve of manifest
* reference to tax group
* remove old not used file fot tax report
* update comments from spanish to english
* only set afip serive date when post the account.move
* unused file
* sum recordsets instead of union
* method name and remove log
* update manifest, delete new menus/fields/models from manifest
* Simply extra steps when loading AR COA: check directly
get_ar_responsibility_match in order to apply the extra verifications
and the extra configs in the company
* update demo refences to new demo for odoo
* return missing fix about _l10n_ar_create_document_sequences
* fixup missing change apply before merge/rebase
* set journal data as no update data.
closesodoo/odoo#36137
Signed-off-by: Josse Colpaert <jco@openerp.com>
In Latin American countries, every partner needs
to be identified even if he does not have the usual
VAT number (whatever it is called) e.g. you can also
be identified by your identity card.
We chose to put those types also in the vat field,
but to be clear what it is, we added a selection field
before the vat field which is VAT by default, but
is e.g. RUT (VAT of Argentina) when you choose Argentina
as country.