Commit Graph
4628 Commits
Author SHA1 Message Date
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
Xavier Morel 2856892077 [IMP] base: cleanup action handlers a bit
* code *must* have an eval_context, `None` would blow up as soon as it
  looks for the `'action'` key
* [accidentally quadratic] eval_value returns a value per line, seems
  silly to evaluate all lines for each line when we can evaluate all of
  them once, then map results to field names
* eval_value doesn't break inside the loop, so every id gets a value
  by construction, `dict.fromkeys` is completely unnecessary (and
  provides no performance benefits)

closes odoo/odoo#53110

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-17 12:10:45 +00:00
Xavier Morel 0d6bb14cfd [IMP] base, sms, mail: change calling conventions of server action runners
Taking a self and a separate action seems unnecessary given self *is
an action*.

Only do this change for the "new" naming scheme, so the old one keeps
working as-is.
2020-06-17 11:28:54 +00:00
Xavier Morel 5f310366a0 [IMP] base, sms, mail: make server action runners not public
There is no reason to call these directly, in fact it's not really
possible to do so as they expect an `action` object as first
parameter.

* warn against the presence of rpc-public runners
* move runner selection outside of ``run``
* improve doc a bit maybe
2020-06-17 11:19:27 +00:00
Xavier Morel 1eadda159f [FIX] core: make state special case overridable
`state` was special cased in `copy_data` such that it would always be
reset to its default value if it had one.

While this special case can be useful (maybe) and is certainly
ingrained in odoo, having it not be overridable can be
problematic. Move the special case to the fields, so it's possible to
explicitly mark state fields as copy.

closes odoo/odoo#53113

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-17 07:23:28 +00:00
Jeremy Kersten adb908fb32 [FIX] base: arch should be required
The attribute has been lost during a previous commit e6695c72d8.

This commit avoid that you can create an ir.ui.view without arch.

Before this commit, if you try to create an ir.ui.view with type but no
arch, the code will raise an exception in _check_xml:
    /odoo/addons/base/models/ir_ui_view.py, line 377, in _check_xml
        view_arch = etree.fromstring(view.arch.encode('utf-8'))
    AttributeError: 'bool' object has no attribute 'encode'

Now, the user will have a warning on create, to say that View Arch field is required.

Could be backported if reported

X-original-commit: 4877bb4b650f5d1c52fefb06dec2fa568afcb121
2020-06-19 15:03:11 +00:00
Xavier ALT c456a26634 [FIX] base: use cached field_id in ir.property
On ir.property model, do get the field_id using the cached result from
ir.model.fields _get() method instead of issuing a direct SQL query

OPW-2067461

closes odoo/odoo#53351

X-original-commit: 24fff41d02fc7469d563f732a607db5c9a150e1e
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-19 15:40:06 +00:00
Victor Feyens bdcad21ccc [FIX] *: correct support of multi records in methods
Wrong usage of self in for loops makes some apparently multi-friendly
methods not work correctly when called with a recordset of len > 1.

This commit replaces those references by the correct unique record
reference which should be used at this iteration of the loop, avoiding
potential exceptions or wrong behavior in the concerned methods.

closes odoo/odoo#53320

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-06-19 13:27:41 +00:00
Nisha patel 4c7d54a7bf [IMP] base: Move the helpdesk under services section on user form view
Purpose of this commit is move 'Helpdesk' under the 'Services'
section on res.users form view instead of 'others'.

closes odoo/odoo#52043

Taskid: 2253481
Related: https://github.com/odoo/enterprise/pull/10821
Related: odoo/upgrade#1351
Related: odoo/enterprise#10821
Closes: #52043
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-16 11:08:13 +00:00
Benjamin Frantzen (bfr) ae15f89f73 [FIX] tools.pdf: do not crash when PDF has no attachments
In the PDF, `DictionaryObject` can be wrapped in `IndirectObject`. For nested
dictionaries, using `get` on a `DictionaryObject` will unwrap the result if it's
an `IndirectObject`, but not `__getitem__` so when trying to futher call `get`
on the result will cause an error: we need to unwrap the object first.
Instead, we patch `DictionaryObject.get()` for it to unwrap the object in case
it's an `IndirectObject`.

