Commit Graph
147292 Commits
Author SHA1 Message Date
Josse Colpaert 144abbe552 [FIX] l10n_gcc_invoice: also add description/label of the invoice line
We did not add the description of the invoice line on the print-out
of the invoice. (probably because description is not translatable
and the name of the product is)

If a product is set, the name of the product becomes the description (label)
on the invoice line,  but of course this depends on the language.

So, we only add the description if it does not correspond
to either the English (/standard language) or Arabic product description.
(People can always add both languages in the same field)

Of course, if the product is not set, it will also just show the description (label).

Also put the : of the payment reference in Arabic on the other side.

closes odoo/odoo#81620

X-original-commit: 3485c7ad368d9c841d75a0b0614082b8989e2afc
Signed-off-by: Florian Gilbert <flg@odoo.com>
Signed-off-by: Josse Colpaert <jco@odoo.com>
2021-12-17 21:59:10 +00:00
Josse Colpaert bc782cfc91 [FIX] l10n_sa_invoice: relax constraint for delivery date
We had a constraint(raise) that said that the delivery date needed
to be after the invoice date, but this is putting too many
constraints.

However, we put a help message to say that they should put the
date of the last delivery.  Also, the delivery date should not be
changed once confirmed like the other information in the invoice.

X-original-commit: 9e1a0fb37930de3c8cbc0ecf88052e5ddf55d474
Part-of: odoo/odoo#81620
2021-12-17 21:59:09 +00:00
William Braeckman 4902075e3d [IMP] hr: allow users to edit their settings in multi-company contexts
Before this commit users were not able to edit their settings if they
had a linked employee for a company that was not currently active for
them.
This is due to the fact that since the employee_ids field is considered
`safe` to read/write by your own user the fields were loaded in sudo and
thus bypassed the security rules that were meant to prevent that issue.
The security rule is now enforced as a domain on the `employee_ids`.

TaskId-2715341

closes odoo/odoo#81612

X-original-commit: b5b105eabd90419a5856e8279e277743c5915fc9
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2021-12-17 16:58:10 +00:00
William Braeckman 60ee56c0ed [REV] hr: revert commit 0e12620
Reverts commit 0e126201bf801e20412ae2b4cdf07e4a600adbd1
from PR #79472

TaskId-2715341

X-original-commit: bf1b27f9a77b42cd969a5129f67b9ffb0feed656
Part-of: odoo/odoo#81612
2021-12-17 16:58:09 +00:00
Adrien Widart 33f8a21155 [FIX] delivery: use tracking number only once
When having a shipper for a DO, if the user creates a backorder, the
information won't be sent to him.

To reproduce the issue:
(Use demo data)
1. Create a sale order SO with 2 products
2. Add Shipping: UPS US
3. Confirm SO
4. In the associated picking, deliver one of the products and create a
backorder
5. Process the backorder

Error: In the chatter, there is a label for the first picking but there
isn't any label for the backorder

When confirming the sale order, the backorder is first created and then
the initial picking is sent to UPS. As a result, considering the current
body of `send_to_shipper`, the field `carrier_tracking_ref` of both the
initial picking and the backorder is defined with the same value (i.e.,
the tracking number of the initial picking)

Therefore, when processing the backorder:
https://github.com/odoo/odoo/blob/f29da79ef64a8166e54544d1787912be5665076a/addons/delivery/models/stock_picking.py#L126-L129
`carrier_tracking_ref` is already defined, so `send_to_shipper` won't be
called

OPW-2678549

closes odoo/odoo#81599

X-original-commit: 89f9281b096e24583ff7780a1bb42f0c4b7b477e
Related: odoo/enterprise#22980
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2021-12-17 16:58:04 +00:00
Arthur Detroux (ard) 583f7ceb2d [IMP] website, web_editor: provide clarity for theme colors
Prior to this commit, the color presets generated by the color palette
would always be visible by the user which could lead to confusion.
Most users would click on the presets and edit them instead of editing
the color palette.

This commit groups the presets into a collapsed section under the color
palette to incentivize the user to click on the color bubbles instead.

