Commit Graph
151076 Commits
Author SHA1 Message Date
Touati Djamel (otd) b2f1d28b39 [FIX] stock_picking_batch: cancel confirmed batches without transfers
Steps to reproduce the bug:
- Create a batch transfer with several pickings
- Confirm it
- Delete all the pickings > save

Problem:
The batch does not cancel as it should’ve been
A batch without transfers cannot be confirmed, so it makes no sense to leave a confirmed batch without transfers

opw-2792471

closes odoo/odoo#90104

X-original-commit: dcbf08edbb3a1ec49e84f0828b8f49ac4f836c25
Signed-off-by: Steve Van Essche <svs@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-04-29 13:13:15 +02:00
Guillaume (gdi) 2eb23cccfb [FIX] website: ensure the persistence of auto-fill of form fields
Before this commit, some editor options could break the autocompletion
of form fields. This commit ensures that auto-fillable fields remain
auto-fillable when using the editor. In addition, this commit improves a
test to ensure that this bug does not reappear.

Steps to reproduce the fixed issue:
 - Go to the "contact us" page or drop a form in a page
 - Edit an auto-fillable field of the form ("Your Name" for example)
 - Change the label position of the field
 - Save
-> The field is no longer auto-fillable.

task-2715201

closes odoo/odoo#90103

X-original-commit: 455e0cc58c7fa1e02ebaa19dd2f99d829ca6e302
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-04-29 13:13:11 +02:00
Guillaume (gdi) 8d0a63f355 [FIX] website, website_hr_recruitment: give the priority to auto-fill
This commit allows to give priority to auto-fill values and to values
coming from a data-for when in addition to one of these values this same
field has a default value. The form's test are also improved so that it
checks for this desired behavior.

task-2715201

X-original-commit: 7b23d3aacd22f87cb0c22ecd0478eba4a17b4bf3
Part-of: odoo/odoo#90103
2022-04-29 13:13:10 +02:00
Guillaume (gdi) 9c25421677 [FIX] website: prevent the deletion of the form's default values
Some form fields are dynamically filled. As the inputs that hold these
values do not always have a value property, their HTML value attribute
can be modified. Before this commit, the form option had to remove these
values before saving so that these values wouldn't become default values
(see [1]). Sadly this system is problematic and can remove default
values set by the user. This commit ensures that only values from
auto-fillable fields and from data-for fields will be removed and from
now, the suppression of these values is done at a more appropriate time
than what is done in [1]. Test is added with this commit to verify that
the default values are not erased on later form edit.

Step to reproduce the fixed issue:
- Create a form, add a (required hidden) field with a default value
- Save, then enter edit mode again
- Add a new field and save again

The default values of the form are gone. Enter edit mode again to see
the hidden input, you will see there is no value.

[1]: https://github.com/odoo/odoo/commit/b637a5e32f767b62736241042f88fa0cecf9f10b

task-2715201

X-original-commit: 043e1fdf923d2037dd8da128ab99388f0c92e544
Part-of: odoo/odoo#90103
2022-04-29 13:13:10 +02:00
tsm-odoo ff1de2a2b0 [FIX] mail: prevent crash when destroying during attachment upload
File uploader might be deleted because it is linked to views, but the process of
upload should still happen for the related thread.

closes odoo/odoo#90102

X-original-commit: aa57c1804ecd9c88188e33c098b805f65f103a33
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-04-29 13:13:04 +02:00
Martin Trigaux 2617b3f072 [FIX] base: include model_terms in check
Translations of type model_terms are similar to model and the access
rights can be checked on the referenced record instead of
ir.translation

closes odoo/odoo#90101

X-original-commit: 992a919d09c3ba224a64241f4a6c16c1a086eb4b
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-04-29 13:13:00 +02:00
Denis Ledoux b9feebc25c [REF] models, fields: refactor fields_get
- Filter in attributes rather than filter out.
  The goal is to not gather attributes which are
  costly in term of performance if they are not requested
  in the first place.
  e.g., with all modules installed:
  - Before rev:
    ```py
       In [1]: %time for _i in range(1000): self.env["res.partner"].fields_get(attributes=['readonly', 'required', 'states', 'invisible']);self.invalidate_cache()
        CPU times: user 1.99 s, sys: 9.83 ms, total: 2 s
        Wall time: 2.03 s
    ```
  - After rev:
    ```py
        In [2]: %time for _i in range(1000): self.env["res.partner"].fields_get(attributes=['readonly', 'required', 'states', 'invisible']);self.invalidate_cache()
        CPU times: user 345 ms, sys: 0 ns, total: 345 ms
        Wall time: 345 ms
    ```

- Use the `_description_` mechanism for the attributes `name` and `type`,
  so its no longer needed to treat them as exception in
  `field_get` and `get_description` respectively,
  and make the code shorter and cleaner.

- Move out from `fields_get` the block
  ```py
      has_access = functools.partial(self.check_access_rights, raise_exception=False)
      readonly = not (has_access('write') or has_access('create'))
      ...
      if readonly:
         description['readonly'] = True
         description['states'] = {}
  ```
  because:
  - It meant you had a different behavior using `fields_get` or `get_description`
    for the keys `readonly` and `states`, meaning a field could be marked as `readonly`
    by `fields_get` but not by `get_description`, which is confusing.
  - It is actually used in only one place, the post-process of back-end views,
    which mark the fields readonly for the web client if you do not have
    the create or write access to their model.

