Commit Graph
117640 Commits
Author SHA1 Message Date
Odoo Translation Bot ebbb5b8d37 [I18N] Update translation terms from Transifex 2019-01-27 03:14:28 +01:00
Denis Ledoux 8fb76c425d [IMP] api: improve storing performance of the api cache
This revision moves the `cache_key` to the first level
dict of the cache, instead of the last one.

Doing so, we reduce the number of times the reference
to the cache key is stored in the dict.

For instance,
for 100.000 records, 20 fields and 2 env (e.g. with and without sudo)
formerly, there were 100.000 * 20 * 2 occurences of cache key references
now, there is only 2 references.

Storing references to an object consumes memory.
Therefore, by reducing the number of object references
in the cache, we reduce the memory consumed by the cache.
Also, we reduce the time to access a value in the cache
as the cache size is smaller.

The time and memory consumption are therefore improved,
while keeping the advantages of revision
d7190a3fd0
which was about sharing the cache of fields
which do not depends on the context, but
only on the cursor and user id.

This revision relies on the fact there are less different references
to the cache key then references to fields/records.
Indeed, this is more likely to have 100.000 different records stored
in the cache rather than 100.000 different environments.

Here is the Python proof of concept that was used
to make the conclusion that setting the cache_key
in the first level dict of the cache is more efficient.
```Python
import os
import psutil
import time

from collections import defaultdict

cr = object()
uid = 1
fields = [object() for i in range(20)]
number_items = 500000

p = psutil.Process(os.getpid())
m = p.memory_info().rss
s = time.time()

cache_key = (cr, uid)
cache = defaultdict(lambda: defaultdict(dict))
for field in fields:
    for i in range(number_items):
        cache[field][i][cache_key] = 5.0
        # cache[cache_key][field][i] = 5.0

print('Memory: %s' % (p.memory_info().rss - m,))
print('Time: %s' % (time.time() - s,))

```
- Using `cache[field][i][cache_key]`:
   - Time: 3.17s
   - Memory: 3138MB
- Using `cache[cache_key][field][i]`:
   - Time: 1.43s
   - Memory: 756MB

Even worse, when the cache key tuple is instantiated inside the loop,
for the former cache structure (e.g. `cache[field][i][(cr, uid)]`),
the time goes from 3.17s to 25.63s and the memory from 3138MB to 3773MB

Here is the same proof of concept, but using the Odoo API and Cache:
```Python
import os
import psutil
import time

from odoo.api import Cache

model = env['res.users']
records = [model.new() for i in range(100000)]

p = psutil.Process(os.getpid())
m = p.memory_info().rss
s = time.time()

cache = Cache()
char_fields = [field for field in model._fields.values() if field.type == 'char']
for field in char_fields:
    for record in records:
        cache.set(record, field, 'test')

print('Memory: %s' % (p.memory_info().rss - m,))
print('Time: %s' % (time.time() - s,))
```
- Before (`cache[field][record_id][cache_key]` and cache_key tuple instantiated in the loop):
   - Time: 4.12s
   - Memory: 810MB
- After (`cache[cache_key][field][record_id]` and cache_key tuple stored in the env and re-used):
   - Time: 1.63s
   - Memory: 125MB

This can be played in an Odoo shell, for instance
by storing it in `/tmp/test.py`, and then
piping it to the Odoo shell:
`cat /tmp/test.py | ./odoo-bin shell -d 12.0`

closes odoo/odoo#29676

closes odoo/odoo#30554
2019-01-25 16:25:27 +00:00
Denis Ledoux 79416ba6c4 [IMP] api: gain some memory by not creating the cache_key tuple multiple times 2019-01-25 16:24:59 +00:00
Raphael Collet f9582bf1db [FIX] base: missing tests on record cache 2019-01-25 16:24:55 +00:00
Hetal Dhanak 1dbef66b49 [FIX] web: date filter operators less than greater than
Before this commit, in the filter, when using a custom filter with a
date field, the operators "is after" and "is before" were set to execute
"is after or equal" and "if before or equal" respectively. That means it
includes in the results, records with the same date as the filter.

Now, the operators 'is after' and 'is before' won't include the records
with the same date as the filter. And the operators 'is after or equal'
and 'is before or equal' will include the records with the same date as
the filter.

Fixes #29868
OPW-1921756

closes odoo/odoo#30560
2019-01-25 14:53:56 +00:00
jev a4a3bfd373 [FIX] mail: activity, crash when activity type is null
When activity_type_id is null on an activity
marking it as 'done and schedule schedule next' crashed