task-2687469

closes odoo/odoo#79921

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-12-17 16:57:57 +00:00
Kevin Baptiste fbc7b78036 [FIX] lunch: show only company locations
All lunch locations were showing regardless of the company the user is
logged in.

Now only the lunch locations of the current company are showing.

closes odoo/odoo#81603

Taskid: 2710417
X-original-commit: 3e87770bb8faf2a58ba0b429148f64256537a4da
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2021-12-17 16:07:37 +00:00
Kevin Baptiste b600373abb [FIX] hr_holidays: fix accrual test
The test `test_unused_accrual_postponed` was expecting at least 25
holidays to be accrued, but started failing around mid-December.

closes odoo/odoo#81592

X-original-commit: c2865b7f5b654a61d4b2690133797aa39712b00d
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-12-17 13:40:06 +00:00
Christophe Monniez 0aa8dbd295 [FIX] hr_holidays: fix freeze_time usage
When Freezegun is used with the `start` and `stop` method and the test
fails before the `stop`, the time stays frozen for all the other tests.

When it happens on runbot, a lot of tests brake with a lot of noise as
they are false negatives.

X-original-commit: 048796dc125b0d494f3c2fcd12625a84ee5cd91d
Part-of: odoo/odoo#81592
2021-12-17 13:40:05 +00:00
Arthur Detroux (ard) b7a110bf21 [IMP] web_editor: improve snippet search placeholder message
Tests showed that users didn't understand the goal of the search bar
above the snippets block under the tabs.

This commit changes the placeholder of the search bar to better
indicate its purpose.

task-2607728

closes odoo/odoo#81222

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-12-17 13:39:57 +00:00
Patrick Hoste af6c434812 [IMP] survey: open result page in new tab
SPECIFICATION

Before this commit, when clicking on the 'See Results' button
the page was loaded on the previous one.
After this commit, the page will open in a new tab.
We also took the opportunity to replace all the '_blank' value
occurence by the 'new' value as '_blank' value is not a valid
value for the 'target' field of the 'ir.actions.act_url' model.

LINKS

Task-2700305
PR : odoo/odoo#80858

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-12-17 13:39:53 +00:00
anhe-odoo 349c3710ae [FIX] website_*: update of the total amount according to the shipping method
Expected behaviour

When buying something on the website, the amount to be paid for the client
should take into account the choice of the shipping method.

Observed behaviour

When choosing a different shipping method than the default one, and only
if this method is a third party acquire, the total amount is updated on
the website, but the amount the client will be asked to pay doesn't take
into account this change, being computed according to the default shipping
method.

Steps to Reproduce this Issue
1. Select a product on the website and add it to the cart
2. View and validate the cart
3. Change the shipping method
4. Click on the "Pay now" button

Problem Root Cause

This issue comes from the fact that the amount was written in the view when
creating the cart view and wasn't updated by a change of shipping method.

Related issue
opw-2686369

closes odoo/odoo#81587

X-original-commit: 617ed0ef47d1496b912d5b85a494e3cda897da4d
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: Hendrickx Anthony (anhe) <anhe@odoo.com>
2021-12-17 12:51:49 +00:00
Antoine Guenet 44a18a3ffa [FIX] mass_mailing: ensure mailing demo has a body_arch field
mass_mailing used to show the body_html but now shows the body_arch
field instead (and body_html only in debug mode). As a result, one demo
that had only defined body_html showed an empty field. This moves
the body_html of that demo into its body_arch.

task-2710460

closes odoo/odoo#81586

X-original-commit: a313276e7a84eac053b0b35b290e3f3132c051e2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2021-12-17 12:51:45 +00:00
Didier (did) 7d7a1e4029 [IMP] mail, website_slides: use mock server for activity test
closes odoo/odoo#81502

Related: odoo/enterprise#22941
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-12-17 12:51:39 +00:00
Andrea Grazioso (agr-odoo) f75abaf37e [FIX] point_of_sale,pos_sale: import tax from orderline
Set up a [TEST] product with a tax A
Create a SO with [TEST] and a tax B and confirm
Open POS, import the created SO

