Commit Graph
145578 Commits
Author SHA1 Message Date
Odoo's Mergebot fcf6edc697 [FW][MERGE] web,*: introduce Layout component
This PR introduces a new component: the layout component.
Its purpose is to make abstraction of most generic components and
classes when writing a view template or an action.

To make use of this component, we also needed a new system to pass slot
from the parent of the layout to the control panel. This was done in a
hacky way and is meant to be replaced as soon as Owl provides a built-in
way to pass slots.

The control panel has also been slightly tweaked to default its props
from an environment's newly introduced key: the 'config'. This has been
done to reduce the amount of props passed to the layout and search
subcomponents.

closes odoo/odoo#77463

Forward-port-of: odoo/odoo#76140
Related: odoo/enterprise#21295
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-09-30 12:38:32 +02:00
Julien Mougenot 53f9b5f235 [REF] *: adapt modules to action and view contexts
This commit handles the adaptation of any component using the search
model's 'action' and/or 'view' key, now replaced by the environment
keys 'actionContext' and 'viewContext'.

Affected modules are:
- base_import
- board
- crm
- google_spreadsheet
- project

X-original-commit: 40f1ae87e1436192a70a8a7432eb72d379cfa6dc
Part-of: odoo/odoo#77463
2021-09-30 10:38:30 +00:00
Julien Mougenot c440c2eb95 [REF] web: Pivot with view layout
This commit rewrites the pivot view template to make use of the view
layout component.

X-original-commit: ebb046c5b9b6b629fd6731a419c5b7daf57a9f7d
Part-of: odoo/odoo#77463
2021-09-30 10:38:30 +00:00
Julien Mougenot 163be99e53 [REF] web: Graph with view layout
This commit rewrites the graph view template to make use of the view
layout component.

It also removes a duplicate test in the graph test suite.

X-original-commit: a9a65fd51a2317adc07bf3742f7edc360236d32e
Part-of: odoo/odoo#77463
2021-09-30 10:38:30 +00:00
Julien MougenotandAaron Bohy 5bcf16311a [IMP] web: View layout
This commit introduces a new component: the layout component.
Its purpose is to make abstraction of most generic components and
classes when writing a view template or an action.

To make use of this component, we also needed a new system to pass slot
from the parent of the layout to the control panel. This was done in a
hacky way and is meant to be replaced as soon as Owl provides a built-in
way to pass slots.

The control panel has also been slightly tweaked to default its props
from an environment's newly introduced key: the 'config'. This has been
done to reduce the amount of props passed to the layout and search
subcomponents.

X-original-commit: 3b29dd230acd961a72fb0cb971f9363958f65b60
Part-of: odoo/odoo#77463
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2021-09-30 10:38:29 +00:00
Julien Mougenot 6dd7efed58 [IMP] web: Only display search panel with sections
Before this commit, the search model would consider displaying a
search panel regardless of whether it had any sections.

Now, the search panel is considered non-displayable when there is no
sections.

X-original-commit: d3b191600b50fb052a956d1199730453789674e2
Part-of: odoo/odoo#77463
2021-09-30 10:38:29 +00:00
Mathieu Duckerts-Antoine da8f749f56 [FIX] web: py.js datetime.timedelta implementation
The identification of timedelta with relativedelta was wrong.

Here we define a class PyTimeDelta used by py.js to evaluate most
expressions in which datetime.timedelta and some operations producing
timedeltas occur.

The class PyTimeDelta allows to:
    - create a timedelta
    - add/substract two timedeltas
    - multiply (divide) a timedelta by a float (resp. an integer);
    - take opposite of a timedelta
    - evaluate equalities between timedeltas and other expressions
    - decide when a timedelta is "false"
    - get total_seconds of a timedelta

In relation with that, we have improved the implementation of PyDate
and PyDateTime to allow most manipulations of datetime.date and
datetime.datetime producing/using timedeltas. It is now also possible to
evaluate equalities between dates/datetimes and other objects.

closes odoo/odoo#77453

