Commit Graph
4253 Commits
Author SHA1 Message Date
Xavier-Do 9c26d4d870 [IMP] core: rename upgrades-paths to upgrade-path
Since this option is soon to be used, this rename is a last tweek
to make it more logical to use since it will point to a single
upgrade dir most of the time.

closes odoo/odoo#44593

X-original-commit: 1c8e2809fb296abce6114b7da906d48a240df418
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2020-02-04 13:19:02 +00:00
Damien Bouvy c2fccc9118 [IMP] base: make name of custom models copied by default
Copying a custom model's record seems pointless by default, since
no field is actually copied.

It makes sense to copy at least the `x_name` field, to make it clear
to the user that the system understood it was duplicating something
and not just creating something entirely new.
2020-02-04 10:46:41 +00:00
Denis Ledoux 355cb45603 [IMP] base_automation, web: give possibility to disable/edit failing automated actions
If an automated action raises an exception, in the traceback modal:
 - For admins, display Disable & Edit automated action buttons
   to be able to directly know with wihch automated action the error occurred,
   and to give the possibility to edit or disable it quickly,
 - For regular users, just add a paragraph to tell with which automated action the error occurred,
   so they can give this useful information to their administrator

This is specially useful for databases which have just been
upgraded to a newer version, and for which the server action
is failing because its code is no longer supported.

closes odoo/odoo#44513

X-original-commit: 8f3940c132bbbc99e47fa3f0cba0e768159d9af2
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2020-02-03 16:16:01 +00:00
Martin Trigaux eafa9f4abc [FIX] *: python 3.8 compatibility
time.clock is deprecated since python 3.3 and no longer exists in python 3.8
time.process_time was introduced in python 3.3

Replace "is" by "==" as this produces a SyntaxWarning in python 3.8

Fixes odoo/odoo#41313

closes odoo/odoo#44502

X-original-commit: f03b4cb5576f264b6845242ba112f02422af4f5f
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-02-03 14:38:20 +00:00
Denis Roussel 68f5883aff [FIX] ir_property: Allows to search on boolean == False
Closes #43580
Fixes #9449

Adds field type conditions for boolean in search for Property model.

As False values are not stored in DB for boolean, the search() does
not return any value for non existent lines with:

* operator: '=' and value: False
* operator: '!=' and value: True

Uses the 'include_zero' and inverse operator mechanisms implemented
in Property model.

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-02-03 14:07:10 +00:00
Yannick Tivisse c7bb0786ed [IMP] base: Remove unused field res.company
closes odoo/odoo#44371

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-01-31 11:38:11 +00:00
Damien BouvyandRaphaël Collet 00205aae2a [IMP] base: support group_expand for custom fields
Allow a naive `group_expand` for manual fields where having the
attribute set to True causes the ORM to include all records from the
relation model of the m2o field in the read_group.

This is particularly useful for custom m2o fields which represent
stages - a grouped list view or a kanban view should include all
possible stage, not only the currently used values.

Co-Authored-By: Raphaël Collet <rco@odoo.com>
2020-01-31 12:07:29 +00:00
Damien BouvyandRaphaël Collet 4d2aa27157 [IMP] base: support ordering on custom models
Up until now, it was impossible to specify the default ordering
on models created manually.

This could somewhat be bypassed by specifying the ordering of records on
views themselves, but this has one main drawback: when using a
relational field that targets a custom model as a group-by key, the
ordering defaulted to the id of the custom record. For example, if I
create a custom field on partners that points to a custom model
'x_grade' on which an 'x_sequence' field exists, I could order my grade
in their own list view according to their sequence, but any read on
partners grouped by this 'x_grade_id' field would order the returned
groups by id while I would prefer to have them ordered according to the
'x_sequence' field.

This commit introduces a new field 'default_order' on the ir.model model
that can store this default ordering clause (as an SQL expression).