[TEST] will be imported with tax A
while tax B should be pulled from the sale order line instead

opw-2699793

closes odoo/odoo#81580

X-original-commit: 0a5cbfeb7edcce6e6bb915d6e61c736491695ada
Signed-off-by: Masereel Pierre <pim@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2021-12-17 11:58:44 +00:00
Florian Charlier 9540dc7772 [IMP] event: Improve logic and appearence of archived registrations
When an attendee's registration was archived, their seat was still
considered taken, which could be problematic such as in cases of
limited seat availability.

Only non-archived registrations are now counted as seats. The same
error as with regular registrations will be raised if there are not
enough seats available to un-archive a registration. These ValidationError
messages now show the name of the fully booked event.

A few python tests are included to verify the impact of (un)archiving on
seats availability for events and for event tickets.

The appearence of archived registrations was also not different in form
and kanban views, which is somewhat confusing and inconsistent with the
aspect of archived records in Odoo. Actions buttons are not available on
archived records.

Filtering in the archived records needed to be simplified from a "Custom
Filter" to a one-click feature, already available for many models.

Task-2646298

closes odoo/odoo#77715

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-12-17 11:04:53 +00:00
Rémy Baranx (bar) 846367530a [FIX] google_calendar: empty event name in google calendar
As explained at https://github.com/odoo/odoo/blob/171e42e380a46463b4359166955dc4c5f6ccf42e/addons/google_calendar/models/calendar.py#L206,
When there is no Odoo user who is the owner of the updated event,
modification are limited to some fields only.

In this case, that means we must use the `PATCH` method instead of the `PUT`
one to avoid erasing all not modified fields such the event name.

opw-2694739

closes odoo/odoo#81341

X-original-commit: 960e63a75350c28f186e55d69bffea6d51dcf7f1
Signed-off-by: Arnaud Joset <arj@odoo.com>
2021-12-17 10:10:49 +00:00
Nicolas Pierre bec3c58df3 [IMP] stock: Inventory Adjustments improvements
Improvements of the Inventory Adjustements page, among which:
 - Add a new 'Apply All' button (without the need to select a record)
 - Show the date at which the last count was done
 - Add warning icon next to duplicated SN
 - Allows to change the lot_id when empty and no quantities are set

closes odoo/odoo#78361

Signed-off-by: Arnold Moyaux <arm@odoo.com>
2021-12-17 10:10:45 +00:00
Younn Olivier aa1134ac05 [FIX] website: fix mega menu items text edition
When inserting a new paragraph by pressing 'enter', it would
automatically close the mega menu.

As inserting a new paragraph triggers a historyRevert at the editor
level, it was leading to two issues:
- The widgets of the public root were stopped then restarted. The
StandardAffixedHeader (the public widget for the header), as an
Animation, would start its effects when started, which would close its
dropdowns. This commit changes the _updateHeaderOnScroll method to close
opened menus and dropdowns only when the animation has scrolled.
- Opening the dropdown was a recorded step. When history was reverted,
it would close it. Now toggling the mega menu is done with the editor
observer unactive.

task-2668908

closes odoo/odoo#81559

X-original-commit: 675430d53f6ef048b77afe95395bd760d3f5a2be
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-12-17 09:18:15 +00:00
Younn Olivier 6e15b916d2 [FIX] website: fix extra menu items dropdown display
[1] changed the structure to adapt it to the new dropdown menus. This
commit changes the css according to these changes so that mega menus are
correctly displayed inside the extra menu items dropdown from the auto
hide menu.

[1]: 29b9280c44534d2f210dbcea83e0049365949f48

task-2668908

X-original-commit: fdd06d70fa78098cbfe0bd5200acd2fa171f4576
Part-of: odoo/odoo#81559
2021-12-17 09:18:14 +00:00
Younn Olivierandqsm-odoo 073e63b824 [FIX] website: improve mega menus editability
This commit adds the possibility to modify some background colors of the
mega menus so that the templates are fully editable.