X-original-commit: fcd4959a65a92e34ce986575c7fc279c195e9a11
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com>
2021-09-30 10:38:19 +00:00
Noe Antoine 01ffaea48b [FIX] survey: allow partial scores to answers almost correct.
BEFORE THIS COMMIT / How to reproduce :

Consider a multiple choice question with single answer.

A. 2 points
B. 1 point
C. -1 point

Here, the user can only select one answer. He picks A. He only obtains 2/3 points.
This is because the maximum score was computed as the sum of all positive scores
for the question. It does not make sense, as the student can only pick one answer.
Therefore, the formula does not allow giving partial scores (here, answer B, close
to the correct answer) while maintaining correct score percentages.

AFTER THIS COMMIT:

The sum of positive scores is still used as maximum score for multiple choice
with multiple answers, as we want the student to pick all good answers for max score.

However, for multiple choice with single answer, we use the maximum positive score
(or 0, if none) among answers, as it the maximum score one can get while selecting
a single answer.

-> example above : I pick A, I obtain 2 points out of max(2, 1, (0)) = 2
-> I obtain max score for the question. 2/2.

ps: As the sum only uses striclty positive values, the negative points are still
operational and the flow is not changed.

TESTS:

A test test_partial_scores_simple_choice is added to make sure the simple_choice
is repaired and always gives 100% of points if the best answer is picked.

Task-2533836

closes odoo/odoo#77426

X-original-commit: 2cdfb7805564943ccf857e49b41d3b597fd727bb
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-30 10:38:15 +00:00
Swapnesh Shah 73188b0d7a [FIX] repair: fix repair mail template
This commit fixes two issues

  * better handle void partner_id;
  * get back ``object.origin`` that was removed when converting into QWeb
    at odoo/odoo@0a180d04b0

Task-2657930

closes odoo/odoo#77451

X-original-commit: 3b3a47f0d3414ae5bee159f6ec4644e64441040f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-09-30 09:14:53 +00:00
Adrien Widart e8df398cbb [FIX] stock_landed_costs: round using the currency rounding
In some cases, it is impossible to validate some landed costs ("Cost and
adjustments lines do not match.[...]")

To reproduce the issue:
(Enable debug mode)
1. Set the Decimal Accuracy of Product Price to 4
2. Create a Product Category PC:
    - Costing Method: FIFO
3. Create 4 storable products (category PC)
4. Create a service product (landed cost)
5. Create a PO with the 4 products:
    - 6 x $0.92
    - 6 x $0.92
    - 3 x $75.17
    - 6 x $20.54
6. Process the delivery D
7. Create a Landed Cost:
    - Delivery: D
    - Product: the service product
        - Split Method: By Quantity
        - Cost: $1000
8. Compute the landed costs + Validate

Error: a User Error is raised "Cost and adjustments lines do not match.
You should maybe recompute the landed costs.". The sum of the additional
landed cost equals $999.99 instead of $1000

From version 14, `additional_landed_cost` is a Monetary field and its
rounding property is no more based on "Product Price":
https://github.com/odoo/odoo/blob/800433bde03a36ead40a78bc6d53cbb95c24f97b/addons/stock_landed_costs/models/stock_landed_cost.py#L371-L372
Therefore, we should use the rounding of the associated currency to
round its value

OPW-2637701
OPW-2631718
OPW-2649348

closes odoo/odoo#77445

X-original-commit: c2750517428be83eb278894932e57e0a9a78fa6d
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-09-30 09:14:49 +00:00
Samuel Degueldre 029ecd3363 [FIX] mail: fix various crashes in webRTC, improve logging
closes odoo/odoo#77430

X-original-commit: ef378ef31833e4feb5e3763b9d28757e488d45cb
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-30 07:51:02 +00:00
Julien Banken 10ce6a806f [IMP] calendar: removes the group-by availability preset filter
It turns out that the group-by 'availability' filter of the
'calendar.event' model is not really meaningful. We will hence remove it
to simplify the interface. Note that the users will still be able to group
the records by 'availability' by defining a custom group.

task-2646322

closes odoo/odoo#76901

Related: odoo/enterprise#21038
Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com>
2021-09-30 07:50:55 +00:00
Simon Genin (ges) ff6823cb24 [IMP] web: xml parsing doesn't fail silently
closes odoo/odoo#77452

X-original-commit: 58c3a36ee955cb2c3bb461244dd026fd0ab798ac
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2021-09-29 23:57:22 +00:00
Samuel Degueldre 6e36705a33 [FIX] mail: fix warning about invalid width/height in rtc layout
closes odoo/odoo#77432

X-original-commit: 2b5c97b9ada063a67810c97af05dd483c4be9cd2
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-29 23:57:17 +00:00
Sébastien Theys bb01546164 [IMP] mail: use exclamation instead of signal on rtc issue
closes odoo/odoo#77431

X-original-commit: e806a1fb173af7cf74953c94a9430b1a1398f87d
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-29 23:57:07 +00:00
dht-odoo 8281b1ecd5 [FIX] survey: display the absolute counter in time limited survey
Before this commit:
Let's consider the following two scenarios while answering time limited survey:

1) attendee's system clock is de-synchronized compared to the real time
2) Odoo server clock is de-synchronized compared to the real time

