Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
5097 Zobrazení

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
Zrušit

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

Nejlepší odpověď

Try this one,

Add

target="inline"

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

Avatar
Zrušit
Autor

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

Related Posts Odpovědi Zobrazení Aktivita
1
lis 22
3397
0
čvn 21
5950
0
bře 21
2774
2
led 20
21733
2
kvě 18
4074