Some of these templates have a column with an extended background, using
the :before css pseudo element.
As this is not a DOM element, it cannot be changed from javascript.
It was decided that using shapes would not produce the same effect as
the designer intended, and that it would be too confusing for the user
to be provided with an option allowing to extend the background of a
column.
Therefore, these specific s_mega_menu_gray_area elements must have their
background hardcoded.

task-2668908

X-original-commit: f01c74118ad4c772fb18866956ab9fb214f781fa
Part-of: odoo/odoo#81559
Co-authored-by: qsm-odoo <qsm@odoo.com>
2021-12-17 09:18:14 +00:00
Tom De Caluwé e9f72aa643 [FIX] website: never hide countdowns with redirect action in edit mode
When editing a countdown with a redirect action, sometimes the
countdown block will be hidden when toggling the "Hide countdown at the
end" option.

The problem is caused by the button that allows previewing
and editing the end message of the countdown, this button does not
apply in the case of a redirect action though. However, the button can
still be activated by selecting a different end action first and
switching to the redirect action afterwards, in which case it will
incorrectly hide the countdown.

task-2638366

closes odoo/odoo#81557

X-original-commit: 7f6ebee33e8a82d7ccdf155c3a543898b187389c
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-12-17 09:18:08 +00:00
Tom De Caluwéandqsm-odoo 9e5d149527 [FIX] website: correctly toggle the preview for the countdown snippet
The countdown snippet has an end action that can be configured to show a
message when the countdown reaches zero. A button in the editor toggles
a preview of this message. However, a bug currently makes the preview
disappear whenever the snippet's widget is restarted... which occurs by
simply hovering some other options.

To solve the problem, the preview visibility is now controlled by a
separate css class s_countdown_enable_preview overriding d-none. This
way, the preview visibility no longer interacts with the widget's logic
and is no longer affected by the widget restarting.

task-2638366

X-original-commit: c37354d457f5b868673b4f974e401f4c635062d2
Part-of: odoo/odoo#81557
Co-authored-by: qsm-odoo <qsm@odoo.com>
2021-12-17 09:18:07 +00:00
qsm-odoo 037bc4c255 [FIX] web_editor: remove useless test-breaking warning
A console.warn instruction was added with [1] in case an user interacts
with an editor widget which does not declare any linked option method
(as it is most probably a dev mistake). We have cases where it makes
sense though, adding a custom button with more complex events and
interactions or simply in some strange custo. This warning prevents to
test those uncommon behaviors in a tour test (which is what following
commits of this PR are trying to do).

This commit simply removes the warning.

[1]: https://github.com/odoo/odoo/commit/be05ac7e2b8d866a72693b761f3bc8576d54e59e#diff-ffb61e86e6b8297ef8997f9c605de14de896b54161c032d88a80bbaeac4f89beR490

X-original-commit: 1b18747c7a328df142d7b2cf206a84c39d5eac05
Part-of: odoo/odoo#81557
2021-12-17 09:18:07 +00:00
Florent de Labarre d8d67f470e [FIX] point_of_sale : allow edit to amount on done payment after reload
When you reload the pos (F5), this.payment_terminal is undefined.
And you can update the amount even if the payment is done.

closes odoo/odoo#81546

X-original-commit: 2e10f33511ced41f296e0f65d2d042f4e041cacb
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Masereel Pierre <pim@odoo.com>
2021-12-17 09:18:00 +00:00
Jeremy Kersten de29bae3ee [FIX] hr: don't use .write() in a computed method
Before this commit, the computed field _compute_is_system make a write which
one is a bad practice and trigger a lot of others calls on res.user model.

opw-2716468

closes odoo/odoo#81555

X-original-commit: f85a67935c5dfa660e94f9bed8e8058c8df256cc
Signed-off-by: Jérémy Kersten <jke@odoo.com>
2021-12-17 08:29:41 +00:00
Aaron Bohy 0376a259e5 [FIX] web: ActionService: send user context to /web/action/run
Since commit [1], the user context wasn't put in the context
sent when executing a server action (only the context of the
action sent). This commit fixes the issue.

[1] 7354d1686915ec21437fc677f15a6c5409106492