In any/both of the above cases, it will lead to a wrong timer display, and will
confuse the user and/or make him fail the test because he will think he still has
more time to submit when he does not.

With this commit:
To fix this, we simply get the offset of server UTC time and moment time, and apply
the offset while calculating the time remaining.

Task-2612972

closes odoo/odoo#77419

X-original-commit: 9e9cd045b2899abc5c8e4a92c43ed6eb2eea158a
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-29 20:48:25 +00:00
Benjamin Vray 03e3c8aa7f [FIX] website_sale: fix create a new ribbon
Before this commit, when creating a new ribbon after selecting an
existing ribbon, the style of the selected ribbon was added to the new
ribbon in addition to the default style.

task-2501515

closes odoo/odoo#77412

X-original-commit: 10867860489214b956fbe7fac5ff36f24c94c46d
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2021-09-29 15:56:34 +00:00
Benjamin Vray 5afaeef864 [FIX] website_sale: fix text color preview of ribbons
Before this commit, the text color preview of the ribbons in the
ribbon selector was wrong. But also, if we selected another ribbon
just after changing the text color of a ribbon. This color was applied
to the selected ribbon.

task-2501515

X-original-commit: 19252137588b30a69ce57f0248a504f7e929b98e
Part-of: odoo/odoo#77412
2021-09-29 15:56:34 +00:00
Jeremy Kersten 96f4b014bb [FIX] website_forum: fix tb on reflag of a post
Before this commit, a traceback was raise:
Cannot read properties of undefined (reading 'displayNotification')

Now, we correctly use self instead of this.

task-2657621

closes odoo/odoo#77360

X-original-commit: ab65d077b7b4ec04155401902eb65418b4d2f415
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-09-29 15:56:21 +00:00
Rémy Voet (ryv) 9779efa93e [FIX] stock: fix lazy list views
- Avoid traceback when click on priority widget
- Also, fetch directly the lazy column if the web client read one record
(happen when we modify a single record).

closes odoo/odoo#77402

X-original-commit: eb26406cff7a0c61768c287a0525c2b6bc123f9e
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-09-29 13:39:56 +00:00
Rémy Voet (ryv) 5ea9dfee32 [IMP] stock: small improve performance of forecasted availability
Avoid some useless read_group on stock move (fetch too much qty fields
in product.product) and use a query object to avoid fetching data.

To compute 11K of forecasted information of stock move (multi-warehouse
):
- Before: 1.704 ± 0.046 sec and 174 SQL request
- After:  1.554 ± 0.012 sec and 134 SQL request

X-original-commit: 338edd616c2afe1d7a08a06a0b0278c3d7083c05
Part-of: odoo/odoo#77402
2021-09-29 13:39:56 +00:00
Juan Jose Scarafia 22117b2311 [FIX] l10n_ar: fix l10n_ar_currency_rate
If an invoice is posted, sended back to draft and the rate was change on res.currency, we preserve the value already existing on l10n_ar_currency_rate