OPW-1928989

closes odoo/odoo#30522
2019-01-25 09:51:34 +00:00
Bohdan Lisnenko 5abad42e7b [FIX] website_sale_comparison: keep attributes order consistent
Backport of 9298c576f4

+ adapt for v11

closes odoo/odoo#30305
2019-01-17 10:25:38 +00:00
Florent de Labarre 1c6c504215 [FIX] l10n_fr: set correct type for account 120 000
Because in France the affectation depends on the result (gain or loss) for the selection of account and thus, we cannot arbitrary choose one.
Was PR #17775

closes odoo/odoo#30527
2019-01-24 15:59:47 +00:00
Katherine Zaoral 43b7dfed67 [FIX] website_sale: do not replace context
Add quantity key to context instead of overwrite the entire context
If another context key was present, it would be lost

Introduced at 166a9d26e3

closes odoo/odoo#30519
2019-01-24 14:42:52 +00:00
Robot Odoo 8f47b028ed [IMP] l10n_be_hr_payroll_fleet, fleet: Adapt CO2 Tax up to 2019
Specification
=============

- Adapt the formula used in the code with the current legal value.
- Add the LPG fuel type in standard fleet module.
- Adapt the atn formula in the code with the current legal value.

Documentation:
https://finances.belgium.be/sites/default/files/downloads/121-faq-voitures-de-societe-2019-version17.pdf
https://www.socialsecurity.be/employer/instructions/dmfa/fr/latest/instructions/special_contributions/companycar.html

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

closes odoo/odoo#30484
2019-01-24 14:22:24 +01:00
sed-odoo dad59a62c3 [IMP] l10n_be_hr_payroll_fleet, fleet: Adapt CO2 Tax up to 2019
Specification
=============

- Adapt the formula used in the code with the current legal value.
- Add the LPG fuel type in standard fleet module.
- Adapt the atn formula in the code with the current legal value.

Documentation:
https://finances.belgium.be/sites/default/files/downloads/121-faq-voitures-de-societe-2019-version17.pdf
https://www.socialsecurity.be/employer/instructions/dmfa/fr/latest/instructions/special_contributions/companycar.html
2019-01-24 12:24:04 +01:00
Nans Lefebvre 8275b6eff8 [FIX] sale, sale_expense, sale_stock: make the False expense_policy selection behaves as 'no'
The sale.order model has an expense_policy selection field, with values in 'no',
'cost', 'sales_price'.
However that value can also be set to False.

The code that handles that field expected the value to always be set to a value.
We explicitly treat False as if it was 'no' (the default value for that field).

opw 1915508

closes odoo/odoo#30336
2019-01-24 07:12:33 +00:00
Christophe Simonis 984a99611e [FIX] l10n_be_intrastat_2019: Python3 compatibility
Oversight of previous forward-port
2019-01-23 16:40:41 +01:00
Christophe Simonis 51a76880f2 [MERGE] forward port branch saas-15 up to 3cba1862d4 2019-01-23 16:05:02 +01:00
Christophe Simonis 3cba1862d4 [MERGE] forward port branch saas-14 up to 81c9e28eab 2019-01-23 15:23:00 +01:00
Christophe Simonis 81c9e28eab [MERGE] forward port branch 10.0 up to f3de712d76 2019-01-23 15:21:30 +01:00
Christophe Simonis d870fd555e [MERGE] forward port branch 10.0 up to 90c1af1151 2019-01-23 14:08:50 +01:00
Nicolas Seinlet 3f4d1e1fbe [IMP] mrp,stock_account: faster computation
Use read_group is faster than the python equivalent,
and then don't push ids in ORM cache, which makes
the ORM faster later in the process.
Also unlink in batch.
2019-01-23 10:30:49 +01:00
Waleed Mohsen 4c5de1c37c [CLA] signature for MohsenWaleed
closes odoo/odoo#30441
2019-01-23 08:23:38 +00:00
Nicolas Lempereur 90c1af1151 [FIX] web: no chrome autocompete on many2one widget
For editing many2one fields (and partially many2many) most widget show
an autocompleting list of targeted records.

They thus have `autocomplete="off"` to prevent browser completion.

But chromium has an history of breaking `autocomplete="off"`, see:

- https://caniuse.com/#search=autocomplete
- https://crbug.com/468153
- https://crbug.com/587466
- https://crbug.com/914451
- https://crbug.com/923895

It seems that since chromium 71, the heuristic to ignore
`autocomplete="off"` has become more aggressive and for example if there
is at least 3 fields like an address in a page, chromium will ignore
`autocomplete="off"` for the fields like an address.

