Write different field values to records

Suppose I have two shipments (in a list called shipments_out), and I want to assign the same effective_date to both of them. I do this and it works:

Shipment_Out = Model.get('stock.shipment.out')
Shipment_Out.write(  shipments_out[:2] ,   {'effective_date': datetime.date(2021,11,29) } , context = config.context )

But if I want to set different effective dates for the two shipments, how do I do it using the write method?

I guess you are using proteus.
The ModelStorage.write method can take as many as argument as needed. So you can call it like:

ShipmentOut.write(shipments[0:1], {'effective_date': ...}, shipments[1:2], {'effective_date': ...}, config.context)

But also you can use the oriented-object design with:

shipments[0].effective_date = ...
shipments[1].effective_date = ...

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