closes odoo/odoo#77388

X-original-commit: 820df9eef856d841863306eab1e26d0437a408b0
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-09-29 11:23:45 +00:00
Nicolas (vin) e1fcd85f26 [FIX] snailmail_account: Fix traceback
When clicking on send&print on an account move without
partner, we are getting a traceback because of the
address verification.
Instead, check if any such move is selected and return
a user error.

Task id #2655365

closes odoo/odoo#77385

X-original-commit: dfba014189c35f9df0140c57effe9ea45637e0ec
Signed-off-by: Florian Gilbert <FlorianGilbert@users.noreply.github.com>
2021-09-29 09:59:07 +00:00
Nicolas (vin) d884fe2965 [FIX] account_edi_facturx: fix facturx import
When importing an invoice with facturx, the space for the name was
wrongly defined which would make it so that it was never found in the
xml.

Task id #2655365

X-original-commit: cf85aa4dc5d3e8cb2565c90be4f487f0aade07f3
Part-of: odoo/odoo#77385
2021-09-29 09:59:07 +00:00
Philippe Wauthy 6367ff2b33 [FIX] hr_holidays: Improve general UX (Back2basics)
General fixes for usability

- Time off type configuration visual : https://tinyurl.com/yj2z6okp
- When you create an allocation, the end date should have a place holder "no limit". If there is no end date recorded, that value should be displayed on loading.
- In Overview, remove filter "people i manage"
- In Approvals / time off : change filters : https://i.imgur.com/uDNjZv8.png
- In Approvals / approvals : change filters like in point 5 (remove people I manage replace with my team)
- In Reporting / By Employee : filters : https://tinyurl.com/yg3u3rkf
- In Reporting / By Type : filters : https://tinyurl.com/yhbpgz5m
- Remove Allocations smartbutton from Employee App
- When you click on TimeOff Smartbutton from Employee App, you should be redirect to this screen : https://tinyurl.com/ygwxzx5b
- When an allocation is created, the validity is added to the name of the allocation like "Allocation X (validity Date --> Date) and hide the validity field in "My allocations".
- Users will have the information of the validity from the name of the allocation

task-2643692

closes odoo/odoo#77376

X-original-commit: 7f92c830d3607167bd76bc43d992fbf720a3ef29
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-09-29 08:33:26 +00:00
Swapnesh Shah b948b197da [IMP] hr: Make timezone required on saved record
`tz` field is technical field related to `resource_id`, which is required field on that model.

However it is possible to try to write a void value, which leads to an issue as it is technically required.
With this commit we make the tz field required at write.

closes odoo/odoo#77372

X-original-commit: 7cda3632b1f50ea757d25369e8a1261d8aeab16d
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-09-29 08:33:22 +00:00
Rémy Voet (ryv) 2306ef1044 [FIX] mrp_subcontracting: fix details move button
The detail move button (`action_show_details`) should also
return record component wizard in case of tracked component
for a strict BoM.

task-2637543

closes odoo/odoo#77358

X-original-commit: 44afac03c560becdaead149bfaa82a3245a54c34
Related: odoo/enterprise#21237
Signed-off-by: Steve Van Essche <svs-odoo@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-09-29 08:33:14 +00:00
William Braeckman bd13371781 [FW][FIX] hr_holidays: Make accrual plan prorated
closes odoo/odoo#77342

Forward-port-of: #77311
Related: odoo/enterprise#21229
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-09-29 08:33:03 +00:00
Aaron Bohy 09da30fbcd [REF] board,web: namespace legacy view root classnames
The pivot and graph views have been rewrote in owl in [1]. However,
the former implemention has been kept as it is still used in some
cases (e.g. board application, studio, PieChart widget), but they
are lazy loaded [2].

Before this commit, both the new and former implementations mostly
shared the same DOM (in particular, their root element had the
same classnames). It means that the scss rules of an implementation
might interfer with the other, and vice versa.