So for example the eidting the many2One field with placeholder "Country"
in a contact page now has a browser autocomplete menu that is:

- hidding the many2one autocomplete
- going to save empty country it appeared visually filled if the
  autocomplete result was selected.

With this changeset, the placeholder in the many2one instance is
interspersed with U+FEFF charcters (ZERO WIDTH NO-BREAK SPACE) so the
browser does enable the autocomplete feature by force.

This should thus remove the issue (until it is fixed by chromium) in the
case of field named "Country" or matching other regexes in this file:

https://github.com/chromium/chromium/blob/cdb1b2073f12/components/autofill/core/common/autofill_regex_constants.cc

U+FEFF has been chosen instead of more recommended characters because
other have been shown erroneous for printing in some windows
configuration (see cb2a3afa7).

10.0 version of #30439
opw-1930588
closes #30439
closes #30449
2019-01-23 01:09:22 +00:00
Florent de Labarre d3affc5798 [FIX] sale: don't send duplicate email
closes odoo/odoo#30455
2019-01-23 07:31:50 +00:00
Nicolas Martinelli b95affa3ee [FIX] sale: taxes and untaxed amount
- Create a SO, do not set a partner
- Add a product with a tax

The untaxes amount as well as the taxes remain 0.0.

This is because there is no pricelist, therefore no currency.

There is actually no need of rounding explicitly since these are
monetary fields which will be rounded automatically.

opw-1931796

closes odoo/odoo#30450
2019-01-22 16:34:31 +00:00
Christophe Simonis c0471dd857 [MERGE] forward port branch saas-14 up to 17adccd95c 2019-01-17 18:07:26 +01:00
Christophe Simonis 17adccd95c [MERGE] forward port branch 10.0 up to 50bae1c0c5 2019-01-17 17:08:39 +01:00
wan 50bae1c0c5 [FIX] account: journal dashboard graph wrong value
OPW 1918926

Current behavior:
  The sql query groups by date,id in a intermediary table instead of the result. This allows to get data in the wrong order if the statements were not produced sequentially. The fill values are computed in the wrong order and may override correct values.

Desired behavior:
  There is no override of the values correctly computed.

closes odoo/odoo#29936
2019-01-17 12:37:36 +00:00
Lucas Perais (lpe) ba39efdfc6 [FIX] base: merge contacts linked to by an o2m field with caps
Define a field on a model as:
- o2m to res.partner
- the field's column, hence its name, has capital letters in it
(studio does that)

create two objects of that class, each one linked to a different partner with the new o2m

merge the partners

Before this commit, the object linked to the second partner, was deleted
This was because merge partner sql requests did not quote the column name

After this commit, the second object still exists

This commit is tested in v12.0 with PR #30300 only. In v10.0 it is not testable as
the model concerned is in CRM, and that no new fields in business modules can be added in stable

OPW 1925060

closes odoo/odoo#30301
2019-01-17 09:59:23 +00:00
Denis Ledoux a409627602 [FIX] ir_ui_view: do not change view mode when just changing the inherit
Some views have the primary mode while having an inherit_id view
In such views, if the user wants to change the inherit_id,
the mode must remain primary.

The use case behind this is a user who want to change
the inherit_id view of the view
product.product.form (product.product_normal_form_view)
to another view.
This view is in primary mode while having an inherit_id
(product.product_template_form_view).
In such a case, the primary mode must remain,
otherwise the view will no longer be opened by default
when opening a product.
Indeed, when searching the default form view of a model,
it only searches for primary mode views for this model.

The `all` is there because this is an `api.multi` method.
We could consider adding a `self.ensure_one`,
but it breaks the API if someones calls this method with multiple records.
This is likely to happen, as this method is used
in `write` which is likely to be called with multiple records.

In my opinion, in master, this should be replaced by an
onchange so the user can see the change of mode
when he adds or remove an inherit_id for a view.

opw-1916324

closes odoo/odoo#30241
2019-01-15 16:43:08 +00:00
qdp-odoo c5a8e39758 [FIX] l10n_be_intrastat: adapt to new regulation for belgian intrastat
This is essentially a backport of module l10n_be_intrastat_2019 made for
Enterprise v12 + the refactoring needed on the original v10 module to
allow the changes to apply where needed.

Was requested by opw-1887019