Co-Authored-By: Raphaël Collet <rco@odoo.com>
2020-01-31 12:07:28 +00:00
Damien BouvyandRaphaël Collet 8dab6caf46 [IMP] tests: add registry cleanups in Single and Savepoint tests
In some cases, the registry might be updated during a test step
(creating custom models/fields, for example).  In those cases, there
should be an explicit call to `reset_changes` on the registry to make
sure that the next test class starts with a registry that is consistent
with the database state.

Co-Authored-By: Raphaël Collet <rco@odoo.com>
2020-01-31 12:06:46 +00:00
Damien BouvyandRaphaël Collet c643be7679 [IMP] base: ensure correct inheritance chain in registry
When removing a custom model, it remained listed in the base classes
(normally `base` and also possibly a list of mixins; e.g. `mail.thread`
or `mail.activity.mixin`) list of inheriting classes, possibly causing a
crash when trying to reload the registry.

This commit ensures that any custom model is removed from its parent
class `_inherit_children` set; it will be re-added automatically during
the call to `_build_model` if the custom model still exists.

Co-Authored-By: Raphaël Collet <rco@odoo.com>
2020-01-31 12:06:46 +00:00
Damien BouvyandRaphaël Collet eaccecd6cc [IMP] base: correctly escape identifiers in reflection queries
When the db reflects the python models at startup, a query is generated
to update various `ir` models (models, fields, etc.). This query did not
properly escape identifiers, preventing the use of the 'order' field
name on ir.model because it is a reserved keyword in SQL and wasn't
escaped.

This commit introduces proper escaping for these reflection queries.

Co-Authored-By: Raphaël Collet <rco@odoo.com>
2020-01-31 12:06:46 +00:00
Xavier Morel 5cfd32db9c [IMP] core: only show JS stacktrace for exceptions & console.trace
When revamping the message fetching from the headless browser, since
stacktraces are available (by default) on console.error and
console.warning events I assumed it could / would be useful to show
them in the Python-level log. And they *were* quite useful during the
original fixing stage.

However they turn out not to be very useful day-to-day:

* they add a lot of noise and lead to the error message itself being
  lost in a big block of red / logging.error
* when a tour fails (which is the vast majority of the failures) the
  JS stacktrace always points to the same location in the tour
  manager (the one which goes "this step never succeeded") which is
  completely useless
* aside from being bundled, normal JS code (where the stacktrace could
  be useful) doesn't generally use console.warn or console.error, it's
  going to straight blow up with an exception in which case we always
  get a stacktrace

Leave the stacktrace formatting for console.trace as that's pretty
much the only point of using this instead of console.log.

closes odoo/odoo#44343

X-original-commit: 34500853f39c9557852cb83cbc274f59d803922f
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-01-30 16:12:33 +00:00
Dhruv Patel d5d2c5524c [FIX] base,web: url widget: add protocol in href
With this commit, the url widget automatically prefixes the href
url by http:// if no protocol is specified, so that clicking on
the url will by default redirect to an external website.

To prevent this behavior, one can still specify the new option
'website_path: true' on the url field node in the view arch.

Thanks to this, we can remove a similar logic (only implemented on
res_partner model) which automatically altered the value saved in
database to force its 'http://' prefix.

task-2153184

closes odoo/odoo#42118

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-30 14:03:36 +00:00
Raphael Collet a707bba744 [FIX] base: avoid systematic invalidation of web.report_assets_common
The issue is: the user wants to send an invoice to a customer, changes
the email template, and after the onchange, the field "Template" of the
wizard is empty.

Here is what happens.  The onchange on the template renders a PDF file
with the corresponding invoice document.  The rendering builds some
assets to convert the invoice to a PDF document, and former assets are
deleted.  The deletion of former assets (`ir.attachment` records)
invalidates the whole record cache, which implicitly clears all the
fields of the record of the onchange.

The problem is that the asset is systematically invalidated by the
rendering of the report itself.  This hack changes the CSS assets to
introduce company-specific colors for the rendering of reports.  This
implementation is actually not consistent with the fact that assets are
kept in cache by the server.

