Commit Graph
6231 Commits
Author SHA1 Message Date
Demesmaeker b1d023e122 [FIX] base: fix UI
classic layout issue due to the group that cause a wrong alignment

closes odoo/odoo#103205

X-original-commit: 2f5b96639c8bb7975696c507c11d57d164e52cbb
Signed-off-by: Morgane Demesmaeker <edm@odoo.com>
2022-10-17 10:11:11 +02:00
Rémy Voet (ryv) 1cfc896f2c [IMP] core: add Json field
To be able to create easily a jsonb column in database,
we create a Json type Field. Currently, it is quite limited
field:

- We cannot modified the value in-place, we need to always set
the entire jsonify value.
- No domain operator is done to work with jsonb. Now, it works as a
text field.

closes odoo/odoo#103097

X-original-commit: 7eeba9d205d2dace571b5d0895ddba6290a512db
Related: odoo/enterprise#32729
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2022-10-17 10:11:09 +02:00
gawa-odoo b8dca3b174 [IMP] analytic, *: Json field for analytic distribution
The `analytic_distribution` field is a Json.
It was stored temporarily as a char.

Search is not available yet, so we do queries by hand when we need to search on keys.

Also added a constraint on account_analytic_distribution_model,
so we don't have models with accounts specific to a company when the model has no company or another company.
It would cause an issue when looking at the models from another company.

X-original-commit: 7064c95aa04e5138bb12ae97acfee04ebb67cc0e
Part-of: odoo/odoo#103097
2022-10-17 10:11:09 +02:00
Romain DerieandXavier-Do 6e21371c1c [FIX] test_assetsbundle: don't pregenerate assets outside test mode
Commit [1] and [2] introduced an assets pregeneration to speed up the
testing suite on runbot.

It seems like it was chosen to always pregenerate the assets when a
module was installed/upgraded. This was done in the `test_assetsbundle`
module to only impact the tests flows, but it was not correct as it was
not only impacting the tests flows but also regular runbot usage.
Indeed, any `all` runbot (the default one) will have that module
installed.
It means that any module operation through regular flow in those DB will
trigger the assets pregeneration.

One of the problem is then that during a theme switch through the
website builder (or configurator), assets would be pregenerated, adding
~40 seconds to the processing time.
Since that theme install was already taking ~30 seconds on `all` runbot,
it sometimes now total over 60 seconds, triggering the `CPU Time Limit`.
You can find some benchmark and metrics on this commit PR.

Obviously, that's not fine because runbot, despite being our testing
tool/platform, is also one of our main demo tool.
That's especially true around the OXP period, where people are recording
video on it but will also use it to show demo to the customers.

Finally, there is no reason to not limit this assets pregeneration to
the test mode anyway.

Note that sometimes, the theme install is failing and responding with a
502 error after a long time, this is yet unsure if this was the cause
but it was during this investigation that this commit fix was found.
It is probably the cause though.

[1]: https://github.com/odoo/odoo/commit/c764c38d7caf300dce7509e87d2bd268eee0161d
[2]: https://github.com/odoo/odoo/commit/d47cf37b688117d6b2514b9b620787aa66312c61

closes odoo/odoo#103105

X-original-commit: 5e77961e4768ef2d3d40f1600dd76a633a0e231b
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: Xavier-Do <xdo@odoo.com>
2022-10-11 18:56:16 +02:00
qdp-odoo 7a6137347d [FIX] tests/common.py: fix context propagation in o2m onchanges in Form()
Previously, the context passed in onchanges calls after a o2m modification in the form view were the one of the parent object, whereas it should have been the context defined on the o2m field itself

closes odoo/odoo#103081

X-original-commit: 31ee570d17db2f5e3e2ff6877a7634ab9be12492
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2022-10-11 17:59:43 +02:00
Chong Wang (cwg) 7718fe9508 [FIX] core: assert translated fields cannot have size
Translated fields are stored as jsonb columns. Since jsonb columns don't have
size, the size attribute for Char field doesn't work. Setting the size attribute
for a Char fild should raise an error

closes odoo/odoo#103031

X-original-commit: 763fbb1c68385f202f5118fac5bc8b23b8760220
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-10-11 14:10:16 +02:00
Chong Wang (cwg) 25e4a53753 [FIX] core: fix search domain containing empty False None
For non-translated field, when search(['name', 'in', list_right])
The behavior of False and the behavior of None in list_right should be the same.

Translated fields need customized process for 'in' operator