closes odoo/odoo#87273

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-04-29 13:12:49 +02:00
Elisabeth Dickinson ed5f7007ff [REF] mail: chatWindowHeader, review and simplify scss
Part of the overall v16 SCSS optimization/restyle, task-2704984

task-2785009

closes odoo/odoo#85842

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-04-29 13:12:44 +02:00
Arthur Detroux (ard) b66409cad4 [FIX] website, *: properly stop widgets before removing snippets
* web_editor

Prior to this commit, removing a snippet while its widget was still
active could lead to slow removal as editors would be created for its
inner content.

Stopping a widget before removing it is good practice as it will clear
the DOM from any content it may leave behind and will prevent snippet
editor to be created for its dynamic inner content.

As an example, the `Products` snippet had SnippetEditors being created
for its product cards, which could lead to slow removal especially
in later versions of Odoo. E.g. in 14.0, because ImageTools were
introduced.

Closes #85464

task-2781418

closes odoo/odoo#90100

X-original-commit: ca1359e0f40b94b93eb8cfd6834a05796f64c675
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-04-29 12:06:26 +02:00
Touati Djamel (otd) eff7cc0056 [FIX] mrp: start the workorder only once
Steps to reproduce the bug:
- Create a MO with work orders
- Confirm the MO
- Under the tab Work Orders > click on the button start multiple times quickly

Problem:
Several `mrp.workcentre.productivity` are created for the work order,
whereas normally the workorder can have only one timer started (without date_end).

Solution:
- If the workorder already has a timer running, return true to stop the process
- Add a constraint to block the user when he tries for example to create with an rpc call several `mrp.workcenter.productivity`
without an end date for the same workoder

opw-2802436

closes odoo/odoo#90094

X-original-commit: dd22195a75ec437e42424ee95ca9a41feeb48b0b
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-04-29 12:06:22 +02:00
Merlin (megu) 90569e55ab [FIX] purchase_stock: use a valid route as default buy route
In a multi-company environment, creating a product template will always
try to assign it's route to `route_warehouse0_buy` but this throws an
error if the current company is not the one of the route

Steps to reproduce:
1. Install Inventory and Purchase
2. Go to Settings > Inventory > Warehouse and enable Multi-Step Routes
3. Open Inventory and go to Configuration > Warehouse Management >
Routes
4. Open the 'Buy' route, assign it to one of the company for example 'My
Company (San Fransisco)' and save
5. Go to Products and select an other company for example 'My Company
(Chicago)'
6. Click on `CREATE`
7. An error is thrown, preventing the user from creating new products

Problem:
Function `_get_buy_route` always fetched the same route but this route's
company might have been changed so an error is thrown when trying to
access it from the other company

Solution:
Check if we have access to `route_warehouse0_buy` before using it.

opw-2805154

closes odoo/odoo#90093

X-original-commit: 1a733ae0bfd9f1cb1e90a2cab80af290560c6f12
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
2022-04-29 12:06:18 +02:00
Horacio Tellez f02cf4a195 [FIX] payment: hide the refund button on payments created from a refund
task-2685480

closes odoo/odoo#90085

X-original-commit: 02eba891cb8cd58985837090f2b60cf263bce065
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Horacio Tellez Perez (hote) <hote@odoo.com>
2022-04-29 12:06:15 +02:00
Jigar Vaghela b64348fa31 [IMP] l10n_in_edi: add neutralize on res.company
set test env and remove username,password,token and token validity
so call never go to production server from test db

closes odoo/odoo#90084

X-original-commit: 955a83f9e773ad1bf7ce0aa4a834d9ca833cd580
Signed-off-by: William André (wan) <wan@odoo.com>
2022-04-29 12:06:10 +02:00
Jacky (trj) 1ce17bde68 [FIX] pos_adyen: leaving PaymentScreen while paying/cancelling
Before this commit: whenever we left the PaymentScreen when we were paying (either by reloading the page or by backing to the ProductScreen), the real payment status was not properly saved even tho the payment has been paid or cancelled.

With this commit: whenever we go to the PaymentScreen with a pending payment line with Adyen, we fetch the latest status from the back end. This way, the front end will always have the latest status of the payment.

opw-2802676

closes odoo/odoo#90083

X-original-commit: 07b30c519b101a2998f5320dde5203bfc964b7e9
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
2022-04-29 12:06:06 +02:00
Thibault Delavallée 5c354ece04 [IMP] mail: strengthen assert email values check
Purpose is to ensure tools are called like intended, notably by filtering
input and raising if an unexpected value check is asked. Some code is also
made a bit more generic to have the same kind of parameters when searching
for mail.mail.

In this commit we therefore fix some bad calls to assertSentEmails which
were not checking the right stuff.

closes odoo/odoo#90082

