Commit Graph
4669 Commits
Author SHA1 Message Date
Jeremy Kersten 79807d6907 [IMP] base, website_sale: handle required zip/state on eCommerce
task-2172788

closes odoo/odoo#54746

Related: odoo/upgrade#1509
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-07-22 09:56:03 +00:00
Thibault Delavallée f8b87c959a [IMP] base: have user_admin / partner_admin available in HttpCaseWithUserDemo on self
Purpose is to simplify future tests to have admin data directly available at
hand, both its user and partner. It will ease future test writing.

LINKS

Task ID 2290016 (improve visitor synchronization and tests)
Prepares Task ID 2252655 (main Online Event task)
Prepares Task ID 2284043 (Visitor-based track wishlist)
PR #54036

X-original-commit: f51fd6e54da5ee8aee0df74e6d510dc0b077eba8
2020-07-22 09:02:55 +00:00
Raphael Collet ef01493678 [FIX] core: update of one2many field on new record with origin
When setting the inverse many2one field on a record, the record is not
removed from its inverse relation if the field's current value is not in
cache.  Fix this by setting the field's value in cache before updating.

closes odoo/odoo#54711

X-original-commit: df12c85816dfa59f298c3e6a077bd88e4b7aa6a6
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-20 11:42:59 +00:00
Xavier Morel b3761a8cba [FIX] core: fix handling of removals in sub-o2m
Issue is specifically in the case of an onchange removing a record in
an o2m in an o2m (so a sub-o2m) if loading an *existing* record in the
SSF: since the server pretty much only returns a REMOVE_ALL followed
by the records to keep or create, conserving the removal information
requires diffing the value currently stored in the form and the result
fo the onchange.

Diff which was properly done for top-level o2ms, but not for the ones
below that (apparently forgot this bit when improving support for
nested o2ms earlier this year).

X-original-commit: 177d009541cca589c6ebb85fc051b893ec001536
2020-07-20 11:42:58 +00:00
Jeremy Kersten c580197a20 [FIX] base: handle_exception should never alter json response
Before this commit, in case you were in --dev-mode, if a json request crash,
it was wrongly intercepted and return a Internal Server Error with status 500
and without the JSON Response

For the change of http code, since it is only in dev mode, it could not impact
a production server (in theory) with custom code based on it.

After this commit, if your rpc fails, you will not have anymore a breakpoint in
the code to help the developer to debug. But you will have a status 200 on the
rpc request.

closes odoo/odoo#54668

X-original-commit: 534cca311db1ecf1005a24d5cbd50e166094ba2a
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-07-17 12:47:59 +00:00
Paul Morelle 119637cf9e [FIX] models: fix permission check in export_data
The permission check in BaseModel:export_data was checking if the
current user was the administrator user, instead of checking if the
environment was administrator (i.e. it should also check if the sudo bit
is set on the environment).

This commit fixes this and allows to export_data with a simple `sudo()`
instead of needing a `with_user(SUPERUSER_ID)`.

closes odoo/odoo#54647

X-original-commit: f69f47b6ba5c6c462bf617f4876a39233f60034f
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
2020-07-17 10:14:06 +00:00
Xavier Morel c0745584aa [FIX] core: handle recordsets in traverse_containers
Since recordsets are self-recursive, they should be treated like
strings (where iterating a string yields a string, infinitely) in case
somebody happens to return a non-downgraded recordset from a method.

closes odoo/odoo#54572

X-original-commit: 6d88845f339d164fc2667c3417dcc331b317e4db
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-16 12:04:57 +00:00
Adrian Torres 9fefa08745 [FIX] core: mapped() does not prefetch as expected
Before this commit, calling `mapped()` on a relational field of a single
record inside a for loop does not correctly propagate the prefetch ids
from the bigger recordset down to the record inside the loop:

    [rec.line_ids.mapped('name') for rec in recs]

To be more precise, `recs` correctly propagates prefetching information
down to `rec.line_ids`, but method `mapped()` does not pass it along to
the record that triggers the prefetching.

