Commit Graph
150205 Commits
Author SHA1 Message Date
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
Pierre-Yves Dufays aef2d27053 [IMP] website: add X-Disable-Tracking header to improve tracking
In this commit we add a request header X-Disable-Tracking that enables the
client to ask the server not to track a request.

This is useful for example when the client prefetches pages to be able to work
offline. In that case, the prefetched pages must not be considered as viewed
by the user. In such scenario and without such header, it is not possible to
get an accurate page tracking.

Task-2476513

Part-of: odoo/odoo#86031
2022-04-29 08:09:58 +02:00
Adrien Widart 0a98036387 [FIX] stock: cancel picking with scrapped SM
Cancelling a picking with scrapped and done SM will cancel this SM too.

To reproduce the issue:
1. In Settings, enable "Storage Locations"
2. Create a storable product P
3. Update the quantity of P: 10 in WH/Stock
4. Create a planned delivery order DO with 2 x P
5. Mark DO as todo, Check availability
6. Scrap 2 x P
7. Cancel DO
8. Open the SM of the scrapping

Error: The SM is cancelled. This is incorrect: the move was done, so
there is a quant with 2 x P in scrap location. There is now an
incoherence between quants and SMs report.

OPW-2805604

closes odoo/odoo#89987

X-original-commit: bd3324acc3ec227438d2cb25a1df1e0fca2a2789
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-04-28 14:59:58 +02:00
std-odoo 044e253ac2 [FIX] mail: fix assertMailNotifications when called in batch
Bug
===
When we called assertMailNotifications in batch, with different
notification status, it might raise an error when it shouldn't.

The reason for that is we check that no mail at all are created, for
the entire batch instead of filtering on the related partner.

`assertNoMail` should only check if no mail are created for the partner
it receive in arguments.

Task-2782150

closes odoo/odoo#89965

X-original-commit: 91be8b1eb2c3592029987524942ae2864988a7d3
Related: odoo/enterprise#26718
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-04-28 12:40:40 +02:00
hoangdinhhieu 7bdb8cc784 [FIX] website_forum: fix batch statistics computation
Currently all iterations share the same dictionary. We have to copy the
default dict in order to have a distinct copy for each id in the loop.

Task-2826303

closes odoo/odoo#89934

X-original-commit: ae145e0909d5f37964eace75053eadf9e8b80c36
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-04-28 11:28:53 +02:00
Denis Vermylen ea913dd39d [FIX] server: close psql connections on shutdown
Stopping a threaded odoo server would spam the postgresql logs with
multiple:

<...> LOG:  could not receive data from client: Connection reset by peer

Let's avoid being rude and not hang up on postgresql connections
unexpectedly.

closes odoo/odoo#89955

X-original-commit: d0da17b167edee82381b6add573742e1cf663a9c
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-04-28 09:59:56 +02:00
Laurent Desausoi (lade) f61f509f7d [FIX] website_hr_recruitment: allow fields in job to be auto-populated
When submitting an Application Form, the name / email / phone number are
not auto-populated.

Step to reproduce:
1. Install "Online Jobs" module
2. Go to /jobs on your website and apply to a job
The form should be auto-populated with the field mentionned before, it isn't.

Solution: From a previous commit [1], the fill-with behavior will replace
the default_values. However, the change was not completed. The
data-fill-with attribute was missing into the XML template.

[1]: https://github.com/odoo/enterprise/commit/fe5a2ffe30b6f5b5d1bd2e64a0e7f11267b34a96

opw-2803166

closes odoo/odoo#89941

X-original-commit: 5739569b2c2a76e3c091c23a12623e8921794834
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Desausoi Laurent (lade) <lade@odoo.com>
2022-04-28 09:59:53 +02:00
Xavier Morel 0569476adc [FIX] calendar: read([]) as a non-admin would not return all fields
Because private fields would automatically add a bunch of fields to
the user's request (in order to do their own post-treatment), unlike
normal behavior `read([])` would be completed to `read(['privacy',
'user_id'])` and would fail to trigger the "select all the fields"
behavior of `BaseModel.read`.