This is a follow-up commit of fece5ab1bf2fef043b131f1bd0886f0841116103

closes odoo/odoo#53269

X-original-commit: 189a0b28ec7fdb7472f936450cfd7b4bfd6912ed
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: bfr-o <bfr-o@users.noreply.github.com>
2020-06-18 16:49:32 +00:00
Olivier Dony 80379606db [REV] Revert c43647f: "[FIX] odoo: Traceback when creating a new contact"
This reverts commit c43647f085a7f62c9c81db6553be6a6e402943d0.

That change was not tested properly and can cause unforeseen errors
because it has far-reaching consequences, modifying the fallback
language on all requests.

One of the consequences is an alteration of the behavior of the
translation function `_()` due to the absence of a default language. For
users with no language set, it will now translate False/None values as
False/None, rather than the empty string fallback. Code that was not
prepared to deal with those non-str translations will now crash.

Besides, 'en_US' is a hardcoded default used in many areas of the code,
and we cannot get rid of it like this, especially in a stable series.

Cfr #52758

closes odoo/odoo#53273

X-original-commit: e220c5a28ecbd160be86b0ce00a7f17bcfaa816e
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-18 17:06:08 +00:00
Paul Morelle 0ee0cb57c2 [FIX] base: make NameManager.available_fields a dict
Until version 13.0, ir.ui.view:postprocess_and_fields returned a tuple
of a string and a dict of field information.
With aae1d57829, it now returns a
defaultdict instead of the dict.

This dict comes from NameManager.available_fields, which is initialized
as a defaultdict. There is no apparent reason to have a defaultdict in
this place, apart from the usage in has_field.

Furthermore, using a defaultdict has a side-effect in the search_view
computed field of all the ir.actions.act_window. On a database, if you
access env.ref('base.paper_format_action').search_view it will contain
a stringified dict, and the string default_dict(<class 'dict'>, {...})
is used in place of just {...} under the fields key.

closes odoo/odoo#53235

X-original-commit: 4586d0fbf0bdd5959b274611c58df911e50f4ef2
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
2020-06-18 10:56:31 +00:00
Martin Trigaux ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02:00
Martin Trigaux 3c3b88f676 [IMP] tools: add placeholder support to _
Mimic the syntax of logging to use placeholders in translatable
message.
The main advantage is to be able to fallback on the source term if the
translation can not be formatted properly.
It is very common to have errors in translations with missing
placeholders or badly translated (ie. the source
     "%(subject)s" -> "%(sujet)s").

Instead of blocking the execution of the code, fallback on source
string.

Task-id: 1853119
2020-06-18 13:03:34 +02:00
Dharmraj Jhala 5af661da7d [FIX] tools: fix tool method to check empty html content
Since a recent commit[1], we have a utility method in tools named
'is_html_empty'  that checks whether the given html content is
void(containing only formatting tags) or not. However, the re from
this method does not consider the case of self closing tags, fox ex
`<br/>`. In such cases, the method returns Falsy value even if the
content is void.

This commit fixes the issue by considering self-closing void tags
in the regular expression.

commit[1] - https://github.com/odoo/odoo/commit/974f512f5f5d3b9f80a8c3fcde290e4f55cf1230

Task - 2267689

closes odoo/odoo#53167

X-original-commit: 0fd6c9388dc959a9b6b7828850683175edb05b9d
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-06-17 14:19:09 +00:00
Paul Morelle 8a94f62e08 [FIX] odoo: stop bloating sys.meta_path
Every call of initialize_sys_path was adding two new hooks to the
sys.meta_path, resulting in very long loading times on databases having
a lot of modules.

For example, 2.27s instead of 752 on a database having 130 installed
modules.

References:
- odoo/odoo#45780
- odoo/odoo#45662

closes odoo/odoo#53121