This resulted in one query per record in `recs`, so if `recs` were a
1000 records recordset, at least 1000 queries would be necessary.

With this commit, the `mapped()` function correctly propagates the
`_prefetch_ids` of the larger recordset (`rec.line_ids`) so that the
prefetching works properly and the 1000 queries are brought down to 1.

This commit is a followup on #42611.

closes odoo/odoo#54565

X-original-commit: 0e97053fee36c0c76b70cb94be5340c3144b178b
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
2020-07-16 11:09:05 +00:00
Xavier Morel 65b8751e32 [FIX] core: mis-updated SQL queries
odoo/odoo#53938 improved the SQL linter and used psycopg2.sql to
silence the linter where that still made sense. However I forgot to
mark table names (pretty much exclusively) as `sql.Identifier` in a
few somewhat rare callsites, which consequently break when invoked as
a simple string is not a Composable and psycopg2 therefore rejects it
when composing the query.

closes odoo/odoo#54556

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-16 09:10:03 +00:00
Raphael Collet a21e8afda4 [FIX] core: update of one2many field on new record with origin
An onchange method can remove an existing line from a one2many field of
a new record with command 2, such as:

    move.line_ids = [(2, <NewId origin=42>), ...]

The processing of the command 2 above incorrectly tries to remove the
new line from the origin record, instead of the new record.

closes odoo/odoo#54545

X-original-commit: 7d138a445acbd9f2e122d9c30ca81877bae6a245
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-07-16 08:16:16 +00:00
Jinal Patel 8d721f6728 [IMP] base: change unique model name sql constraint message
-Purpose of this task is to make the unique model name constraint
 clearer by specifing name of the model needs to be unique.

-In this commit, change the constraint message from
 'Each model must be unique!' to
 'Each model must have a unique name.' to let the user know name
 of the model causes the issue.

task-2254964
Closes-#51513

closes odoo/odoo#51513

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-05-19 09:08:36 +00:00
Nicolas Martinelli 5718764ed9 [FIX] base: currency of Slovakia
The currency of Slovakia is EUR (since 2009).

opw-2293328

closes odoo/odoo#54507

X-original-commit: 7a414dd666ae57285762f059e1c3e3cdb4801a1f
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-07-15 12:28:01 +00:00
Xavier Morel 470fb905a9 [FIX] base, mail: properly annotate Partner.find_or_create
In 6e25a510b3 `find_or_create` was
modified to return a recordset rather than just an id. This made it
incompatible with the RPC protocol and it was not annotated to
downgrade the return value back to an id.

Fixes odoo/odoo#54466

closes odoo/odoo#54476

X-original-commit: a7e3894e20207b714cebefa908be090967866791
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-15 07:36:23 +00:00
Raphael Collet 6c9da4a206 [FIX] core: search on boolean field with operator in
closes odoo/odoo#54457

X-original-commit: 363533b7d50448c06cef2baa68d6f4f634346252
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-07-14 15:15:11 +00:00
Nasreddin (bon) 05dc6679b9 [FIX] base: Handle custom field under country in contact kanban view
Issue

	- Install "Studio" and "Contact" apps
	- Edit with Studio the Contact Kanban View
	- Add field under city/country

	Field appears only if no city is set.

Cause

	The new field has as anchor the 5th <li> with the field country
	who will appear only if not city is set. However, in case there a city
	AND a country, the 6th <li> will appear instead of 5th (the target one).

Solution

	Let only one <li>, one country and one city field but with the right conditions.

opw-2288545

closes odoo/odoo#54423

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-07-14 09:12:03 +00:00
Julien Mougenot 669c2ebaec [IMP] web: improve eval context dates
This commit handles 2 things:

1) the merging of the `py_utils.context()` into the evaluation context
returned by `BasicModel._getEvalContext` to access the same time-related
keys,

2) the addition of 2 new keys into the `py_utils.context` (thus
transmitted to the basic model): `today` (an alias for the already
present `current_date`) and `now` which represents the current date and
time value.

