Unsynched model data for customized report after each update

Since I was working in 5.0 I have some troubles with model data synchronization for customized report every time I run trytond-admin. But it doesn’t happens always so I’m confused …

Let me explain a case:

I have a custom module where I modify the report path for delivery note report.

<record model="ir.action.report" id="stock.report_shipment_out_delivery_note">
    <field name="report">mymodule/delivery_note.fodt</field>
</record>

When I run trytond-admin I give the warning:

WARNING trytond.convert Field report of 636@ir.action.report not updated (id: report_shipment_out_delivery_note), because it has changed since the last update

After that the ir.action.report record has the initial value on field “report” (stock/delivery_note.fodt). So I fix both ir.model.data record from Administration menu and report action record.

So I run trytond-admin again and the value is unsynched again (stock/delivery_note.fodt).

What I’m doing wrong?
May I deactivate “report_shipment_out_delivery_note” report and create a new one instead of updating from xml?

Maybe is because you must replace the existing report, isn’t it?

For sure! :thinking:
I used to update existing report but it seems to not work anymore.

directly modifying a record in other module isn’t really supported. As you see, trytond-admin doesn’t understand another module modify it and instead complains “something” externally modify it, and prefer to do nothing instead of beraking things.

you should first backout your change in the stock record:

  • maybe with an explicit setting of report field to restore the original value (via trytond-admin) (it should be done in multiple steps: first restore the value, next remove the record modification)
  • or with a SQL query to restore the original value (and remove the record modification from mymodule)

next, trytond-admin will be able to update the record.

I confirm that it worked and still works for us in the way

    <record model="ir.action.report" update="1"
            id="account_invoice.report_invoice">
        <field name="report"><our_custom_module>/<path>/invoice.fodt</field>
    </record>

Yeah! I tried and it works!

So in order to implement it correctly, what is the option we should use?

Have you probed the official way to replace existing Tryton reports?

If it works, why are you looking for “another way” to resolve that out of the official way? Do you see an advantage for “another way” to do that?

Not now but I have installed some third party module that do it in that way and it worked.

I’m not looking another way but I would like to know if the @yangoon is also an official way.

The only advantage is the re-coding time I need to fix all extended reports (modify xml record, add new xml record for report, new keyword, new translation, …).

The example in the docs dates from version 4.0 and was never an elegant solution to just replace the path to an [f]odt file. The solution with update=“1” works for us since 4.0, so we see no need to go the extra way to replace the whole report definition instead of only the path.

No it is not and if it works it is by chance.
There are some reasons why you should not change the path of an existing report:

  • translations are mixed between the former and the new report
  • the XML loader may not be able to understand which values are correct and so prevent further update
  • during update the value may change and upgrade code may trigger the report with the wrong template
  • it breaks the modularity if two modules change the same report (an long waiting idea was to add an xpath-like way to extend existing report)

The update keyword exists only to allow to reference the same id in the same module to support circular referencing (e.g. in the past for warehouse and locations).

So now it’s 100% clear. Thanks @ced.

This will be a great feature to just replace the path as mentioned @yangoon.

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