X-original-commit: d9759b2ee86b79b4fb2739a4aebd24a8044cf947
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-04-29 12:06:03 +02:00
tsm-odoo 22aa1be37a [IMP] test_mail: prepare tracking tests to new env
This PR helps redducing the noise in the one introducing the new environment
in discuss. Indeed, the createWebClient helper will always be used so we won't
be able to use the form utils anymore.  Moreover, since the clean up of the widget
is now handled by the start method, the calls to widget.destroy in those test was
not required.

task-2582313

closes odoo/odoo#90079

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-04-29 12:05:59 +02:00
Antoine Vandevenne (anv) 5440a27550 [IMP] payment: allow the public user to tokenize payments
Before this commit, the public user would be prevented from creating,
reading, or using payment tokens entirely. This was put in place in an
effort to homogenize the way each application interacts with tokens,
and because it was considered more logical to only create tokens when
you can see actually them afterward. This however led to an undesirable
side effect in Subscriptions where customers would pay while being
logged out, thus preventing the token from being saved and failing the
automatic renewal of the subscription.

With this commit, we enable the public user to create tokens from any
payment flow. This also means that when a token is created, its owner
will not see it until they log in. This commit also reverts 2a084c48
which was intended to hide payments acquirers from the public user if
their payment would end up being tokenized.

opw-2789340

closes odoo/odoo#90061

X-original-commit: 4e03d4b6106f10522dd5f1839a0f941ca6b202fa
Related: odoo/enterprise#26741
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-04-29 12:05:55 +02:00
Alexandre Kühn 5bd9361c3c [IMP] mail: introduce view models (step 3)
This commit introduces models that define records being 1:1 map with components,
as a step to move further to having essentially all business code in models.

Having code in models is desirable to have very maintainable code, thanks to
robust and declarative code with an ORM-like architecture.

Task-2831082

closes odoo/odoo#90057

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-04-29 12:05:49 +02:00
qsm-odoo 90a2f5381f [FIX] website: remove the background color behind the affixed navbar
For some unknown reason (part of a huge refactoring during the BS3 to
BS4 migration at [1]), a background color was applied to the <header>
(behind the navbar) once it becomes fixed (after scroll if the related
header scroll effect has been chosen).
That $light color made no sense as is visible if the header uses rounded
corners but is impossible to edit / remove.

This commit, for master, simply removes it. This is not possible to
migrate (for example to try and handle the case where the menu color is
transparent) as it would require to know the color of $light. It would
be overkill anyway, this just relies on users with that problematic
transparent header (probably nearly no one) to review their header in
the next Odoo version.

[1]: https://github.com/odoo/odoo/commit/09f40036b9c14161db90c6128861369c91c8c64e

opw-2686695

closes odoo/odoo#90058

X-original-commit: f721e6187933cde4366a7f987fb80612da581670
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-04-29 12:05:45 +02:00
tsm-odoo 958cf7d602 [IMP] mail: replace local_storage service by the browser one
This PR prepares the ground for the introduction of the wowlEnv in the discuss app.
Indeed, the local_storage service is not available as a service anymore so the one
from the browser is used instead. In order to reduce the noise in the main PR, this
change is done separately.

task-2582313

closes odoo/odoo#89851

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-04-29 12:05:39 +02:00
xlu-odoo 5b3f735171 [REF] mail: PopoverView, review and simplify scss
Part of the overall v16 SCSS optimization/restyle, task-2704984

task-2833318

closes odoo/odoo#89663

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-04-29 12:05:35 +02:00
xlu-odoo 217dfa08e6 [REF] mail, hr_holidays: PartnerImStatusIcon, review and simplify scss
Part of the overall v16 SCSS optimization/restyle, task-2704984

task-2832067

closes odoo/odoo#89544

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-04-29 12:05:31 +02:00
mafo-odoo ac04c9dbfd [FIX] account: remove nested html p tag in p tag for invoicing report
Current behavior:
The invoice payment term of the report is a p tag with another p tag inside like:
<p name="payment_term">
	<span>
		<p> This is a payment term note</p>
	</span>
</p>
but because nested p tags are not supported in html de result in the browser is something like:
<p name="payment_term">
        <span></span>
</p>
<p> This is a payment term note</p>
<p></p>

Similar behavior can be observe for the fiscal position note.

Expected behavior:
The code should respect html format rules and not have nested p tags.

Solution: We replace the parent p tags by div tags, and we modify xml file that have xpath relying
on this tag.

opw-2804933

closes odoo/odoo#88660

Related: odoo/enterprise#26372
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2022-04-29 12:05:24 +02:00
Horacio Tellez 20fbc19a2d [FIX] sale: Report on converted currency
Before when reporting in the sale module in a multi-company
environment currencies where not converted to a unique currency
before mathematical operations (sum, avg, ...).
Now before mathematical operations currencies are converted to
the currency of the company currently selected.

Task - 2696759

closes odoo/odoo#83550

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-04-29 12:05:21 +02:00
Carlos Dauden 1cbacccf69 [FIX] purchase: Description is changed after quantity is modified if seller is set
TT36008

closes odoo/odoo#90056

