Commit Graph
157627 Commits
Author SHA1 Message Date
Thibault Delavallée 2175bde607 [IMP] mail: add sanity checks for message_post and its helpers
Purpose of this commit is to clearly check input of ``message_post`` method
and its main helpers in order to prevent wrong usage of message post API.

Some values used to populate message fields should not be set directly when
posting or logging messages. Indeed they may be part of other process (like
notification process managed by ``_notify_thread``, or could be setup by
custom routes like 'reaction_ids', or custom usage of 'model' and 'res_id'
that could conflicts with record on which methods are called).

We therefore add checks and cleanup in those methods to be sure the API
is used as intended and avoid unwanted side effects.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00
Thibault Delavallée 023bc67327 [IMP] mail: introduce a batch version of Partner._find_or_create ()
Purpose is to be able to create find or create partners in batch based on a
list of emails. When sending email in batch, notably using templates, doing
sequentially a search or create for each potential email to contact is not
efficient from computation point of view. This commit introduces a new batch
method for that purpose.

If no valid email is found for a given email, it is used as it to try to
find partners with same invalid email and/or keep the value in order to
allow updating it afterwards. Notably with notifications resend it is
possible to update emails, if only a typo prevents from having a real
email for example.

Falsy emails do not create partners as those have no real interest.

Task-3034875 (Mail: Speedup and batch partners find or create with templates)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée 418761e344 [LINT] mail, various: use explicit subtype in message_post_{with_...}
RATIONALE

Purpose of this commit is to be explicit in subtype chosen when invoking the
message composer / calling message_post. As default value may not always be
clear, better be explicit in case the composer default value changes.

SPECIFICATIONS

Add explicit references to subtype when it is not obvious what will be the
final subtype, notably when using helpers (post_with_view or template which
uses the composer that is not crystal clear in its subtype management).

In this commit we also add support of XMLID-based subtype when invoking the
composer. A ``default_subtype_xmlid`` context key is transformed into a
``default_subtype_id``, to be used notably in JS where we cannot easily
use a ``ref``-like statement. Post API now also supports 'subytpe_xmlid'
argument allowing to give the xml id and ease calling the methods.

Use ``_xmlid_to_res_id`` to get directly the ID of subtypes in order to
avoid useless queries from ``ref`` that does an exists.

Also remove useless values given to post API, notably author_id that is by
default the current users' partner.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée d6aa0050da [FIX] mail: stop spamming CCs of outgoing emails
Fix usage of CCs when sending emails. Currently CCs are added to all outgoing
emails, which leads to unnecessary spam. Recipients are currently computed like

  * create an outgoing email based on 'email_to';
  * create one outgoing email / partner in 'recipient_ids';
  * add CCs to all outgoing emails;

They are now sent only once, either with the email_to if given, either as
standalone. That way partners receive specific emails (due to tracking and
partner specific links management), email_to / email_cc are sent on their own.

Task-3093268 (Mail: Stop spamming CCs)
Prepares Task-2684479 (Mail: Better report errors when sending emails)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée 91672b1cab [IMP] mail: log a warning when having invalid headers on mail.mail
In this commit we add some logs when we fail to evaluate the 'headers' field
on a 'mail.mail' record, used to populate the headers of outgoing emails.

Some tests are added to ensure we do not crash if headers is malformed, and
to cover the feature itself as it was still not really done.

Task-2710804 (Mail: Clean MailThread Posting API)
Task-3093268 (Mail: Stop spamming CCs)
Prepares Task-2684479 (Mail: Better report errors when sending emails)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée b1d678b12a [REF] mail, mass_mailing: extract outgoing email values preparation into a method
RATIONALE

When sending a ``MailMail`` some data preparation is done. This is done
directly in ``_send`` and in sub-methods. As a given MailMail may lead to
several emails being sent we have to go from a mail to a list of emails
to send :

  * one email for ``email_to``. They all receive the same email, as those are
    just a list of emails to contact and no specific post-processing is done;
  * one email for each partner in ``recipient_ids``. It enables a partner-based
    update of the body, for example for links or traces in mass mailing;

SPECIFICATIONS

In this commit we move code so that all preparation is done in a sub-method
``_prepare_outgoing_list``. That way it can be cleanly overridden to add or
modify values before sending the actual emails.

