Steps to reproduce:
1. Install stock
2. Go to Inventory > Products
3. Cog wheel > Import records
4. Make a xlsx document where:
5. the first sheet has at least 2400 records (with header)
6. the second sheet only one record (with header)
7. Upload the document
8. Select the second sheet
9. Set batch limit at 2000
10. Click on import
11. 2 records successfully imported
Cause of the issue:
When initially uploaded, this.state.fileLength
is set to the length of the first sheet
And isn't refreshed when changing sheet
opw-3507544
closesodoo/odoo#139470
X-original-commit: 27f0a0253bc9b44854e5d6436d6e550429cdb93c
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
Signed-off-by: Antoine Demany (ande) <ande@odoo.com>
When a user tries to import the CSV file with an empty text delimiter
or more than one character in text delimiter at that time the traceback
will be generated.
Steps to reproduce:
- Install Accounting module.
- Click on import in the bank statement.
- Select any CSV file for the bank statement line or can download and import
this file - https://drive.google.com/file/d/1lnScw4RN6T01pOkyNON8vvb3FQOPiy1O/view?usp=drive_link
- Enter empty text delimiter or more than one character in text delimiter.
- Click on the test or Import button.
- Error will occur.
Error: ValueError: Unsupported file format "text/csv", import only supports
CSV, ODS, XLS and XLSX
The issue is occurring because text delimiter (options['quoting']) is used
as quotechar while reading csv file and quotechar is always a single
character string. Check here -
https://github.com/odoo/odoo/blob/0fde590bee71618f78e5f954349530bd007c62cf/addons/base_import/models/base_import.py#L494-L497
To solve this issue the length of text delimiter has been checked and if it
is not equal to one then a warning is given to the user.
sentry-4390461991
closesodoo/odoo#138638
X-original-commit: 1f4aa620779ebe6a0cb7f7ca1910080a258d6fac
Signed-off-by: Achraf Ben Azzouz (abz) <abz@odoo.com>
Signed-off-by: Saurabh Choraria (sauc) <sauc@odoo.com>
This issue occurs when a customer imports or uploads a file, and that file
contains an image that is attached to the URL as text or HTML. then,
The error would be generated.
Step to Produce:-
- import CSV file (Ex.'product.product' model)
> that CSV file must have one URL Image(In that URL has content of text or
Html form)
- Click On the 'Test' Button.
Applying these changes will resolve this issue.
sentry:-4046190590
closesodoo/odoo#137611
X-original-commit: acbb5af7ee96cdc579850427bc2bca6d7bf184e4
Signed-off-by: Achraf Ben Azzouz (abz) <abz@odoo.com>
Steps to reproduce:
1. Install hr_attendance
2. Go to attendances
3. Select any line
4. Change the check-out date to next day
5. Change the check-out time to 00:00:00
6. Export that line, file format xlsx
7. Favorites > import records
8. Upload the exported file > Test
9. Column check_out contains incorrect values.
Error in line 2: unconverted data remains: 2023-06-11
Cause of the issue:
options.get('date_format') is empty
opw-3374883
closesodoo/odoo#136485
X-original-commit: 973af5854de4a9fa3a9f5bd3bca8c7b342ff71e9
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
In this viewtiverse, the heroes remove the context dependencies for
`get_views`, from the views and python fields (such as domain). To reduce
inconsistencies and the number of rpc.
Current issues:
* There may be inconsistencies in views at the JavaScript level. Some
overrides modify the behavior of get_views or domains on fields via
context keys, therefore by changing the action, the rendering may be
different. However, these views are cached. However, the cache key
(Javascript) does not reflect the entire context, and requires additional
post-processing from the server.
* Multiple rpc for the same rendering. get_views being dependent on the
context, as soon as it changes, a new rpc is performed. In most cases,
when JavaScript needs the same view, there is no change depending on the
context, the rpc is useless.
* Inconsistency when rendering subviews, some views could be different
depending on the context, this context can be modified in the view itself
via the context attributes. However, the JavaScript client does not redo
an rpc for each change of these sub-contexts. Therefore the result may be
inconsistent.
Solution:
Limit as much as possible the number of context keys provided when calling
get_views, and use the context provided as a cache key. The authorized
keys are 'lang' and '*_view_ref'. For the cache key, options are added in
the get_views method.
Instead of using the context, it is inserted into python expressions.
This will be evaluated by JavaScript and thus avoids inconsistencies.
task-3414108
task-3414068
closesodoo/odoo#135145
Related: odoo/enterprise#47584
Signed-off-by: Raphael Collet <rco@odoo.com>
Before this commit, when selecting the field to import, the name, external
id and database id could not be selected separatly while they should.
This commit fixes that by comparing the full field path instead of the id
of the fields.
closesodoo/odoo#135482
X-original-commit: 587ee0797bd0075dc7d3a0393ec95360c8ab0770
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
When a user tries to import the CSV file with a different separator at that
time, the values in mapper and rows_to_import are not correctly mapped. So
the traceback will be generated.
Steps to reproduce:
1. Click on import in the bank statement.
2. Select any CSV file for the bank statement line or can download and import
this file https://drive.google.com/file/d/1lnScw4RN6T01pOkyNON8vvb3FQOPiy1O/view?usp=drive_link
3. Select any separator other than a comma.
4. Click on the test or Import button.
5. Error will occur.
Error: IndexError: list index out of range.
To solve this issue, a row's length is checked with the
number of fields.
sentry-4021250095
closesodoo/odoo#134596
X-original-commit: 0eb30132c14420d42f88a5f54a81ba1dc51a867c
Signed-off-by: Achraf Ben Azzouz (abz) <abz@odoo.com>
Signed-off-by: Saurabh Choraria (sauc) <sauc@odoo.com>
This partially reverts commit da50ce31ae825ef9f4b527553a2e2caec970d290.
Whilst the behavioral changes done in the task are correct, the wording
is not optimal and was better understood by users before this change.
Task-3483936
closesodoo/odoo#133511
Related: odoo/enterprise#46503
Signed-off-by: Florent Dardenne (dafl) <dafl@odoo.com>
Issue :
When you try to import a big file it will display a blank error.
Steps to reproduce the error :
1-install inventory and e-commerce
2-go to products and import records
3-upload the file attached the ticket
Reason :
Before, there was a type included in the `reason` but now
it seems that the error has no type neither a message.
Fix:
I tried to just output a general error.
opw-3410954
closesodoo/odoo#133950
X-original-commit: 95cc5c84c3b4529cd269cf278fd4ab289f28685f
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
In this commit, all usages of env._t() are replaced by _t().
In templates files, env._t() didn't work because terms used
in attributes where not extracted into the translation files.
Only string are exported from .xml files to translation files.
So, to make it works, we set a variable that is then used
in attributes.
For example :
<t t-set="string_to_translate">String to translate</t>
<Dialog title="string_to_translate>...</Dialog>
task-3292454
closesodoo/odoo#131390
Related: odoo/enterprise#45631
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
Goal:
* Simplified modifiers to only have one way to define modifiers;
* Remove states attributes on python field;
* Use python expression in view `required`, `readonly`, `invisible`;
* More accurate validation of xml views.
This commit change the syntax to python expression. The next commit
will update/convert all xml views.
Before this commit:
* the `required`, `readonly` and `invisible` attributes can only have
values of `True`, `False`, 1, 0 or a python expression to use the
context;
* the `attrs` attribute define a dict. The key of this dict was
`required`, `readonly` and `invisible` and the values are the domain or
a string representing a domain to be evaluate as python expression.
This python expressions was evaluate by the javascript with view fields
and other contextual values as: context, uid, parent, active_id,
active_ids, active_model, allowed_company_ids, current_company_id.
* the `states` attribute in the view was a comma separated list of the
state. This list was combined with the `invisible` attribute;
* the `invisible` attribute on python field is used as default value;
* the `states` attribute on python field was dictionnary with state as
key and list of tuple. This structure was combined with `readonly` view
attribute.
* After combining, the resulting domains of the different attributes
`required`, `readonly` and `invisible` are evaluated with the values of
the fields. The `invisible` attributes is splitted into two use:
`invisible` and `column_invisible`.
After this commit:
* The attributes `required`, `readonly`, `invisible` and
`column_invisible` define python expression. This python expressions
are evaluate by the javascript with view fields and other contextual
values as: context, uid, parent, active_id, active_ids, active_model,
allowed_company_ids, current_company_id.
The domains can contains contextual value and will be evaluate by the
javascript.
```xml
<field name="field_a" readonly="not context.get('show_a')" attrs="{'readonly': [('field_b', '!=', False), ('field_c', '=', parent.c)]}"/>
<field name="field_b" states="draft"/>
```
will be replaced by
```xml
<field name="field_a" readonly="not context.get('show_a') or field_b and field_c == parent.c"/>
<field name="field_b" invisible="state != 'draft'"/>
```
Some inherited views will be modified differently in order to maintain
the previous behavior:
```xml
<field name="field_a" readonly="not context.get('show_a')" attrs="{'invisible': [('field_b', '!=', False)]}">
```
```xml
<field name="field_a" position="attributes">
<attribute name="attrs">{'readonly': [('field_c', '=', False)], 'invisible': [('field_d', '!=', '3')]}<attribute>
</field>
```
will be replaced by
```xml
<field name="field_a" readonly="not context.get('show_a')" invisible="field_b">
```
```xml
<field name="field_a" position="attributes">
<attribute name="readonly" add="(not field_c)" separator=" or "/>
<attribute name="invisible">field_d != 3<attribute>
</field>
```
Validation:
A stricter control is made on the level of the attributes (modifiers)
and the fields necessary for these. The use of the previous attributes
'attr' and 'states' triggers an error (these no longer exist after the
application of the migration script)
task-2495504
Part-of: odoo/odoo#104741
As all the templates are now imported in the owl app, there is not need
anymore to specify the owl="1" attribute in the templates.
Part of task~3443861
Part-of: odoo/odoo#130467
Improve gettext to directly handle value injection within translations,
removing the need for sprintf.
closesodoo/odoo#123932
Related: odoo/enterprise#45370
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
In the commit [1], the patch has been refactored to support the
native keyword `super`. The current commit just adapts the codebase
to that change.
task 3410198
[1]: 19ea1ac08043e22a811630968e44715cc3bfc495
Part-of: odoo/odoo#125716
One of the main issue with ormcache is that the invalidation clears
everything, meaning that some value, slow to compute but with a long
lifetime, can be removed from the cache because an easy to invalidate
value is cleared, like after writting or creating a product has an
example.
Most example in the code will try to invalidate the cache of the models
doing something like `env['ir.qweb'].clear_caches()` but it is
finally equivalent to `env.registry.clear_cache()`, and cross worker.
The idea is to have multiple cache, maybe with specific sizes for a
specific purpose.
Having one per model is maybe a bad idea because it will be difficult
to size the LRU correcly, and it is too dynamic. Checking invalidation
may be expensive.
The proposed solution is closed allow a limited number of named caches,
using onse sequence per cache. This is actually close to the
cache_longterm.
We want to discourage using a specific cache for one use case in
the buisness code. Adding a cache shouldn't be something easy, doable
in stable.
Note that we could also change the invalisation mecanism using an
insert only table. We an check the sequence of this table, but also
fetch all invalidation messages.
Another possible improvement, especially if we have more than x cache is
to have a global sequence, checking signaling would mean to check the
main sequence, and only the other ones if the main one changed.
Note that this poc is inspired from the long term cache but not all
use case where applie yet.
Part-of: odoo/odoo#119813
This commit changes the behavior of the "Search More..." option in
Many2XAutocomplete and analytic distribution by making it available
as long as there's at least one record in the search results and by
renaming it to "View all".
task-3258625
closesodoo/odoo#126041
Related: odoo/enterprise#43660
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
*: account, base_import, board, website
This PR enhances the "cog menu" by fixing several UX flaws.
Notable improvements include:
- Reordering entries in a more logical manner, enhancing user intuitiveness.
- Assigning icons to common actions for quick comprehension.
- Grouping both print actions and module-specific actions for better organization.
Enterprise:
- https://github.com/odoo/enterprise/pull/41851
task-3337951
task-3355224 (milk post-merge fixes)
part of task-3326263
closesodoo/odoo#124413
X-original-commit: 596772885a87016d29f002cd4e41b5a973965e40
Related: odoo/enterprise#42212
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
Co-authored-by: Brieuc-brd <brd@odoo.com>
Co-authored-by: Pierre Paridans <app@odoo.com>
Co-authored-by: stefanorigano (SRI) <sri@odoo.com>
=== ISSUE ===
If you go to PLM > click on a primary button > click on the cog >
import records, the buttons have a `.m-1` which is added on top
of a `.gap-1`.This result in a double margin, which is not consistent
with other CP's behavior and affects the whole CP layout.
=== AFTER ===
We remove these unnecessary `.m-1`, making sure that no matter how many
buttons are shown they have a correct spacing.
task-3355375
part of task-3326263
closesodoo/odoo#124337
X-original-commit: 40666bfe89ff5bc9013fbb20928c18001b66c6ad
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
When user tries to add non ascii characters in image field column in a file and
then when he tries to import it the error will occur.
Steps to reproduce:
1. Install contacts
2. export a contact and keep image field in fields to export.
3. Now in that file change the image data and add non ASCII characters
(for example: 'ô').
4. Now try to import this file in contacts.
5. The error will occur.
Applying this commit will fix this issue.
Currently, a ValueError is raised when we give non-ascii characters as input.
So I have reported an issue in python in which I have mentioned to edit the
documentation to note that it may raise ValueError for non-ascii content, or
to fix '_bytes_from_decode_data' function to raise binascii.Error instead of
ValueError.
To track the issue - https://github.com/python/cpython/issues/105193
sentry-4029823200
closesodoo/odoo#123572
X-original-commit: ceb67160e1747f0a886efb8ca0a60499e2b080d1
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Currently, only stable releases see their translations updated. This has
resulted in master accumulating outdated stuff for years, which can be
confusing for users testing master on runbot.
This one-shot commit resynchronizes master translations based on the
content from 16.0 and removes empty PO files (i.e. no longer containing
translations).
closesodoo/odoo#121629
Related: odoo/enterprise#41171
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
[FIX] *: selectors in tours
[FIX][TMP] account: CogMenu selector in tours
[FIX][TMP] web*: Breadcrumb targetting in tours
Adds a `o_breadcrumb` class to target the whole breadcrumb, no matter
how much elements it contains (collapsed parts, visible path, single
name...).
add classname on last breadcrumb item
[FIX][TMP] project: View buttons selector in tours (moved away from CP)
[FIX][TMP] project: Kanban selectors in tours (quick create)
[FIX][TMP] *: SearchBar selectors in tours (toggle menu)
[FIX][TMP] *: ButtonBox selector in tours
[WIP][IMP] web: add toggleSearchBarMenu in search helpers
adapt and unskip 3 list tests
adapt and unskip calendar tests
unskip web_tour test that actually pass
post rebase fix
allow to lose cell focus after multi edition (given to searchbar) - bug reported, to check later
post rebase fixes
fix
Part-of: odoo/odoo#116641
This commit adapts the directional icons to improve the usability and
maintain consistency with the ui icons library.
task-2818586
Part-of: odoo/odoo#116641
This commit brings the ControlPanel into a single line with 3 main
sections:
- buttons & breadcrumb
- layout related actions (ie. the SearchBar in multirecord view or
ButtonBox in formView)
- navigation (pager, switch view...)
Add new search bar menu, this is a merge of the following components
into one big component display in column:
* comparison_menu
* favorite_menu
* filter_menu
* group_by_menu
Also adapt navigation hook.
Part-of: odoo/odoo#116641
This commit improves the suggestions displayed to the user when editing
the date or datetime options in the sidebar of the Import action.
A tooltip is also displayed next to each label, to let the user know how
to format properly the date if he wants to write a custom one to match
his own needs.
Since commit [1], a legacy utils was imported to convert a moment format
to strftime. Since this file was legacy, it was needed to remove its import
from the import action and replace it with a newer utility function. Because
this function was not imported elsewhere, it could be removed completely.
In dates.js, a new function allow a user to write a date format in a
human readable format, while converting it to a valid Python strftime
format, to send back to the server the right date.
A test has been added for this improvement.
[1]: 2361f021c3
task-3248787
closesodoo/odoo#117750
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
When we try to import bank statement CSV file with all required columns and
set the encoding format as koir8_r we get (ValueError: Unsupported file format
text/csv, import only supports CSV, ODS, XLS and XLSX) this error.
steps to reproduce:
1. Go to accounting and then import bank statement.
2. Select a csv file to import with all required columns.
3. Set Encoding format as koir8_r and then click on 'TEST' or 'IMPORT'.
4. The error will occur.
see this traceback: https://tinyurl.com/24bxk7bt
Applying this commit will fix this issue.
sentry-4049996747
closesodoo/odoo#120054
X-original-commit: 7270bbf589a9d3d794e399b3cf3ad18acf7a2ed6
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
With commit (1), the clear button is only displayed when a selected
value is found from the available choices. But since we used
shallowEqual to find the corresponding choice, we couldn't use objects
containing objects in its values, since a simple comparison was made
in the utility function. This was a wrong usage of the SelectMenu and
we don't want to support objects and arrays as values. The value
attribute should only be a string, and it's the parent responsability
to handle any object related to this string.
The test using an object and an array as values has been removed since
it had no purpose after the removal of this partial and wrong support.
With this fix, an assertion for the presence of the clear button has
been added instead for the import action.
(1): d760b81271closesodoo/odoo#119298
Related: odoo/enterprise#40177
Signed-off-by: Géry Debongnie <ged@odoo.com>
When importing documents that have a `date` or a `datetime` field
a conversion is done on the format string in case it was still in the
old moment format (e.g. YYYYMMDD).
The problem is that this conversion was done regardless if the format
string was valid or not. This was producing botched format strings that
would prevent any import having a date or datetime field with proper
format string.
closesodoo/odoo#119340
X-original-commit: 20f4102e9aef42c557c6f7e0b5b5e591a18b1b4f
Signed-off-by: Luca Vitali <luvi@odoo.com>
Add support for converting moment.js date formats
to strftime format in BaseImportModel
Steps:
- Try to import csv with date_format "YYYYMMDD"
- ImportValidationError:
-> "Column date_format contains incorrect values"
error is raised because the date format is not
converted before being send to the python import
method.
opw-3247615
closesodoo/odoo#118308
X-original-commit: ee940fc6911656263fb56f9ce63a564f45cdc16b
Signed-off-by: Luca Vitali <luvi@odoo.com>
Signed-off-by: Guillaume Vanleynseele (guva) <guva@odoo.com>
They dates from < 2027 and are quite outdated. Favour the nl
translation instead.
n_BE is not on Transifex so it was not possible to correct bad
translations.
closesodoo/odoo#115845
X-original-commit: d04c8b7e484db8306d858c891a7a2b11885fdcd9
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
To reproduce
============
- on any app try to import a record that has subfields
- subfields are not matched and not even found on the list
Problem
=======
comparing to 16 **Allowing subfields matching** is disabled here in 16.1,
because of this condition that is checking the list of fields on a variable `fields`,
but this variable is not set before importing the file, so the condition is always true.
Solution
========
apply the condition on `res.fields` instead
opw-3209365
closesodoo/odoo#115639
X-original-commit: 284fab64e33ca398a0ebf69d3d6d59685480156d
Signed-off-by: Luca Vitali <luvi@odoo.com>
Before this commit:
=====================
KeyError 'selection_values' that occur in base_import/_handle_fallback_values()
while importing a data file. If any field(s) is many2one or many2many and we
tried to import the value of that field(s) that is not created in the database.
In that case when we set the 'Prevent Import' option.
It will raise an error like KeyError: 'selection_values'.
After this commit:
=====================
Solved the issue when there is a many2one or many2many field(s) and the import
value of that field(s) which is not available in the database. also, the method
is only for the 'selection' field and 'boolean' field so the code works when
there is a selection field and their selection_values only.
sentry - 3958065223
closesodoo/odoo#115056
X-original-commit: 0ef930cd7598bd15227ff025d2662d4331f8e45b
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
This commit fixes a couple of issues linked to relational fields:
- When previewing a file with relational fields/ids, they were not
correctly mapped to their respective fields in the selects, the fields
were also not correctly mapped in the arguments given for the import.
- The select label was also only showing the name of the last sub-field
while it should show the full path ("External ID" vs "Company / External
ID").
- Some errors were not correctly displayed: wrong field name, not in a
column when it should be.
Task ID: 3210337
opw-3203704 + opw-3192403
closesodoo/odoo#114490
X-original-commit: 871690afdc2ce4da2770a144cc4fc5ed038e6f73
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
During the conversion to Owl of the base_import action, the fields
mapping for each column was made incorrect.
The fields are now properly sorted between the suggested, additional and
relational categories and the subfields are also correctly handled (no
more duplicates and correct labels).
closesodoo/odoo#109416
Signed-off-by: Luca Vitali <luvi@odoo.com>
In the default import options, some separators had a wrong value by
default. This commit fixes those, which will fix some failing imports.
A test has been added to verify the default options set.
closesodoo/odoo#108710
Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
This commit removes the state-machine.js library. It can be remove as
this library was mainly used to handle the import action process, and
that it has been rewritten without the need of the library.
Copyright mentions to the library have also been removed, since it is no
longer necessary.
closesodoo/odoo#106265
Related: odoo/enterprise#34249
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit reimplements the import action view to fully use Owl instead
of its legacy implementation. Different components have been created to
separate the UI in smaller blocks, and a model file contains the main
aspects of the import logic.
The SelectMenu component is now used instead of the jquery select2, and some
other web components and hooks have been used or modified to bring this
action to a better state. A custom ImportBlockUI component is used, to
support custom messages and the use of components. It was required to
reimplement the loading progress and indicator used by the view.
The set_file route in the base_import controller has been adapted to remove
the usage of jsonp type of code for this situation since it is no longer
needed nowadays.
On top of the rewrite, js tests have been added to make sure the feature
behaves correctly, and to assert the intended specs.
Finally, legacy files have been removed, since they are no longer required.
Enterprise PR: https://github.com/odoo/enterprise/pull/34249
task-3092474
Part-of: odoo/odoo#106265
Co-authored-by: Bastien Fafchamps <bafa@odoo.com>
The main goal of this commit is to reduce the size of the registry by
removing the (almost) useless __last_update field.
Statistics # of fields with all modules installed:
before 30184 fields, 1299x last_update (4.30%)
Before this commit, the computed field __last_update was added on every model.
The idea behind this field was to have a computed field that had either
the write_date or the create_date if the write_date was empty. However,
the write_date is always written, even on creation, making it useless
to have the computed field __last_update
After this update, we completely remove from BaseModel:
* __last_update
* CONCURRENCY_CHECK_FIELD that was always defined as "__last_update"
* _compute_concurrency_field that was the compute function for __last_update
closesodoo/odoo#105739
Task-id: 3062140 (part of 3062137 improve registry load time)
Related: odoo/upgrade#4038
Related: odoo/enterprise#33939
Signed-off-by: Raphael Collet <rco@odoo.com>
Translated fields no longer use the model ir.translation. Instead they store
all their values as JSON, and store them into JSONB columns in the model's
table. The field's column value is either NULL or a JSON dict mapping language
codes to text (the field's value in the corresponding language), and must
contain an entry for key 'en_US' (as it is used as a fallback for all other
languages). Empty text is allowed in translation values, but not NULL.
Here are examples for a field with translate=True:
NULL
{"en_US": "Foo"}
{"en_US": "Foo", "fr_FR": "Bar", "nl_NL": "Baz"}
{"en_US": "Foo", "fr_FR": "", "nl_NL": "Baz"}
Like before, writing False to the field makes it NULL, i.e., False in all
languages. However, writing "" to the field makes its value empty in the
current language, but does not discard the values in the other languages.
Here are examples for a field with translate=xml_translate:
NULL
{"en_US": "<div>Foo<p>Bar</p></div>", "fr_FR": "<div>Fou<p>Barre</p></div>"}
Change for callable(translate) fields: one can now write any value in any
language on such a field. The new value will be adapted in all languages, based
on the mapping of terms between languages in the old values. Basically the
structure of the value must remain the same in all languages, like before.
Reading a translated field is now both simpler and faster than the former
implementation. We fetch the value of the field in the current language by
coalescing its value with the 'en_US' value of the field:
SELECT id, COALESCE(name->>'fr_FR', name->>'en_US') AS name ...
The raw cache of the field contains either None or a dict which is conceptually
a subset of the JSON value in database (except for missing languages). For the
sake of simplicity, most cache operations deal with the dict and return the text
value in the current language.
Trigram indexes have been adapted to the new storing strategy, and should enable
to search in any language. Before this change, only the source value of the
field ('en_US') could be indexed.
Computed stored translated fields are not supported by the framework, because of
the complexity of the computation itself: the field would need to be computed in
all active languages. We chose to not provide any hook to compute a field in
all languages at once, and the framework always invokes a compute method once to
recompute it.
Code translations are no longer stored into the database. They become static,
and are extracted from the PO files when needed. The worker simply uses a cache
with extracted code translations for performance. This is reasonable, since
fr_FR code translations for all modules takes around 2MB of memory, and the
cache can be shared among all registries in the worker. Changing code
translations requires to update the corresponding PO file and reloading the
worker(s).
Performance summary:
(+) reading 'model' translated fields is faster
(+) reading 'model_terms' translated fields is much faster (no need to inject
translations into the source value)
(+) searching translated fields with operator 'ilike' is much faster when the
field is indexed with 'trigram'
(+) updating translated fields requires less ORM flushing
(-) importing translations from PO files is 2x slower
Some extra fixes:
- make field 'name' of ir.actions.actions translated; because of the PG
inheritance, this is necessary to make the column definition consistent in
all models that inherit from ir.actions.actions.
- add some backend API for the web/website client for editing translations
- move methods get_field_string() to model ir.model.fields
- move _load_module_terms to model ir.module.module
- adapt tests in test_impex, test_new_api
- because env.lang is injected into SQL queries, its returned value is
now guaranteed to correspond to a valid active language or None
- remove wizard to insert missing translations (no longer makes sense)
task-id: 2081307
Co-authored-by: Fabien Pinckaers <fp@openerp.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
This commit is three-fold:
1) we now honnor attributes `create` and `import` which can be
set to a falsy value in archs (and in these cases, we disable
the import feature)
2) we converted the base_import test suite to use the owl views
3) we whitelisted the base_import addon for the lint/prettier
script
closesodoo/odoo#100026
Signed-off-by: Géry Debongnie <ged@odoo.com>
- Remove FEC from res.config.settings - everything is now linked in the import guide (in enterprise)
- Compute debit and credit from opening_balance
- Update import templates for account.account, account.move, res.partner
- Small UI changes in base_import: add an action title and improve the template button design
task-2888243
closesodoo/odoo#96291
Related: odoo/enterprise#29627
Related: odoo/upgrade#3794
Signed-off-by: Cedric Snauwaert <csn@odoo.com>