X-original-commit: d696f070c6a0412236816a9f36ebba8b15ab0cf2
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2022-04-29 11:01:55 +02:00
Louis Wicket (wil) def3b8e408 [IMP] mail: use make_json_response in DiscussController
Use make_json_response to send JSON responses.

closes odoo/odoo#90034

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-04-29 11:01:47 +02:00
roen-odoo 6c51a265c0 [FIX] sale_mrp,stock : correctly split quantity between kit in package
Current behavior:
When 2 steps delivery and product packing is activated, and have 2 kit products that have common components.
If you create a sale order with those 2 kits and pack them in the first step of the delivery. And in the second delivery step mark the pack as done the done quantity in the package
are not correct.
Before this fix, all the products quantities from different kits were on the same stock move line and the other lines were ignored,
this result in lines with too much products and lines with no product. When validating this
incorrect transfer an unnecessary backorder was created and the sale order lines were not correctly marked as delivered.

Steps to reproduce:
- Activate 2 steps delivery and product packing.
- Create Kit A with Component A and Component B
- Create Kit B with Component A and Component B
- Create a SO with 1 Kit A and 1 Kit B
- Confirm the SO
- Go in the first step of the delivery and put everything in a pack
- Go in the second step of the delivery and set the pack as done
- Go in the package details : The first component A has 1 reserved and 2 done, same for component B

opw-2754106

closes odoo/odoo#90033

X-original-commit: b81f70babc774eff2e04d2f7854d75ec7273a757
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-04-29 11:01:44 +02:00
Florian Damhaut a91c9e1be4 [FIX] hr_expense: Expense unit price is readonly if it has a cost
Step to reproduce:
- Create an expense for an expense product which has a cost

Current behaviour:
- Expense's unit price is modifiable which shouldn't be
 the case according to the help message of hr.expense.unit_amount

Behaviour after PR:
- Expense unit price is only modifiable is there is no unit_amount
(unit_amount = 0)

opw-2781040

closes odoo/odoo#90014

X-original-commit: 44b6d60de301651e52df4c41e32e38d23b0a154e
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-04-29 11:01:40 +02:00
rhe-odoo d4be21d4c5 [FIX] pos_loyalty: fix gift card
It was impossible to create a new gift card or pay with a gift card from the front end.

With this fix, it's possible to use a gift card code in the front end and to generate a new gift card. The gift card product is now available in the pos.

closes odoo/odoo#89999

X-original-commit: 2a9b6a763b11084735cf46ac9aa83b39098b958c
Signed-off-by: Masereel Pierre <pim@odoo.com>
2022-04-29 11:01:37 +02:00
Brieuc-brd 542f0c76a4 [REF] mail: MessageReactionGroup, review and simplify scss
Part of the overall v16 SCSS optimization/restyle, task-2704984

task-2835543

closes odoo/odoo#89980

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-04-29 11:01:33 +02:00
tsm-odoo 0c83ada7de [IMP] web: move mock relational field tests
Since those tests are related to the legacy mockServer, they have been
moved to the legacy folder.

task-2582313

closes odoo/odoo#89883

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-04-29 11:01:29 +02:00
tsm-odoo 54a25b32b3 [IMP] mail: add notify to messaging
This PR prepares the ground for the one introducing the new env in discuss.
The signature of the notify function has changed a lot from the one in the old env.
In order to ease the transition and reduce the noise, the discuss models now
rely on the messaging's notify function.

task-2582313

closes odoo/odoo#89877

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-04-29 11:01:25 +02:00
tsm-odoo 0b60725288 [IMP] mail, *: add rpc to messaging
*: calendar, hr, im_livechat, mail, mail_bot, snailmail, website_slides.

This PR prepares the ground for the one introducing the new env in discuss.
The signature of the rpc function has changed a lot from the one in the old env.
In order to ease the transition and reduce the noise, the discuss models now
rely on the messaging's rpc function.

task-2582313

closes odoo/odoo#89858

Related: odoo/enterprise#26676
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-04-29 11:01:18 +02:00
sofiagvaladze 5dca077c68 [IMP] hr_recruitment: Improve multi applicant count
Purpose:
At the moment, you can only find multi applications for the same applicant
based on the similar email.
Not every application comes through the same email.

We want to find same applicants based on the same email, phone or
mobile phone.

task - 2701472

closes odoo/odoo#86428

Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-04-29 11:01:15 +02:00
Elisabeth Dickinson 8746b164a7 [REF] mail: chatWindow, review and simplify scss
Part of the overall v16 SCSS optimization/restyle, task-2704984

task-2784763

closes odoo/odoo#85839

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-04-29 11:01:11 +02:00
Ipsita Borisagar 1e4ddef514 [IMP] hr(_timesheet)_attendance: improvements for the ui
PURPOSE

Generic improvements for services.

SPECIFICATION

- For all reporting menus: removed the group by in the search view, and kept grouping
  the grid, pivot and graph views by the corresponding field.
- For timesheet/attendance, switched the pivot and graph views from their places.
- Renamed 'billable type' into 'billing type'.

task-2766164

closes odoo/odoo#85726