Task 2269697
2020-07-14 09:10:32 +00:00
Nicolas Lempereur 930db42b3a [FIX] models.py: group by date with DST change
When we group by date with DST change within a range, we could get a
reocrd inside two date range grouping, or inside no grouping.

This is because we computed range just with [+ 1 month], so we possibly
had these ranges (in UTC):

- October 2019 : [('datetime', '>=', '2019-10-01 02:00:00')
                  ('datetime', '<', '2019-11-01 02:00:00')]

- November 2019 : [('datetime', '>=', '2019-11-01 01:00:00')
                   ('datetime', '<', '2019-12-01 01:00:00')]

So a record on 2019-11-01 01:30:00 would be both inside October and
November.

This happen because the DST is removed on happen on 27 October 2019 and
this was not taken into account when computing the end of the range.

With this changeset, for the given example aboth, we will have:

- October 2019 : [('datetime', '>=', '2019-10-01 02:00:00')
                  ('datetime', '<', '2019-11-01 01:00:00')]

Added test without the change fails with "AssertionError: Lists differ"
because:

- "Q1 2019" finished on 17:00:00 instead of 16:00:00
- "Q3 2019" finished on 16:00:00 instead of 17:00:00

opw-2278829
closes #54056

closes odoo/odoo#54345

Note: maxDiff added for test to work in 13.0
X-original-commit: af5d03de28fa300ebbaa37a3d226b41051ebdf0f
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-07-10 15:39:25 +00:00
william bffb3b7fce [REF] base: clean dosctring and remove deprecated function
The function check_with_xsd has been deprecated for more than 3 years.
Docstring is now compliant with PEP 257

closes odoo/odoo#54338

X-original-commit: 29938397ee17835645e89ee0dadb26e14ef45927
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-07-10 14:18:13 +00:00
william 048c7fef67 [IMP] base: _check_with_xsd from ir.attachment
Search the xsd files from in the database.
To enable this option, the Environment should be passed to the optional
`env` parameter. Both the XSD root and the XSD imported by the root and
the recusrively imported files will be searched in the database.

X-original-commit: 06a35f2e11230db81b8c21696d228097b31cf649
2020-07-10 14:18:12 +00:00
Xavier Morel e162e6f714 [FIX] test_lint, *: false negative in sql injection linter
The linter would miss / fail to warn on injection of *local variables*
in some cases.

Try to improve it to be stricter and more reliable, after discussion
with odo, sql which is "correctly" dynamic should use psycopg2's sql
package in order to bypass the linter (bonus: it should also properly
escape & quote identifiers).

closes odoo/odoo#53938

Related: odoo/enterprise#11718
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-07-10 07:12:35 +00:00
Xavier-Do dbf4060649 [IMP] tests: allow to run at_install tests without update
Debugging/improvement of an at install test may be tedious because of
the need to update the module, spending most of the time checking
tables and xml file.

1. This commit proposes to allow to execute test without installing or
updating a module. The test is still executed during the loading, and
the behavior should be close to an execution of tests during an update.

Co-authored-by rco-odoo <rco@odoo.com>

2. keep previous behavior if -i or -u is given

Three solutions were possible:
- The clean one that changes dev habits.
When test-enable or test_tags is given, all tests are always executed,
a test_tags is needed to select tests to execute:
Example: `-u module --test_enable` becomes `-u module --test-tags /module` to keep the same behaviour
This solution is the simplest, and executed tests does not depends on database already installed modules.
- The conservative solution.
When giving -i or -u, the behavior stays the same as before. When giving test-enable
without -i/-u, test are executed on all installed modules.
- The intermediate solution:
When no test_tags is given but a -i and -u is given, only the given modules are tested.
This is quite close to the second solution except that a -i module on a new database won't
test all dependencies on the first install.

The chosen solution is the second one to minimize changes on dev old habits,
only an almost unused feature is impacted: using test-enable without any -i or -u.
Before this pr only post install tests were executed in this case. Now at_install tests are also executed.
This combination is actually used by runbot to execute post_install test in parallel, but a `--test-tags -at_install`
tag is given so nothing to worry about here.