X-original-commit: a9a3c666f08c5612432dba40a69c7cfdc54ba96e
Part-of: odoo/odoo#103031
2022-10-11 14:10:16 +02:00
Chong Wang (cwg) 105e0b9ef2 [FIX] core: search translated fields with characters needed to be escaped
The trigram index function jsonb_path_query_array("column_name", '$.*')::text
uses all translations' representations to build the indexed text. So the
original text needs to be JSON-escaped correctly to match it.

X-original-commit: 7547df664945dddcb839e4903068f7f25ecfc08c
Part-of: odoo/odoo#103031
2022-10-11 14:10:16 +02:00
Chong Wang (cwg) be1eed6cd7 [FIX] core: fix search for translated field
make searching translated field language dependent
add an extra filter using trigram index to speed up '=' and 'like' search

X-original-commit: 5b6f0a9e5f9d60735e306709a3e7d7ac46a586be
Part-of: odoo/odoo#103031
2022-10-11 14:10:15 +02:00
Chong Wang (cwg) bde30899a4 [FIX] core: new PO file overrides old ir_translation
Before: while upgrading to 16.0, the PO file is loaded before migrating
ir_translate. As a result, old translations from ir_translation
override the new translations imported by new PO files.

After: translations imported by the PO file take priority over the
translations migrated from the ir_translation table.

X-original-commit: 178270eff48221537a4efba1ad8fa0b53a1516f2
Part-of: odoo/odoo#103031
2022-10-11 14:10:15 +02:00
luvi e4ff2afaec [FIX] web: correct form style in x2ManyDialog
Since o_form_view class was not placed on the right element, as the
form is displayed in a dialog, some styles were not applied in x2Many
dialogs using a form view. Now, the selector matches all cases and
dialogs will be stylized as expected, since the class is placed on the
dialog container instead of the first div.

Now, we are consistent both for dialogs and standard form views.

Tests have been adapted to work as expected.

closes odoo/odoo#102953

X-original-commit: af67305b43d51e1669df19d376d9bda7418ba863
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Signed-off-by: Luca Vitali <luvi@odoo.com>
2022-10-11 13:16:02 +02:00
Pierre Paridans dd9877e080 [REF] web,*: each module handle its own dark mode variables
Instead of having a dedicated module for all-things dark mode related,
this commit moves the (S)CSS files into their respecting modules and
uses `web` and `web_enterprise` to provide the base infrastructure for
the dark mode (cf. dedicated assets bundle).

Note:
Don't forget that you have to handle 2 cases:
1: SCSS variables must be placed BEFORE bright ones
2: CSS variables must be placed AFTER

task-2710677

Part-of: odoo/odoo#102868
2022-10-11 13:15:56 +02:00
Pierre Paridans efc30998a4 [MOV] base,web: move onboarding variables in a dedicated file
Commit preparatory to the introduction of dark-mode.

task-2710677

Part-of: odoo/odoo#102868
2022-10-11 13:15:56 +02:00
stefanorigano (SRI) 5234fad374 [IMP] web, base: adapt for dark-mode
This commit adapts several components in order to correctly handle
color-scheme variations.

It also allows user_menu to handle switch entries 

task-2710677

Part-of: odoo/odoo#102868
2022-10-11 13:15:53 +02:00
Damien Bouvy e647a2de09 [IMP] *: adapt to grid form views
The recent switch from tables to css grids for form views `group` nodes
has introduced several inconsistencies/issues with several views accross
modules - these will not be the last fixes.

closes odoo/odoo#102174

X-original-commit: 836568dfd59886a6d52f15e0e2109709903b6803
Related: odoo/enterprise#32295
Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
2022-10-11 13:15:12 +02:00
Victor Feyens 9ded78ede0 [IMP] core: docstring improvements
* clean and improve docstrings in orm
* fix typos found with codespell
* rely on the Environment class docstring instead of doc content (and
therefore move part of the doc inside the class docstring)

closes odoo/odoo#102969

X-original-commit: 8250cd4b210005d223a4cdb8afa4014425ca6fa3
Related: odoo/documentation#2803
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-10-10 19:55:37 +02:00
Xavier-Do 503ed05029 [IMP] tests: add generic Basecase.start for patch
Using patcher.start() can easily lead to incorrect cleanup.
-> after a copy paste, patcher is working, but stop is forgotten
-> stop is present, but won't be called if something fails during the
test

This commit add an utility `start(patcher)` to always have the add
cleanup.

Using a standard way to start the patcher with an automated addCleanup
should prevent this kind of mistake. This is why this commit also
replaces all valid patch.start() (followed immediately by a addCleanup)

closes odoo/odoo#102873

X-original-commit: 7d5a193d86316965a0908c65cfacfb607dc3f3ad
Related: odoo/enterprise#32618
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-10-10 16:11:01 +02:00
Denis Ledoux 6ed63b9fee [IMP] base: possibility to archive companies
It is technically nearly impossible to delete a company
when it actually dealed with customers
(emitted invoices, received payments, ...).