Related: odoo/enterprise#24940
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-04-29 11:01:07 +02:00
Laurent Smet bbc2128ba1 [FIX] base: Blacklist invoice specific reports in generic test
Some reports are specific to invoices and are raising an UserError if called without the correct business objects.
Since version 13.0, invoices have been merged into `account.move`.
The test is making a `search` on `account.move` to test the report generation but there is no guarantee there are invoices.
To prevent random failures in the futur, this commit allows custom domain to get the records in order to test these reports correctly.

closes odoo/odoo#85150

Task: 2726507
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2022-04-29 11:00:56 +02:00
Laurent Smet 7c4e591d58 [REF] base,account: Refactor PDF generation to allow CH QR-bills
For the Switzerland localization, we need to append some extra pages during the PDF generation such as QR barcodes or ISR payment slip.
There were multiple difficulties with the current codes:
- The ir.attachment was generated before the hook allowing to append the extra pages.
- There is no existing hook allowing to get the pages for each invoice when printing on multiple records at once.

This commit aims to dispatch the generation of PDFs from the creating of extra attachments:
- `_render_qweb_pdf_prepare_streams` is called first and creates a stream for each record containing the PDF pages.
- Then, the ir.attachment are generated if necessary.
- Finally, all streams are aggregated together to get the final PDF.

Task: 2726507
Part-of: odoo/odoo#85150
2022-04-29 11:00:56 +02:00
Odoo's Mergebot ce08fba382 [IMP] event: ease registration follow-up
Globally ease event registrations followup by improving the related search
views and by allowing a quick access to statistics.

Specifications:

1. A stat button has been added on event that go to attendee reporting filtered
on the event

2. a) in the attendee reporting, the text search has been modified as follows:
- order: first search on event
- order + added: then search on responsible
- order + added: then search on organizer
- order: then search on participant
- then other field already present

2. b) still in the attendee reporting, filter "archived" has been moved as the
last filter

2. c) still in the attendee reporting, group by for campaign, medium and source
have been added

3. link to confirmed and expected attendee in the kanban view box now redirect
to the new stat view with the suitable filter

Technical remarks:
- view for a specific event launched from the event view uses a specific
search view which doesn't include search on event (name, organizer, ...).

Task 2761011

closes odoo/odoo#84546

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-04-29 11:00:51 +02:00
Pierre-Yves Dufays 909d577918 [IMP] event: eases registration follow-up
Globally ease event registrations followup by improving the related search
views and by allowing a quick access to statistics.

Specifications:

1) A stat button has been added on event that go to attendee reporting filtered
on the event

2.a) in the attendee reporting, the text search has been modified as follows:
- order: first search on event
- order + added: then search on responsible
- order + added: then search on organizer
- order: then search on participant
- then other field already present

2.b) still in the attendee reporting, filter "archived" has been moved as the
last filter

2.c) still in the attendee reporting, group by for campaign, medium and source
have been added

3) link to confirmed and expected attendee in the kanban view box now redirect
to the new stat view with the suitable filter

Technical remarks:
- view for a specific event launched from the event view uses a specific
search view which doesn't include search on event (name, organizer, ...).

Task 2761011

Part-of: odoo/odoo#84546
2022-04-29 11:00:50 +02:00
Pierre-Yves Dufays c04a99ca52 [MOV] event: split view in multiple files to ease changes
The split allows to:
- have one file per model and shorter files
- ease finding of views
- ease tracking of changes

Task-2761011

Part-of: odoo/odoo#84546
2022-04-29 11:00:50 +02:00
Odoo's Mergebot 6c05dd9d10 [REF] models: Refactor load_views to send only once the fields
# Main quest

Refactor the `load_views` API so it no longer sends multiple times the same
fields description.

e.g.
When `load_views` is called to get the kanban, tree and form views,
the list of fields of the model was sent 4 times:
- Once for each view, with only the fields used in the view,
  in `['fields_views']['kanban']['fields']` for instance
- Once globally, with all the fields of the model, in `['fields']`

The goal of this revision is to change that so it sends the list of all fields
only once.

In addition, if a view contains x2many fields,
the fields description of the comodel is also sent.
It was sent in the `views` key of the view fields dict.
e.g.
When calling `load_views` of `res.partner` to get the kanban,
tree and form views,
the `res.partner` fields description was actually sent 6 times:
- Once for each view
- Once globally
- Once for each view of the many2many field `child_ids` of the form view, in
  - `['fields_views']['form']['fields']['child_ids']['views']['kanban']['fields']`
  - `['fields_views']['form']['fields']['child_ids']['views']['form']['fields']`

The change suggested in this revision is to:
- Remove the fields description for each view in `['fields_views']`.
  As it no longer contains the fields,
  the key becomes `['views']` instead of `['fields_views']`.
- Replace the dict key `['fields']` by `['models']`,
  which is a dict with as key the model name and as values
  the model fields description. It contains the fields description
  for all models implied in the view:
  the model of the main view and the model of all one2many and many2many fields.

With this change, the fields description will only be sent once by model
implied in the view.