Move the privacy management to a `_read` override instead. Also update
the code to be more linear and straightforward, without a bunch of
intermediate helper function.

This is also a small performance optimisation, although apparently
much more minor for 14 (best case of about 5%) than on 15.0 (where it
seemed to reach 30). The gain is mostly for private events being read
for non-participants: because the non-public fields get neutered
before computation (rather than after), fields are computed on a
neutered basis and thus largely do nothing. This is especially salient
with computations relying on relations (in this case
`attendee_status`), as from an empty starting point they essentially
do not do anything.

This leads to the effort (and cost) of private events being read by
non-participants to be about the same as the cost of public events,
whereas before the change there is a visible overhead. The signal is
quite noisy though.

NOTE: backported the addition of `privacy` to the public fields from
      2f4a91c0ce as that is better
      behavior and makes the tests more logical (and easier to forward
      port probably)

OPW-2831113

closes odoo/odoo#89936

X-original-commit: b0c6f2969596fb715e0a6c62865b5c7dbc0bcc78
Related: odoo/enterprise#26699
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-04-28 09:59:49 +02:00
Samuel Degueldre f36306c8ff [FIX] web: fix ComponentWrapper lifecycle on out-of-DOM updates
Previously, updating a component that was mounted out of the DOM would
rerender it and patch it. In owl 1, patched was not called when a
component was mounted outside of the document. This caused crashes when
something done in onPatched depended on something done in onMounted (as
mounted is also not called when not it the DOM, which was handled
correctly by the compatibility layer).

This commit fixes that by ignoring requests to render a component that
is not yet in the DOM as a new render will be initiated anyway when
mounting the component in the document for real.

closes odoo/odoo#89935

X-original-commit: fc6a843abe52cfee084ed476f00a12a8ba1d1669
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-04-28 09:00:54 +02:00
Nicolas Bayet fa796c76ad [FIX] web_editor: past mulitple lines and undo
Before this commit, when pasting multiples lines a new step per line.
So when performing an undo, only one line was removed instead of the
whole pasted text.

task-2833740

closes odoo/odoo#89932

X-original-commit: 06fb4e3e8377dedb02644779f0077e0d883df918
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-04-28 09:00:50 +02:00
Nicolas Bayet 444fb09d1e [FIX] web_editor: prevent crash when inserting empty string
Before this commit, when unsing the function `insert()` with data being
an empty string, the function crashed but shouldn't.

task-2833740

X-original-commit: d44302550ddc027d4891ad04bf16c364e171e5ad
Part-of: odoo/odoo#89932
2022-04-28 09:00:50 +02:00
Nicolas Bayet c40d9e513c [FIX] web_editor: make checklist work in firefox
task-2833778

closes odoo/odoo#89918

X-original-commit: e3304148035ec04f435475bbf9ba803dc630ae37
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-04-28 09:00:45 +02:00
Julien Van Roy afb957e347 [IMP] account: add helper functions on the chart template
These helpers are used to create the repartition lines and the taxes in
the upgrade script which upgrades the tags on the taxes.

See https://github.com/odoo/upgrade/pull/3137

closes odoo/odoo#89912

X-original-commit: 8927003d0c32e81d28ece68e61c1a737bd7532d2
Signed-off-by: Olivier Colson <oco@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
2022-04-28 09:00:41 +02:00
Samuel Degueldre 03763da5bf [IMP] web: update owl to version 2.0.0-beta-7
Release notes: https://github.com/odoo/owl/releases/tag/v2.0.0-beta-7

closes odoo/odoo#89937

X-original-commit: b0a807ff5ea36b08ec027ac19ac6d0b9ee360ab8
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-04-28 08:02:05 +02:00
Adrien Peiffer 48e410477d [FIX] Use currency of analytic line
As the company is not mandatory on both the employee and the analytical account,
if neither is filled in, it causes the application to crash.

This commit ensures that the currency of the current analytical line's company
is provided when no company is set on the analytic account.

closes odoo/odoo#89957

