Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
5100 Widoki

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})]})
Awatar
Odrzuć

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

Najlepsza odpowiedź

Try this one,

Add

target="inline"

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

Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
1
lis 22
3400
0
cze 21
5953
0
mar 21
2775
2
sty 20
21733
2
maj 18
4078