== Issue ==
A business code error was detected by the internal team on our
production. The cache and assets where invalidated !WAY! too often for
the past months.
It was hard to figure but finally the error was tracked down to be
located in the assets retrieval stack of our code when a database is
accessed through multiple different domains.
In our production use case, whenever one was accessing `odoo.com/web`
after someone accessed `accounts.odoo.com/web`, the assets would be
invalidated and recomputed, again and again, whenever someone accessed
the backend on a domain after someone else did with another domain.
Obviously, on our production, this could be occuring multiple time per
minute.
Technically, this is because the "assets retrieval stack" had a mismatch
in multiple endpoint when trying to find if a current website was
involved (serving for the frontend).
Some business method were using `env.context.get('website_id')` while
others were using `env['website'].get_current_website(fallback=False)`.
From there, when the code was called without a `website_id` in the
context, `get_current_website()` would still return a `website_id` when
called from `http://odoo.com` as there is a website having its domain
set to it. `get_current_website()` is then finding it and returning it.
But it would not when the user is on `http://accounts.odoo.com`.
Since we have a custom scss override (done through our website builder,
basically an ir.asset linked to a "url type" attachment:
`/website/static/src/scss/options/colors/user_color_palette.scss`) for
our website to define the website colors which is shadowing the scss
file from disk.
So, depending of the host/domain, either the real file disk for this URL
or the ir.asset linked to our website for this URL would be fetched to
generate the bundle hash (which is basically the last modification date
of the files/attachments).
Obviously, the file on disk and the ir.assets have a different last
modification date.
The system would then consider the assets as outdated and would
regenerate it.
You can see it in the logs where the attachment id of the assets URL
would get higher and higher everytime you access the DB through another
domain.
Using `get_current_website(fallback=False)`:
- `_get_related_assets()` https://github.com/odoo/odoo/blame/30d3b97b5ece379d9ddcbceda9d12c03dc7f4a48/addons/website/models/ir_asset.py#L14
- `filter_duplicate()` https://github.com/odoo/odoo/blame/30d3b97b5ece379d9ddcbceda9d12c03dc7f4a48/addons/website/models/ir_asset.py#L41
- ..
Using `get_current_website()`:
- `_get_custom_attachment()` https://github.com/odoo/odoo/blame/30d3b97b5ece379d9ddcbceda9d12c03dc7f4a48/addons/website/models/assets.py#L162
- ..
Using `context.get('website_id')`:
- `_get_asset_url_values()` https://github.com/odoo/odoo/blame/30d3b97b5ece379d9ddcbceda9d12c03dc7f4a48/addons/website/models/ir_qweb.py#L23
- ..
== Fix ==
A fix could have been to aligned those to use the same way of retrieving
the website but it would be too fragile (definitely some other places
where the same bug is involved but not yet found).
What is done in this commit is something we wanted to do for a long time
(see [1]) but was based purely on guess and feeling rather than concrete
bug / use case, but now that we found a real use case, we will do it:
- It doesn't seems to make sense to consider the request host/domain
when we are in the backend
- Same for the forced session, those should only impact the frontend
calls.
But this seems to have too much impact in stable to be changed, as it
would require to check every caller to also check for the session if
it makes sense. This will be done in master as not really needed to
prevent the critical bug fixed here.
- When something wants to alter the backend with a website, it should
explicitely be passed in the context, which is still considered
regardless if it's a backend/frontend call.
- If something needs to consider the forced website in session in the
backend, it should explicitely check it, not relying on
`get_current_website()`.
== Step to reproduce ==
- Start a db with website installed
- Enter the website builder in edit mode and change the "Theme Colors"'s
first "Color Presets"'s background color (it is white by default).
- Set the website domain to `http://127.0.0.1:8069/`
- Go to `http://127.0.0.1:8069/web` and login
- Go to `http://127.0.0.2:8069/web` and login
- Now start refreshing those 2 pages one after each other.
Everytime you will refresh the page, it will take a very long time
(~5-10 seconds) before loading the page, and monitoring the logs will
show something about invalidating the cache and huge query count.
== Benchmark ==
For the explained "multiple domain access" case, the backend /web will
now be loaded in less than 10ms and with ~10 SQL Queries when website is
installed, while it was taking ~4 seconds and ~200 Sql Queries before
the fix.
Before the fix:
```
odoo.modules.registry: At least one model cache has been invalidated, signaling through the database
GET host1.com/web HTTP/1.1 200 - 222 0.135 3.840 <-- 222 Queries, ~4s
odoo.modules.registry: At least one model cache has been invalidated, signaling through the database
GET host2.com/web HTTP/1.1 200 - 181 0.101 3.692 <-- 181 Queries, ~4s
odoo.modules.registry: At least one model cache has been invalidated, signaling through the database
GET host1.com/web HTTP/1.1 200 - 215 0.121 3.704 <-- 215 Queries, ~4s
odoo.modules.registry: At least one model cache has been invalidated, signaling through the database
GET host2.com/web HTTP/1.1 200 - 181 0.100 3.616 <-- 181 Queries, ~4s
```
After the fix:
```
odoo.modules.registry: At least one model cache has been invalidated, signaling through the database
GET host1.com/web HTTP/1.1 200 - 101 0.043 0.353 <-- 101 Queries, ~0.3s
GET host2.com/web HTTP/1.1 200 - 11 0.004 0.007 <-- 11 Queries, ~10ms
GET host1.com/web HTTP/1.1 200 - 11 0.003 0.005 <-- 11 Queries, ~10ms
GET host2.com/web HTTP/1.1 200 - 11 0.003 0.008 <-- 11 Queries, ~10ms
```
[1]: https://github.com/odoo/odoo/pull/94161#discussion_r904780031 (Also other PR/task but couldn't find those.)
closesodoo/odoo#120364
X-original-commit: 28dd35eb3c681b630f0b3c109a7d8209f9fa42d8
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Steps to reproduce:
- Go to a website page > Add a 'Form' block > Add a new 'Selection'
field.
- Go to the page (in 'edit_translations' mode) > The selection field
options are not translatable.
The goal of this commit is to make the select options translatable
by adding an intermediate `.o_translation_select` element.
This element will handle option's text translations from the linked
`<select/>`. The final values are copied to the original element
right before save.
opw-3233360
closesodoo/odoo#120363
X-original-commit: 5ff53d7f289ec531f8369a47d02bd58252bb98a5
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Current link in settings leads to 404 error page,
changing the path to the right one
opw-3279614
closesodoo/odoo#120356
X-original-commit: beffb2fcab99439c9bf9b398e500e2437e38f9f9
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
In case you write user_id = False on the sale order,
It will match the first sale team without sale team manager.
It is because False != None.
After this fix, we check if user_id is Falsy instead of None.
closesodoo/odoo#120346
X-original-commit: 8adde86c719b2dc76e21e440c32de1307e5c4da3
Signed-off-by: Jérémy Kersten <jke@odoo.com>
Stock valuation layers are generated for storable and consumable products. However, given that we don't keep track of its quants we hide those layers by default.
by adding a domain [('product_id.type', '=', 'product')].
On the dashboard, such domain is currently not present. As a result, our inventory valuation value is not the same if we look at it though the dashboard.
This commit adds the same domain so that the value of the inventory shown is always the same (which means not including consumable products).
OPW-3275521
closesodoo/odoo#120267
X-original-commit: d392087941367d93ef63fd0ccdb0b988b338218c
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
avoid overriding payment views by creating new computed field in the payment provider property and override it if needed in inherited payment models
task-3120983
closesodoo/odoo#116573
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This task change the people who can edit a calendar event.
This calendar event currently allow every user to modify every
event in the calendar. This cause issue where one user can
modify the time-off event for other employees.
This PR change the right to modify an event from the calendar
view in the calendar app. With these changes, only the people
attending an event will be able to modify it from the calendar
view.
task-id : 3185743
closesodoo/odoo#112964
Signed-off-by: Arnaud Joset <arj@odoo.com>
This commit fixes a few things in the UI:
- The format selection labels could be confusing to users, for example the word "billing" is not necessary here. Now the labels are clearer and structured in a similar way.
- `peppol_endpoint` is recomputed whenever there is a change in the vat but we do not want to make changes if there is already some value in this field. This commit adds a check for whether `peppol_endpoint`is already filled in.
- Same for the `peppol_eas` field - should not be changed if it's already there.
- Both of these fields should be logged in the chatter when changed
closesodoo/odoo#120344
X-original-commit: f749033466c674d91722a2ac753645955da04bad
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Aliya Tastemirova (alta) <alta@odoo.com>
Steps to reproduce the bug:
- Go to Decimal accuracy:
- Select the “Product Unit of Measure”
- Set the Value to “4”
- Create a storable product with BoM:
- add any product as component
- save
- Click on the BoM overview widget
Problem:
The “Product UoM” precision is not used
opw-3288403
closesodoo/odoo#120296
X-original-commit: 837a6ca90d6944f9faf4b28e69703f5310c6ec6a
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
Before this PR, using the message component wihtout a thread could crash because
props.thread could be undefined (as thread is an optional props).
This PR just add the guard.
closesodoo/odoo#120233
Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
*: barcodes_gs1_nomenclature,point_of_sale
In this commit, we are converting the `BarcodeParser` to js class. As a
consequence, instead of having 2 options of instantiating the parser -- via
nomenclature_id or via nomenclature -- we are removing the first option.
Instantiating the parser will now only require the built nomenclature object.
This is possible because in all the pathways where the parser is instantiated,
the web services are ready, meaning `rpc` and/or `orm` services are ready. As a
result, the consumer of the parser can just build the nomenclature object itself
by fetching the nomenclature details from the server. A helper static method
called `fetchNomenclature` is introduced in the `BarcodeParser` class to aid in
building the nomenclature object it needed.
Furthermore, the methods that return the required nomenclature and rule fields
are converted to static fields which can still be patched (check
barcodes_gs1_nomenclature in enterprise).
closesodoo/odoo#120228
Related: odoo/enterprise#40582
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Before this commit, on a blog page with the "regular cover" and "read
next article" options enabled, the image in the "read next article"
block would shrink when the text was too long.
Steps to reproduce the bug:
- Go to a blog page (e.g. "Sierra Tarahumara").
- Enable the "regular cover" and "read next article" options.
- Enter edit mode.
- Scroll down the page.
- Enter a lot of text as the title of the "read next article" block.
- Bug: As the text increases, the width of the image decreases.
opw-3267842
closesodoo/odoo#120025
X-original-commit: 06a6e78b0f41188dd4c7c45c26f6038ecbd5b311
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Before this commit:
When using shift+enter to move to a new line, now applying bold, italics,
underline, etc and then trying to add a color to both lines would result in
lines merging.
After this commit:
Now when the both lines are bold and then applying a color to both the lines
would no longer merge.
closesodoo/odoo#119701
Task: 3269922
X-original-commit: 0473dbd0090dd7b2fb1ff59a83a38df941303681
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit makes the `dependencies` param of
`odoo.define` mandatory. It was optional and when
omitted, a regexp read the function to find the
dependencies. We can simplify it now almost all js
modules have been converted to esm.
The transpiler already adds the param for the es
modules except if the module has an alias.
task id: 3271352
closesodoo/odoo#119145
Related: odoo/enterprise#40040
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Purpose: HR can view employee leave records from the calendar but can
not approve, validate or refuse it from there.
In case they want to make action, they have to go through
menu < time off < approvals < time off < find the employee
< find the requested time off < open it < approve.
In this commit the action buttons are added on the dashboard.
task - 3175495
closesodoo/odoo#116342
Signed-off-by: Kevin Baptiste <kba@odoo.com>
*:pos_epson_printer,pos_epson_printer_restaurant,point_of_sale,
pos_restaurant,pos_hr_restaurant
Before the printers only worked in the pos_restaurant and not in the
point_of_sale. Indeed, the methods managing the printers were located
in the pos_restaurant.
Now all these methods have been moved.
For the community part here are the affected modules:
- The methods in pos_epson_printer_restaurant have been moved to
pos_epson_printer.
- The methods in pos_restaurant have been moved to point_of_sale.
- The module pos_epson_printer_restaurant has been removed as it only
handled printers.
Some of these methods have been adapted/renamed to better suit
the needs.
This branch the first part of the following task: 3224508
closesodoo/odoo#114655
Related: odoo/upgrade#4414
Related: odoo/enterprise#37901
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
To improve onboarding experience, configuring Stripe
has been added in Invoice onboarding process.
For db with other apps(ecommerce or sales) if onboarding is
done in one place it is considered done in other places with
exclusion of Sales, unless it was done in Sales.
task-3208045
closesodoo/odoo#114131
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
When the payment method was detached from the customer, trying to pay
with the linked payment token would end up with a crash because Stripe
failed to send us the payment intent, as it could not create it.
With this commit, we test for the existence of the returned payment
intent and prematurely return in `_send_payment_request` to prevent a
cursor rollback. The transaction is set in 'error' and the error
message is logged in the stdout and on the transaction's state message
field.
closesodoo/odoo#120348
X-original-commit: 4ebf0efc16ef78ca568ef93fb2c36ce404cb0c12
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Purpose
=======
All the properties field file respect prettier rules defined in
/web/tooling (like normal field), during odoo/odoo#118929 we forgot
to apply those rules.
Task-3188915
closesodoo/odoo#119811
Related: odoo/enterprise#40363
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Purpose
=======
When the focus is inside the label of the property, if we click
outside of the popover we need to click a second time to close the
popover.
Before that code was used to solve a bug where the definition popover
was closed when you select the text inside the property label. It
seems not necessary anymore, and it causes the issue above.
Task-3188915
Part-of: odoo/odoo#119811
Purpose
=======
Most of the template in web use the `and` syntax instead of `&&`,
use this syntax for consistency.
Task-3188915
Part-of: odoo/odoo#119811
Purpose
=======
When this option is enabled, the button to create new properties
is invisible. We create a client action instead, and when the user
executes client action for the first time, the button becomes visible
until the user refreshes the page.
This is useful because most of the time, the user will create the
properties and then won't change them. So this button uses space
unnecessarily in the form view (for the most of the use cases).
Task-3188915
Part-of: odoo/odoo#119811
Fixes a situation where users who are part of the Attendances Officer (or Manager) group but
without access to private employee data would see the following error when trying to book time
off.
`ValueError: Invalid field 'last_check_in' on model 'hr.employee.public'`
Other instances of the same ValueError were observed by managers trying to approve employee leave
and employee expenses.
As per hr/models/hr_employee.py:22-26 fields not available on hr.employee.public should have
groups='hr.group_hr_user' and this was not the case in hr_attendance.
closesodoo/odoo#120324
X-original-commit: ff4e7d6a414097d000e62825cf43425ea14bd77e
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Current behavior:
When you try to open the pos as a demo user, you get an error message.
Steps to reproduce:
- Install pos and loyalty modules
- Log in as demo user
- Try to open the pos
- You get an error message
opw-3297341
closesodoo/odoo#120334
X-original-commit: 5f6a1df7eda6909df302bc6cfa3ba02d8a2de3d7
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
Description of the issue/feature this PR addresses:
---
When a user chooses "Repeat Pattern" as the background image position,
nothing happens.
Current behavior before PR:
---
As the background size is set to auto, for background-position
`repeat-pattern` no effect[1] can be seen in the
background size.
[1]: https://bit.ly/3MM31Ac
Desired behavior after PR is merged:
---
Not a bug but can be considered an improvement in features by setting
some default[2] width or height for a repeat-pattern option for all
relevant snippets.
[2]: https://bit.ly/3GbGIBo
task- 2862510
closesodoo/odoo#102995
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
In the Invoicing dashboard, the "Average Invoice" scorecoard displays
the wrong amount of invoices. It displays the number of
"account.invoice.report" lines.
This commit fixes the issue by displaying the count_unique measure
of "move_id"
task 3180524
closesodoo/odoo#120322
X-original-commit: 6232896fe06640de6d461e645811673fe27481aa
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
* Indentation
* Explicit field attributes
* Double quoted strings for strings shown to users (single quoted ones for the rest)
closesodoo/odoo#120245
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
As module versions can be single digit, an upgrade script for version
`x.y.z`, is currently parsed as an upgrade script for module
version `z` in Odoo `x.y`.
However 3-digits module versions are more common than single-digit ones
and developers may expect the `x.y.x` upgrade scripts to be major-less
scripts.
This ambiguity can lift off if we accept module versions to be **only**
2-digits or 3-digits. This however make the `x.y.z` upgrade script
major-less. This can be fixed by renaming the script to `x.y.z.0`.
Part-of: odoo/odoo#118420
Fixed the popup call. The call was made with the old method showPopup.
The call is now made with the new .add method on the popup service.
closesodoo/odoo#120274
X-original-commit: d174e6cdacfdde6973e4ced931bb7572b6bd0511
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Signed-off-by: Monnom David (moda) <moda@odoo.com>
Before this PR, the `Updating the parent message of a reply also
updates the visual of the reply` test was failing in a non-deterministic
fashion.
This PR fixes this issue by replacing the `nextTick` by a specific
`waitUntil` in order to ensure the DOM is properly updated before
asserting.
Fixes 20829 runbot issue.
closesodoo/odoo#120273
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
*: web, web_editor, payment
Before this commit, templates with %d was given to sprintf but it was not interpreted by the function
After the commit, %d are replaced by %s in templates for sprintf
Also this commit converts a last _.str.sprintf into sprintf
PR#120143
closesodoo/odoo#120143
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Steps to reproduce:
- activate `group_stock_reception_report` in settings
- activate `auto_show_reception_report` for the "Receipts" operation type
- create a receipt w/ any product + confirm
- create a return w/any product + confirm
- select both the receipt + return in the (Operations > Transfers) list
view > action > Validate
Expected result: both pickings are validated
Actual result: stacktrace due to expected singleton ValueError
enterprise PR : https://github.com/odoo/enterprise/pull/37518
task-3204596
closesodoo/odoo#120190
X-original-commit: b2ac4b2f30e15c4b8a50628798b2fc39d7d43331
Related: odoo/enterprise#40570
Signed-off-by: Tiffany Chang <tic@odoo.com>
Steps to reproduce:
- create a product;
- disable the continue selling option for the out-of-stock;
- do not have a stock quantity for this product.
- go to ecommerce;
- without click on the product, add it in the cart with the cart icon (on the picture).
Issue:
It is possible to add the product to the cart.
If we repeat this several times, we will create quotations.
Solution:
Hide the button if the product is a storable product
and we don't want to sell it if we have no stock.
We also check the quantity available.
opw-3148069
closesodoo/odoo#120176
X-original-commit: bf4b5962c396101f242822058b5ddf815408e3f8
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Lefebvre Thomas (thle) <thle@odoo.com>
Before this commit, when chatter message list was lower
than 2500px, the message-list had scrollable of 2500px
of height.
This happens because the area detecting present time was
always 2500px. thus making the content have this value as
scrollheight.
This commit fixes the issue by making presence area not
go above the conversation height. So if message list is
250px of height, then presence area is 250px, not 2500px.
closesodoo/odoo#120173
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Starting with Firefox 109, a widget element prototype that is put
inside an iframe will not be instanceof its original constructor.
See: https://github.com/webcompat/web-bugs/issues/118350
This is because a node that is adopted by an iframe will have its
prototype changed to match the constructor from within the iframe
instead of its original one. This has been the case for a long time.
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1470017
It largely went unnoticed because of another quirk of Firefox related
to the use of instanceof which was fixed in version 109.
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1360715
Since this bug was fixed it became apparent, in the form of a
traceback, that the wrong instance of ClipboardJS was being used
in the case of Firefox, due to the forced prototype change.
This commit could be reverted once Firefox is fixed.
Steps to reproduce the issue in Firefox > 109:
- Create a new mass mailing.
- Choose the third template with "Thank you for joining us!".
- Click on the "LOGIN" button link inside the email.
- Get a traceback about a paremeter not being the right type.
Task-3186513
OPW-3172914
closesodoo/odoo#120171
X-original-commit: c0da01c716716f9d35abe9d90dad27cce1452ebb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Jinjiu Liu <jili@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>