Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
5102 Vistas

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})]})
Avatar
Descartar

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.

Autor

i have a wizard that has one2many field on it. i need to write values on that one2many field

Mejor respuesta

Try this one,

Add

target="inline"

in your action window of wizard to prevent to close the wizard.

Avatar
Descartar
Autor

i am using xpath to include my button , im not redefining the action. But it just closes the form.

Publicaciones relacionadas Respuestas Vistas Actividad
1
nov 22
3401
0
jun 21
5955
0
mar 21
2778
2
ene 20
21734
2
may 18
4079