I am trying to write values in one2many field. I am using Odoo v8. I have a wizard with one2many field. A button is associated and on clicking the button I am using write method to add values into one2many field.My button function is being called but it closes the wizard without doing anything. I dont get any error or exception.
My XML code is as:
<button name="split_qty" type="object" string="Split" class="oe_highlight"/>
My python code is as:
for i in range(1,11):
self.write({'item_ids':[(0, 0, {'product_id':pID,'quantity ':1, 'sourceloc_id':sID,'destinationloc_id':dID})]})
To me it's unclear what your setup is. If you have object A with a one2many to object B and a wizard on it called object C, do you want to populate the one2many on object A or C? If you populate a field on a wizard, it will be gone after closing.Wizards (or transient models) get cleaned from database after a certain time. If you want to populate the field on object A, simply create a valid object B that links back to A. There is no need to populate the one2many as well.
The best example would most likely be Sale order. On the sale.order.line object you will find a field called 'order_id'. Filling this with an existing sale order id will make the line appear on that order automatically.
Also ... SELF.WRITE on a wizard means that you try to write to the WIZARD and not your initial object. If you check self._context you will most likely find that the active_id and active_model are your goals.
i have a wizard that has one2many field on it. i need to write values on that one2many field