Werkzeug 0.15 modified ProxyFix such that by default it only forwards
the REMOTE_ADDR when enabled, whereas before 0.15 it would also
forward scheme and host. This breaks proxied odoo as the base url
becomes incorrect (cf #34412).
Use properly configured ProxyFix when running with werkzeug 0.15, old
configuration otherwise.
Closes#35085closesodoo/odoo#36212
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
ee03fc3770 introduced a non deterministic bug by choosing an
environment in a set, so the environment is not always the good one.
closesodoo/odoo#36056
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
When an HttpCase browser_js test is unable to join a request thread, a
warning is logged.
To avoid mergebot failures, this commit changes the warning to a log
info.
This problem was introduced by the refactor in this commit: 3ca788f55closesodoo/odoo#36022
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
During an HttpCase, when a browser_js test is finished, cookies are
removed to ensure that the next call will start on a clean base. From
time to times, when an HttpCase have multiple tests methods that call
browser_js, the user session of the previous test is being used.
With this commit, the session cookie is explicitely deleted and should
prevent that kind of problem. By the way, the browser's cache is also
cleared.
When issuing the first json command, it happens that the chrome process
has crashed. As a consequence, a log entry appears with saying that it
could not connect to chrome debugger.
After some investigations, it appeared that it was only happening with
google-chrome versions 75.0.3770.90 and 74.0.3729.169.
This error message was seen on the chrome stderr:
listp->slotinfo[cnt].gen <= GL(dl_tls_generation).
As a conclusion, it seems that we were hit by this issue:
https://github.com/GoogleChrome/puppeteer/issues/2207
While this commit does not fix the google-chrome issue, it adds a new
verification to check if google-chrome process is running before trying
to issue the json command. If it's not case, an error message is logged
with the error code.
After a browser_js, http requests threads are joined. If one of them
doesn't finish gracefully, a dumpstacks occurs.
As the dumpstacks call is in a loop, it can quickly polute logs. Even
more, a the dumptack may include threads that were not yet processed and
that will be joined in a future loop.
With this commit, dumpstacks will be called once and for all at the end
of the method, if at least one thread is remaining.
Furthermore, before this commit a sleep of 0.5 sec occured at most ten
times for each thread before considering it as lost. It means that each
thread is benefiting of the cumumulated time of the previous ones.
That's not fair.
With this commit, a default timeout of 10 sec is used for all threads.
The original warning is kept for each remaining request.
* disable background networking like GoogleUrlTracker ...
see https://codereview.chromium.org/3312014
* disable backgrounding occluded windows is a CLI swith that was
specifically written for tests to avoid non deterministic behavior. To
avoid test flakiness, it should come with disable renderer-backgrounding
and disable background-throttling as stated here:
https://github.com/smooth-code/jest-puppeteer/issues/137
* disable breakpad is used to disable crash reporting, the difference
with disable crash-reporter is not clear.
see https://peter.sh/experiments/chromium-command-line-switches/
* disable defaults-apps, prevent installation of default apps on the
first run
* disable dev-shm usage that may cause crashes
Undeterministic failures "Cannot connect to chrome"
can occurs in two scenarios:
-One time on a build, occasinnaly. This seems to be linked to chrome version.
runbots using version 71 don't have this problem when it occurs on runbot
with version 74 and 75.
-For all (36) attemps of the build to connect to chrome debugger,
this is exeptionnal but add a lot of noise by adding this type of
failure on any runbot.
Used chrome versions at this time:
r11-r22 -> 71.0.3578.98
r23-r24 -> 74.0.3729.169
r25-r28 -> 75.0.3770.90
All 'Could not connect' failure by runbot by day
day r13 r20 r24 r25 r26 r27 r28
07-15 36 4 2
07-16 6 1 1
07-17 36 2 1 2 2
07-18 2 39 1 2
07-19 1 3 1 3
07-20 1
07-21
07-22 2 1 4 1
07-23 1 1 1
07-24 4 3 2 1
07-25 2 5 2
07-26 3 3 1 1
07-27
07-28
07-29 36 1 1 1
07-30 3 1
07-31 1 3 2 1
08-01 3 1 1
08-02 3 1 1 1
08-03 1
08-04
08-05 1 5 4 1
08-06 1
08-07 2 1 2
08-08 2 2 2 1
08-09 2 2
08-10
08-11 1
08-12 2 1 4 3
08-13 1 2 1 2 72
Having two attributes for this was probably overkill. We now have
a single attribute 'width' which can specify either a fixed width
(e.g. '120px') or a factor (e.g. '2.5').
Purpose
=======
To correctly choose in which account a line should be posted,
we have to know if the partner is a customer or a supplier.
Specification
=============
Keep track of the number of account moves "in" and "out"
a partner has. These counts should be based on the posted
account moves. A customer that has been created from the
'Customer' menuitem will have a rank=1. When a customer
invoice will be created for him, the generated account moves
will be taken into account to compute its rank. The most
invoices we have for a partner, the higher his rank is.
Note: To avoid any concurrent update failures on the partner,
if one transaction has already locked a partner row, the count
update will be skipped that time.
This means the values may be approximative in the database!
The exact values will eventually be correctly computed at
the next successfull try.
Known limitation of this approach: The computation ignores
the set of currently selected companies. Actually, storing
context dependent values in the database is a bad practice,
and is avoided in that case by taking all the companies into
account.
Use the stored fields `customer_rank` and `supplier_rank`
to order partners when searching by name. This allows to show
best customers or best suppliers on top.
To choose if best customer or supplier are shown on top,
the context key `res_partner_search_mode` is used.
The context key can take two values: 'customer' or 'supplier'.
This decision partially reverts/revamps 8766f38 to only use
account moves instead of PO and SO
On actions showing partners, set a default filters to menus to
only display customers (customer_rank > 0) if the string is
"Customers", and only suppliers if the string is "Vendors" or
"Suppliers".
TaskID: 2049131
closesodoo/odoo#35942
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This is a performance optimization: modifying a regular record will not
trigger some recomputation on a transient record. Most transient
records are simply waiting to be garbage-collected, so there is no need
to keep their fields up-to-date.
closesodoo/odoo#35909
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Babel is already taking the language into account while
formating a time delta into a readable string like '2 minutes ago'.
_format_time_ago was put in translate.py file to be able to use
the _ translate class. But it can be placed in misc like other
format function already using babel.
This fix the PR #34624
and is linked to Task ID : 2028059
Task ID: 2055847
Closes PR #35806
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
One cannot override the attribute `selection`, and list selections can only be
extended with `selection_add`.
Adapt the bad extensions to be consistent with the new warnings
closesodoo/odoo#35663
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
When extended with the selection_add parameter, a singleton (value,)
where `value` appears in the overriden selection, can be used.
The new values are inserted in an order that is consistent with the
overridden selection and this list.
selection = [('a', 'A'), ('b', 'B')]
selection_add = [('c', 'C'), ('b',)]
> result = [('a', 'A'), ('c', 'C'), ('b', 'B')]
When the registry is not ready, allow modifications of the selections
The following use case must reset the values:
- removing a selection on a custom field via studio
- changing the static selection definition and updating the module
The value must NOT be reset when:
- trying to remove manually a base field
- updating a module without all override being computed yet
(i.e. install)
Fully replacing the selections in an override should not happen
Instead of relying on the context, check if the registry is ready
before marking the selections as to remove.
If a static selection is removed and the module updated, it will be
removed correctly during the _process_end method as the selections
will not be present in pool.loaded_xmlids
Before this commit, updating a module A was doing a SET NULL for
selection values added by a module B via a selection_add
closesodoo/odoo#35871
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Martin Trigaux <mat@odoo.com>
This version adds full support of string templates.
Before this version, rjsmin may produce wrong code with string
templates. For example:
```js
const url = `https://odoo.com`;
console.log(url);
```
was minified to:
```js
const url=`https:console.log(url);
```
Because `//` was wrongly handled as a comment inside the string
template.
closesodoo/odoo#35867
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Each model of the relation can define `ondelete` for its `column2` foreign key.
This way the behavior is similar to m2o where the target of the `ondelete` is
the `comodel` foreign key.
Some models were already defining `ondelete` 'restrict' on m2m fields and after
review it appears the behavior introduced in this commit is the expected
behavior for them.
The 'restrict' from product.product has to be removed however because the rest
of the code needs adaptation now that it is properly restricted. These changes
will be done on a separate PR.
closesodoo/odoo#35654
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Create two models, `object` and `category`. The object have a Many2One
to the category. Override the `search` on the category so it returns a
subset of the records if a context key is present. Create an IR Rule on
object with the following pseudo-domain: `categ_id in category.search([])`.
Search on object with the context key present. Even if the context
should only be applied to category, it is applied to object too thus
there are some object missing.
When evaluating the domain of IR Rules, the current user is propagated
with the current environment context. API calls triggered by the domain
are called with the given context, possibly populating the cache with
different records than it would normally does without the context (i.e.
at `addons/point_of_sale/models/account_journal.py#L19-L23`). Following
requests do use that invalid cache thus return invalid results.
Forcing an empty context on the user used during the evaluation of the
context ensures the IR Rules are working as they should and is
future-proof (cf `load_company` v13 context key)
opw-2041667
closes#35123closes#35125closesodoo/odoo#35667
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Co-authored-by: Hugo Adan <hugo@vauxoo.com>
In some cases, the first request of a test is made before the
proper setting of the cookie. In that case, Odoo picks a new session,
leaving the request unauthenticated.
closesodoo/odoo#35780
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Pdf files created with third party tools could trigger an exception in
several modules that attempt to manipulate them (see example below).
```
File "/usr/lib/python3/dist-packages/PyPDF2/pdf.py", line 2239, in mergePage
self._mergePage(page2)
File "/usr/lib/python3/dist-packages/PyPDF2/pdf.py", line 2277, in _mergePage
originalContent, self.pdf))
File "/usr/lib/python3/dist-packages/PyPDF2/pdf.py", line 2199, in _pushPopGS
stream = ContentStream(contents, pdf)
File "/usr/lib/python3/dist-packages/PyPDF2/pdf.py", line 2673, in __init__
stream = BytesIO(b_(stream.getData()))
File "/usr/lib/python3/dist-packages/PyPDF2/generic.py", line 845, in getData
decoded._data = filters.decodeStreamData(self)
File "/usr/lib/python3/dist-packages/PyPDF2/filters.py", line 346, in decodeStreamData
data = FlateDecode.decode(data, stream.get("/DecodeParms"))
File "/usr/lib/python3/dist-packages/PyPDF2/filters.py", line 111, in decode
data = decompress(data)
File "/usr/lib/python3/dist-packages/PyPDF2/filters.py", line 49, in decompress
return zlib.decompress(data)
zlib.error: Error -5 while decompressing data: incomplete or truncated stream
```
This is caused by the decompression function used by default in PyPDF2
which uses a limited buffer, unable to store all the data.
The solution, as per
[zlib documentation](https://docs.python.org/3/library/zlib.html#zlib.decompressobj),
is to use an intermediate ```decompressobj``` object to handle
the decompression.
However we do not directly control the library, which is also used
multiple times in the codebase so we decided to apply a fix directly into
the core module instead of patching every call.
opw-2048029
closesodoo/odoo#35646
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
In other words, when a field F depends on a non-stored field G, it also depends
on G's dependencies. This guarantees that whenever a dependency of G is
modified, F will be invalidated and marked to recompute (if necessary).
The transitive closure of dependencies is not computed over stored fields.
Anyway stored fields already trigger the recomputation of their dependent
fields during their recomputation. The performance impact on the loading of a
registry is negligible (less than 1%), and the increase of recomputation
triggers is small (less than 10%).
(cherry picked from commit 3fbd86bcbe)
opw-2033493
closesodoo/odoo#35636
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>