This patch does not fix the root cause of the problem, but it reduces
the sides effects of it, and makes the issue above less frequent.  It
simply consists in not updating the asset's attachment when its value is
already correct.

OPW 2168623
OPW 2171040

closes odoo/odoo#44295

X-original-commit: b1ddd9c95bc642e42eb0d3d51066902d5283ba04
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-01-30 12:31:58 +00:00
Xavier Morel c4e075cf04 [IMP] core, web: test failure reporting
* remove misleading documentation about a "test failed" message, in
  13.0 any uncaught exception or console.error will cause the current
  test to be interpreted as failed
* fix tour manager to console.error its step and not add a second
  useless error message
* fix menu tester to try and display the failure cause on failure
* improve qunit's test reporter to print the number of tests failed in
  case of test suite failure

Should make test failures in tours a bit clearer.

closes odoo/odoo#44296

X-original-commit: 78121b68d099b16f2d775a7a8a963a2a0f474843
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-01-30 12:33:05 +00:00
Ankita Raval 0052222b54 [REF] web: calendar: allow disabling the delete button
In this commit, we add a new attribute "Delete" for user conveniency
if he don't want 'Delete' button on popover card they easily achive
by "delete=false" attribute and also add a testcase for it.

task-id:2088954
2020-01-29 09:57:23 +00:00
Nicolas Lempereur df29632282 [FIX] base: search user by name negatively
When we name_search a res.user, we have a special hack so we will
firstly perform an exact search on the res.users login, if none is found
we will search over res.users name.

This is intended but in the case of negative search since 660cebb4faaeb,
for example operator='not ilike' and name='test' would probably just
return all user that do not have a login that is exactly test.

This is not the intended behavior, in this instance we should just
return user that do not have "test" in their names.

Without fix, added test would fail on:

- .name_search('vlad', operator='not ilike') => finding everyone but
  user with exactly login vlad instead of user not containing vlad in
  their name

- .name_search('', operator='not ilike') => find all users instead of
  finding no user

- .name_search('lad', operator='not ilike') => find all users instead of
  just finding "Nothing similar"

opw-2170517
closes #44040

closes odoo/odoo#44152

X-original-commit: 2378fb63c132c0bcf027785d478c0608b59a3409
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-28 20:04:29 +00:00
fw-bot 48b51e67c9 [FIX] module.py: --upgrades-paths dynamic hooks
Migration have long been only accessible thanks to a symlink from
`odoo.base.maintenance` to our private migration repository. Thank to
the change of bbb1a8f it is now possible to give a load the
migrations scripts from a path given in options.

The `initialize_sys_path` function has been updated to hooks the new
paths or the legacy symlink and to provide aliases to the previous
import logic to ensure backward compatibility.

`odoo.upgrades` (`community/odoo/upgrades`) is a new namespace that hook
all `--upgrades-paths` directories or the
`community/odoo/base/maintenance/migrations` symlink if none is previded.
`odoo.addons.base.maintenance.migrations` has been made an alias to
`odoo.upgrades`.

The `odoo.upgrades` is the desired method for accessing migrations
scripts and should be used by all new scripts.

closes odoo/odoo#44117

Task: 2178274
X-original-commit: d963cc05acd882729c4eb5ab940dae2a2197e55a
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-01-28 14:16:02 +00:00
Martin Trigaux a74a648030 [IMP] *: use ast.literal_eval
When simply need to parse a domain, it is easier

Add .strip() on ir.ui.view as ast.literal_eval produces an syntax
error if the node starts with spaces (as done in the xpath of
hr_attendance.view_employee_form_inherit_hr_attendance)

closes odoo/odoo#43831

Related: odoo/enterprise#7894
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-01-28 13:58:05 +00:00
Goffin Simon edb9dad5f2 [FIX] base: Changing company_id of a partner with child_ids
Steps to reproduce the bug:

- Let's consider a company partner P with company_id = A
- Let's consider an other partner C which is a child of P
- Change the company_id of P to B