In addition, the web client was getting the information about the fields
sometimes in the global fields description list (e.g. `['fields']`),
sometimes in the fields description list of the view type
(e.g. `['fields_views']['form']['fields']`),
making it a pain to try to make changes / performance gain
in these field description dictionaries, because you never knew in which dict
the web client was getting its info.
Now, as there is only one place to get the fields description from,
it's clearer and cleaner.

# Secondary quests

- one2many and many2many fields views are passed directly in the main view
  architecture rather than being put in the `views` key
  of the field description.
  This is actually easier to treat by the web client,
  and this will allow in a future work to cache an entire view in one block
  of text rather than having to combine multiple cached blocks of text
  to return one view.
- one2many and many2many fields which do not have directly embedded views
  have their views directly injected in the architecture,
  so the web client doesn't have to do RPC calls to `load_views`
  for each one2many and many2many fields not having embedded views.
  For instance, this allow to reduce the number of RPC calls to `load_views`
  from 8 to 1 when loading the form of `product.product`.
  Currently, this behavior is limited to 1 level deep but we consider making it
  go all the way down in future works. We did not do it for the moment because
  in certain cases it rises the processing time and the size (bytes) too much.
  e.g. the sale.order view can be 5 levels deep,
  meaning you can reach 4 dialogs on top the main view.
  ```
  sale.order form > order_line > sale.order.line form > invoice_lines >
  account.move.line form > asset_ids > account.asset form >
  depreciation_move_ids > account.move form.
  ```
  This will also benefit in future works to cache an entire view in one block
  of text rather to having to combine multiple cached block of text
  to get one view.
- `fields_view_get` becomes `get_view`.
  As it no longer returns the fields description,
  keeping the `fields` in the name `fields_view_get` no longer makes sense.
  Hence removing `fields` from the method name, it becomes `view_get`.
  As it gets renamed anyway, we take the opportunity to rename it `get_view`,
  which is more in line with the general getter/setter guidelines
  in the model object world.
- `_fields_view_get` becomes `_get_view`. For the same reasons than above.
- `load_views` becomes `get_views`.
  This is not mandatory, there is no technical reason to rename `load_views` as
  it practically sends the same info as before,
  the view architectures and their fields description. Just in another way.
  We just take the opportunity of this pull request to suggest a cleaner API:
  `_get_view`, `get_view` and `get_views`.
- Arguments `toolbar=False, submenu=False` fo the methods
  `_fields_view_get` and `fields_view_get` are converted to a kwargs `**options`
  in `_get_view` and `get_view`.
  The rationale is that submenu was already no longer used (deprecated)
  and the mobile options is introduced.
  The mobile options is necessary to tell the server to send the mobile views
  for x2many fields (kanban instead of tree).
  Instead of adding a new argument each time we add a new option to
  `fields_view_get`, it seems wiser to have a kwargs `**options` to avoid
  to re-write all overrides each time a new option is introduced.
- `_fields_view_get` returned a dict containing the arch in text and some of the
  view information. Now, `get_view` returns a tuple with the view architecture
  as an `etree` node, and the view as a browse record. The rationale is that all
  overrides of `_fields_view_get` were about modifying the arch only
  (e.g. changing the address format/re-organizing the address related field
  nodes of the partner according to the company country).
  To do so, all these overrides were doing `etree.fromstring` to parse the arch
  which was sent in text to convert it to an `etree`,
  then operations were done on the `etree`,
  and then `etree.tostring` was called to convert back the arch to string.
  With this change of signature to send the arch as an `etree`,
  all these back and forth `etree.fromstring` -> `etree.tostring` are avoided,
  allowing some performance gain and less code in the end.
- A cleanup of the keys returned in the dict of `fields_view_get`
  has been performed in `get_view`:
  - `fields` is removed, as explained above,
  - `view_id` is renamed `id`,
  - `name` is removed, it was unused by the web client,
  - `type` is removed, it was unused by the web client,
  - `field_parent` is removed, it was unused by the web client,
  - `base_model` is removed, it was unused by the web client.
- `filters` is moved from the global dict returned by `load_views`
  (now `get_views`) to the dict returned by `fields_view_get` (now `get_view`)
  as it applies only to the `search` view type.
- Retro-compatible methods for the 3 methods
  `fields_view_get`, `_fields_view_get` and `load_views` are provided,
  with deprecation warnings in them.

# Future quests

- The web client could cache the model fields description
  (as it already caches the views),
  so it doesn't need to fetch them again if it asks for another view of a model
  for which he already has the fields description.
  If we do so, `get_views` could return only the list of models used by
  the views, without the fields description as of now,
  and the web client would then call `fields_get` independently only for
  the models for which it doesn't have yet the fields description.
  This would avoid the server to return the fields description
  and to call `fields_get`, which is costly, for each `get_views`,
  therefore gaining performances.
- Inject the views of the one2many and many2many fields all the way down,
  unlimited depth level, as explained above.
- Cache with `ormcache` the architecture of back-end views.
  This is already done for qweb views, it's not done for back-end views.
  Therefore the postprocessing of the views is performed for each `get_views`,
  which is costly, while the view architecture doesn't change for users
  belonging to the same groups, according to the groups implied by the view.

### Credits
This pull request is co-authored by
Aaron Bohy (aab) for the web client part and
Denis Ledoux (dle) for the server part.