This commit adds the "legacy" keyword in the root classnames of
those views, and properly namespaces the scss rules of legacy views
to properly dissociate the style of new and legacy views.

For the pivot view, we re-used the same scss file, so in this
commit, we duplicate it (one for the new view, the other, lazy
loaded, for the legacy view).

[1] 0134495ba5
[2] bd3cf85c841168dfd87f7166b545dd00d9b38bf4

closes odoo/odoo#77323

X-original-commit: 3862d5aae1df72d3585f915e8a2a2626322e74ad
Related: odoo/enterprise#21223
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-09-29 08:32:55 +00:00
Pierre Paridans c0f736c056 [FIX] website: don't show empty burger menu on mobile
When the current app doesn't provide menu-items (or the user doesn't
have the rights to access them), the mobile burger menu should fallback
to the user menu instead of an empty one (like on the App Switcher).

task-2345001

closes odoo/odoo#77322

X-original-commit: 90eecd990c7c97f5914252a9cad28eeb71859e0d
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2021-09-29 08:32:51 +00:00
sofiagvaladze 415ab27126 [IMP] hr_holidays: Time Off smartbutton
task - 2634892

closes odoo/odoo#75941

Related: odoo/upgrade#2852
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2021-09-29 08:32:44 +00:00
Hubert Van de Walle (huvw) 8b7d840646 [FIX] web: Select the correct record when there is an html table in a line
Steps to follow

  - Add an HTML field in the sales order line view
  - Create a sales order
  - Add a product
  - Add a table with multiple rows in the HTML widget
  - Add a new product
  -> The new product isn't selected

Cause of the issue

  The CSS selector used for finding the record to edit was taking all tr
  element into account

Solution

  Only select direct descendants of the tbody

opw-2632817

closes odoo/odoo#77380

X-original-commit: a8a0f38f5f45f18bc8221bf835d6e54ddabc471d
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Hubert Van De Walle <hubvd@users.noreply.github.com>
2021-09-29 07:12:29 +00:00
Simon Genin (ges) b6be398743 [FIX] web: Allow the graph context option fill_temporal to be set
The option was available before but was forgotten when the graph view
was refactored.

closes odoo/odoo#77330

X-original-commit: 624fd812c5d6b01c0cc11e8620dc703dc0370f73
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-09-29 07:12:24 +00:00
Aaron Bohy dd47708f5f [FIX] web: clickbot: correctly wait for next view
Before this commit, the clickbot test failed when switching from
a dashboard view to a pivot, graph or cohort view, because the
condition to wait before toggling the filters in the next view was
wrong. As a consequence, we started to toggle the filters for the
next view on the dashboard view, so when we actually switched to
that view, the filter menu was closed and the tour was blocked.

The previous condition used the `.o_{view_type}_view` classname,
targetting the root node of the view (which appears in the DOM when
the view is loaded). Unfortunately, since [1] and the new
implementation of the graph and pivot views, we added root
classnames to graph and pivot (o_graph_view and o_pivot_view),
whereas it wasn't the case before. So when leaving a dashboard
view to a graph or pivot view, the former condition was directly
true (if the dashboard contained those views), and we didn't wait
for the next graph or pivot view to be loaded.

Note that the former implementation of the cohort view already added
the "o_cohort_view" classname on its root node, but it didn't make
the clickbot test fail because we don't have cohort views next to
dashboard views in standard actions.

This commit changes the condition to use the view switcher icons
instead.

[1] 0134495ba5

closes odoo/odoo#77324

X-original-commit: bc53eebc8b9cd9f6e949bbe7e91ec2f98e5a0dfc
Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-09-29 07:12:20 +00:00
Xavier Morel 1af688d534 [FIX] core: flushing around HTTP calls
Explicit flushing of the cursor had been implemented in the "legacy"
`url_open` helper, but it was missing when going through `requests`
directly (via the `opener`), or when performing XML-RPC calls.

Fix that:

* extend `requests.Session` and `xmlrpc.client.Transport` so they take
  a cursor
* move the setup of the XML-RPC clients to `setUp` so they can *get*
  the cursor