X-original-commit: e1c3690142236887cac4a4fba4599ada22bbf0ca
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-04-27 23:32:21 +02:00
Ricardo Gomes Rodrigues (rigr) bf3bf40fc6 [IMP] l10n_pt: add a demo company for Portugal
closes odoo/odoo#89949

X-original-commit: 870610dc6e75afee6b0410ff7fc5322aee5d41fe
Signed-off-by: William André (wan) <wan@odoo.com>
2022-04-27 21:28:36 +02:00
William Braeckman fb86ae3371 [FIX] website,website_sale: fix unable to save in multi company settings
This commit is a follow-up to https://github.com/odoo/odoo/pull/89707
The above PR fixed most issues with the configuration but since the
default value was not set anymore for `auth_signup_uninvited` a
configuration with no website attached would make the config not
saveable (required field not set).

closes odoo/odoo#89938

X-original-commit: 5fab73f7730a10636642ba96b1fdd7a7455fe6f9
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
2022-04-27 21:28:32 +02:00
Sébastien Geelen (sge) 1bec40e88e [FIX] web_editor: save editor value during urgentSave
Ensure the current editor value is set in the Odoo FieldHtml during
`commitChanges` so it can be used by the `urgentSave` when needed.

closes odoo/odoo#89916

X-original-commit: 43dfc8140760497d9f0352897d71ad49b12fd6e5
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-04-27 21:28:28 +02:00
momegahed 74af2b85c6 [FIX] pos_sale: inconsistent behavior Sales vs. PoS
If applied, this commit will fix the following bug by making the
behavior of applying a down payment similar to doing it in sales app

Steps to reproduce:

1- install sales, POS
2- set customer tax t on down payment product and use the product in
POS and sales
3- Create a product p with tax t
4- add p to a new sales order so
from sales:
5-apply a down payment of a percentage per (let's say 100% for clarity)
6- the down payment is calculated correctly and the total amount to
be paid is per * (p.untaxed_price + t * p.untaxed_price)

now from POS:
5- choose SO from the list
6- apply down payment of percentage per
7- the down payment is calcualted incorrectly. the SO is double taxed.
now the amound due is
(per * (p.untaxed_price + t * p.untaxed_price)) * (1 + pos_default_tax)

Bug:

when applying a down payment the full amount is treated as the untaxed
amound and then later the POS tax is added on it.

Fix:

using the untaxed total and also using the down payment product tax
similar to what happens in sales since the 2 flows can be mixed

OPW-2790821

closes odoo/odoo#89915

X-original-commit: 7dbd8d8e6ea5149c0b8d388ebfb1d97e43d47783
Signed-off-by: Masereel Pierre <pim@odoo.com>
2022-04-27 21:28:24 +02:00
Alexandre Kühn 5842a0e87d [IMP] mail: introduce view models (step 2)
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#89905

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-04-27 21:28:19 +02:00
John Laterre (jol) 51fbb89976 [REV] account: display correct price_unit with 100% taxes
This reverts commit fe7d56dc32c71e04b54de9dbd756a48942a832f4.

The original commit created an unwanted side effect that was
being solved here https://github.com/odoo/odoo/pull/89632

But while testing the new PR, it appeared that the initial bug
was no longer there, even without the original fix.

Hence this PR.

closes odoo/odoo#89895

X-original-commit: af01dac8e35fe814b1d42a1620ff766908425b33
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: John Laterre <jol@odoo.com>
2022-04-27 21:28:15 +02:00
Umesh Gupta 458693e2ac [FIX] mass_mailing: enhance mass mailing template preview behavior
Currently, if user clicks the mass mailing template (theme) and holds
the click while moving the mouse (as if performing drag and drop), a
weird white highlight appears on the preview of the template.

This commit fixes the behavior by setting appropriate background color
instead of the default one of drop-down item, when the template is
focused.

task-2812312

closes odoo/odoo#89893

X-original-commit: e49f55e6f34486f8425653323544838f1a9fbd38
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-04-27 21:28:11 +02:00