closes odoo/odoo#53499

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-07-09 10:01:45 +00:00
Raphael Collet dd8a6b8a82 [ADD] test_new_api: tests on queries made by create with computed fields
closes odoo/odoo#54209

Related: odoo/upgrade#1464
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-07-08 11:58:33 +00:00
Denis Ledoux d5d79805d2 [FIX] models: prevent fields inherited from delegate=True to be deleted
Use case:
 - `./odoo-bin -d mydb -i website`
 - `./odoo-bin -d mydb -i base_automation`
 - `./odoo-bin -d mydb -u website,base_automation`
 ```
 odoo.addons.base.models.ir_model: Deleting 2652@ir.model.fields (base_automation.field_base_automation__website_published)
 odoo.addons.base.models.ir_model: Deleting 2651@ir.model.fields (base_automation.field_base_automation__website_url)
 odoo.addons.base.models.ir_model: Deleting 2650@ir.model.fields (base_automation.field_base_automation__website_path)
 ```

The issue comes from the fact:
- `website` adds multiple website related fields on `ir.actions.server`
  https://github.com/odoo/odoo/blob/30e94d305f9cffa816ddc213e0b9329c0263c145/addons/website/models/ir_actions.py#L16-L18
- `base.automation` inherits by delegation of the `ir.actions.server` fields
  thanks to `delegate=True` on its field `action_server_id`
  https://github.com/odoo/odoo/blob/30e94d305f9cffa816ddc213e0b9329c0263c145/addons/base_automation/models/base_automation.py#L37
- when `base_automation` is installed after `website`
  when `_reflect_model` is called,
  the website related fields on `ir.actions.server` are well in the `_fields` of the `base.automation` model,
  and there an xmlid for these fields is created
  e.g. `field_base_automation__website_published`
  https://github.com/odoo/odoo/blob/30e94d305f9cffa816ddc213e0b9329c0263c145/odoo/addons/base/models/ir_model.py#L881-L882
- during the `-u website,base_automation`, `_reflect_model` on `base.automation` is called before
  the website related fields coming from its inherits on `ir.actions.server` are added in its `_fields`,
  and is not recalled after they are added, when the `website` module is loaded and these website related fields
  are added on `ir.actions.server`.

Because of this, at the end of the upgrade, in the `ir.model.data` `_process_end`,
as the xmlids of these fields have not been loaded,
they are being deleted, because the ORM considers these fields were dropped
from the source code because their xmlids have not been loaded during the upgrade.

Adding the model `base.automation` in the `inherits_children` of `ir.actions.server`
when the delegate field `action_server_id` is added make sure
`_reflect_model` is called on `base.automation`
after the website related field are loaded on the model `ir.actions.server`,
and therefore ensure the xmlids are properly loaded,
therefore preventing the fields deletion.

Additionaly, `delegate` and `inherits` are supposed to be equivalent,
it's just two ways to do the same thing.

Before this revision,
when using `delegate`, `base.automation` is not in the `inherits_children` of `ir.actions.server`:
```
In [1]: env['ir.actions.server']._inherits_children
Out[1]: set()
```

while, by converting the `delegate` to an `inherits`:
```diff
diff --git a/addons/base_automation/models/base_automation.py b/addons/base_automation/models/base_automation.py
index 196ebe9965f..c073150386a 100644
--- a/addons/base_automation/models/base_automation.py
+++ b/addons/base_automation/models/base_automation.py
@@ -30,11 +30,12 @@ class BaseAutomation(models.Model):
     _name = 'base.automation'
     _description = 'Automated Action'
     _order = 'sequence'
+    _inherits = {'ir.actions.server': 'action_server_id'}

     action_server_id = fields.Many2one(
         'ir.actions.server', 'Server Actions',
         domain="[('model_id', '=', model_id)]",
-        delegate=True, required=True, ondelete='restrict')
+        required=True, ondelete='restrict')
     active = fields.Boolean(default=True, help="When unchecked, the rule is hidden and will not be executed.")
     trigger = fields.Selection([
         ('on_create', 'On Creation'),
```
it is:
```
In [1]: env['ir.actions.server']._inherits_children
Out[1]: {'base.automation'}
```