* move the rest of `HttpCase.__init__` to `setUpClass` and drop the
  override entirely
* remove the now-redundant flush in `url_open` (as it's done by the
  `opener`)

closes odoo/odoo#77359

X-original-commit: c7bdae34690f31960d1fa95b5c3b4052540f5d07
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-09-29 05:48:42 +00:00
Sébastien Theys bdbcf51bf4 [IMP] mail: add ping for active RTC session and clean obsolete
closes odoo/odoo#77382

X-original-commit: 263e77e5d252b61e1dd838c7559e957a20fa2b18
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-29 01:10:51 +00:00
Odoo's Mergebot 8908017621 [FW][MERGE] mail, various: use QWeb in mail templates
RATIONALE

Jinja is used a templating engine in various places, notably in mail templates
and digest content. It is known to have some limitations

  * its syntax is specific and is concurrent with Odoo QWeb template language.
    Additional knowledge is required just for that purpose;
  * it is not XML compliant, meaning we quickly run into issues when editing
    its content as HTML. Notably rendering engine (browsers) may reorder
    jinja content arbitrary when its syntax is not valid, which is often
    the case with advanced constructs involving nested for and if;
  * jinja template do not benefit from improvements done in QWeb and its
    integration in our HTML editor;
  * it is an outside templating engine that we do not control;
  * it adds an external dependency;

PURPOSE

Replace Jinja with Qweb so that we can now build tools to edit a Qweb
template, mainly for ``mail.template`` records. In this merge we now
support QWeb as rendering engine for mail templates. All templates are
updated accordingly. Some other records using jinja are also updated like
``digest`` content (tips).

To be able to edit template content from the backend interface a plugin to
the Odoo editor has been made to seamlessly edit documents. It includes :
  * allow to make dynamic variables (eg. `<t t-out="variable"/>`) not
    editable when required;
  * group and hide related logical branching (ie. t-if, t-elif and t-else)
    in order to see only one at once;
  * a floating select input to switch visibility of a particular logical
    branching;

TEXT RENDERING

Not all content previously rendered using jinja holds HTML content. For
example some email fields (e.g. ``email_from`` or ``subject``) used Jinja
syntax for rendering (e.g. ``Email for ${object.name}`` or
``${object.email_formatted | safe}``).

We want to keep dynamic rendering for those char fields. However as it is
not XML we use a new rendering engine called "inline_template". It is
based on QWeb rendering used to evaluate expression and attributes like
``t-att-href="{{object.link}}"``. Expressions should be enclosed by `{{` and
`}}` to highlight they are dynamic. For most expressions this is equivalent
to jinja expressions with a simple marker change.

LINKS

Task-2497930 (Main editor task)
Task-27033 (Main functional task)

closes odoo/odoo#77377

Forward-port-of: odoo/odoo#77074
Related: odoo/enterprise#21246
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-29 01:42:56 +02:00
Nicolas Bayet e52bde906f [IMP] web_editor: allow qweb edition
Add a plugin for the Odoo editor that includes:
- make dynamic variables (eg. `<t t-out="variable"/>`) not editable
  (for preventing the user to shoot himself in the foot)
- group and hide related logical branching (ie. t-if, t-elif and t-else)
  in order to see only one at once
- a floating select input to switch visibility of a particular logical
  branching
- style t-tags to make them stand out

Task-27033

X-original-commit: odoo/odoo@300da82eb4
Part-of: odoo/odoo#77377
2021-09-28 23:42:55 +00:00
Nicolas Bayet 810f832703 [FIX] web_editor: allow to delete backward a contenteditable
Deleting a node content-editable false did not work.

X-original-commit: odoo/odoo@de42d0f965
Part-of: odoo/odoo#77377
2021-09-28 23:42:54 +00:00
Nicolas Bayet 4813f42997 [IMP] mail,*: replace jinja with qweb
Jinja as a templating engine was problematic in differents respect:
- introduce external dependency to Odoo (less controll)
- add another templating mechanism in the stack
- specific feature in qweb cannot be reused
- difficulty in rendering easily editable templates
- more knowledge required with no betterment