Hence, if you want to get rid of a company,
for instance because you closed one of your subsidiaries,
giving the possibility to archive your company,
thanks to an active field, would be the best way to go.

We are hesitating to do a related field to the
`partner_id.active`, but we are a bit afraid
some people archive the partner linked to their company
for other valid reasons than get rid of their subsidiary
(such as avoid changing the address of their company
by mistake through the Contacts app),
while still wanting the company itself to be active.

So, we make it an independant column at the moment,
so we have the actual stored column in case we need it,
and will do a related stored to the partner
later on if we change our mind.

Manual forward-port of #102801

closes odoo/odoo#102586

Signed-off-by: Olivier Dony <odo@odoo.com>
2022-10-10 11:56:51 +02:00
Laurent Desausoi 7593c073d2 [IMP] core: use inert SQL based neutralization
Before this commit the neutralize system introduced in v16 was using ORM
methods in order to change appropriate records. Although flexible, this approach
could lead to call some methods with side effects while neutralizing
(eg: overloads of write).

This patch converts the neutralize system to a safer "inert" SQL based approach
by migrating the generic method _neutralize to SQL files exposed in the
data folder.

Task id: 2961687

closes odoo/odoo#102792

X-original-commit: e5dbded9bb363351feff7ca8a56c7f8a6860f492
Related: odoo/enterprise#32580
Signed-off-by: Fabien Meghazi <fme@odoo.com>
2022-10-09 22:04:00 +02:00
Denis Ledoux 94e05f9eed [IMP] base, web: do not set on_change="1" on most views
Only kanban, tree and form implements onchanges.
Therefore, on calendar, graph, pivot, ..., putting `on_change="1"`
is useless and is a waste of resources and KB.

e.g. CRM lead pivot view

Before:
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row"/>
    <field name="stage_id" type="col" on_change="1"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" on_change="1" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

After:
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row"/>
    <field name="stage_id" type="col"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

I would have like something smarter, like using the `editable` concept
for instance, but it's not that easy.
e.g. kanban is not considered as editable, while it does support
onchanges when grouping record by a field and drag and dropping
record from one column to another.
However, if we change the kanban view to make it editable,
the view validation will start validating the fields domain:
https://github.com/odoo/odoo/blob/45d4ac14f65c53dcde56592715d50169bde116ad/odoo/addons/base/models/ir_ui_view.py#L1439-L1442
causing issues:
- If a field used in the domain is not in the view, it will need to be
  added in the view,
- while it will not be used, as you cannot do a search in related fields
  in kanban views anyway.
e.g.
```
odoo.tools.convert.ParseError: while parsing /data/build/odoo/addons/analytic/views/analytic_line_views.xml:120
Error while validating view near:
<kanban class="o_kanban_mobile" __validate__="1">
                <field name="date"/>
                <field name="name"/>
Field 'company_id' used in domain of field 'account_id' ([('company_id', 'in', [company_id, False])]) must be present in view but is missing.
```

In addition, the kanban doesn't need the readonly and required
attributes on the field nodes, as other editable views (tree and forms)
do.