Bug:

The company_id of C was not changed even if the field company_id
of C is in readonly as he has a parent.

opw:2179632

closes odoo/odoo#44061

X-original-commit: f41f7dc0f4f2a1682c6f81aba6512306ecf86067
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-01-28 08:48:06 +00:00
Xavier-Do e2bbf402dc [FIX] core: ignore studio_customization when checking modules states
Studio customization is an exception, a data module added to ir_module
but that is never added to graph since there is no manifest.

OPW #2180885
closes #43880

closes odoo/odoo#43940

X-original-commit: 4051ac83b5e7cc1cb91a264b51401ad5601ad4e2
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2020-01-24 15:28:03 +00:00
Victor Feyens 11ff605319 [REM] test_lint: uninstall hook
closes odoo/odoo#44027

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2020-01-27 15:20:42 +00:00
Nisha patel ce02a0ba89 [IMP] membership: category many2many tag field on partner
Purpose of the task is to get the contact tags in the list view, even if
membership is not installed and get the actual tags instead of 'Records 3'
by setting a many2many_tags widget on it.

closes odoo/odoo#43399

Taskid: 2172137
Closes: #43399
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-01-16 11:05:23 +00:00
jbm-odoo 00b2046460 [IMP] calendar: Adapt views and test for new color and filters
closes odoo/odoo#41573

Taskid: 2153249
Related: odoo/enterprise#7157
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-01-27 16:08:34 +00:00
Lucas Perais (lpe) e25aec5631 [FIX] base: kanban_record doesn't support <field/>
Open the form view of Contacts with some children
Some children have phone number set on them.

Before this commit, the phone was not displayed
This is due to the same reason as #35869

After this commit, the phone number is displayed.
Although widgets can't be supported in this case

closes odoo/odoo#40266

Related: odoo/enterprise#6706
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-27 09:31:54 +00:00
Lucas Perais (lpe) 9538245267 [IMP] *: adapt views for phone widget sms enabled default
Task 2123526

This commit adapts the views to take into account
that the phone widget enables sending an sms by default

*: crm, hr, sms, base
2020-01-27 09:31:53 +00:00
Raphael Collet 9ce78bff5f [FIX] core: search on one2many fields with context
Consider an x2many field `foo_ids` with `context={'active_test': False}`
in its definition, and a comodel with an active field.  The value of the
field includes inactive records.

Now consider a search with a domain like `[('foo_ids.bar', op, value)]`.
The search should return all the records with corecords that satisfy the
domain `[('bar', op, value)]`, including inactive corecords, because the
field's context explicitly disables filtering on the active field.

closes odoo/odoo#43625

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-01-21 09:31:58 +00:00
Jason Van Malder 3b4cdbebf2 [FIX] odoo: default Dutch language settings
Dutch default settings are incorrect:
- Separator Format []
- Decimal Separator ,
- Thousands Separator (empty)

This must be:
- Separator Format [3,0]
- Decimal Separator ,
- Thousands Separator .

OPW-2179020

closes odoo/odoo#43956

X-original-commit: 5c2ea7426d3f70ad897328b41e2df02508708c61
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-01-24 17:57:11 +00:00
Sébastien Theys 25708586a7 [FIX] fields, test_new_api: fix m2m commands in batch
Before this commit executing m2m commands in batch would lead to undesired
results, such as duplicating the related records on every subsequent record of
the batch.

Indeed since [1] the `create` and `unlink` are called in a loop, but their
content was not reset at each iteration.

[1] 9920f20e4c

closes odoo/odoo#43950

X-original-commit: 0800f64b011c8f020c0d7dd6e1c149aebd1a4627
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-01-24 17:13:05 +00:00
Xavier Morel b66a7feb0f [IMP] core: strip log_handler items before splitting them
Allows better formatted and commented log_handler items in
configuration files: configparser allows multiline values and
interspersed comments (stripping out comment lines), but while it
removes indent it leaves the linebreaks, so e.g.

    foo =
      bar,
      # qux
      quux