closes odoo/odoo#30400
2019-01-22 07:22:59 +00:00
Christophe Simonis a909bb3391 [FIX] bus: correctly compute presence of partners with multiple users
closes odoo/odoo#30344
2019-01-18 10:39:00 +00:00
Christophe Simonis 3374ac805f [MERGE] forward port branch saas-14 up to 28785f21e4 2019-01-15 11:45:44 +01:00
Christophe Simonis 28785f21e4 [MERGE] forward port branch 10.0 up to 6edfadbdd2 2019-01-15 10:48:11 +01:00
Julien (juc) Castiaux 357b374a7e [FIX] mail: URL with semi-colon
When posting a URL containing a semicolon, odoo stops the link
before the semicolon instead of continuing the link to the end
although it is a valid characters in URL (see RFC-3986)

e.g. the url "example.com&foo;bar" matches "example.com&foo"
     instead of the whole link

opw-1918367

closes odoo/odoo#30198
2019-01-15 09:02:12 +00:00
Nicolas Martinelli 180ace7b1b [FIX] product: unwanted attribute values in name
- Create the following attributes with values:
  Size: S, M, L, XL
  Color: Black, White
- Create a product template with the following attribute values:
  Size: S, M, L, XL
  Color: Black

The `name_get` of `product.product` returns `Name (SIZE, Black)` while
it should only return `Name (SIZE)`.

When using `attribute_id.value_ids`, the list of values contains all
possible values of the attribute, not only the values which apply to the
given product. In this case, it contains 'Black' and 'White', therefore
the condition `> 1` is verified and the attribute is kept for display.

We go back to the original filtering, and add `attribute_line_ids` in
the list fields read in order to avoid prefetching.

opw-1922140
opw-1922447

closes odoo/odoo#30273
2019-01-16 14:48:33 +00:00
Joren Van Onder 302d8a5264 [FIX] point_of_sale: allow refunds on non-cash journals
Cherry pick of 5b769650d6 in version 11.0

A customer can pay an order with a non-cash journal (e.g. a credit
card through a stand-alone terminal).

When this order has to be refunded later it should be possible to do
so on that same journal.

Some code prevented this from happening, notably a check in
order_is_valid which explicitly prevented this for an unknown
reason. There is no explanation in the
commit (4647f896a4) introducing that.

This commit allows the following:

1. input what you want to refund with a negative qty
2. click 'Payment'
3. click the Credit Card (type Bank) journal
4. (amount is auto-populated)
5. click 'Validate'

opw-805302
opw-1913731

closes odoo/odoo#30218
2019-01-16 14:19:13 +00:00
Nicolas Martinelli 614babd1e7 [FIX] account: bank statement with many AML
- Create a bank statement with more than 80 lines (therefore more than
  80 AML)
- Reconcile the lines
- Go back to the bank statement, and try to add a new line

An error arise:
"You cannot do this modification on a posted journal entry, you can just
change some non legal fields"

The error arise on the `move_line_ids` field on which the web client
tries to write.

Actually, this field is hidden since it is only used in the domain of a
stat button. We can make it read-only.

opw-1921138

closes odoo/odoo#30266
2019-01-16 11:09:21 +00:00
Iryna Vyshnevska 92e4c4c347 [CLA] signature for ivyshnevska
Backport to 10.0 of 3b14a7daa6

closes odoo/odoo#30090
2019-01-16 10:03:03 +00:00
Manuel Vázquez Acosta 6ac32c655e [FIX] survey: don't disclose the survey via print
To avoid bigger changes, only verify if the login is required.
A proper refactoring has been implemented in master at 9771fdfe8f

Closes odoo/odoo#30166
2019-01-16 12:51:43 +01:00
larisa 6edfadbdd2 [FIX] hr_payroll_account: correct account move lines creation
The super call of action_payslip_done executes the method compute_sheet.
Without this compute_sheet call, there is no salary lines and no accounting
move is created.

closes odoo/odoo#29737
2019-01-14 15:16:44 +00:00
Manuel Vázquez Acosta 9c6d969775 [CLA] Add Larisa to Merchise Autrement. 2019-01-14 15:05:40 +00:00
Nans Lefebvre 573ce17d0a [FIX] mail: keep attachments when switching between note and message
Start a message mail (respectively note) in the chatter. Attach a file.
Switch to note (respectively mail). The attachment is lost.

With this commit, we keep the attachments after the switch.

opw 1925588

closes odoo/odoo#30197
2019-01-14 14:54:47 +00:00
ougc27 8cba55ce31 [FIX] stock_landed_costs: cost account when dropship
- Set FIFO as costing method in product category
- Create a stockable product with the category configured previously
- Create a SO with the stockable product for 1 unit with dropship route
  and confirm the SO