This commit does not change behavior and calls done to ``build_email``. This
will be updated in the next commits, notably to improve "cc" management.

Task-2710804 (Mail: Clean MailThread Posting API)
Task-3093268 (Mail: Stop spamming CCs)
Prepares Task-2684479 (Mail: Better report errors when sending emails)

Part-of: odoo/odoo#99482
2023-01-17 20:58:32 +01:00
Thibault Delavallée 18e6f7d376 [PERF] mail: skip state computation when posting through composer
Composer holds code to check recipients email and avoid sending emails when
recipients do not have valid emails. Purpose is to avoid bloating the email
queue with emails that are about to fail.

It is done by analyzing recipients of emails, aka checking 'recipient_ids'
value before creating the mail.mail.

When being in comment mode, this code has no use as recipients are computed
by the notification process, not by the composer. We can therefore skip this
part. It adds the 'state' and 'failure_type' values that are used on mail
model, but not on messages.

The same kind of processing could be done in notification process to avoid
sending unnecessary notifications, but this improvement belongs to another
commit and task.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:32 +01:00
Thibault Delavallée 1394903873 [IMP] test_mail: add tests for exclusion list and duplicates in composer
Purpose of this commit is to add tests for exclusion list and duplicates
management in composer.

When being in email mode (mass_mail) state of emails is pre-processed in
order to already flag emails that should not be sent or will bounce back.
Notably emails in exclusion list or duplicates emails are set as cancel
with the right failure type.

Some tests already exist at higher level in mass mailing but having tests
at composer level is better when trying to improve code and add tests for
corner cases.