closes odoo/odoo#87522

Related: odoo/enterprise#25736
Related: odoo/upgrade#3478
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-04-29 09:57:46 +02:00
Aaron Bohy 30d2d2e7dc [FIX] web: py_js: add "true"/"false" in context
Before this commit, py_js was unabled to evaluate expressions
containing "true" or "false" (boolean values, JS syntax), which
seems reasonnable for a python interpreter. However in Odoo, we
often use that syntax in modifiers (e.g. required="true"). For
that reason, we need to add those two keywords in the evaluation
context.

Part-of: odoo/odoo#87522
2022-04-29 09:57:46 +02:00
Aaron Bohy 0c30f9e378 [IMP] web: utils: add array intersection
Part-of: odoo/odoo#87522
2022-04-29 09:57:45 +02:00
Aaron Bohy 45119056ee [REF] web: tests: makeView: let View do the "get_views"
Before this commit, the makeView test helper processed the given
arch and generated the fields to pass to the View component. This
led us to do a similar work as what is done in the view service,
i.e. duplicate code, or factorize/reuse code.

An alternative is to let the View component fetch whatever it needs
(view arch, fields, search view...). This is the purpose of this
commit. That way, the code of the view service is executed (and
thus tested as well) in each test doing a "makeView".

This commit makes that change, and adapts some tests accordingly
(mainly, tests doing assertions in mockRPC, since we do a get_view
in every test).

Part-of: odoo/odoo#87522
2022-04-29 09:57:45 +02:00
Aaron Bohy 89112f8ecf [IMP] mail: do not call getViews for chatter fields
Before this commit, in form views, a call to "getViews" was done
for each field in the div with className "oe_chatter" (i.e.
"message_ids", "message_follower_ids" and "activity_ids"). Those
calls were unnecessary since those fields are displayed with a
custom widget (the Chatter) anyway.

Part-of: odoo/odoo#87522
2022-04-29 09:57:45 +02:00
Aaron Bohy f573e93bb2 [REF] web,mail: adapt code to new load_views API
Part-of: odoo/odoo#87522
2022-04-29 09:57:44 +02:00
Denis Ledoux b03c227e88 [REF] models: refactor fields_view_get, load_views
Refactor the `load_views` API so it no longer sends multiple times the same
fields description.

e.g.
When `load_views` is called to get the kanban, tree and form views,
the list of fields of the model was sent 4 times:
- Once for each view, with only the fields used in the view,
  in `['fields_views']['kanban']['fields']` for instance
- Once globally, with all the fields of the model, in `['fields']`

The goal of this revision is to change that so it sends the list of all fields
only once.

In addition, if a view contains x2many fields,
the fields description of the comodel is also sent.
It was sent in the `views` key of the view fields dict.
e.g.
When calling `load_views` of `res.partner` to get the kanban,
tree and form views,
the `res.partner` fields description was actually sent 6 times:
- Once for each view
- Once globally
- Once for each view of the many2many field `child_ids` of the form view, in
  - `['fields_views']['form']['fields']['child_ids']['views']['kanban']['fields']`
  - `['fields_views']['form']['fields']['child_ids']['views']['form']['fields']`

The change suggested in this revision is to:
- Remove the fields description for each view in `['fields_views']`.
  As it no longer contains the fields,
  the key becomes `['views']` instead of `['fields_views']`.
- Replace the dict key `['fields']` by `['models']`,
  which is a dict with as key the model name and as values
  the model fields description. It contains the fields description
  for all models implied in the view:
  the model of the main view and the model of all one2many and many2many fields.

With this change, the fields description will only be sent once by model
implied in the view.

In addition, the web client was getting the information about the fields
sometimes in the global fields description list (e.g. `['fields']`),
sometimes in the fields description list of the view type
(e.g. `['fields_views']['form']['fields']`),
making it a pain to try to make changes / performance gain
in these field description dictionaries, because you never knew in which dict
the web client was getting its info.
Now, as there is only one place to get the fields description from,
it's clearer and cleaner.

- one2many and many2many fields views are passed directly in the main view
  architecture rather than being put in the `views` key
  of the field description.
  This is actually easier to treat by the web client,
  and this will allow in a future work to cache an entire view in one block
  of text rather than having to combine multiple cached blocks of text
  to return one view.
- one2many and many2many fields which do not have directly embedded views
  have their views directly injected in the architecture,
  so the web client doesn't have to do RPC calls to `load_views`
  for each one2many and many2many fields not having embedded views.
  For instance, this allow to reduce the number of RPC calls to `load_views`
  from 8 to 1 when loading the form of `product.product`.
  Currently, this behavior is limited to 1 level deep but we consider making it
  go all the way down in future works. We did not do it for the moment because
  in certain cases it rises the processing time and the size (bytes) too much.
  e.g. the sale.order view can be 5 levels deep,
  meaning you can reach 4 dialogs on top the main view.
  ```
  sale.order form > order_line > sale.order.line form > invoice_lines >
  account.move.line form > asset_ids > account.asset form >
  depreciation_move_ids > account.move form.
  ```
  This will also benefit in future works to cache an entire view in one block
  of text rather to having to combine multiple cached block of text
  to get one view.