closes odoo/odoo#54171

X-original-commit: 3fd162db3ab51cc473d99bd90fce6c135f3b4ff3
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2020-07-07 09:12:27 +00:00
Xavier Dubuc 5afc70faef [FIX] mail: fix open thread in discuss
See also odoo/enterprise#11684
task-2282273

closes odoo/odoo#54141

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-07-06 14:23:17 +00:00
Victor Feyens 37f5424593 [IMP] core: simplified error message
-> 1 less translation
-> the first part of the message didn't add anything useful

closes odoo/odoo#54118

Related: odoo/enterprise#11676
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-07-06 10:30:29 +00:00
Christophe Simonis 85c3fd8b73 [FIX] core: do not mark ir.model* unique fields as modified
These field combinations [1] are actually secondary keys. They are
unique and represent the record identity.

Marking them as modified had a nasty side-effect: on some models, there
is a m2o to an ir.model and a stored related to ir.model/model that will
be recomputed at each model reflection. This can take some time on big
tables.
Moreover, some other stored fields may depend on those ir.model/model
related store, which adds useless time lost at recomputing unchanged
values.

[1] ir.model/model, ir.model.fields/{model,name} and
    ir.model.selection/{field_id,name}

closes odoo/odoo#54126

X-original-commit: db013a01ca4e10640ac33a59466c9cb5746e3698
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: Christophe Simonis <chs@odoo.com>
2020-07-06 11:11:05 +00:00
Yannick Vaucher 3230ae6441 [FIX] l10n_ch - Swiss QR layout cleaning
This intend to enforce specifications and improve readability

Layout changes:

* [FIX] Amount section must be placed under the QR code
* [FIX] Don't display empty additional information
* [FIX] Rename slip sections and labels
* [IMP] Rework of the layout

    Group content like adresse by removing line spacing
    Reduce character size to follow Swiss Implementation Guidelines QR-bill v2.1
    Reduce left margin to avoid overlap of spaced ISR reference on the Receipt

* [FIX] Missing street on Receipt
* [FIX] Add thousand separators

    Official specs asks for:
    - thousand separators as blank. (using a non breaking to avoid spliting the amount)
    - decimal separators as a full stop

    > If  the  amount  isincluded  in  the  Swiss  QR  Code,  then  it  must  be  printed  after  the currency code. A blank (space) should be used as the thousands separator and a full stop «.»as  the  decimal  separator.  The  amount  must  always  include  two  decimal places (e.g. CHF 1 590.00).

QR-Code:

* [IMP] Align QR code upper and improve accuracy of size

    Add an option on reportlab to print QR Code without surounding blank space
    this is required to compute with accuracy the width of 46mm x 46mm defined
    in the specs.

* [FIX] Street and street2 issues

    Removes an extra space between street values when only one is given.
    Test the right partner street, only the company street was checked.

QRR generation

* [FIX] make it possible to generate QRR

    It must be possible to generate QRR without ISR subscription number.

Content removed as not present in the specs version 2.1:

* [RM] procedure section
* [RM] due date

Translations:

* [IMP] Add translations of the QR-bill in DE, FR and IT
* [FIX] QR-bill lang is now based on customer lang

Tests:

* [IMP] Add unit tests for Swiss reality check for the QR-bill

closes odoo/odoo#54053

X-original-commit: 4f4edd0594b29252a5d44281cc773230c09521e9
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2020-07-03 13:01:15 +00:00
Aaron Bohy e17dc1a793 [IMP] web: form: labels of several occurrences of a field
Before this commit, when the same field occurred multiple times in
a form view, all occurrences were associated with the same id, and
all occurrences of the corresponding label (if any) had the same
'for' attribute. As a consequence, besides the fact that there were
warnings in the chrome console, clicking on any occurrence of the
duplicated label focuses the first occurrence of the field.