Task-3132710 (Mail: Configurable composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:32 +01:00
Thibault Delavallée c98f259736 [IMP] mail: improve tests tooling methods
In this commit we add a method to check MailMail, based on a given record.
When having duplicates to differentiate in a given mailing, having just
recipients is not sufficient as multiple emails may match a given recipients
list. Checking model / res_id is another method for finding emails.

This will be used notably to add tests for exclusion list and duplicates
management in standard mail composer, outside of mass mailing context.

While being at it, use subTests when having loops checking values. That
way it is easier to fix tests that have several failing values in the same
global assertMailMail_* .

Task-3132710 (Mail: Configurable composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée 7d16ae5551 [FIX] point_of_sale: avoid entities in emails
Purpose of this commit is to avoid html entities in sent emails message by
correctly using string and html formatting.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée 3e7acff8d9 [FIX] website(_sale): fix logs coming from website forms
Purpose of this commit is to avoid html entities in logged message by correctly
managing enclosures. For that purpose a new tool 'nl2br_enclose' is added that
eases Markup management on top of 'nl2br' simple tool.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée eccac1ce7b [FIX] website(_sale): stop creating message manually
In website(_sale) messages are created from website forms. However those
are technical models, you should always use the MailThread API notably to
ensure values coherency. In our case using message_log seems to be what
original committers wanted to do (even creating a message as a comment
which has no effect as the notification process is not called that way).

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée 7b96e7cb22 [FIX] mail: correctly display errors when previewing templates
In this commit we correctly set 'error_msg' field as computed. As it was not
defined as computed, it was not really updated and therefore not displayed
in the preview form view. It is now the case.

ValueError are now also catched, for example when having badly configured
'partner_ids' field we may face this kind of error, which is now logged
in the preview wizard.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Thibault Delavallée 44a316275d [FIX] mail: avoid cache miss when opening the template previewer
Sometimes the previewer crashes in rendering with cache-based records, hence
trying to check directly the id of the related reference record.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Thibault Delavallée 11906b776e [FIX] mail: remove microseconds when parsing vague datetime
Mail holds an helper function to convert datetime from a char input into a
datetime value. It is used notably when having to store a datetime value
(e.g. on a mail_mail) from a string generated by templates with expression
like ``{{ datetime.datetime.now() + datetime.timedelta(days=2)}}``.

In this commit we explicitly remove microseconds, as otherwise we end up with
something that the web client cannot parse, not speaking of even going into
server side storage with this value not matching the expected format.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Thibault Delavallée 04a6b74d09 [FIX] mail, various: update query counters
Update counters according to latest runbot counters. It allows to better spot
side effects of upcoming changes.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Nicolas (vin) d39396c728 [IMP] account,l10n_*: remove company currency symbol in reports
There is a lot of use case where reports are exclusively in the company
currency, or have columns only in this currency. In these case, showing
the currency symbol is redundant, takes space and makes the reading
slower.

With this change, we will avoid displaying the symbol in a variety of
use case where it is not needed.

Task id #2868674

closes odoo/odoo#109666

Related: odoo/enterprise#35671
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-01-17 19:55:50 +01:00
Romeo Fragomeli 51db7cd7b6 [FIX] *: some border aren't apply anymore
* = digest, hw_posbox_homepage, im_livechat, mass_mailing, web_editor,
website, website_slides_forum

Since the migration of Bootstrap 5 [1], some CSS rules was automatically
converted (`border-left` and `border-right`) when it shouldn't be.
These conversions were made because the CSS rules was embedded in
HTML/XML code and the REGEX for the conversion had no protection for
these cases.

This commit restores the old correct value.

Ref:
[1] odoo/odoo@1fcd098af5

closes odoo/odoo#110141

X-original-commit: 0cbf7c00ecc307fc725da345415647828e771bb4
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: Romeo Fragomeli (rfr) <rfr@odoo.com>
2023-01-17 18:12:48 +01:00
Ivan Yelizariev 3ff9c48ba9 [FIX] sale: use partner's lang on creating invoices
This commit adds lang context on preparing invoice lines. Othwerwise we may get
lines in user's lang instead of partner lang.

For example, it's needed in sale_subscription module:

https://github.com/odoo/enterprise/blob/e5e168d596aaefcd842fc553890e474aff3322f2/sale_subscription/models/sale_order_line.py#L235-L236
https://github.com/odoo/enterprise/blob/e5e168d596aaefcd842fc553890e474aff3322f2/sale_subscription/models/sale_order_line.py#L262

STEPS:

- Use English as your user language
- Set a language different from English on a customer C
- Create a subscription product P
- Create a SO for C with P
- Create the invoice

opw-3104785

closes odoo/odoo#110152

X-original-commit: 6dee103df5e5f64d8edf871d4e1a284ef4d21725
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2023-01-17 16:47:27 +01:00
Ivan Yelizariev 85f5006018 [FIX] web: fix export m2m fields on using group_by
Export tool is based on ORM method `_export_rows`. The method has special
processing of m2m fields when user checked *Import compatible* option [1].
Before this commit the negative value of `import_compatible` parameter wasn't
passed when data are exported in grouping mode. This led to empty values in m2m
fields.

STEPS:
* Order some products via website and pay via wire transfer
* Open Orders menu in backend
* group order by any field
* expand group with the order
* add field *Transactions/Acquirer/Display Name*

[1]: https://github.com/odoo/odoo/blob/b28c44a38698018ebbbc420f6567c17b2b97c279/odoo/models.py#L894-L914

opw-2864737

closes odoo/odoo#110151

X-original-commit: 6647ac83467207f4f4ef23aac96ebaf5333b967b
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2023-01-17 16:47:24 +01:00
Dũng (Trần Đình) 3062f8acc4 [FIX] account: None type of search panel
closes odoo/odoo#110149

See: 26dd1d9627cdd04e12c3187f0f53c0e11892a345
X-original-commit: b03d4c6436472d5e78bcdd612171ce56c56d906c
Signed-off-by: William André (wan) <wan@odoo.com>
2023-01-17 16:47:21 +01:00
Kevin Baptiste ae45b2f83f [FIX] hr: use correct close tag
There was an error in the XML template of the department org chart, the
opening tag was a `<t>` but closed with a `</div>`...

closes odoo/odoo#110142

X-original-commit: 10ce40dd6b181f6dd6e434f208aa9f13b33975d3
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-01-17 16:47:14 +01:00
gawa-odoo a599320259 [FIX] analytic: search for analytic account with ref
An analytic account was searchable in an invoice with the Ref field.
Before this commit, it is not possible, while it should.
So we add it to the search domain.

opw-3119740

closes odoo/odoo#110135

X-original-commit: f5e24b8f7ba4291b0e5ea970da948215b83e6184
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Wala Gauthier (gawa) <gawa@odoo.com>
2023-01-17 14:17:06 +01:00
Arnaud Joset c48973aba3 [FIX] calendar: fix attendee model typo
closes odoo/odoo#110133

X-original-commit: 4352aa837b3ffabbda2d3e8a6eb3e793c5b56656
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-01-17 14:17:03 +01:00
Arnaud Joset 74c0d8862f [FIX] calendar: allow update meeting status was crashing
Before this commit, when somebody updated the status of recurrent meeting
the dialog was crashing because the component was destroyed and the orm call
could not be done.

X-original-commit: 544b7d9bf805f7860dd318293964cf822b05e0b9
Part-of: odoo/odoo#110133
2023-01-17 14:17:03 +01:00
Jorge Pinna Puissant 4af6fcd779 [FIX] web: kanban view flickering unfiltering columns
Before this commit, when unfiltering a column in a kanban view, a
flickering occurs and the show more button is visible for a moment.

closes odoo/odoo#110130

X-original-commit: 0cd9c7dbba12e362a6445f47d52b43c48dffdb61
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-01-17 14:16:59 +01:00
tsm-odoo 3752ac6832 [FIX] bus: fix websocket timeout burst
Before this commit, the keep alive timeout could occur for many websockets at
the same time resulting in a burst of transaction (cursor is open when connecting,
disconnecting a websocket).

This issue was even worse because the cursor was opened even when it was
not needed: we don't need to open a cursor if there is no callback
registered for the lifecycle event (OPEN/CLOSE).

This commit fixes those issues by:
- adding a random delay to the keep alive timeout of every websocket.
- not triggering lifecycle events if no callbacks are registered.

closes odoo/odoo#110127

X-original-commit: b4fb1359021b6c882ece3037c82aaaf65cfc2e1e
Signed-off-by: Julien Castiaux <juc@odoo.com>
2023-01-17 14:16:56 +01:00
luvi b6612fca69 [FIX] web: fix ids to export with selected domain
This commit fixes the export when all records are selected (full domain).
Since many records ids might be present when an entire domain is selected,
the request should contains 'false' instead of a list of ids. As a limit
is set in session.active_ids_limit, not all the records were considered.

This means that only the limit was actually exported instead of the full
list that is present. As the legacy implementation of the ExportDialog
allowed to export all records, the behavior has been fixed.

A test has been added to verify the correct parameter during the download
call.

closes odoo/odoo#110126

X-original-commit: 7200e1c5875bc148fb64187fd67d58a7d6c13c7c
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-17 14:16:54 +01:00
luvi 6a74bfae9f [FIX] web: fix export templates list filtering
Before this commit, exporting templates were not filtered as
expected. It means templates were visible even on other domains,
polluting the list of templates of a model.

This restores the legacy behavior by filtering the domain in the
rpc and only displaying the desired template list.

A test has been modified to verify the presence of the domain
filter in the parameters of the rpc.

task #3127779

X-original-commit: 30a673c044e53bfb1edc1e6733b2c83c67e0232c
Part-of: odoo/odoo#110126
2023-01-17 14:16:53 +01:00
Xavier ALT 20f5e0f708 [FIX] project: do not set partner as assignee when task created by mailgateway
When a message is processed through the mail gateway, the partner should
never be set as the assignee of that task.

This commit allow to correctly let pass `{'default_user_ids': False}`
context from `message_new()` down to `create()`

closes odoo/odoo#110124

X-original-commit: 08e24d683bf19a77982a7ffba6c64b5fc6fdf85a
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-01-17 14:16:50 +01:00
Renaud Thiry 9828ce96d0 [FIX] web: handle falsy m2m_tags
Before this change, if a user left a string value in a m2m_tags
and removed it afterward without selecting a tag, the update method
of Many2XAutoComplete would be called with false.

As the update method for m2m_tags expects a record or record list
this caused a traceback.

The fix is to simply skip the update in that case.

task-3109811

closes odoo/odoo#110123

X-original-commit: 14f314feb7594dc888de6af4e4ad23a948044854
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-01-17 14:16:47 +01:00
Jorge Pinna Puissant e54d00f832 [FIX] web: kanban: concurrency issue with animated numbers
Before this commit, in the kanban view, if we click the progress bar to
filter the column multiple times, the count of records number's could
show an incorrect value. This occurs because when removing the filter
from the progress bar, an animation is done to the number (to increase
the value until the correct number of records). Contrariwise, when
activating a filter, the number of records is set directly without
animation. When we remove and add again a filter quickly, the animation
to increase the value of the number finishes when the filter is already
apply and the value shown is the old count of records (without the
filter).

To avoid this, in this commit, we stop the animation when the count of
record changes.

Unfortunately, testing this is very complicated (because it involves
animation frames and Date.now()), and as the cost/reward ratio is very
low, we didn't add a test of this behaviour.

closes odoo/odoo#110121

X-original-commit: 4c8bb53df6ad6382c5b168532c8493ddbb1f7252
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-17 14:16:45 +01:00
gawa-odoo 4f9a5a73f4 [FIX] account_report: change formula's update of expression
How to reproduce:
- Have a report line with a custom creation with a 'balance' label
- Replace the expression by an `account_code_formula` in the xml
=> The 'balance' expression does not exist anymore in the xml,
so the ORM removes it, and a new one is not created.

We changed the update so only 'balance' label expressions are changed:
- if we have an expression with an xml_id, we remove the expression and
recreate a new one.
- if we don't (custom created or coming already from a formula shortcut),
we just update its values.
We also created a way to remove a formula shortcut (making it falsy will
unlink the expression that was linked to it)

closes odoo/odoo#110119

X-original-commit: d01a7b76bee4471444eeedacc05bd52fe9c0399c
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Wala Gauthier (gawa) <gawa@odoo.com>
2023-01-17 14:16:42 +01:00
Jeremy Kersten e2c082717b [FIX] website_slides: fix qweb template slide_content_detailed
odoo.addons.base.models.ir_qweb.QWebException: Error while render the template

closes odoo/odoo#110117

Attributeerror: 'slide.channel' object has no attribute 'can_access_channel'
Template: website_slides.slide_content_detailed
Path: /t/div[6]/div/div[2]/t[3]/t[2]
Node: <t t-if='not slide.channel_id.can_comment and slide.channel_id.can_access_channel'/>
X-original-commit: 1ca26014a32a8aca528a4769451b7f7cf5f61b1a
Signed-off-by: Jérémy Kersten <jke@odoo.com>
2023-01-17 14:16:39 +01:00
niyasraphy 324913beea [FIX] payment: readonly/invisible fields when provider is not installed
before this commit, from the payment providers menu, even though the provider is not installed in the database, the company, website and image fields are editable for the users.

after this commit, the fields will be editable/visible only after the provider is installed in the db.

publish/unpublish button will be shown only when provider is installed.

closes odoo/odoo#110114

X-original-commit: e910dee3ce4b526aa956ad489e83442b3a425c36
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-01-17 14:16:36 +01:00
Rémi Rahir 3e7bdd40fa [FIX] spreadsheet: Catch access errors on spreadsheet
Currently, a user opening a spreadsheet containing pivots/lists/graphs
that they don't have the rights to access (be it because of the parent
model or the domain applied) will end up in an infinite loop.

While starting the datasources, the fetch step will throw, potentially
spamming the user with access errors.

Manual forward port of https://github.com/odoo/enterprise/pull/35146

Task 3107650

closes odoo/odoo#110113

X-original-commit: 1555e79be0b52c30df43e8de50f5db56fbbda630
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
2023-01-17 14:16:34 +01:00
fdardenne e554f5688c [FIX] web: list view: make the scrollbar above the thead in safari
Since odoo/odoo#107631, in Safari (version tested 15.6.1),
the scrollbar stayed below the list view thead and thus looked glitchy.

Now, the scrollbar stays above the sticky thead. The fix applied is
documented in this stackoverflow thread
The fix applied is described in this stackoverflow thread:
https://stackoverflow.com/questions/20832531/mobile-safari-positionfixed-z-index-glitch-when-scrolling

closes odoo/odoo#109773

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-17 14:16:25 +01:00
bat-odoo 662eed1f3d [IMP] l10n_in_edi_ewaybill: fix JSON value for Transportation Mode
Currently, when we select Transportation Mode with Rail, Air or Ship and try
to generate an e-waybill the system raises an error. because of using the wrong fields.

Also made some improvements:
- updated error message
- updated timeout params for jsonrpc because, in the test server, it takes around 61 seconds so we set timeout to 70 seconds.
- filter E-waybill Document Type based on the invoice type

closes odoo/odoo#110111

X-original-commit: d6e40019c137dc353ecaa4785f91d6afa4cf954d
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Bhavin Patel (bat) <bat@odoo.com>
2023-01-17 12:59:05 +01:00
bat-odoo 6816335f8c [IMP] l10n_in_edi: check partner country code for overseas customer
In this commit, before updating the JSON value we check the partner country code
for overseas customers.

X-original-commit: 875d5959d502ad8f761a034aef1dc5b568802f25
Part-of: odoo/odoo#110111
2023-01-17 12:59:05 +01:00
Samuel Degueldre 76a44b29f5 [FIX] web: improve performance in list views with date/datetime fields
When rendering the list view, we evaluate the evalContext for each field
so that we can give it infos such as readonly, required, invalid or
empty. In doing so, date and datetime feels are serialized and added to
the evalContext, but serializing dates can be slow, especially when not
using the default English locale. Internally, luxon checks whether the
locale is English which instantiates an Intl object which can be slow
and this is compounded by the fact that the method is called hundreds of
time in a single render.

This commit caches serialized dates and datetimes in a WeakMap, as the
luxon Date objects are immutable, this is safe, and because these
objects are not recreated often, it also eliminates a lot of the calls
to luxon's toFormat. In the quotation list view, this brings the render
time from ~1100ms to ~270ms. While this is still slow and further work
will be undertaken to make the evalContext lazy (so that only
date/datetimes which are actually used are serialized), it is a good
first step and brings the performance back to a level where the list
view is reasonably usable.

closes odoo/odoo#110103

X-original-commit: 64eeeef4d3d93a9b2753520e0067aa7996988d4c
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-17 12:58:59 +01:00
John Laterre (jol) 3330215c4d [FIX] account: add uom category constraint
Steps to reproduce:
- Create an invoice with a product.
- Confirm it.
- Go to the product and select a UoM of another UoM category.

Issue:
Traceback

Cause:
https://github.com/odoo/odoo/blob/51ead4b2d52e0faec2065b475dac7f376328c425/addons/uom/models/uom_uom.py#L155-L159

Solution:
Add a constraint to prevent the user from changing the UoM category
of a product if it is used in a posted invoice.

At the same time, a similar constraint is added on `account.move.line`
to make sure the line's uom remains consistent with its product.

opw-3039419

closes odoo/odoo#110102

X-original-commit: aeb798d01aafee5fcaa8614f7e2b39a380d0b6ce
Related: odoo/enterprise#35887
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: John Laterre (jol) <jol@odoo.com>
2023-01-17 12:58:56 +01:00
Thomas Carlier(thc) ac8c6736fc [FIX] project_timesheet_holidays: Fix traceback when no timesheet_task_id is found.
-steps to reproduce:
 do a search in project.task on is_timeoff_task when no
 timesheet_task_id is defined on any hr.leave_type.
 This will trigger the _search_is_timeoff_task method

-before this commit:
 crash when no leave_type with timesheet_task_id is found

-after this commit:
 creation of an empty list as expected

opw-3086486

closes odoo/odoo#110091

X-original-commit: b98949b1cb85514ee5a56ff1a5860591c10b0994
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-01-17 12:58:48 +01:00
mehjabin aa1d5ca617 [FIX] base: make action name translatable
before this commit, the action name was not translatable to user language.

after this commit, action name will be shown in user's language.

closes odoo/odoo#110090

X-original-commit: 98fdef318968ae0ee81532c691ca5b372975d486
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-01-17 11:34:35 +01:00
David Monjoie f6c7c1e655 [FIX] mass_mailing: always use the link dialog with the basic template
The basic "Plain Text" template does not have the sidebar and
therefore cannot use the link tools that are in it and must use
the link dialog instead.

Task-3128388
Task-2889670

closes odoo/odoo#110089

X-original-commit: 399e5919c18145371791092868839a5ef11209a2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-17 11:34:32 +01:00
David Monjoie 462f2517f6 [REV] mass_mailing: revert automatically open linktools when clicking a link
This behavior only made sense with [1] applying in all cases, but
since it was wrong to begin with (because of the "Plain Text"
template) and was reverted in the previous commit of this PR, then
the behavior does not make sense anymore, as the dialog would open
as soon as the user clicks on the link.

This reverts commit aaf70d3692.

Task-3128388
Task-2889670

[1] https://github.com/odoo/odoo/commit/61f7366d686b353ae9614285370e952253ec067c

X-original-commit: 33e5dcdb41ae2d4bb2a47ea3fd92f522b09b53e8
Part-of: odoo/odoo#110089
2023-01-17 11:34:32 +01:00
David Monjoie cb69c04233 [REV] mass_mailing: revert do not open link dialog with Powerbox
Since [1], the /link and /button commands did not open in the dialog
anymore and used the sidebar instead. This was wrong for the "Plain
Text" template which does not use the sidebar, and was otherwise
confusing as the main effect of the command would be to focus in the
sidebar.

Task-3128388
Task-2889670

[1] https://github.com/odoo/odoo/commit/61f7366d686b353ae9614285370e952253ec067c

X-original-commit: 44c9be11f1bc5451adc76a69862e7e513c2d9bba
Part-of: odoo/odoo#110089
2023-01-17 11:34:32 +01:00
abd-msyukyu-odooandAntoine Guenet a817a865c3 [FIX] web_editor,knowledge: suspend wysiwyg onBlur with dialogs
Sometimes, there is a crash when uploading a file when loading an article for
the first time.

Impacted versions:
16.0+

How to reproduce:
- open the odoo home page (module menu) and CTRL+f5 (force reload)
- go to the knowledge app
- in an article, put the cursor somewhere and type ENTER to create a new line
- type the /file command in that line
- try to upload a file
- traceback (if it does not happen, try again from the first step, it is not
  always consistent)

Fix:
Delay the _onBlur handling of the wysiwig when using the modal. The Blur event
may occur and may trigger an update on the html_field, which may in turn induce
a rerendering of the component and its value.
We don't want this to occur when using the modal, because the selection was
registered by the modal to restore it when the modal closes (`preserveCursor`).

If the contents of the html_field are updated, then the stored position used to
restore the selection won't be in the DOM anymore, and the restoration will
fail. As such when we try to insert the Knowledge file block, the selection is
not in the editor and the method fails.

Task-2889670
Task-3128388
Task-3086694

X-original-commit: 2591d343793f59e2e70e7ffe8fa666661995348f
Part-of: odoo/odoo#110089
Co-authored-by: Antoine Guenet <age@odoo.com>
2023-01-17 11:34:32 +01:00
Dmytro Lazariev 67328ebd39 [FIX] web_editor: fix missing allow_command_image XML option
Both `allow_command_video` and `allow_command_image` options are supported by the
editor, but only `allow_command_video` was being sourced from the XML of the view.

This works:
<field name="body" widget="html" options="{'allow_command_video: false}"/>

But this didn't work without this commit:
<field name="body" widget="html" options="{'allow_command_image': false}"/>

It looks like that particular option was simply forgotten. This commit rectifies that.

Impacted version:

 - 16.0
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

closes odoo/odoo#110088

X-original-commit: c81c5918e6ba2f263e173b27978194de1f71f1db
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-17 11:34:27 +01:00
Martin Trigaux eaa39012ba [FIX] base: allow calling install_lang in RPC
This method is used in Transifex synchronisation scripts and needs to
be called in RPC.
It was the case before 727ef9e0a2ca9308

closes odoo/odoo#110087

X-original-commit: 3b7e4535d358e554f7b089828efb82bc6b0a40e3
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-01-17 11:34:25 +01:00
Nasreddin Boulif (bon) 27fe31c317 [IMP] website_sale: extract order line update processes to ease override
In order to be able to do a pre or post processing on the order line
updates, we extract the code to a dedicated method.

i.e.: will be used in this PR: https://github.com/odoo/enterprise/pull/35689

opw-3099515

closes odoo/odoo#110082

X-original-commit: 7129806a9aad0ea87e0e73b9322b56006caed202
Related: odoo/enterprise#35879
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2023-01-17 11:34:18 +01:00