In addition, the tree list is currently considered as "editable" only
when it has `editable="bottom" or `editable="top"`, while
a tree without this editable attribute can still trigger onchange,
for instance when using `widget="handle"` or `widget="boolean_toggle"`.
We should therefore making the tree list editable whatever the case,
leading to the same issues than listed for the kanban above,
or make an exception for field in non-editable tree views using a
widget..

So, as the smarter way seems difficult and risky, for a limited gain
I choose the easy way by separating the concept "editable" and
"onchange-able" and to not set `on_change="1"` on views not considered
as "onchange-able".

closes odoo/odoo#102788

X-original-commit: aeb65ee536b1611c1cb829c91906f327f8e331c7
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-09 21:07:47 +02:00
Damien Bouvy b903a355f7 [FIX] base: update reifed view for users with new grid form
Replace some layout magic with some layout determinism; in particular,
the view attempted to have a 4 column layout which is not well supported
in grid form views.

This commit instead create a "normal" structure (outer group > inner
group) for "boolean" group access (e.g. 'Extra Rights' or 'Technical'
sections of the user form access groups, whilst in debug mode).

closes odoo/odoo#102789

X-original-commit: fd854e87d8a138052302afbd3da486f41102c695
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-10-09 16:34:51 +02:00
Samuel Degueldre 94f81ed41d [FIX] base: fix sourcemap header offset
in b1d57adf6ff3 the size of the header added to source files while
concatenating them was reduced, but the corresponding offset use when
generating source maps was not adapted, causing source maps to drift
further and further from the actual source location the further in the
compiled asset the line is.

This commit fixes that by decrementing the header offset as needed.

closes odoo/odoo#102651

X-original-commit: 4d4585ee6c905c2a3adc4692098c1a3544417629
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-10-08 11:35:14 +02:00
Antoine Dupuis 5a09449ddc [FIX] tools: fix filename resolution in XSD imports
With PRs odoo/89145 and enterprise/26393 came new methods for
retrieving XSD files and using them for XML validation.

The new retrieval method expects modules to provide a 'prefix' that
is prepended to the XSD's filename. For example, l10n_cl_edi will
name its XSD files 'l10n_cl_edi.<filename>.xsd'.

However, this messes things up when one XSD file needs to import
another. For example, l10n_cl_edi.DTE_v10.xsd has the statement
'<xs:include schemaLocation="SiiTypes_v10.xsd"/>'

Currently, the filename resolver has no way of knowing that this
should resolve to 'l10n_cl_edi.SiiTypes_v10.xsd', not
'SiiTypes_v10.xsd'.

In addition, the new retrieval method saves the ZIP archives
received over the network under the '<filename.xsd>'. Thus
'SiiTypes_v10.xsd' might actually be a ZIP-encoded file.

So, we need to do something to fix the imports.
Here are two possible solutions:
1. We scrap this 'prefix' stuff and either save the ZIP files under
   a different name, or we just don't save them.
2. Or, we provide a mechanism for indicating a prefix to the filename
   resolver.

Personally, I don't see the point in saving the ZIP files, and this
'prefix' stuff seems pointless. So I prefer solution 1.

But, because I assume there must be a reason to all of that 'prefix'
stuff, here is an implementation of solution 2.

I'd be keen to know the reason, btw.

EDIT:
In addition to the first issue described above, we have the second
issue that some XSD files returned by the Chilean SII are encoded
using ISO-8859-1 encoding (e.g. SiiTypes_v10.xsd). If we leave them
in this encoding, then LXML isn't able to parse them when performing
imports.

closes odoo/odoo#102601

Solution: convert the files to UTF-8 before storing them.
X-original-commit: 75555df56475b457331938453657c1f73d231e33
Related: odoo/enterprise#32482
Signed-off-by: Josse Colpaert <jco@odoo.com>
2022-10-07 14:37:14 +02:00
Xavier-Do cd309a200f [IMP] base: don't add bundle name in bundles
The bundle name is irrelevant in the bundle content and will prevent
attachment to store the same file if the bundles are exactly the same.

closes odoo/odoo#102502

X-original-commit: b1d57adf6ff358aa79f41817f4f7bfe60f9e5ac0
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-10-07 11:12:59 +02:00
Xavier-Do 4e9ad91107 [FIX] tests, base: gc filestore at the end of a tests
During the tests, many attachment can be created and unlink.
They will be eventually cleaned up if the cron is ran but this is
usually not the case during tests. The disk usage can increase to reach
more than one 1 Go when design theme is installed.

This can lead to unnecessary big database dumps.
This is also a problem on odoosh where the filestore max size is limited
to 1Go.

The gc should be quite fast if nothing was changed since it will just
check the content of an empty directory.

The method is made accessible in the test case in order to be able to gc
on demand. This may be useful in the test_01_crawl_every_themes that
can generate around 600~ Mo of attachment in the loop.

X-original-commit: 187309f5a39f8fef9b07959fd73475fd6732efb3
Part-of: odoo/odoo#102502
2022-10-07 11:12:59 +02:00
nda-odoo 9f37a9d93d [FIX] base: make extract_rfc2822_addresses more robust
If source is something like
"admin@éxample.com" <admin@éxample.com>

candidates founds are
['"admin@\xc3\xa9xample.com"', 'admin@\xc3\xa9xample.com']

and the first one raises an error because of "".

Malformed addresses should be ignored.

opw-2982426

closes odoo/odoo#102353

X-original-commit: 35ad2dd630a8ed173c6a9275585eac46b9a19363
Signed-off-by: Raphael Collet <rco@odoo.com>
Signed-off-by: Julien Castiaux <juc@odoo.com>
2022-10-07 10:07:35 +02:00
Xavier Morel 9b891b6bb2 [IMP] core: error reporting on tour timeouts
When 2e8647bf16 converted the browser
runner to a more reactive / evented system, one bit was missed in
"wait_code_ok": concurrent.futures.Future raises exceptions on various
events, such as tour timeouts. Because those exceptions were not
caught (or just ignored) the code which takes screenshots was
bypassed, leading to a lack of screenshots on tour timeouts (and a few
other rarer errors), making debugging more complicated.

The error reporting was also not ideal as `wait_code_ok` would raise
an unexpected (by its caller) `TimeoutError` rather than
`ChromeBrowserException`.

Fix those two issues, should hopefully makes these occurrences clearer
and easier to diagnose.

closes odoo/odoo#102403

X-original-commit: 974217968ea970330946c5184bd3b3550ec3cde3
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-10-06 18:01:27 +02:00
Benoit Socias 720a8c9940 [IMP] base, web: unify the behavior of cookie setters
Both implementations of `set_cookie` in `http.py` and the one of
`setCookie` in `cookie_utils.js` are slightly different.

This commit unifies both Python implementations and replicates the same
behavior in JS:
- default the cookie type to "required"
- if setting that type is not allowed, delete that cookie if it was
previously set

task-2800976

closes odoo/odoo#102380

X-original-commit: fa8fdab2894607f1f89cdd195f62ec37af7b0342
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-10-06 17:00:33 +02:00
Victor Feyens e05d01c12a [FIX] sale: do not allow opening the product form view from the SO lines
X-original-commit: 328f528c4007be087085a020616c78a04b91e92c
Part-of: odoo/odoo#102245
2022-10-06 14:57:00 +02:00
Martin Trigaux fde3f4d4b9 [I18N] *: export 16.0 source terms
closes odoo/odoo#102163

X-original-commit: 011d7aac5aacedb3ab373f247471ba69d67f50f3
Related: odoo/enterprise#32288
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-10-06 14:56:52 +02:00
Sylvain LE GAL 547c3da36e [FIX] base : correct display of Documents to Delete
closes odoo/odoo#102173

X-original-commit: 0d0cd890bc823497a03bb709b2949e833f9ed6a4
Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
2022-10-06 10:42:37 +02:00
Stanislas Sobieski e57804207b [FIX] core: avoir firebase_admin DeprecationWarning
With version of urllib3 in ubuntu 22.04 (1.26.5) and with version of firebase_admin between 2.17.0 and 4.5.2 a gives the following
warning:
In firebase_admin/_http_client.py:30: DeprecationWarning: Using 'method_whitelist' with Retry is deprecated and will be removed in v2.0. Use 'allowed_methods' instead

It has been fixed in later version
https://github.com/firebase/firebase-admin-python/pull/532 since v4.5.2

closes odoo/odoo#101731

X-original-commit: 66934cde91843a90b99ec02557b41cb68c281119
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2022-10-06 10:42:34 +02:00
std-odoo 499f25759b [IMP] web: allow to add the properties field in a kanban view
Purpose
=======
Allow to add the properties field in the kanban view.

An option has been added in the property definition, "View In Kanban",
to decide which field must be visible in the kanban view.

We need an option because in practice we might have a lot of
properties, and it might break the view.

Task-2980121

X-original-commit: 3af5a59c23183dd43341c1952a04354acbf3a60d
Part-of: odoo/odoo#102243
2022-10-06 00:37:10 +02:00
std-odoo 6823aa5f99 [IMP] base: improve the performance of properties when used in batch
Purpose
=======
Check the existence of the relational properties (many2one / many2many)
in batch and prefetch the values in batch as well to reduce the number
of SQL queries.

Technical
=========
The existence is checked in the read method of the properties field,
because we have the entire recordset. Then, the non-existing ids are
remove from the properties values and the cache is updated.

Task-2965523

X-original-commit: dba9b684d29c0041a32a5508284573851b8dd097
Part-of: odoo/odoo#102243
2022-10-06 00:37:09 +02:00
Denis Ledoux fa67f44794 [IMP] base, web: do not pass field readonly/required for readonly views
pivot, graph, cohort views do not care to know whether a field
is readonly or required, as you cannot edit records in these views.

Even kanban is readonly in most cases:
- you can drag and drop records from one column to another,
  which is prevented if the group by field is readonly
  but this shouldn't rely on the fact the field is
  within the architecture, as you can group by on any fields
  from the search views / control panel.
  Hence, this shouldn't rely entirely on the modifiers passed on the field
  nodes in the view architecture alone.
- you can create new record inside the kanban,
  with a simplified form, thanks to the `quick_create`,
  but this uses an independant form view, in which the readonly and
  required modifiers are correctly passed.
So, `modifiers="{'readonly': true, 'required': true}"` can be dropped
for kanban views as well.

This allow to spare some KB by not setting useless modifiers in views.

e.g. CRM > My pipeline pivot

Before
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row" modifiers="{&quot;readonly&quot;: true}"/>
    <field name="stage_id" type="col" on_change="1" can_create="true" can_write="true"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true, &quot;readonly&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" on_change="1" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

After
```xml
<pivot string="Pipeline Analysis" sample="1">
    <field name="create_date" interval="month" type="row"/>
    <field name="stage_id" type="col" on_change="1"/>
    <field name="expected_revenue" type="measure"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="automated_probability" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="message_bounce" modifiers="{&quot;invisible&quot;: true}"/>
    <field name="probability" on_change="1" modifiers="{&quot;invisible&quot;: true}"/>