This commit generates a unique id for each pair label/field, when
possible. However, there is a case that can't be handled
automatically: when the label isn't automatically generated (field
located outside a group, or with nolabel attribute set to "1").
Typically, in this case, there is a <label> node with "for"
attribute referencing the associated field. In this situation, the
id must be defined in the arch, and used in the "for" attribute:

  <form>
    <label for="phone"/><field name="phone"/>
    <label for="phone_2"/><field name="phone" id="phone_2"/>
  </form>

Task 2261697
2020-07-02 13:57:37 +00:00
Victor Feyens ad6b5e35f2 [IMP] *: do not translate logs
The logs should all be in the same language, s.t. one does not need to 
understand multiple languages when browsing/reading the server logs.

closes odoo/odoo#53984

Related: odoo/enterprise#11615
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-07-02 15:12:56 +00:00
Victor Feyens 79a7cf9be5 [IMP] base: remove old checks for deprecated methods
Those checks have been present for 3 to 4 years ([1] & [2]), spanning
over multiple major Odoo versions.

They can be safely removed for V14.

[1] https://github.com/odoo/odoo/commit/100f320217643d61432e6e93b3551f7779c338e8
[2] https://github.com/odoo/odoo/commit/7ede9bcb2de9d52994b3a6fcb84edc3f81d60284
2020-07-02 15:10:56 +00:00
Raphael Collet ee46de8b14 [FIX] test_new_api: make test work in post-install
closes odoo/odoo#54004

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-07-02 13:17:25 +00:00
Victor Feyens 07e4b9e02e [IMP] base: better translation of view validation messages
* Use of new _ signature (and placeholders)
* Ensure all error messages are translated
* No translation for warning logs
* Improved/fixed validation messages

closes odoo/odoo#53804

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-07-02 09:14:33 +00:00
Martin Trigaux 400cc4f14e [FIX] *: correct all or improve code translation lookup
This commit fixes all issues detected by the new pylint
gettext-variable test.
It converts some calls to the new syntax
  _("Foo %s", bar)

to progressively migrate the code to the new syntax.

A few calls were not technically incorrect but still detected by the
linter.

  _("Foo" +
    "Bar")

has been converted to

  _("Foo"
    "Bar")

as it has the same effect and make sure the argument is of type
asteroid.Const instead of BinOp).

closes odoo/odoo#53683

Related: odoo/enterprise#11467
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-30 10:19:59 +00:00
Martin Trigaux 241f06d868 [ADD] test_lint: add test to detect bad usages of _
More often than it should, translations calls are made using
  _("Foo %s" % bar)

instead of
  _("Foo %s") % bar

or the even better (but more recent)
  _("Foo %s", bar)

The issue of using the first writing is that the translation lookup
won't work at the execution (looking for ir.translation for src "Foo
Alice", "Foo Bob",... instead of "Foo %s").

Add a pylint test to ensure this won't happen anymore
2020-06-30 10:19:59 +00:00
Martin Trigaux 110263df56 [IMP] tools: use same syntax for _lt than _
A new gettext syntax was added at odoo/odoo#52155 but only for _, not
for _lt
Allow to have the same syntax
2020-06-30 10:19:50 +00:00
Martin Trigaux d12813f7ee [IMP] tools: fallback on empty translation
Avoid returning False if, for any reason, the return is falsy (False,
None,...)

Following the discussion in odoo/odoo#53254, the root cause was a call in the form
  _(foo)

where foo was equal False

While nothing else than a string should be the argument of _, it's
still technically possible to pass something else and get a bad return
value.
Fallback on empty string to be consistent.
2020-06-30 08:53:29 +00:00
Sébastien Geelen (sge) 6d93c72564 [IMP] base : improve messages text in access_error pop-ups
* Improve layout of access error messages from group restriction
 * Improve layout of access error messages from security records rules
 * Use the error title in the js crash manager when possible
 * adapt unit tests

closes odoo/odoo#50369

Taskid: 2206787
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-30 13:59:23 +00:00
Xavier Morel 75f2984834 [REM] base: precision() override on ir.qweb.field.float
Code's been dead since 3407fb70e4
essentially inlined its behaviour into the base class.

