-
Couldn't load subscription status.
- Fork 116
[FIX] mail, web: correctly handle mounting operation cancelled error #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexkuhn
merged 1 commit into
master-mail-owl
from
master-mail-owl-mount-operation-canceled-aku
Apr 22, 2020
Merged
[FIX] mail, web: correctly handle mounting operation cancelled error #233
alexkuhn
merged 1 commit into
master-mail-owl
from
master-mail-owl-mount-operation-canceled-aku
Apr 22, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
659e448 to
ae9bb67
Compare
seb-odoo
requested changes
Apr 21, 2020
addons/mail/static/src/messaging/widget/form_renderer/form_renderer.js
Outdated
Show resolved
Hide resolved
addons/mail/static/src/messaging/widget/form_renderer/form_renderer.js
Outdated
Show resolved
Hide resolved
ae9bb67 to
4d618b7
Compare
|
just applied suggested changes |
|
Ok, looks better. So if you remove the await stuff, with the previous version it crashes, and the new version it works? Because the diff was just doing nothing otherwise. |
|
It no longer crashes if we use `.catch()` in update, without async. I
prefer async await for the nicer syntax.
…On Tue, 21 Apr 2020 at 20:38, Sébastien Theys ***@***.***> wrote:
Ok, looks better. So if you remove the await stuff, with the previous
version it crashes, and the new version it works? Because the diff was just
doing nothing otherwise.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#233 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSD3LUX5NHZ7AG7LAW4QMTRNXRYTANCNFSM4MNNRTZQ>
.
|
aj-fuentes
added a commit
that referenced
this pull request
Jan 30, 2024
When we update an inline translated element (like `<span>`) for the base language `en_US` we should update the modifiers attributes for all languages. For example when updating from (16.0) https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/views/ir_ui_view_views.xml#L127-L129 https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/i18n/fr.po#L7233-L7235 to (17.0) https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/views/ir_ui_view_views.xml#L126-L128 https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/i18n/fr.po#L12087-L12089 The base term, `en_US`, is updated since the text matches but the attributes of the translated terms, `fr_FR` for example, are not updated. Later when the PO file is loaded in non-overwrite mode the translated terms for `fr_FR` is not updated. This causes all sort of issues during an upgrade for inline-translated terms -- like `<span>`. More so since the recent change that converts domain-based attributes into inline Python expressions. In this patch we propagate modifiers attributes from inline-translated items in the new base term into all translated terms when the base term is updated. In that way we ensure the attributes are correct in all languages even if later the loading of their corresponding PO file doesn't update the term. For a detailed example, let's see what happens when loading the view above during an upgrade 16->17, right at the first load of the XML file at https://github.com/odoo/odoo/blob/b1461d28/odoo/fields.py#L1864 ``` (Pdb) p old_term '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">This view has no previous version.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">This view is not coming from a file.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">You need two views to compare.</span>' (Pdb) p closest_term '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[old_term] defaultdict(<class 'dict'>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` As we can see the new term will get an updated value for its `invisible` attribute, while also removing `attrs`. The translated terms will be still keep the old modifier though. Now later when the fr_FR.po file is loaded we reach this point https://github.com/odoo/odoo/blob/b1461d28/odoo/tools/translate.py#L1442 ``` (Pdb) p term_en '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[term_en] defaultdict(<function DeepDefaultDict at 0x7fc9640cdfc0>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` Thus the translated values are NOT updated, keeping the _wrong_ modifiers. This is later fixed during the upgrade in a clumsy way. C.f. the warnings like this one in runbot: ``` Incomplete conversion for view(id=77, lang=fr_FR) at <span attrs="{'invisible': [('reset_mode', '!=', 'soft')]}">Cette vue n'a pas de version antérieure.</span> ``` Note that such warnings are gone in current PR CI. The root issue here is that when the fr_FR translation is loaded the terms are not updated due to a combination of factors: 1. The text content of the term didn't change 2. There is no override flag set for translations Option 2 is not a valid option during upgrades because we want to keep custom translations. We could instead of the current patch tweak how option 1 works and perhaps make the closest term more restricted. This would lead to the update of the whole translation though while the actual issue here is _just_ the modifiers. Moreover if the translations are out of sync the translated terms will still keep the wrong values that could still be essential for the correct functioning of the record they belong too (view archs -- for example). Finally this is a more extreme case (16.0): https://github.com/odoo/enterprise/blob/1e63b4a8/sale_subscription/views/sale_order_views.xml#L142 In this case during the upgrade we fix the modifier value (refer to runbot warning above -- it's the same script that fixes it) and set ``` invisible="(subscription_management == 'upsell') or (recurrence_id == False)" ``` for translations, which is wrong. The correct value is (17.0): ``` invisible="not plan_id or subscription_state == '7_upsell'" ``` https://github.com/odoo/enterprise/blob/530ba3ad/sale_subscription/views/sale_order_views.xml#L136
fw-bot
pushed a commit
that referenced
this pull request
Jan 30, 2024
When we update an inline translated element (like `<span>`) for the base language `en_US` we should update the modifiers attributes for all languages. For example when updating from (16.0) https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/views/ir_ui_view_views.xml#L127-L129 https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/i18n/fr.po#L7233-L7235 to (17.0) https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/views/ir_ui_view_views.xml#L126-L128 https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/i18n/fr.po#L12087-L12089 The base term, `en_US`, is updated since the text matches but the attributes of the translated terms, `fr_FR` for example, are not updated. Later when the PO file is loaded in non-overwrite mode the translated terms for `fr_FR` is not updated. This causes all sort of issues during an upgrade for inline-translated terms -- like `<span>`. More so since the recent change that converts domain-based attributes into inline Python expressions. In this patch we propagate modifiers attributes from inline-translated items in the new base term into all translated terms when the base term is updated. In that way we ensure the attributes are correct in all languages even if later the loading of their corresponding PO file doesn't update the term. For a detailed example, let's see what happens when loading the view above during an upgrade 16->17, right at the first load of the XML file at https://github.com/odoo/odoo/blob/b1461d28/odoo/fields.py#L1864 ``` (Pdb) p old_term '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">This view has no previous version.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">This view is not coming from a file.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">You need two views to compare.</span>' (Pdb) p closest_term '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[old_term] defaultdict(<class 'dict'>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` As we can see the new term will get an updated value for its `invisible` attribute, while also removing `attrs`. The translated terms will be still keep the old modifier though. Now later when the fr_FR.po file is loaded we reach this point https://github.com/odoo/odoo/blob/b1461d28/odoo/tools/translate.py#L1442 ``` (Pdb) p term_en '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[term_en] defaultdict(<function DeepDefaultDict at 0x7fc9640cdfc0>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` Thus the translated values are NOT updated, keeping the _wrong_ modifiers. This is later fixed during the upgrade in a clumsy way. C.f. the warnings like this one in runbot: ``` Incomplete conversion for view(id=77, lang=fr_FR) at <span attrs="{'invisible': [('reset_mode', '!=', 'soft')]}">Cette vue n'a pas de version antérieure.</span> ``` Note that such warnings are gone in current PR CI. The root issue here is that when the fr_FR translation is loaded the terms are not updated due to a combination of factors: 1. The text content of the term didn't change 2. There is no override flag set for translations Option 2 is not a valid option during upgrades because we want to keep custom translations. We could instead of the current patch tweak how option 1 works and perhaps make the closest term more restricted. This would lead to the update of the whole translation though while the actual issue here is _just_ the modifiers. Moreover if the translations are out of sync the translated terms will still keep the wrong values that could still be essential for the correct functioning of the record they belong too (view archs -- for example). Finally this is a more extreme case (16.0): https://github.com/odoo/enterprise/blob/1e63b4a8/sale_subscription/views/sale_order_views.xml#L142 In this case during the upgrade we fix the modifier value (refer to runbot warning above -- it's the same script that fixes it) and set ``` invisible="(subscription_management == 'upsell') or (recurrence_id == False)" ``` for translations, which is wrong. The correct value is (17.0): ``` invisible="not plan_id or subscription_state == '7_upsell'" ``` https://github.com/odoo/enterprise/blob/530ba3ad/sale_subscription/views/sale_order_views.xml#L136 X-original-commit: ce3aac8
fw-bot
pushed a commit
that referenced
this pull request
Jan 30, 2024
When we update an inline translated element (like `<span>`) for the base language `en_US` we should update the modifiers attributes for all languages. For example when updating from (16.0) https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/views/ir_ui_view_views.xml#L127-L129 https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/i18n/fr.po#L7233-L7235 to (17.0) https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/views/ir_ui_view_views.xml#L126-L128 https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/i18n/fr.po#L12087-L12089 The base term, `en_US`, is updated since the text matches but the attributes of the translated terms, `fr_FR` for example, are not updated. Later when the PO file is loaded in non-overwrite mode the translated terms for `fr_FR` is not updated. This causes all sort of issues during an upgrade for inline-translated terms -- like `<span>`. More so since the recent change that converts domain-based attributes into inline Python expressions. In this patch we propagate modifiers attributes from inline-translated items in the new base term into all translated terms when the base term is updated. In that way we ensure the attributes are correct in all languages even if later the loading of their corresponding PO file doesn't update the term. For a detailed example, let's see what happens when loading the view above during an upgrade 16->17, right at the first load of the XML file at https://github.com/odoo/odoo/blob/b1461d28/odoo/fields.py#L1864 ``` (Pdb) p old_term '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">This view has no previous version.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">This view is not coming from a file.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">You need two views to compare.</span>' (Pdb) p closest_term '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[old_term] defaultdict(<class 'dict'>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` As we can see the new term will get an updated value for its `invisible` attribute, while also removing `attrs`. The translated terms will be still keep the old modifier though. Now later when the fr_FR.po file is loaded we reach this point https://github.com/odoo/odoo/blob/b1461d28/odoo/tools/translate.py#L1442 ``` (Pdb) p term_en '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[term_en] defaultdict(<function DeepDefaultDict at 0x7fc9640cdfc0>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` Thus the translated values are NOT updated, keeping the _wrong_ modifiers. This is later fixed during the upgrade in a clumsy way. C.f. the warnings like this one in runbot: ``` Incomplete conversion for view(id=77, lang=fr_FR) at <span attrs="{'invisible': [('reset_mode', '!=', 'soft')]}">Cette vue n'a pas de version antérieure.</span> ``` Note that such warnings are gone in current PR CI. The root issue here is that when the fr_FR translation is loaded the terms are not updated due to a combination of factors: 1. The text content of the term didn't change 2. There is no override flag set for translations Option 2 is not a valid option during upgrades because we want to keep custom translations. We could instead of the current patch tweak how option 1 works and perhaps make the closest term more restricted. This would lead to the update of the whole translation though while the actual issue here is _just_ the modifiers. Moreover if the translations are out of sync the translated terms will still keep the wrong values that could still be essential for the correct functioning of the record they belong too (view archs -- for example). Finally this is a more extreme case (16.0): https://github.com/odoo/enterprise/blob/1e63b4a8/sale_subscription/views/sale_order_views.xml#L142 In this case during the upgrade we fix the modifier value (refer to runbot warning above -- it's the same script that fixes it) and set ``` invisible="(subscription_management == 'upsell') or (recurrence_id == False)" ``` for translations, which is wrong. The correct value is (17.0): ``` invisible="not plan_id or subscription_state == '7_upsell'" ``` https://github.com/odoo/enterprise/blob/530ba3ad/sale_subscription/views/sale_order_views.xml#L136 closes odoo#150152 Signed-off-by: Raphael Collet <rco@odoo.com>
fw-bot
pushed a commit
that referenced
this pull request
Jan 30, 2024
When we update an inline translated element (like `<span>`) for the base language `en_US` we should update the modifiers attributes for all languages. For example when updating from (16.0) https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/views/ir_ui_view_views.xml#L127-L129 https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/i18n/fr.po#L7233-L7235 to (17.0) https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/views/ir_ui_view_views.xml#L126-L128 https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/i18n/fr.po#L12087-L12089 The base term, `en_US`, is updated since the text matches but the attributes of the translated terms, `fr_FR` for example, are not updated. Later when the PO file is loaded in non-overwrite mode the translated terms for `fr_FR` is not updated. This causes all sort of issues during an upgrade for inline-translated terms -- like `<span>`. More so since the recent change that converts domain-based attributes into inline Python expressions. In this patch we propagate modifiers attributes from inline-translated items in the new base term into all translated terms when the base term is updated. In that way we ensure the attributes are correct in all languages even if later the loading of their corresponding PO file doesn't update the term. For a detailed example, let's see what happens when loading the view above during an upgrade 16->17, right at the first load of the XML file at https://github.com/odoo/odoo/blob/b1461d28/odoo/fields.py#L1864 ``` (Pdb) p old_term '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">This view has no previous version.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">This view is not coming from a file.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">You need two views to compare.</span>' (Pdb) p closest_term '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[old_term] defaultdict(<class 'dict'>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` As we can see the new term will get an updated value for its `invisible` attribute, while also removing `attrs`. The translated terms will be still keep the old modifier though. Now later when the fr_FR.po file is loaded we reach this point https://github.com/odoo/odoo/blob/b1461d28/odoo/tools/translate.py#L1442 ``` (Pdb) p term_en '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[term_en] defaultdict(<function DeepDefaultDict at 0x7fc9640cdfc0>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` Thus the translated values are NOT updated, keeping the _wrong_ modifiers. This is later fixed during the upgrade in a clumsy way. C.f. the warnings like this one in runbot: ``` Incomplete conversion for view(id=77, lang=fr_FR) at <span attrs="{'invisible': [('reset_mode', '!=', 'soft')]}">Cette vue n'a pas de version antérieure.</span> ``` Note that such warnings are gone in current PR CI. The root issue here is that when the fr_FR translation is loaded the terms are not updated due to a combination of factors: 1. The text content of the term didn't change 2. There is no override flag set for translations Option 2 is not a valid option during upgrades because we want to keep custom translations. We could instead of the current patch tweak how option 1 works and perhaps make the closest term more restricted. This would lead to the update of the whole translation though while the actual issue here is _just_ the modifiers. Moreover if the translations are out of sync the translated terms will still keep the wrong values that could still be essential for the correct functioning of the record they belong too (view archs -- for example). Finally this is a more extreme case (16.0): https://github.com/odoo/enterprise/blob/1e63b4a8/sale_subscription/views/sale_order_views.xml#L142 In this case during the upgrade we fix the modifier value (refer to runbot warning above -- it's the same script that fixes it) and set ``` invisible="(subscription_management == 'upsell') or (recurrence_id == False)" ``` for translations, which is wrong. The correct value is (17.0): ``` invisible="not plan_id or subscription_state == '7_upsell'" ``` https://github.com/odoo/enterprise/blob/530ba3ad/sale_subscription/views/sale_order_views.xml#L136 X-original-commit: ce3aac8
fw-bot
pushed a commit
that referenced
this pull request
Jan 31, 2024
When we update an inline translated element (like `<span>`) for the base language `en_US` we should update the modifiers attributes for all languages. For example when updating from (16.0) https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/views/ir_ui_view_views.xml#L127-L129 https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/i18n/fr.po#L7233-L7235 to (17.0) https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/views/ir_ui_view_views.xml#L126-L128 https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/i18n/fr.po#L12087-L12089 The base term, `en_US`, is updated since the text matches but the attributes of the translated terms, `fr_FR` for example, are not updated. Later when the PO file is loaded in non-overwrite mode the translated terms for `fr_FR` is not updated. This causes all sort of issues during an upgrade for inline-translated terms -- like `<span>`. More so since the recent change that converts domain-based attributes into inline Python expressions. In this patch we propagate modifiers attributes from inline-translated items in the new base term into all translated terms when the base term is updated. In that way we ensure the attributes are correct in all languages even if later the loading of their corresponding PO file doesn't update the term. For a detailed example, let's see what happens when loading the view above during an upgrade 16->17, right at the first load of the XML file at https://github.com/odoo/odoo/blob/b1461d28/odoo/fields.py#L1864 ``` (Pdb) p old_term '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">This view has no previous version.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">This view is not coming from a file.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">You need two views to compare.</span>' (Pdb) p closest_term '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[old_term] defaultdict(<class 'dict'>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` As we can see the new term will get an updated value for its `invisible` attribute, while also removing `attrs`. The translated terms will be still keep the old modifier though. Now later when the fr_FR.po file is loaded we reach this point https://github.com/odoo/odoo/blob/b1461d28/odoo/tools/translate.py#L1442 ``` (Pdb) p term_en '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[term_en] defaultdict(<function DeepDefaultDict at 0x7fc9640cdfc0>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` Thus the translated values are NOT updated, keeping the _wrong_ modifiers. This is later fixed during the upgrade in a clumsy way. C.f. the warnings like this one in runbot: ``` Incomplete conversion for view(id=77, lang=fr_FR) at <span attrs="{'invisible': [('reset_mode', '!=', 'soft')]}">Cette vue n'a pas de version antérieure.</span> ``` Note that such warnings are gone in current PR CI. The root issue here is that when the fr_FR translation is loaded the terms are not updated due to a combination of factors: 1. The text content of the term didn't change 2. There is no override flag set for translations Option 2 is not a valid option during upgrades because we want to keep custom translations. We could instead of the current patch tweak how option 1 works and perhaps make the closest term more restricted. This would lead to the update of the whole translation though while the actual issue here is _just_ the modifiers. Moreover if the translations are out of sync the translated terms will still keep the wrong values that could still be essential for the correct functioning of the record they belong too (view archs -- for example). Finally this is a more extreme case (16.0): https://github.com/odoo/enterprise/blob/1e63b4a8/sale_subscription/views/sale_order_views.xml#L142 In this case during the upgrade we fix the modifier value (refer to runbot warning above -- it's the same script that fixes it) and set ``` invisible="(subscription_management == 'upsell') or (recurrence_id == False)" ``` for translations, which is wrong. The correct value is (17.0): ``` invisible="not plan_id or subscription_state == '7_upsell'" ``` https://github.com/odoo/enterprise/blob/530ba3ad/sale_subscription/views/sale_order_views.xml#L136 closes odoo#151927 X-original-commit: ce3aac8 Signed-off-by: Raphael Collet <rco@odoo.com> Signed-off-by: Alvaro Fuentes Suarez (afu) <afu@odoo.com>
aliyatastemirova
pushed a commit
that referenced
this pull request
Feb 1, 2024
When we update an inline translated element (like `<span>`) for the base language `en_US` we should update the modifiers attributes for all languages. For example when updating from (16.0) https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/views/ir_ui_view_views.xml#L127-L129 https://github.com/odoo/odoo/blob/7ecd9413/odoo/addons/base/i18n/fr.po#L7233-L7235 to (17.0) https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/views/ir_ui_view_views.xml#L126-L128 https://github.com/odoo/odoo/blob/b1461d28/odoo/addons/base/i18n/fr.po#L12087-L12089 The base term, `en_US`, is updated since the text matches but the attributes of the translated terms, `fr_FR` for example, are not updated. Later when the PO file is loaded in non-overwrite mode the translated terms for `fr_FR` is not updated. This causes all sort of issues during an upgrade for inline-translated terms -- like `<span>`. More so since the recent change that converts domain-based attributes into inline Python expressions. In this patch we propagate modifiers attributes from inline-translated items in the new base term into all translated terms when the base term is updated. In that way we ensure the attributes are correct in all languages even if later the loading of their corresponding PO file doesn't update the term. For a detailed example, let's see what happens when loading the view above during an upgrade 16->17, right at the first load of the XML file at https://github.com/odoo/odoo/blob/b1461d28/odoo/fields.py#L1864 ``` (Pdb) p old_term '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">This view has no previous version.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">This view is not coming from a file.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">You need two views to compare.</span>' (Pdb) p closest_term '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[old_term] defaultdict(<class 'dict'>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` As we can see the new term will get an updated value for its `invisible` attribute, while also removing `attrs`. The translated terms will be still keep the old modifier though. Now later when the fr_FR.po file is loaded we reach this point https://github.com/odoo/odoo/blob/b1461d28/odoo/tools/translate.py#L1442 ``` (Pdb) p term_en '<span invisible="reset_mode != \'soft\'">This view has no previous version.</span>\n <span invisible="reset_mode != \'hard\'">This view is not coming from a file.</span>\n <span invisible="reset_mode != \'other_view\'">You need two views to compare.</span>' (Pdb) p translation_dictionary[term_en] defaultdict(<function DeepDefaultDict at 0x7fc9640cdfc0>, {'fr_FR': '<span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'soft\')]}">Cette vue n\'a pas de version antérieure.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'hard\')]}">Cette vue ne provient pas d\'un fichier.</span>\n <span attrs="{\'invisible\': [(\'reset_mode\', \'!=\', \'other_view\')]}">Vous avez besoin de deux vues pour comparer.</span>'}) ``` Thus the translated values are NOT updated, keeping the _wrong_ modifiers. This is later fixed during the upgrade in a clumsy way. C.f. the warnings like this one in runbot: ``` Incomplete conversion for view(id=77, lang=fr_FR) at <span attrs="{'invisible': [('reset_mode', '!=', 'soft')]}">Cette vue n'a pas de version antérieure.</span> ``` Note that such warnings are gone in current PR CI. The root issue here is that when the fr_FR translation is loaded the terms are not updated due to a combination of factors: 1. The text content of the term didn't change 2. There is no override flag set for translations Option 2 is not a valid option during upgrades because we want to keep custom translations. We could instead of the current patch tweak how option 1 works and perhaps make the closest term more restricted. This would lead to the update of the whole translation though while the actual issue here is _just_ the modifiers. Moreover if the translations are out of sync the translated terms will still keep the wrong values that could still be essential for the correct functioning of the record they belong too (view archs -- for example). Finally this is a more extreme case (16.0): https://github.com/odoo/enterprise/blob/1e63b4a8/sale_subscription/views/sale_order_views.xml#L142 In this case during the upgrade we fix the modifier value (refer to runbot warning above -- it's the same script that fixes it) and set ``` invisible="(subscription_management == 'upsell') or (recurrence_id == False)" ``` for translations, which is wrong. The correct value is (17.0): ``` invisible="not plan_id or subscription_state == '7_upsell'" ``` https://github.com/odoo/enterprise/blob/530ba3ad/sale_subscription/views/sale_order_views.xml#L136 closes odoo#151932 X-original-commit: ce3aac8 Signed-off-by: Raphael Collet <rco@odoo.com> Signed-off-by: Alvaro Fuentes Suarez (afu) <afu@odoo.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.