Adding translation on confirm attribute defined in other module


We have a custom module that defines the confirm attribute of the Confirm button of the Sale model. I will expect to include the translation of such attribute under or custom module but we are failing to do so. Here is my xml definition of such change:

        <record model="ir.model.button" id="sale.sale_confirm_button">         
            <field name="confirm">Are you sure to confirm the sale?</field>    

The issue here is that the translation created by the system is related to the sale module (because the button is created from such module) so we can not update such translation using the standard translation system.

I tried creating an override translation for the Spanish language on the new string but this fails when updating the module:

  File "/home/pokoli/.virtualenvs/sale_confirm/bin/trytond-admin", line 7, in <module>
    exec(compile(, __file__, 'exec'))
  File "/home/pokoli/projectes/sale_confirm/trytond/bin/trytond-admin", line 23, in <module>
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/", line 57, in run
    pool.init(update=options.update, lang=list(lang),
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/", line 165, in init
    restart = not load_modules(
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/modules/", line 438, in load_modules
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/modules/", line 406, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/modules/", line 256, in load_module_graph
    load_translations(pool, node, lang)
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/modules/", line 184, in load_translations
    Translation.translation_import(language, module, files)
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/ir/", line 801, in translation_import
  File "/home/pokoli/projectes/sale_confirm/trytond/trytond/ir/", line 768, in override_translation
    translation, =
ValueError: not enough values to unpack (expected 1, got 0)

This problem is because the original translation does not exist in the sale module for the Spanish language as the XML import just created the translation for the English language.

Am I doing something wrong? How can I translate such string?

I guess you have to define a new button.

But I can not as the button name should be unique and the ir.model.button can not be deactivable.

Do you mean defining a new button with a diferent name and updating all the views to use the new button? Maybe this can work but I find it quite complex to just update the confirm attribute.

Maybe write_records should use self.module instead of module.

I tried such change and everything works well on the translation database but the problem is that the translation will never be updated as it does not exist any ModelData record for the confirm button related to the overriding module. So tryton thinks this is a local translation and does not export them.

Here is the related code.

I do not see why you are overriding the translations.

If I update write_records the translation is not overriden but related to the current module.
The problem is that the export wizard ignores it as is not related to any model data.

I guess it is a limitation of Tryton.
Any way modifying XML record has never been a clean thing.
For the confirm attribute of button, I guess it is better to modify the attribute in the view.

Also the ir.model.button unique constraint has been at multiple times a problem. I guess it should be replaced by an Exclude for active only. So they can be customized like reports.

I filled Issue 11284: Allow to deactivate button access - Tryton issue tracker which replaces the unique by Exclude for active only.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.