closes odoo/odoo#53774

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-29 06:16:01 +00:00
Xavier Morel 6c6c3d7090 [FIX] base: reintroduce log method in merge partner wizard
Well odoo/odoo#40872 is definitely the gift that keeps on giving,
after causing grief with the logging configuration change turns out
inlining the method was *also* a terrible idea because it's overridden
in `mail` in order to note merges on the destination partner, which I
apparently completely missed back then.

Task 2285876

closes odoo/odoo#53756

X-original-commit: 41209dababfaebca7bfd3be6ee5a2f41e9bb4ff5
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-26 15:08:29 +00:00
Martin Trigaux 7ab957d7b0 [I18N] base: export source terms
Was missing demo data and some modules

closes odoo/odoo#53666

X-original-commit: 957bad16b6df1ee712e0db218fe03285fbf5c420
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-06-25 12:42:15 +00:00
Xavier Morel d72720cd08 [REM] core: DefereredException use
DeferredException was removed in
ab4000fb3c but this specific use was
apparently missed.

closes odoo/odoo#53657

X-original-commit: 0de46bc231622d5b7e4c3e3afeaece6767426af2
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-25 11:48:35 +00:00
Guewen Baconnier a353077452 [FIX] expression: simplify sub-searches order
Performance fix: when parsing domains using special operators
(`child_of`, ...), or with dotted field on the left value
(`['partner_id.name', ...]`), the ORM starts by a first call on
`search()` and builds a new domain so the final query has "IN (<ids
found by sub-search>)".

The sub-search issued on the comodel uses the default "order by".
The order of the ids is irrelevant here, we only need to know the ids.

A good example is when the sub-search happens on `product.product`,
which is ordered by `default_code, name, id`. The field `name` is
inherited and translated, so the ordering requires a JOIN on
`product_template` and a LEFT JOIN on `ir_translation`. Ordering by `id`
avoids these 2 JOINs.

Some discussion took place about modifying `_generate_order_by()` to
remove the `ORDER BY` clause when the `order` argument is False or ''.
Apart the fact that it would be a breaking change, @odony has shown that
sorting by `id` is so cheap that removing the `ORDER BY` might not
bring significant performance boost [0].

[0] https://github.com/odoo/odoo/pull/52368#issuecomment-646643773

opw-2270690

closes odoo/odoo#53629

X-original-commit: fc91f7b4e8f9f8a95862df1ce95a9639cf7d1363
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-25 08:40:21 +00:00
Nasreddin (bon) 3c169a415b [FIX] tools: Return input_str when removing accents if empty
Issue

	The misc feature remove_accents(input_str) return a
	string 'False' if the param is a boolean.

Solution

	Return input_str if equal '' or False.

opw-2278959

closes odoo/odoo#53572

X-original-commit: 3fc7ce3b5599355933734e5e3f59d14a7a9b199c
Related: odoo/enterprise#11391
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-06-24 11:06:01 +00:00
Denis Ledoux c219727974 [FIX] base: prevent loop in module categories Administration during upgrades
Revision 07631a5185
inverts the parent/children relationship of the module categories
`module_category_administration`
and
`module_category_administration_administration`,
by swaping the `parent_id`.

During an upgrade, e.g. from 12.0 to 13.0,
as the `parent_id` node has been removed from the category
`module_category_administration` in the data xml file,
the field `parent_id` of the category was left untouched,
therefore leaving the former parent,
creating a recursion between the two categories.

```sql
select id,name,parent_id from ir_module_category where name ilike 'administration';
 id |      name      | parent_id
----+----------------+-----------
 79 | Administration |        78
 78 | Administration |        79
```

closes odoo/odoo#53568

X-original-commit: e4bc0a6c6b1181b7c723df415c75f6983ff91927
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2020-06-24 10:25:41 +00:00
Xavier Morel ff669b68cb [IMP] test_lint: disable deprecated-method
It's not super useful as we've re-enabled DeprecationWarnings though
logging, and it turns out to be a *very* expensive lint, as it more
than doubles the runtime of pylint locally:

