In Odoo 13, when I duplicate a sale order which has invoices linked to it, the new sale order has no invoices linked to it, which is OK.
The problem is that in my case, there are a lot of third party apps installed in my database, and here, when I duplicate a sale order, the new one has the same invoices linked to it than the source one, which obviously is a wrong behavior.
I am trying to fix it. So first I checked even through the interface that the following fields have copy=False:
- The Many2many field
invoice_linesfrom the modelsale.order.line. - The Many2many field
sale_line_idsfrom the modelaccount.move.line.
Both seem to be OK, with copy=False. Why is this happening then? I've also modified the code to break the program if they are modified in create or write ORM methods of both models, but they aren't.
Any ideas of how can I locate the guilty code?
Finally I've found the problem: one of the multiple third party apps installed on the database adds a new Many2many field on
sale.orderpointing toaccount.move. This field has notcopy=False. It shouldn't affect to sale order invoices link, but it does because the app also overwrites de method_get_invoiced()fromsale.order, to add the value of that M2M field to the originalinvoice_ids. The combination of both actions is the problem.I was able to fix it just adding a
copy=Falseto that third party app new field. The problem was also fixed if I commented the_get_invoiced()overwrite, but I've chose the first option to preserve what that app does.These are the reasons why checking
sale.ordercopy()method or checkingcopyattribute on original fields gave no clues.