X-original-commit: 2444fde7f852787d87589a93c4bc385d76ff20e9
Signed-off-by: Christophe Simonis <chs@odoo.com>
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2020-06-17 08:49:29 +00:00
Goffin Simon f5089a0b0e [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.

opw:2267711

closes odoo/odoo#53064

X-original-commit: c43647f085a7f62c9c81db6553be6a6e402943d0
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-06-16 13:04:46 +00:00
Xavier Morel add22ec8ef [FIX] base: change password wizard should be restricted to ERP managers
ACLs on the wizard lines should match that of the wizard, otherwise
ERP managers can see the action but get an error as soon as they open
the wizard.

Since ERP managers have write access on arbitrary users, that's
probably the right group to use.

Task 2275134

closes odoo/odoo#53007

X-original-commit: 657d44f08c402bc0547b7cbb01c2d447e641d062
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-16 06:04:48 +00:00
Christophe Monniez 0e1ce4c660 [IMP] core: bump master release version to 13.5
closes odoo/odoo#52991

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2020-06-15 19:57:53 +00:00
William Henrotin 0e2765f5fd [REF] mrp: no more produce wizard
Use a view similar as the pickings one.

task-2241471
2020-06-15 16:59:41 +02:00
Florian Gilbert 7db53df9cb [IMP] account & account_edi: Some visual improvements.
Hide invoice_origin field.
Hide partner_bank_id for customer invoice.
Remove margin-bottom for report layout in "base" module.
Hide electronic invoicing message for "Send & Print" action.

Task ID: #2277282

closes odoo/odoo#52953

Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2020-06-15 08:54:12 +00:00
Kevin Baptiste 6267d5978c [IMP] base: new widgets in partner list view
Use the new widgets in the list view of res_partner.

closes odoo/odoo#52897

Taskid: 2274257
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-12 09:09:55 +00:00
Mathieu Duckerts-Antoine 8a2a25e7fc [REF] base: remove useless attribute in search panel arch
The attribute groupby is useless for select="one" search panel fields.
2020-06-12 13:34:04 +00:00
Mathieu Duckerts-AntoineandJulien Mougenot 46306b95d8 [IMP] web: expand domain != count domain
In the search panel, the domain used to compute the field image values
(when the attribute expand is false) was the same as the domain used
to compute counters (if enabled). The idea was that a value bringing an
empty domain is totally useless and should not displayed.
That being true, it turns out that if one does not allow them and
several fields are used, selecting a value in the search panel will very
often totally transform the search panel. From a UI perspective,
this turns out to be bad: the search panel 'moves'.
Let us give an example:
Let us start from a search panel that looks like to:

first_field
    A  1
    B  3
second_field
    C  1
    D  2 <--- mouse above D
    E  1

with first_field and second_field both with expand="0" and
enable_counters="1". Let us also assume that no record in the global
domain has both first_field=A and second_field=D.
Click on D would make the search panel look like to something like

first_field
    B  1
second_field
    C  1
    D  2
    E  1 <--- mouse here

(the selection of D does not impact the values for the second_field but
does for the other first_field values).

This has led us to use basically only the domain comming from
outside of the search panel to compute field image values.

This means that we might now have value with zero count even if expand
is false. In the above situation, a click on D would give us

first_field
    A
    B  1
second_field
    C  1
    D  2 <--- mouse still above D
    E  1

Task ID: 2154749

Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-12 13:34:04 +00:00
Mathieu Duckerts-Antoine 3306a0f414 [IMP] *: limit in search panel
This commit introduces a new attribute 'limit' for search panel fields
that allows to avoid performance issues. That integer attribute (with
default 200) allows to fix a maximal number of values to display for the
fields. When the number of field values to display reaches the limit,
no values will be displayed. Instead, a warning message will be shown
in the corresponding search panel section.
Note it is possible to have no limit using limit="0" on a field.
This commit reintroduces in a better way the principle brought by the
fix 8d57153b34c04952a85f6642951cb2697016da84.

Task ID: 2154749
2020-06-12 13:34:04 +00:00
Mathieu Duckerts-AntoineandJulien Mougenot e5585c078e [IMP] *: expand and hierarchize in search panel
The commit introduces two new attributes for search panel fields:

    - hierarchize: boolean attribute (default True) available for
      many2one fields with select="one". It allows to choose whether
      to hierarchize the field values using the _parent_name (if set)
      on the field comodel.
      Note that a sanitization of the parent hierarchy takes place.
      Basically, it ensures that parent chains are
      completely in the domain (on comodel) accessible by the user.
      See _search_panel_sanitized_parent_hierarchy documentation for
      more information.

    - expand: boolean attribute (default False) available for many2one
      and many2many fields. If set to true, all field values are fetched
      and displayed in the search panel. If set to false, only the
      values that have at least one corresponding value in the field
      model (and in some domain) are fetched.
      An exception in the case of an hierarchized field
      (hierarchize=True and _parent_name set): more/less values can be
      displayed in order to have a good representation of the parent
      hierarchy. That means we complete and sanitize the set of initial
      field image values.

Note that the fix 8d57153b34c04952a85f6642951cb2697016da84 bringing the
notion of limit in search panel has been reverted in the present commit.
An upcomming commit will reintroduce the limit principle in a better way.

Task ID: 2154749

Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-12 13:34:04 +00:00
Julien Mougenot f5f0ca843d [IMP] *: enable_counters with false as default
In the search panel, the attribute disable_counters with default False
has been changed to enable_counters with default False.
2020-06-12 13:34:04 +00:00
william 394e9fa4aa [IMP] account: small improvements before 13.4
Task 2274998

1/ In the accounting dashboard, maximum one primary button per box
2/ In all boxes : "Sample data" must be removed. (Too obvious)
3/ In the configuration of Accounting Periods
  * Opening date and fiscal year end must be on a same line.
  * Remove the button "Configure your tax accounts".
4/ "Configure your tax accounts" is still available in the settings.
  * But also make it available while doing the Tax Report Entry, if an
  error message pops up.
5/ Chart of Account (list view)
  * Captital D for opening Debit/Credit
  * Rename "Name" into "Account Name"
6/ While génerating an Invoice
  * Rename "Post" button into "Confirm"
  * Check that the incremental number is added as a suffix of the name
  of the bill ; not as a prefix
7/ Vendor Bill (list view)
  * Status must appear as a Tag ; like it is already done in "Payment
  State"
  * Rename "Payment State" into "Payment Status"
8/ Bank journals
  * On the bank journal level, if bank feed is set to synchronization,
  then while selecting that journal from the accounting dashboard, then
  directly go to the statement lines rather than the bank statement
  itself.
  * In the bank statement's account moves, remove the button duplicate.
  It is enough to have it in the actions.

closes odoo/odoo#52818

Related: odoo/enterprise#11081
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-06-12 13:28:40 +00:00
std-odoo b16843230d [IMP] mass_mailing: send a statistics email to the mailing responsible
Purpose
=======
Provide a follow-up/overview of the Mailing 24 hours after its been sent.

Specifications
==============
Send an email to the responsible of the mailing 24 hours the last email
of the mass mailing.

During the link trackers creation, extract the button label if exists
(so we can display them in the statistics email).

Technical remarks
=================
The statistics email is sent to the responsible of each mailing in the
CRON of mass mailing.

Task-2227411

closes odoo/odoo#49836

Related: odoo/upgrade#1094
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-06-12 11:49:45 +00:00
Raphael Collet 4f9efd2eb1 [FIX] core: flushing an environment should not leave things to compute
Upon cursor `commit()`, the pending computations are performed with
method `flush()`.  However the latter method leaves fields to compute on
new records.  As the `commit` ends the current transaction, we can clear
those pending computations.

X-original-commit: d27e98d9048d0cb1250522205286ebc7b7d5ea39
2020-06-11 14:40:33 +00:00
Raphael Collet 150f68108c [FIX] core: do not compute a field on a mix of new and real records
This fix looks like good practice to avoid confusing developers when
writing compute methods for fields, and should not be necessary.  But it
actually fixes an extremely obscure bug in the computation of the field
`sale.order.invoice_status` when dealing with timesheets (module
sale_timesheet_enterprise).  The bug seems triggered by the fact that
the field is computed on both a given sales order and a new record with
that sales order as origin.

X-original-commit: f9c128c6f567dfaab5cfb0080e4fdc847942911a
2020-06-11 14:40:33 +00:00
Raphael Collet b15c280369 [FIX] core: update on new records should only recompute new records
The following situation can occur: a computed field depends on one2many
lines, and during an onchange, a line is modified.  Both the main record
and the line are new records.  If the many2one field is not in cache on
the line, its value is fetched from the line's origin, and the field
will be triggered for recomputation on the main record's origin instead
of the record itself.

The fix enforces the following property: if new records are modified,
only new records can be triggered for recomputation.

X-original-commit: f038b6c40b7045b6fe569c009d29ea092b614ed6
2020-06-11 14:40:32 +00:00
Pierre Collinet (pic) f1c99a60fa [IMP] crm: improve onboarding tour of module CRM
Add an autocomplete for opportunity name. If no name is set when a customer is
selected set the name partner_id.name's Opportunity

Change help title and subtitle to be more explicit. Change title from "Create
an opportunity in your pipeline" to "Create opportunities to keep an eye on
all your ongoing sales talks." Concerning subtitle, if a valid
and active email alias is found : Emails sent to ALIAS@address automatically
create opportunities.

Improve crm onboarding tour text messages and display.

Change menuitem from Teams to Team Pipelines to be more explicit. Update
the corresponding act_window name in the sales_team module.

Make the "schedule an activity" button bigger (100% of the div) and highlight
the entire Schedule button box.

Update test tours accordingly. Since quick create opportunity form is updated
the tests were failing. Reason is a trigger on input:first trying to detect
the field "name". This is not the case after this commit's changes.

Task ID 2226563
Community PR #51587
2020-06-11 12:26:45 +00:00
Nicolas Lempereur eaef67323b [FIX] tools: add bdi tag as safe tag
We already have BDO tag as allowed tag in sanitized HTML that is
similar to BDI tag, so this commit also adds BDI in allowed tags.

BDI* tags make sense in email since email client can have different
orientation than Odoo (alternative is to use `<div dir="auto"></div>`).

*: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdi

opw-2256982
closes #52787

closes odoo/odoo#52801

X-original-commit: 68edebb0d862acb3dc14f839aaef744306c5e269
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-06-11 06:39:11 +00:00
eacbec1e03 [IMP] web,*: highlight quick create feature to user
Generally, Users are not necessarily aware that they can quick create a most
records by simply typing in their name+enter in the many2xxx field input.
The exact purpose of this commit is to make sure the user discovers the quick
create feature of our many2xxx fields.

For that, when the input is empty, display 'Start typing to create a record...'
at the bottom of the dropdown when can_create is set and no_create_edit option
not set. So the user can easily understand that by typing and pressing enter
will create the new record.
Also "Search and Create" options in the dropdown only been shown to the user
when it type anything in the input box as the same case in the "Create" option.

Task : 2266557

Co-authored-by: Mohammed Shekha <msh@openerp.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-10 13:08:33 +00:00
Benjamin Frantzen (bfr) b1d19c61b1 [FIX] tools.pdf: do not crash when PDF has no attachments
Depending on the PDF version and the presence of embedded files, the PDF
document catalog `trailer["/Root"]` may not have any Name Dictionary
`["/Names"]`, and the latter may not have any `EmbeddedFiles` entry.

In that case `getAttachments()` should return an empty list rather than
raising a `KeyError`.

closes odoo/odoo#52312

Ref: Section 7.7.2, 7.7.4 and 7.11.4 of [PDF 1.7 spec](https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf)
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2020-06-03 14:08:37 +00:00
1c522ee778 [ADD] odoo-bin cloc cli subcommand.
Odoo cloc is a tool to count the number of relevant lines written in Python,
Javascript or XML. This can be used as rough metric for pricing maintenance of
customizations.

It has two modes of operation, either by providing a path:

    odoo-bin cloc -p module_path

Or by providing the name of a database:

    odoo-bin cloc --addons-path=dirs -d database

In the latter mode, only the custom code is accounted for.
Both modes can be used simultaneously.

Files that cannot be parsed are shown at the end of the report.
Parsing can fail due to syntax errors or excessive file size.

closes odoo/odoo#52635

X-original-commit: ae858c3ac66267b4726db459032b91a6be1cc1d6
Related: odoo/enterprise#11018
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Co-authored-by: Thibault Francois <tfr@odoo.com>
Co-authored-by: Antoine Vandevenne (anv) <anv@odoo.com>
2020-06-09 00:30:55 +00:00
fja-odoo 061ff011df [IMP] base, website: fix prewebsite specific views
Things to know about specific views:

Since the introduction of website specific views, we can have multiple
views that are related to a website (specific views). These views have
no xml_id as it is only set on the original view (generic view).
We rely on the view's key to identify related views as it is the same
for all specific views of a generic view. Also the key is equals to the
xml_id.

When a generic view is updated, we will check if the specific views have
the same values as the generic view. If it is the case, the value that
are the same are considered updatable and are updated on both the
generic and specific view. Else these are considered as noupdate.

When a generic view is created we will check if the potential parent
generic view has specific views. If it is the case we will create a copy
of the created view for each specific view.

The issue:

The method that checks if a created/updated view has specific views is
located in website. When we update a module, each modules are
initialized and updated in a specific order. If a generic view that has
specific views located in a module loaded before website this view's
specific views will not be updated/created as the method does not exist.
This issue is mainly affecting portal views at the moment.

The solution:

For write:
We now COW(copy on write) the views in base module, meaning this will
apply to all qweb views that are duplicated and not only the website
specific ones.

For create:
We  will create the generic view as before but wait until we have
updated all the modules to gather all generic views that are supposed
to have a specific view but don't and create the specific views.
This will result in a change of behavior being that if a specific view
that have a parent is deleted it will be recreated on update
(same behavior as a generic view).

closes odoo/odoo#52629

X-original-commit: b1a90ee2bb441aa52e3cf4607c43fb464b55b1d7
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Signed-off-by: fja-odoo <fja-odoo@users.noreply.github.com>
2020-06-08 17:23:59 +00:00
Nasreddin (bon) c503faab53 [FIX] base: User loses company access when merging the related contact
Issue

	- Create a second company
	- Create user with access to main and second company
	- Go to "Contacts" app
	- Edit contact of the new user, and under the "Sales & Purchases" tab,
	  ensure that the company field is set
	- Create a new contact with same email of the new user
	- In list view, select both contact related to new user
	- Click on Action->Merge Selected Contacts, then merge contacts

	User has no more access to both companies, only company related to
	merged destination Contact/Partner.

Cause

	All related companies are unliked from user, and instead overwrited
	with one company related of the merged destination Contact/Partner.

Solution

	Instead of unlink all companies, we will only add the contact company
	to the allowed companies of the user.

opw-2269397

closes odoo/odoo#52620

X-original-commit: e00b23b73f00fb24b2771ea8894031b35204e65e
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-06-08 15:04:06 +00:00
fja-odoo 9ffd3cda87 [FIX] base: fix the burmese translation iso
The burmese ISO 639-1 code is "my" which conflicts with the page /my
We will now use the ISO 639-3 code "mya" for the url_code.
https://iso639-3.sil.org/code/mya

closes odoo/odoo#52571

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-06-08 10:15:24 +00:00
Martin Trigaux c9f93eb639 [FIX] tools: remove max language length constraint
There is no reason for this constraint to be. Languages with a code
longer than 5 do exists in standard, (e.g. ar_001, sr@latin)

Introduced at 004a0b996f

Fixes odoo/odoo#52558

closes odoo/odoo#52569

X-original-commit: 54340487adaed962750c9719fb50fc7e000da476
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-06-08 09:00:02 +00:00
Samuel Degueldre c2de755bc6 [IMP] web_editor, *: change image cropping from modal to inline widget
*: base

Previously, cropping an image was done inside of a modal window, turning
it into an inline widget makes the editor feel more integrated and
allows you to better see the result of cropping directly in the page,
it's also less intrusive to the user's edition workflow.

At the same time, the way cropped images are saved was refactored to use
the new original_id field on ir_attachment, as the old system was
creating problems.

Part of https://github.com/odoo/odoo/pull/51517
task-2192755
2020-06-05 18:11:42 +00:00