when parsed and split on "," results in `['\nbar', '\nquux']` which is
obviously an issue for logging (as it assumes the leading `\n` is part
of the logger name proper).

Since log_handler items can be fairly long and are not necessarily
self-descriptive as to *why* they were selected for re-configuration,
allowing one per line & comments is helpful.
2020-01-21 06:56:15 +00:00
Xavier Morel 7b13ce17c2 [IMP] base, test_access_rights: mute ir_rule logging on ACL tests
The tests are willfully triggering ACL failures, logging the
information is noisy and not useful.
2020-01-21 06:56:15 +00:00
Xavier Morel 0198c3e05d [IMP] core: reporting of browser logs / errors during setup
Sink handling of JS logging, exceptions and websocket timeouts so
calls other than _wait_code_ok handle them somewhat properly: the
issue fixed by odoo/odoo#41231 passed because it occurred during
module loading, which happens during initial page loading (browser_js
> navigate_to > _websocket_wait_event), which ignored logs (and
exceptions though here it's a console.error log), and as a result
reported no failure (and would simply miss that specific test as well
as every test following it).

Also since ChromeBrowser treats console.error as an exception,
important messages should be logged atomically. Merge two consecutive
console.error into a single one at the loading of modules so we don't
just get an exception "error while loading foo.bar" without any of the
useful details.

That ChromeBrowser treats console.error as exception is also why the
new method gets a flag (to suppress this behaviour): in the case of
two console.error, upon encountering the first it's treated as an
error so we try to take a screenshot, which goes through the messages
in order to get the screenshot response, which encounters the second
console.error, which gets treated as an exception, which hides the
first error.

Instead, screenshotting (and more generally _websocket_wait_id) should
treat console.error as a regular logging call, probably.

Also run JS tests in debug=assets for easier debugging (ha!) and
improve formatting of exception object when receiving an exception:
* if we can get a description on an `exception` remote object just
  print that, it's formatted to show the exception type, message &
  traceback
* otherwise format the garbage that is an "ExceptionDetails" object
2020-01-21 06:55:32 +00:00
Xavier-Do cbab786eb2 [IMP] core: do not log error for unmet dependencies on add_modules
When migrating a database, load_marked_modules will be called multiple times, alternating
to upgrade and to install modules. The main reason for this is still a litle confusing
but it as the side effect to log "Unmet dependencies" error multiple time in add_modules,
even if the dependency will be resolved later.

This commit removes the error level for this log, and replace it by another check,
performed at the end, logging any module in "to install"/"to upgrade" state.

Also log removed module as info (25), not warning. This may be changed latter

closes odoo/odoo#43797

X-original-commit: c5d6a3977de85fb974a4940fb11d54ef847e08e4
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2020-01-22 17:33:32 +00:00
Martin Trigaux 9aef423d4d [FIX] auth_ldap: replace the deprecated library by one up to date
At 795c7b0a94 the external dependencies was changed from trying
to import 'ldap' to checking than 'pyldap' package was installed.
The problem is that pyldap is a unmaintained library that should no
longer be used, as explained on the package page:
https://pypi.org/project/pyldap/
"The pyldap fork was merged back into python-ldap, and released as
 python-ldap 3.0.0."

Having pyldap version >= 3.0 installs python-ldap automatically and
will not cause any issue.

The Debian control file package name is adapted to use the latest.

The "ldap" externalm dependency defined in __manifest__.py will cause
pkg_resources.get_distribution() to fail in both case ("python-lap" or
"pyldap"), but the "import" fallback will succeed. For that reason, the
log warning is turned into a log info.

closes odoo/odoo#43769

Note: This library should be replaced by the pure python "ldap3" library.
X-original-commit: 1afd0ccf20881ba97e3c07dffb33e9a3a0b2cda4
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2020-01-22 14:09:46 +00:00
Yenthe666 c76345999c [FIX] base: search on partial mobile phone numbers too
Before this commit the search would search for phone numbers that contained a part of a string. The mobile phone would only look at exact matches so if we'd search for '0492700' the only result would be contacts with this exact match. After this commit every mobile phone that contains '0492700' will match and be shown. This allows for quickly finding customers by a partial mobile, just like the phone number does.

closes odoo/odoo#43752

X-original-commit: 8a34a6a66f3f06829231e5d0ba536fcdd27d17ea
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-01-22 12:21:56 +00:00
wan d8c5cc1335 [IMP] account: add a readonly group
Task 2092079
Accounting firms that want to give access to their customers avoiding
mistakes and risks will love this profile that can't do anything
wrong... Maybe as well as companies auditors..?

closes odoo/odoo#39860

Related: odoo/enterprise#6576
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2020-01-22 11:23:16 +00:00
Nicolas Martinelli a7e2a7b2ee [FIX] base: correct rounding
Correct the rounding of several currencies which should be 0.001.

opw-2172122

closes odoo/odoo#43715

X-original-commit: 71f01060ea359814ffdb9ef506a01a2543dfc9ea
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-01-22 08:10:29 +00:00
Martin Trigaux 194ed76c5c [ADD] base: replace Filipino by Tagalog language
This is the second move to replace Filipino by Tagalog language

Using Filipino (code fil_PH) is problematic as conflicts with Finnish
(code fi_FI) and users having their browser in Finnish were redirected
to the Filipino version of the website (cf discussion at opw-2172710).

This problem was also raised in other softwares like in the below
discssion in Mozilla L10N groups
https://groups.google.com/forum/#!topic/mozilla.dev.l10n/TW2qYyDDNoE

Quoting the discussion in above thread:

> Filipino is the national language of the Philippines, but it is
> commonly referred to (and registered as) Tagalog, since most of the
> terms therein were derived from it (Tagalog).

This commit targets the master (future 14.0 as of today), adds a new
Tagalog language and removes the Filipino.
In 12.0, only the Tagalog was added.
As fil_PH is only translated on odoo-com project but remains at 0% in
other Transifex project, it is assumed the language switch won't
impact too many people.

closes odoo/odoo#43634

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2020-01-21 13:12:12 +00:00
Adrian Torres 1d13928764 [IMP] core: improve mapped and filtered performance
Previously, mapped was following a very naive approach, which was simply
calling the field name passed as input for every record in a recordset,
sequentially.

The problem with this approach is that we will potentially recompute the
same fields multiple times for differents records, when this could be
done once per field for ALL records, and store this value in cache for
further access.

Another potential problem is that we don't take advantage of the ORM's
prefetching to fetch all the records that are not in cache at once,
instead of doing the same query for every record in the recordset.

Yet another problem is the conversion of each cache value to a record
format and then combining all of the individual records into a single
recordset, which, depending on the size of the recordset, can take an
unbelievable amount of CPU time.

With this new implementation of `mapped()` we take care of all of these
problems:

This is done by first delegating `mapped()` from the model to the field,
this mapped takes a recordset as input and it will try to batch compute
and prefetch as much as possible for the entire recordset, but it will
not keep these values for the actual output, it just stores everything
in cache and then at the end, retrieves everything from the cache to
guarantee the same order.

After the mapped, the conversion from cache format to record format is
delegated to the new `convert_to_record_multi` which will fetch all the
ids and then perform a single browse to encapsulate all of the records
into a single recordset with the least amount of overhead possible.

Part of Task 2170344

closes odoo/odoo#42611

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-01-21 14:06:50 +00:00
Damien Bouvy 2f900d4f1c [FIX] account, base: Creating contacts from their parent or setting their parent
Bug in 13.0 regarding company_id field of partners when creating them from
their parent contact or when setting their parent.
The field 'company_id' of res.partner is set by an onchange on 'parent_id'
to that of it's parent; unfortunately the field is readonly if parent_id
is set and not set to force_save.
Furthermore, creating a child partner from the main one (in the 'Contact'
tab of the main partner form view) does not follow the same behaviour
(company_id is unset in that case, meaning that children don't have
the same company as their parent).
Since the company_id is already set by an onchange when we change 'parent_id'
and set to readonly in that case, I assume the expected behaviour is actually
that children partners should have the same company as their parent by default.

Fine tuning of 7b49f5836c

opw:2176384,2167106

closes odoo/odoo#43621

X-original-commit: 92737f21acf9b044df99e111fceffc08e05abe65
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-01-21 10:00:55 +00:00
51b36c3dbb [IMP] base: add default image for users + placeholder if unassigned
1/ When the new database is created without demo data, the admin has a
   'silhouette' as a default picture. When a new user is created without
   picture given by the current user, the new user will have a 'silhouette'
   as a default profile picture.

2/ web: image for fa-user-slash. This image will be used when a record is
   unassigned.

3/ web, *: Change placeholder by default when record is unassigned.
   We want to have a fa-user-slash icon when a record is unassigned instead
   of 'placeholder.png'. A method is created in the BaseModel to have a
   generic method to change easily the placeholder for other models.

4/ Adapt kanban test to keep the same behaviour. Attention the behaviour is
   a bit different. Because, now the default image is given by the server to
   change easily the default image when a record doesn't have an image.
   Thus, we don't say if it's the default placeholder, but we can say it's
   not the same image of the record (in this test, the record, it's the
   partner).

5/ misc: display 'Unassigned' in the hover on kanban cards if record is unassigned

closes odoo/odoo#41356

Taskid: 2060206
Related: odoo/enterprise#7758
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: jdoutreloux <jud@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2020-01-21 09:22:46 +00:00
Adrian Torres be01db2f71 [IMP] api: move cache_key to the Environment and cache it
Computing the `cache_key` turned out to be a big factor during the
lifespan of a `BaseModel.mapped` call and a lot of this time is spent
computing the same `cache_key` over and over.

These unnecessary computations can be easily reduced to a couple by
moving the `cache_key` method on the environment (instead of the field)
and by implementing a memo for that method.  The rationale is that the
`cache_key` of a field does not change for a given environment.

The result of this patch is up to 50% faster `Field.__get__` which in
turn means a GLOBAL gain in performance, especially for methods /
functions that rely heavily on `__get__` such as `BaseModel.mapped`.

closes odoo/odoo#42674

Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
2020-01-21 08:28:36 +00:00
Jeremy Kersten 5198b209f5 [IMP] base: improve log for wrong xpath
Before create_multi, in case of invalid syntax used in an XPath, only
the problematic record was displayed. It was not ideal for long
definition but still usable.
Since the views are created using create_multi, the whole file content
is displayed in the error traceback, making it almost impossible to
locate on files with multiple records.

closes odoo/odoo#43590

X-original-commit: 8622469e1fdd4789cc45ed52093d0f329abca14e
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-01-20 16:31:09 +00:00
Raphael Collet 238e7436ed [FIX] expression: performance of search on one2many fields
We optimize the search on domains like `[('line_ids', 'in', ids)]`.
The condition is rewritten `('id', 'in', ids1)` where `ids1` is the
result of

    SELECT <many2one_field> FROM <comodel_table> WHERE id IN <ids>

The issue is that the latter potentially returns many duplicate values.
The fix consists in having as few duplicates as possible in `ids1`.

Note that domains like `[('line_ids.foo', '=', 42)]` implicitly benefit
from the optimization, as they are rewritten as the one above with

    ids = comodel.search([('foo', '=', 42)]).ids

closes odoo/odoo#43574

X-original-commit: a13c05fa5df9c98504e8e1cdb09d8d4a8d13ea91
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-01-20 13:43:29 +00:00
Raphael Collet cdc4547168 [FIX] models: duplicates in records to prefetch
Fix the prefetching mechanism to never consider a recordset with
duplicates.

closes odoo/odoo#43426

X-original-commit: c312e1e5e5e23d1d8dc172aa6e5f8f07f5638792
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-01-16 15:11:58 +00:00
Raphael Collet a8ea77a771 [FIX] base: browse(record) in company-dependent field value
The faulty code modifies a dictionary in-place to apply a formatting
function to each value.  In this case, the formatting is `browse`, and
the issue occurs when `ids` contain duplicates:

    for id in ids:
        result[id] = format(result.get(id, default))

Fix it by returning a new dictionary based on `result`.

X-original-commit: bd4565e227c7196604af9c5c51ce136a2beac088
2020-01-16 15:11:57 +00:00
Christopher Ormaza 51de5eb041 [FIX] core: disable wait_callback during copy_from
Apparently some solutions (e.g. bitnami) deploy odoo using async
workers, and not all pg/psycopg2 features are supported in that mode,
notably COPY FROM (bulk-copying data from a stream to postgres). Work
around this issue by disabling "async mode" as we do the copy (by
resetting the wait callback) then re-enabling it.

While this is not an officially supported run mode, it should Do No
Harm™ for normal operations and could help users and clients.

Of important note: while this fixes an error running in async mode, it
will also prevent the worker from yielding while copy_from is
executing. Hopefully that doesn't take too long (as the entire point
of the copy_from is to be fast) but there you are.