closes odoo/odoo#81552

X-original-commit: fee371be291ba3d6f1adc71c08420b6510fdf386
Signed-off-by: Géry Debongnie <ged@odoo.com>
2021-12-16 19:12:37 +00:00
Xavier BOL (xbo) cc87856017 [FIX] hr_timesheet: archive/unarchive ir.rule for project sharing
Before this commit, the ir.rule called `timesheet_line_rule_portal_user`
is added just for the project sharing and have to be unarchived when at
least an external collaborator is added into a project. But this rule is
never unarchived.

This commit archives/unarchives the ir rule when the condition is
satisfied.

part of task-2648955

closes odoo/odoo#81553

X-original-commit: a6f0aaeea8b621040559738d7b27d320b6208b58
Related: odoo/enterprise#22956
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2021-12-16 18:25:04 +00:00
Odoo's Mergebot dd002e56da [MERGE] test_event_full, event(_*): clean tests and add performance tests
Purpose of this merge is to clean and add tests for event application and
its sub modules.

We notably

  * clean common files, lessen "shared" data and make tests more localized;
  * remove manual patch of datetime to use freezegun;
  * add more tests in test_event_full about synchronization with event
    types and seats computation;
  * add some performance tests;
  * add performance tests around page browsing and registration flow;

Task-2703289 (Event testing and coverage)
Preparing Task-2703285 (Event performance improvements)
Somehow related to Task-2341656 (Event submenus shenanigans)

closes odoo/odoo#81068

Related: odoo/enterprise#22783
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-12-16 18:33:50 +01:00
Thibault Delavallée 2411a6b69c [IMP] test_event_full: add performance on frontend and registration tour
Purpose of this commit is to add performance tests for some commonly used
URLs related to event: the main event page and browsing a given event.

A complete registration tour involving buying tickets, answering questions
and filling billing information is also added under a query counter check.
This allows to see a bit how many queries are involved in that flow. To
ease reproduction a data is added but not imported, allowing to quickly see
what happens locally instead of having to debug tests.

Task-2703285 (Event performance improvements)
Task-2703289 (Event testing and coverage)

Part-of: odoo/odoo#81068
2021-12-16 17:33:49 +00:00
Thibault Delavallée eee03e9ce0 [IMP] test_event_full: add performance tests
Add performance test for event and registration creation. This serves as a base
for future cleaning and improvements for both models and performance in event
models targeting v16.

Task-2703285 (Event performance improvements)
Task-2703289 (Event testing and coverage)

Part-of: odoo/odoo#81068
2021-12-16 17:33:49 +00:00
Thibault Delavallée 79c2979c90 [IMP] website_event(_questions): add anchors to ease registration testing
Add some classes and name on some DOM elements easing tests writing. Otherwise
xpath are hard to write, especially in tours where it can quickly become a
PITA to write and update.

Task-2703285 (Event performance improvements)
Task-2703289 (Event testing and coverage)

Part-of: odoo/odoo#81068
2021-12-16 17:33:48 +00:00
Thibault Delavallée d55165931a [FIX] website_event: pre-compute website_menu
With this commit we ensure website_menu field is computed before calling
create. Indeed otherwise it is computed after the create if value is not
given and stays to False. This is due to the compute that does not distinguish
a False value from user from a False value added as default. This breaks
the event type -> event synchronization when no form view is used (either
through UI or in code).

With this commit, it is computed before resuming the creation and field
is correctly synchronized with the template value unless the user gives
a value at create time.

Task-2341656 (Event submenus shenanigans)

Part-of: odoo/odoo#81068
2021-12-16 17:33:48 +00:00
Thibault Delavallée ea56328280 [IMP] test_event_full: add tests for template and seats synchronization
Purpose of this commit is to add tests about template (``event.type`` model)
synchronization when creating an event. Some tests already exist in event sub
addons but this one has all community features activate. It eases checking the
final result.

Tests about seats computation and registration creation prevention due to
limits are also added as this behavior may be re-implemented soon.

Task-2703285 (Event performance improvements)
Task-2703289 (Event testing and coverage)