By replacing jinja with qweb we can now build tools to edit a qweb
that will work with the previously jinja encoded document
(essentially `mail.template` records).

There is a catch however. Some email fields (eg. email_to) used jinja
syntax for rendering dynamic variables (ie. ${object.something} and
${object.something_that_should_not_be_escaped | safe}).

We still want user to use dynamic variables for some char fields (eg.
subject, from, to, ...). We made a new rendering engine called
"inline_template" that will render an expression enclosed by `{{` and
`}}`.

To be able to edit the templates from the backend interface, a
plugin to the Odoo editor has been made for seamlessly edit the
document.

This qweb plugin includes:
- make dynamic variables (eg. `<t t-out="variable"/>`) not editable
  (for preventing the user to shoot himself in the foot)
- group and hide related logical branching (ie. t-if, t-elif, and t-else)
  in order to see only one at once
- a floating select input to switch visibility of a particular logical
  branching

Task-27033

X-original-commit: odoo/odoo@68182baff4
Part-of: odoo/odoo#77377
2021-09-28 23:42:54 +00:00
Samuel Degueldre ecf5fbb4a8 [FIX] mail: fix "cannot read 'id' of undefined" in RTC calls
closes odoo/odoo#77371

X-original-commit: e2a2d9f17d7bf3b48ca45c5000547bb82dde3225
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-28 21:02:36 +00:00
Samuel Degueldre 567a09f58a [FIX] mail: fix crashes in methods on PeerConnection in invalid state
closes odoo/odoo#77370

X-original-commit: 5caa7f1aa094813c9f450ad839f1511045e33cca
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-28 21:02:32 +00:00
Thibault Francois 7b1eb7a1c6 [FIX] mail: make possible to search on channel_partner_id
Issue
-----
Adding ('channel_partner_id', 'ilike', name) when searching for
mail.channel.rtc.session does not filter out any record

because the model mail.channel.partner does not define any _rec_name
only the name_get

Solution
-------
Implement a _name_search method consistent with the name_get

closes odoo/odoo#77369

X-original-commit: 6c731a75295bbc8107d08ac3ed5c3d01245c782d
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-28 21:02:27 +00:00
Samuel Degueldre 347756909a [FIX] mail: fix crash when trying to catch result of play()
Some browsers don't return a promise from mediaElement.play(), we wrap
it in promise.resolve to solve the issue.

closes odoo/odoo#77368

X-original-commit: 50898870067d05fb01722487dc2d63a1a5155c7d
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-28 21:02:23 +00:00
Nicolas Bayet 21e9088839 [FIX] web_editor: save codeview changes
Before this commit, if there were a change in the codeview of the
field html and the record was saved while the codeview was still open,
the changes made in the codeview were not saved.

closes odoo/odoo#77367

X-original-commit: d8a9d23a66d3662fc1c5e4e07e35a1de6800ffa5
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2021-09-28 21:02:18 +00:00
Rémi a4159afe71 [IMP] survey: display description_done field
It is currently about impossible to edit this field. Having it available
in backend makes sense, allowing to fine-tune its content before publishing
or launching live surveys.

Task-2657694

closes odoo/odoo#77366

X-original-commit: a37842c69b23b136a60ac992770144698e553f2c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-28 19:51:16 +00:00
Raphael ColletandStanislas Sobieski (sts@odoo.com) 31c3f75396 [FIX] expression: avoid ORDER BY clause in subqueries
This fixes a performance issue: ORDER BY clauses in subqueries can make
the query unexpectedly slow.  We should avoid this situation, since
ORM-generated queries have an ORDER BY clause which is not relevant in
the context of a subquery.

The following example was found:

    SELECT "pos_payment"."id" AS "id"
      FROM "pos_payment"
     WHERE ("pos_payment"."pos_order_id" in
              (SELECT "pos_order".id
                 FROM "pos_order"
                WHERE ("pos_order"."company_id" in (1))
             ORDER BY "pos_order"."id"))
       AND "pos_payment".id IN (1285508)