Fixes odoo/odoo#24145

closes odoo/odoo#43481

X-original-commit: c4583cf89c2b24085a2eeafea5ef76f474c5ff84
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-01-17 12:20:03 +00:00
Nicolas Lempereur b239201190 [FIX] *: avoid muting res.users().context_get return
Some code modify return of res.users().context_get, but this is a
cached method so this will unexpectedly affects totally unrelated code.

For example, changing the company with the company switcher could add
`allowed_company_ids` inside the cache, then it will be cached until the
server is restarted, even if we change company again inbetween.

Added test failed with:

"NotImplementedError: '__setitem__' not supported on frozendict"

on the line with `User = User.with_context(context)` where User already
contained `allowed_company_ids` in its context.

note:

in this forward-port, context_get is also changed to return frozendict
and prevent being able to have an unexpected issue by code that modify
context_get returns.

opw-2158340
closes #42465

closes odoo/odoo#42723

X-original-commit: 5d69885c1cd6921b3de00aae7e0ed6fff243ff95
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-15 16:19:03 +00:00
Thibault Delavallée d6e6e2d771 [IMP] base, account: move bank accounts partner information from base to account
Before this commit, bank accounts tab on partner view is available directly
in base whereas it should not, as it contains information useful only
for accountants. We therefore move them directly to account.