</pivot>
```

Regarding the change of behavior shown in `addons/web/static/tests/views/kanban_view_tests.js`.
It was introduced very recently, by myself, in
odoo/odoo#100806
I revert this possibility to set readonly="0" on a field node in a
kanban view, because:
- First, this is not used anywhere in both odoo/odoo and
odoo/enterprise.
- Second, this really makes things harder if we want to do so:
  - as readonly="0" is passed, the "readonly" gets removed from the node
    modifiers, as they are simplified by removing falsy value:
    modifiers="{'invisible: True, 'readonly': False}" becomes modifiers="{'invisible': True}"
  - as readonly in not amongst the modifiers, it fallbacks on the model
    field property, in the javascript code, which is readonly: True.
  - the thing to do would be to still transfer "readonly"
    from the field attributes to the node modifiers.
    - which either mean to consider a kanban view as editable
      - this will cause issues because the validation mechanism
        will suddenly check the domain attribute property
        https://github.com/odoo/odoo/blob/d4a92b112d0554a2624f7768feb7d54e0484469f/odoo/addons/base/models/ir_ui_view.py#L1443
        and there will be plenty of views where some field used in the
        domains will be missing. Besides it is pointless to validate these
        domains as they are completely unused in kanban views
    - either mean to find another mechanism than "editable" to decide
      wheter to transfer the modifiers "readonly"/"required" or not,
      which over-complicates things.
    - besides only "readonly" would need to be passed, not "required.
So, to keep the code stupid simple, I remove this possibility added only
a few days ago, which is actually not used anywhere in standard for the
moment.

closes odoo/odoo#102221

X-original-commit: 69c3d5aa25655173ed66a52570559322c650c7df
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-06 00:37:00 +02:00
Denis Ledoux 01e62c051c [FIX] base: no back-end view caching in --dev xml mode
In `--dev xml` mode,
you would like the views to be loaded from their definition
in the XML file directly.

The view caching introduced in odoo/odoo#99417 prevents that feature,
as once the view has been loaded a first time, the views are returned
directly from the cache, therefore not taking into account changes
directly done in the XML file views.

Setting a conditional decorator,
disabling the caching when in `--dev xml` mode,
solves this issue.

Solves https://github.com/odoo/odoo/pull/99417#issuecomment-1241977197

closes odoo/odoo#102117

X-original-commit: 5fe1d89f4d8718df92c39a80d4b575b8d0381c19
Related: odoo/documentation#2786
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-04 18:06:41 +02:00
Denis Ledoux 3e151bf30a [IMP] base: move view related methods out of odoo/models.py
By definition, views are useless without the web client.
The web client is in the module `web`.
Therefore, in a perfect world, the `get_views` model method
and any related method should be within the `web` module,
as without it they are useless.

Let's imagine you would like to use fully in command-line,
without web client, all those view related methods are useless.

Maybe excepted for reports, as you might still like to be
able to print reports while using odoo fully in command line.

Views related method therefore shouldn't be in `odoo/models.py`.

Also, when you think about it, `get_views` related methods do not
make sense without the model `ir.ui.view`, which is loaded after
the `get_views` related methods, which also doesn't make sense.

However, moving these methods fully in the `web` module is an harder
work. For instance, there are base models, such as res.partner,
already overriding `get_view` in the `base` module,
and therefore relying on these view related methods.

As a first step, we move view related methods direcly in the
`odoo/addons/base/models/ir_ui_view.py` file, where
the `ir.ui.view` model is loaded.

This is not only a design / cleaning change,
but a required change to be able to use content of
`odoo.tools.config`, which is loaded after `odoo/models.py`.
For instance, if you want to configure a conditional decorator based on
the config `odoo.tools.config['dev_mode']`, it is not possible
to do so in `odoo/models.py` because the config is parsed/loaded
after `odoo/models.py`.
The config is loaded here:
https://github.com/odoo/odoo/blob/31de2b0a7a0921cab3c6c54045d15da46c8e6d8a/odoo/cli/server.py#L127
While, within the same file, `odoo/models.py` gets loaded through the
`import odoo`
https://github.com/odoo/odoo/blob/31de2b0a7a0921cab3c6c54045d15da46c8e6d8a/odoo/cli/server.py#L26

And we would like to put such a decorator based on `odoo.tools.config['dev_mode']`
on `_get_view_cache`, to not cache the back-end views when `--dev xml` is
passed in the server arguments.

X-original-commit: 0901adc38a724aec75676285977f1905a84ed8ee
Part-of: odoo/odoo#102117
2022-10-04 18:06:40 +02:00
Walid HANNICHE (waha) 82265c52ca [FIX] tools: fix underline and italic in logged notes
Steps to reproduce:
- in any app log a note using full composer
- add styles to the text (underline, strike-through, italic)

Bug:
styles except bold are removed

Fix:
added missing styles to the whitlelist

opw-2956374

closes odoo/odoo#102056

X-original-commit: eb07ab104d5f47574e14db811108a7d0cbbbe4b2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-10-04 16:01:06 +02:00
Martin Trigaux eba7ed6e9c [I18N] *: translate fr_BE based on fr
Automatically translate "avoir" into "note de crédit"

closes odoo/odoo#102002

X-original-commit: 69b141d8ec613e101b8a7050da057bfe5a74af50
Related: odoo/enterprise#32220
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-10-04 07:28:57 +02:00
Xavier ALT 3b6c20805c [FIX] base: fix mock smtplib connection for server with 'starttls' encryption
During tests, when matching ir.mail_server has `smtp_encryption` set to
`starttls`, connect() will crash with an AttributeError as follows:

2022-09-22 07:04:27,882 20445 ERROR tests-150-starttls odoo.addons.base.tests.test_ir_mail_server: ERROR: TestIrMailServer.test_mail_server_send_email
Traceback (most recent call last):
  File "/home/odoo/src/odoo/15.0/odoo/tools/misc.py", line 804, in deco
    return func(*args, **kwargs)
  File "/home/odoo/src/odoo/15.0/odoo/addons/base/tests/test_ir_mail_server.py", line 261, in test_mail_server_send_email
    IrMailServer.send_email(message, mail_server_id=self.server_domain.id)
  File "/home/odoo/src/odoo/15.0/odoo/addons/base/models/ir_mail_server.py", line 575, in send_email
    smtp = self.connect(
  File "/usr/lib/python3.8/unittest/mock.py", line 1081, in __call__
    return self._mock_call(*args, **kwargs)
  File "/usr/lib/python3.8/unittest/mock.py", line 1085, in _mock_call
    return self._execute_mock_call(*args, **kwargs)
  File "/usr/lib/python3.8/unittest/mock.py", line 1146, in _execute_mock_call
    result = effect(*args, **kwargs)
  File "/home/odoo/src/odoo/15.0/odoo/addons/base/models/ir_mail_server.py", line 313, in connect
    connection.starttls(context=ssl_context)
AttributeError: 'TestingSMTPSession' object has no attribute 'starttls'

This commit adds a dummy `starttls()` method to `TestingSMTPSession` to
gracefully handle such case.

closes odoo/odoo#101962

X-original-commit: ec156901dd4db2fc7a2827b1eb78515f6259699e
Signed-off-by: Julien Castiaux <juc@odoo.com>
Signed-off-by: Xavier Alt (xal) <xal@odoo.com>
2022-10-03 19:22:48 +02:00
Florian Charlier 8af6e04a76 [FIX] base: use higher res profile pictures
Purpose: Enhance the profile picture of
 * Mitchell Admin and Marc Demo as they
are now sometimes shown in larger sizes (as in appointment).
* Joel Willis, whose picture is used on his eLearning profile

Task-2992949

closes odoo/odoo#101945

X-original-commit: d0e1360e63efca56c06fad82780ab6a96fb6f0eb
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-10-03 16:19:03 +02:00
Denis Ledoux 99a9cce9ba [IMP] base, web: set can_create/can_write only on editable nodes
Setting the attributes `can_create` and `can_write` in views
which are not editable is useless as you cannot edit the record
in these views.

This allow to gain some KB when serving the view to the web client,
as well as making the view cleaner.

e.g. the graph view in the CRM > My Pipeline menu

Before:
```xml
<graph string="Opportunities" sample="1">
    <field name="stage_id" can_create="true" can_write="true"/>
    <field name="user_id" on_change="1" can_create="true" can_write="true"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