Part-of: odoo/odoo#81068
2021-12-16 17:33:48 +00:00
Thibault Delavallée ad5c08ca09 [REF] test_event_full: cleanup tests
Purpose of this commit is to make test_event_full globally independent from
other event sub modules testing data. We now define a complete event type
with all sub options clearly activated in a single setup. That way tests
in test_event_full are easier to read, understand and modify.

A custom report replacing badge report is added as the base one is quite
complex. It is easier to test the result with simpler templates.

Task-2703285 (Event performance improvements)
Task-2703289 (Event testing and coverage)

Part-of: odoo/odoo#81068
2021-12-16 17:33:48 +00:00
Thibault Delavallée 237911775c [REF] website_event_*: remove manual datetime patch
Use freezegun as it is more easy to use and allow to remove a lot of extra
boilerplate. Indeed manually patching datetime is a PITA as a lot of imports
have to be patched.

A custom patching has to be done for create_date, as it is done using a value
stored on the cursor (cr._now), based on SQL now. As it has nothing to do
with standard python library it cannot be patched using freezegun.

Task-2703285 (Event performance improvements)
Task-2703289 (Event testing and coverage)

Part-of: odoo/odoo#81068
2021-12-16 17:33:47 +00:00
Thibault Delavallée db19463f25 [REF] event(_*): clean tests common files
Purpose is to have a common event class for users and useful stuff (customers,
products, ...) but lessen usage of common test data through sub modules.
Indeed having a "global event type" test data updated in various addons is
actually complicated to maintain.

Sub add-ons are updated to use mainly the ``EventCase`` test class holding
users and side data. Data specific to those modules (event type with some
specific configuration notably) is created and used in tests in the given
module only, and not through generic event_type_complex and event_0 test
data anymore.

With this commit tests are more localized to their add-on and modifying data
in a given add-on has less chances to have unwanted side effect in other event
submodules unit tests.

Task-2703285 (Event performance improvements)
Task-2703289 (Event testing and coverage)

Part-of: odoo/odoo#81068
2021-12-16 17:33:47 +00:00
Antoine Guenet 62dbff18ca [FIX] mass_mailing, website: prevent merge lines in s_numbers snippet
When double clicking a number in the numbers snippet, then typing a new
number, the number line would be merge with the text underneath. This
prevents that by adding a line break in between so they aren't
considered the same line by the editor (an inline with a block as
sibling is a tricky case for edition).

task-2711644

closes odoo/odoo#81551

X-original-commit: 886af1f328a9f1664b0d3e204bf984bfee28b215
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet <age@odoo.com>
2021-12-16 16:44:56 +00:00
Antoine Guenet 9d1fabbda0 [FIX] mass_mailing: flag blockquote and highlight as inner snippets
The wrong classes were declared for the s_blockquote and
s_text_highlight snippets in the selector of so_content_addition. As a
result, these snippets could not be inserted inside other snippets.

task-2711645

closes odoo/odoo#81550

X-original-commit: 8d05470e51b9a48d73f8ffaba4789321523b3129
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet <age@odoo.com>
2021-12-16 16:44:52 +00:00
Antoine Guenet e60949bc55 [FIX] mass_mailing: properly select text color based on background
When changing a mailing's background color to black, the text of many
snippets would change to white, even though the mailing's body was
white. This was because said body was applied in css while the mailing's
body was applied with a class that also set the text's color.
This fixes that issue by applying the white background on the body via
such a class rather that via css.

task-2711643

closes odoo/odoo#81549

X-original-commit: 31abb63fca22c73b85912eb9ba2cf08806aab679
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet <age@odoo.com>
2021-12-16 16:44:49 +00:00
Antoine Guenet 1f9f7a13d4 [FIX] web_editor: prevent traceback on remove flex styles
A traceback was triggered when removing flex styles in convert_inline.
This is fixed by iterating over the styles rather that over all keys of
the style object.

task-2697159

closes odoo/odoo#81540