Task ID: 2172260

closes odoo/odoo#43322

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-01-15 09:30:07 +00:00
Adrian Torres ee29cb9147 [FIX] tests: make --test-file great again
Sort of but not really, this commit fixes a special case in which
launching a --test-file of a file with at least two SavepointCases would
create a postgresql deadlock and it would be impossible to terminate the
Odoo process without sending a SIGKILL or waiting for the lock to
timeout.

This was introduced at #39368 and happens because of the way that
unittests unwraps suites, to keep it short, when it unwraps the custom
OdooSuite class internally, it ends up with a vanilla TestSuite with
which to run the different test cases, and since #39368 depends on the
overrides added to OdooSuite to function, the class cleanups are not
triggered at the end of a test class (rollback, cache cleanups, env
reset, registry reset, etc.).

The fix is to manually unwrap the suite of tests to keep OdooSuite as
the suite with which to call the tests, which was already done for
--test-enable (although for different reasons, --test-tags?) which is
why --test-enable didn't have any problems.

This commit also fixes a typo I found on the backport, which meant
classCleanups were not being executed if the setUpClass failed, but it
had no effect on classCleanups during tearDownClass.

Task-ID 2160398
Depends on #43135

closes odoo/odoo#43296

X-original-commit: 7a5ded7d40afc29043d356b5dece0dbe1fbd5ab3
Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
2020-01-14 16:26:50 +00:00