- `fields_view_get` becomes `get_view`.
  As it no longer returns the fields description,
  keeping the `fields` in the name `fields_view_get` no longer makes sense.
  Hence removing `fields` from the method name, it becomes `view_get`.
  As it gets renamed anyway, we take the opportunity to rename it `get_view`,
  which is more in line with the general getter/setter guidelines
  in the model object world.
- `_fields_view_get` becomes `_get_view`. For the same reasons than above.
- `load_views` becomes `get_views`.
  This is not mandatory, there is no technical reason to rename `load_views` as
  it practically sends the same info as before,
  the view architectures and their fields description. Just in another way.
  We just take the opportunity of this pull request to suggest a cleaner API:
  `_get_view`, `get_view` and `get_views`.
- Arguments `toolbar=False, submenu=False` fo the methods
  `_fields_view_get` and `fields_view_get` are converted to a kwargs `**options`
  in `_get_view` and `get_view`.
  The rationale is that submenu was already no longer used (deprecated)
  and the mobile options is introduced.
  The mobile options is necessary to tell the server to send the mobile views
  for x2many fields (kanban instead of tree).
  Instead of adding a new argument each time we add a new option to
  `fields_view_get`, it seems wiser to have a kwargs `**options` to avoid
  to re-write all overrides each time a new option is introduced.
- `_fields_view_get` returned a dict containing the arch in text and some of the
  view information. Now, `get_view` returns a tuple with the view architecture
  as an `etree` node, and the view as a browse record. The rationale is that all
  overrides of `_fields_view_get` were about modifying the arch only
  (e.g. changing the address format/re-organizing the address related field
  nodes of the partner according to the company country).
  To do so, all these overrides were doing `etree.fromstring` to parse the arch
  which was sent in text to convert it to an `etree`,
  then operations were done on the `etree`,
  and then `etree.tostring` was called to convert back the arch to string.
  With this change of signature to send the arch as an `etree`,
  all these back and forth `etree.fromstring` -> `etree.tostring` are avoided,
  allowing some performance gain and less code in the end.
- A cleanup of the keys returned in the dict of `fields_view_get`
  has been performed in `get_view`:
  - `fields` is removed, as explained above,
  - `view_id` is renamed `id`,
  - `name` is removed, it was unused by the web client,
  - `type` is removed, it was unused by the web client,
  - `field_parent` is removed, it was unused by the web client,
  - `base_model` is removed, it was unused by the web client.
- `filters` is moved from the global dict returned by `load_views`
  (now `get_views`) to the dict returned by `fields_view_get` (now `get_view`)
  as it applies only to the `search` view type.
- Retro-compatible methods for the 3 methods
  `fields_view_get`, `_fields_view_get` and `load_views` are provided,
  with deprecation warnings in them.

- The web client could cache the model fields description
  (as it already caches the views),
  so it doesn't need to fetch them again if it asks for another view of a model
  for which he already has the fields description.
  If we do so, `get_views` could return only the list of models used by
  the views, without the fields description as of now,
  and the web client would then call `fields_get` independently only for
  the models for which it doesn't have yet the fields description.
  This would avoid the server to return the fields description
  and to call `fields_get`, which is costly, for each `get_views`,
  therefore gaining performances.
- Inject the views of the one2many and many2many fields all the way down,
  unlimited depth level, as explained above.
- Cache with `ormcache` the architecture of back-end views.
  This is already done for qweb views, it's not done for back-end views.
  Therefore the postprocessing of the views is performed for each `get_views`,
  which is costly, while the view architecture doesn't change for users
  belonging to the same groups, according to the groups implied by the view.

This pull request is co-authored by
Aaron Bohy (aab) for the web client part and
Denis Ledoux (dle) for the server part.

Part-of: odoo/odoo#87522
2022-04-29 09:57:44 +02:00
Odoo's Mergebot 89e3d9559f [IMP] website_event: improve web tracking
PURPOSE

When opening the event page on the website, there is a service worker in place
that pre-fetches all links in order to be able to work offline.
This commit aims to disable the page tracking for those prefetch requests to
avoid polluting the statistics with "fake" page views.

SPECS

- Add a preparation commit to introduce a "X-Disable-Tracking" header
- Put the header on all requests in the event module that prefetch content

See underlying commit for details.

Task-2476513

closes odoo/odoo#86031

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-04-29 08:09:59 +02:00
Pierre-Yves Dufays 80115e8dd3 [IMP] website_event: improve web tracking
In 2 ways:
- by ignoring prefetched pages: indeed some page were reported inaccurately
as being viewed by the user when they were only prefetched.
- by adding the page /event in the tracked page as the page is obviously
important in the event business

Technical notes:
- The prefetched pages are ignored thanks to an header X-Disable-Tracking added
on each prefetch request in the service worker.
- Adding the page /event as a tracked page has increased the number of queries
when browsing the page /event. That's why some query count have been updated in
TestOnlineEventPerformance.

Task-2476513

Part-of: odoo/odoo#86031
2022-04-29 08:09:58 +02:00