- Confirm the PO created from the Sale Order to generate the delivery
- Process the stock picking
- Create a new Landed Cost with the stock picking delivered with a cost
  line with split method "Equal".
- Generate the valuation adjustments and confirm the landed cost to
  generate the journal entry

The debit account is wrong because the system takes the inventory
valuation account instead the expense account.

Odoo must take the expense account because the product never enter to
the company inventory, so is a cost of sale.

opw-1922633

closes odoo/odoo#29947
2019-01-23 10:59:11 +00:00
wan 017184331b [FIX] account: get credit and debit regarding to company
Detected with OPW 1920765

Reproduce : set multi-companies, install accounting. The due amount for all companies is the sum of the due amount for every single company

Cause : the context for company_id is not set in account.move.line:_query_get

Solution : set it in res.partner:_credit_debit_get in case _query_get is used elsewhere

closes odoo/odoo#30463
2019-01-23 09:15:17 +00:00
Nans Lefebvre 8ac0e8e447 [FIX] delivery: make the form view work from the Install more Providers action
Go to 'delivery methods', edit a delivery method.
Click on 'install more providers'.
You land on the 'Apps' app, already filtered on the 'delivery_' modules.
Click on 'more info' of a module: nothing happens.
It should open the form view of the module.

What happens is that the action doesn't contain 'form',
so the framework fails to open the form view from the kanban view.

opw 1928711

closes odoo/odoo#30437
2019-01-22 13:17:52 +00:00
Nicolas Martinelli ac270d63ad [FIX] stock_account: Average Cost
- Create a product where the associated product category has Costing
  Method "Average Cost (AVCO)"
- Create a PO. Order:
  2 units at 40
  4 units at 35
- Receive the picking

The cost of the product is set at 35 (or 40, depending on the order of
the lines in the PO).

Since we are in a situation where the available quantity is zero, we
enter in the `if float_is_zero...` condition, where the `qty_done` is
not set.

We should set it in all cases.

opw-1907328

closes odoo/odoo#30422
2019-01-22 09:28:34 +00:00
Nicolas Seinlet 15520c8e58 [IMP] sale: better use of the ORM
Search outside of the loop, use read_group, ...

closes odoo/odoo#29668
2019-01-22 12:00:47 +00:00
Jorge Pinna Puissant d79007cb09 [FIX] account: Date maturity in duplicate journal entry.
Before this commit, when the journal entry date was duplicated, the
maturity date (in the journal entry lines) stayed unchanged (it kept the
values of the original journal) and the user wasn't able to modify it.

Now, when the user duplicated a journal entry, the user can modify the
maturity date.

Note that, as is the case for the journal entry date, the maturity date
can't be modified after saving the journal entry.

OPW-1914706

closes odoo/odoo#30393
2019-01-22 10:29:35 +00:00
Nicolas Martinelli 79bfb23488 [FIX] website_sale_wishlist: new price
- Create a Public Pricelist without discounts
- Create a pricelist with a discount for all products, with 'Discount
  Policy' set to 'Show public price & discount to the customer'
- Assign the discount pricelist to the administrator partner
- Go to the eCommerce as public user (or any user with the Public
  Pricelist as default)
- Add a product to the Wishlist
- Go to the Wishlist

The discount of the admin pricelist is shown.

This is because the `product.wishlist` is browsed as superuser and the
computed field `price_new` depends on the user (ultimately through
`_website_price`)

opw-1912726

closes odoo/odoo#30358
2019-01-18 13:12:36 +00:00
Nans Lefebvre 102467ae23 [FIX] sale: add force_save on product_uom in views
Create a sale order. Confirm it. Add a new line. Change the UoM on this line.
The onchange is applied, modifying the unit price.
Save: the saved product UoM is the default one.

So for example if the user changes the UoM from day to hours,
he will sell one day for the price of one hour.

This is because the field product_uom is set to read_only if the state of the
sale order is confirmed ('sale') (as well as if the state is 'done' or 'cancel')
However it is still possible to change it when adding a new line.

opw 1923534

closes odoo/odoo#30420
2019-01-22 07:36:40 +00:00
José Francisco Martínez Salgado 16b873c771 [CLA] signature for xyvs
closes odoo/odoo#30372
2019-01-21 15:26:55 +00:00
qsm-odoo 6930f9c353 [FIX] web_editor: restore less files edition
Broken by https://github.com/odoo/odoo/pull/30186

closes odoo/odoo#30403
2019-01-21 11:38:32 +00:00