Before:

    odoo.addons.test_lint.tests.test_pylint ran 1 tests in 376.27s, 2 queries

after:

    odoo.addons.test_lint.tests.test_pylint ran 1 tests in 114.05s, 2 queries

It also seems to significantly increase peak memory consumption (by
~60% though that's not a precise measurement), which can lead to
non-deterministic memory errors.

Also disable mixed-indentation since it doesn't do anything (mixed
indentation is illegal in Python 3).

closes odoo/odoo#53562

X-original-commit: 8062098d0586048a9e91543290c6ab1c8d8d7009
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-24 09:52:28 +00:00
Adrian Torres ce4fcebbbb [FIX] orm: don't log errors on constraint failure unless necessary
Given an scenario in which a field F of model M is defined in module X
as `required=True` and is extended by another module Y as
`required=False` in a database with data not satisfying the original
constraint:

During an upgrade of base the original constraint will be re-applied
on the data (and fail) even though it is no longer necessary because
module Y relaxes the NOT NULL constraint.

This failure in and of itself is non-blocking, the upgrade will go
through but an error and a warning are logged anyway which are not
problematic either except in the case of automated testing
infrastructure (such as runbot), because of this it would be best if
these errors would not be logged at all unless we're 100% sure that the
constraint that was applied is not relaxed downstream.

With this commit, the `finalize_constraints` method will verify that the
constraint is applicable (field is required) before re-applying the NOT
NULL constraint.

opw-2269220

closes odoo/odoo#53529

X-original-commit: f09f4826fbdd1a547503c51a3cfad71285312c49
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-23 15:33:04 +00:00
Raphael Collet ea83473eab [FIX] core: flush() with one2many fields
This ensures that flushing a one2many field automatically flushes its
inverse many2one/integer field.  Without that, a search like:

    model.search([('o2m_ids', 'in', ids)])

can return incorrect results.

closes odoo/odoo#53514

X-original-commit: b91b485a5d9a62acfe44b12c64a46dcca23981ce
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-23 14:00:42 +00:00
Goffin Simon a220f05f4d [FIX] odoo: Traceback when creating a new contact
Steps to reproduce the bug:

- Let's consider a new instance with default installed language 'en_US'
- Install CRM
- Activate a second language (e.g. en_GB)
- Set that language in all users
- Inactivate default language 'en_US'
- Reset the language of your current user (no value)
- Go to contact and try to create a new one

Bug:

A traceback was raised because the lang en_US did not exist.

PS: Forcing the user to set a language ensures that this fallback
will never occur anymore.

opw:2267711

closes odoo/odoo#53375

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-06-22 14:00:19 +00:00
Julien Castiaux 5d5a3d7fa4 [FIX] base: missing xmlid for mixin fields
We want to create a XMLID for every first exhibition of a field in a
model. That is, we just want one XMLID by field by model and not one
XMLID by field by class. Previous implementation was determining the
"first field exhibition" by making sure the field was created and used
as part of the same module.

This assumption is invalid when we consider mixins. A mixin is an
abstract model that define fields and methods to be included in other
models. As it is abstract, it does not exhibits the field by itself. The
field will only be exhibited when included in a concrete model via
inheritance. When it is included in another module, the XMLID creation
is discarded.

Take a module M1 that defines a model A, take another module M2 that
defines a mixin X with a field X1. In a third module M3, extend A to
inherit from X. While M3.A is the first model module to exhibit the
field X1, the XMLID creation was discarded because `"M2" != "M3"`.

See https://github.com/odoo/odoo/issues/49354#issuecomment-614093767

Task: 2235368
Closes #49354

closes odoo/odoo#53435

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-22 16:05:56 +00:00
Jérémy Hennecart 9389f7ce2e [IMP] *: enable sample data in several views
This commit sets attribute sample="1" in a bunch of list and
kanban views, to enable the new sample data feature when views are
empty.

Task 2232801

X-original-commit: 5471309b35619f307242c2704c7681ba63d2be42
2020-06-22 13:04:02 +00:00