Add Reference field to parent in One2Many


How to add in the ‘origin’ field of production moves (inputs and outputs) a link to the parent production order (I would like to do it here to standardize the use of the origin field in stock movements) ?

I added the production object to the list of possible objects and assigned move.origin = self when creating them by the production order.
However when creating the production order I got the error:

AttributeError: 'production' Model has no attribute '_changed_values': <trytond.model.model.production._record object at 0x7f56dcb6c1b0>

Fault: 'production' Model has no attribute '_changed_values': <trytond.model.model.production._record object at 0x7f56dcb6c1b0>

I suspect it’s because the production order is not yet registered, is there another way to do it?


This is redundant with the existing production_input and production_output and not consistent with the shipments which are also not using origin but shipment.
Finally it is not following the design principle of Tryton about origin field which is to link a record with the record responsible of its external creation.

Yes you can not store in a field the current record in an on_change call.
I do not think it is possible to do what you want.