Here are the query plans made by PostgreSQL on this query with and
without the ORDER BY clause.  The query time went from 1240ms to
0.402ms, which is 3000 times faster!

EXPLAIN ANALYZE SELECT "pos_payment"."id" as "id" FROM "pos_payment" WHERE ("pos_payment"."pos_order_id" in (SELECT "pos_order".id FROM "pos_order" WHERE ("pos_order"."company_id" in (1)) ORDER BY  "pos_order"."id"  )) AND "pos_payment".id IN (1285508);
                                                                    QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------
 Merge Semi Join  (cost=2.88..82726.85 rows=1 width=4) (actual time=1239.361..1239.364 rows=1 loops=1)
   Merge Cond: (pos_payment.pos_order_id = pos_order.id)
   ->  Sort  (cost=2.46..2.46 rows=1 width=8) (actual time=0.021..0.022 rows=1 loops=1)
         Sort Key: pos_payment.pos_order_id
         Sort Method: quicksort  Memory: 25kB
         ->  Index Scan using pos_payment_pkey on pos_payment  (cost=0.43..2.45 rows=1 width=8) (actual time=0.014..0.015 rows=1 loops=1)
               Index Cond: (id = 1285508)
   ->  Index Scan using pos_order_pkey on pos_order  (cost=0.43..66770.53 rows=1282120 width=4) (actual time=0.013..1148.194 rows=1182463 loops=1)
         Filter: (company_id = 1)
 Planning time: 0.272 ms
 Execution time: 1239.396 ms
(11 rows)

EXPLAIN ANALYZE SELECT "pos_payment"."id" as "id" FROM "pos_payment" WHERE ("pos_payment"."pos_order_id" in (SELECT "pos_order".id FROM "pos_order" WHERE ("pos_order
"."company_id" in (1)) )) AND "pos_payment".id IN (1285508);
                                                             QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
 Nested Loop  (cost=0.85..4.89 rows=1 width=4) (actual time=0.047..0.049 rows=1 loops=1)
   ->  Index Scan using pos_payment_pkey on pos_payment  (cost=0.43..2.45 rows=1 width=8) (actual time=0.027..0.028 rows=1 loops=1)
         Index Cond: (id = 1285508)
   ->  Index Scan using pos_order_pkey on pos_order  (cost=0.43..2.45 rows=1 width=4) (actual time=0.018..0.018 rows=1 loops=1)
         Index Cond: (id = pos_payment.pos_order_id)
         Filter: (company_id = 1)
 Planning time: 0.322 ms
 Execution time: 0.080 ms
(8 rows)

closes odoo/odoo#77357

X-original-commit: 947c3bd72ee84c3a298e0c9c365340ddf16b307d
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Stanislas Sobieski (sts@odoo.com)
2021-09-28 19:51:05 +00:00
Samuel Degueldre 5ae5c81a23 [FIX] mail: fix settings crashes
In odoo/odoo#76941 some getters were removed but the code using those
getters was not entirely adapted, causing crashes.

This commit also fixes an unrelated crash, where we were attempting to
save the push-to-talk settings for guests, which cannot work as they do
not have a correspoding user.

closes odoo/odoo#77343

X-original-commit: 99a5a59c610ee4d421f5671aa6680377df08168a
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-28 17:45:17 +00:00
Samuel Degueldre e648513376 [FIX] mail: stop showing "Add a description" to guests
closes odoo/odoo#77341

X-original-commit: 38b5e110469b6a3a49e39df3ac0c7b73795aae1f
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-28 17:45:13 +00:00
Samuel Degueldre 3d3f6e6b15 [FIX] mail: fix guest getting session expired warning on mention
When attempting to mention a user or a channel, an RPC is performed.
This uses a method on a model, which guests cannot perform as they don't
have a valid session cookie. This commit deactivates the mention
functionality for guests.

X-original-commit: fe6f2b660a84cfdb74834d52d6ff7860776a2e70
Part-of: odoo/odoo#77341
2021-09-28 17:45:13 +00:00