</graph>
```

After:
```xml
<graph string="Opportunities" sample="1">
    <field name="stage_id"/>
    <field name="user_id" on_change="1"/>
    <field name="color" modifiers="{&quot;invisible&quot;: true}"/>
</graph>
```

This revision takes the opportunity to port the `editable` concept
from the server to the web client MockServer,
in order to be able to test the removal of these attributes from the views
in the QUnit tests.

The `_editableNode` JS function added here is the translation of the
existing `def _editable_node` method in `addons/base/models/ir_ui_view.py`

https://github.com/odoo/odoo/blob/f5edde3624f4fe40f87cc7fed7dcfc4bbce1f19f/odoo/addons/base/models/ir_ui_view.py#L1282-L1301

closes odoo/odoo#101902

X-original-commit: f0beddf534a57e972ac3a7bef6afa1caae1dcff3
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-03 15:18:55 +02:00
Ernad Husremović 871c430c47 [FIX] base: Bosnian language settings
Uses the non-SI continental style (groups of 3 digits, comma decimal
separator, period group separator).

Closes #101723

closes odoo/odoo#101888

X-original-commit: 10b89303dfec2b668ad896ac36627741dddde708
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-10-03 15:18:52 +02:00
Jeremy KerstenandBenoit Socias 878351d840 [IMP] base, web, website, *: differentiate essential & optional cookies
*: im_livechat, survey, utm, website_crm_iap_reveal, website_forum,
   website_livechat, website_sale, website_sale_comparison

Before this commit all cookies were considered essential.

This commit makes some of them optional. It also makes it possible for
the website visitor to only accept the essential cookies.

task-2800976

X-original-commit: 9a8a9463289a7446e9be0ef62ff895feb37a4de4
Part-of: odoo/odoo#101845
Co-authored-by: Benoit Socias <bso@odoo.com>
2022-10-03 10:56:58 +02:00
Denis Ledoux 1cd610a9b6 [FIX] base: invisible="context.get(...)" takes priority only if True
This is an oversight in odoo/odoo#100130

A modifier set with `context.get('...')`,
for instance
`invisible="context.get('sign_directly_without_mail',False)"`
takes priority on attrs
only if the result of `context.get('...')` isn't falsy

e.g.
https://github.com/odoo/enterprise/blob/1a4e4fafe4fc78dab0aad7ab6241a6f4a7be317a/sign/wizard/sign_send_request_views.xml#L64

should return
- `modifiers="{'invisible': [['is_user_signer', '=', false]]}"`
  with `context.get('sign_directly_without_mail') == False`
- `modifiers="{'invisible': true}"`
  with `context.get('sign_directly_without_mail') == True`

closes odoo/odoo#101813

X-original-commit: a3dc5f5fd34671c67253c6ff36bb7c960f9170ff
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-10-01 21:35:09 +02:00
Damien Abeloos 1f6005070f [IMP] tools: keep additional data when sanitizing
Purpose is to allow to have ``data-behavior-props`` and ``data-prop-name``
on HTML nodes and keep it even when HTML content is sanitized. Those attributes
will be used notably in Knowledge application to store some structured content
e.g. used to populate props.

Prepares Task-2796156
Prepares odoo/enterprise#29423

X-original-commit: 7ddb4685567c115ca4e14fa7e5f845b0cb33fd7c
Part-of: odoo/odoo#101694
2022-09-30 10:33:01 +02:00
Ahmad Khanalizadeh 91a3bfc34a [FIX] base: use time zone aware display field for currency rates
Steps to reproduce:

1. change system and admin's time zone to one with a different
date than UTC
2. enable multi-currency in the accounting module
3. add rates for the current date in local time zone and UTC
4. go to settings > currencies
5. the rate for the UTC date is displayed

To fix this, we should use a time zone aware field in `res_currency`.

opw-2945108

closes odoo/odoo#101686

X-original-commit: 2f1d8d6db4efab86d35f362138e80e03692537dd
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Khanalizadeh Ahmad (khah) <khah@odoo.com>
2022-09-30 09:32:29 +02:00
Martin Trigaux e856beb782 [I18N] *: export 16.0 source terms
closes odoo/odoo#101659

Related: odoo/enterprise#32040
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-09-30 09:31:52 +02:00
Lucas Lefèvre f07cd645c9 [FIX] tools: don't extract missing spreadsheet data source name
Previous versions of spreadsheet files don't have a name
for list and pivot datasources.

The spreadsheet template "pipeline dashboard" in `document_spreadsheet_crm`
is such a file.
As a consequence, exporting the source terms from this module fails
with a `KeyError: 'name'`

Part-of: odoo/odoo#101659
2022-09-30 09:31:52 +02:00
std-odoo 608bffff59 [FIX] base: fix the default properties value
Bug
===
If we re-write the same definition record, the default values were
applied again (even if the definition record didn't change).

This is because the compute on the properties is called even if the
definition record didn't change.

Task-2965523

X-original-commit: 70d80771f2430f83c91e7ef46eeebde8de70c3fe
Part-of: odoo/odoo#101487
2022-09-28 19:31:53 +02:00