X-original-commit: 18db94d9fc320c35e811d991fc4a32533d481083
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2021-12-16 15:58:25 +00:00
David Monjoie 8b1012a79d [FIX] web_editor: fix css rules computing everywhere
X-original-commit: bf9928d28818324c85318968a235d238398bca68
Part-of: odoo/odoo#81540
2021-12-16 15:58:24 +00:00
David Monjoie 096c3ab82f [FIX] web_editor: remove unneeded calls to jQuery html method
X-original-commit: 41788a90157e50659a338467b9e18113a467957c
Part-of: odoo/odoo#81540
2021-12-16 15:58:24 +00:00
David Monjoie c05b700bed [FIX] web_editor: properly export toInline
X-original-commit: c30029e0c5112a092441353873cc627c6b0bf94c
Part-of: odoo/odoo#81540
2021-12-16 15:58:24 +00:00
Antoine Guenet bd884ae51d [REF] web_editor, mass_mailing: abstract convert_inline function calls
This adds a `toInline` function that replaces the code that was
duplicated between convert_inline and mass_mailing_widget. The
duplication was confusing and error prone.

X-original-commit: 916582af2d707fc1aa462c6feffa3f5defda75a2
Part-of: odoo/odoo#81540
2021-12-16 15:58:23 +00:00
Antoine Guenet 770ea95b5b [REF] web_editor: reorder, rename and document convert_inline functions
This simply reorders (alphabetically and public/private), renames and
document (with docstrings) all functions of convert_inline.

X-original-commit: 970a3686b1f5edea97bbf86bf4fadc90cfe63357
Part-of: odoo/odoo#81540
2021-12-16 15:58:23 +00:00
Antoine Guenet de558e5da0 [REF] mass_mailing, web_editor: speed up class to inline conversion
When saving an email, its contents pass through convert_inline to ensure
wide e-mail client compatibility. One phase of that process is the
conversion of classes to inline styles, which involves parsing through
all the styles in all the stylesheets of the document, and matching them
with each element in the DOM. That is an extremely expensive process and
because of that, saving an e-mail can take a very long time depending on
how large the DOM is.
This refactors it for performance gains. Tested on an exaggeratingly big
DOM, what used to take about 12s now takes about 5s.

- The process of parsing through the document's stylesheets is now done
  on opening the email (about 500ms) rather than on saving it so we
  split the processing time between the two.
- When parsing the stylesheets, we now also preprocess them by grouping
  whatever can be grouped together and precomputing the specificity so
  as to sort them appropriately. This has the benefit of considerably
  reducing the number of rules to iterate over for each element (from
  11k+ to 3k+).
- In the process, some things were re-written for improved readability.

X-original-commit: 10e749537186dfb80aee1f2537f3b5804f66cfe5
Part-of: odoo/odoo#81540
2021-12-16 15:58:23 +00:00
Antoine Guenet 638d60460f [ADD] web_editor: unit tests for convert_inline
This provide tests for the main unit testable functions of
convert_inline, as well as a couple of test utils to that purpose.

X-original-commit: 6a17ff7442a8395663c3e215cc14c057c098d4b5
Part-of: odoo/odoo#81540
2021-12-16 15:58:22 +00:00
Antoine Guenet 6ec1f4cc4e [FIX] web_editor: include doctype in iframe
This introduces a doctype declaration in the initialization of html
fields iframes and wysiwyg iframes. That prevents the browser from
rendering in Quirks mode[1] which makes tables override the usual style
inheritance patterns. As a result, this fixes an issue with text colors
and alignments that were lost on converting divs to table structures.

[1] See https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode

X-original-commit: da5cf4bcac696a73c33d856ac889342fe8670e65
Part-of: odoo/odoo#81540
2021-12-16 15:58:22 +00:00
Antoine Guenet b1c21a696d [FIX] web_editor: fix missing docstrings and hard-to-read code
This covers minor refactors in convert_inline, and adds docstrings to
some of its functions that were missing them.

X-original-commit: 7c67a703ac5874cbd05ab5e82f566499b1e07849
Part-of: odoo/odoo#81540
2021-12-16 15:58:22 +00:00