Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
10658 Näkymät

i added a button to update a field in product template from another computed field but when i press this button only self product be update and the method didn't go over all product

i tried a lotin this problem but i can't solve it and this the simple i have added

@api.multi
def button_name(self):
    for template in self:
        self.name4 = self.name3

    pass
Avatar
Hylkää
Paras vastaus

Try this

@api.multi
def button_name(self):
    products = self.env['product.template'].search([]) for product in products:
product.name4 = product.name3
pass
Avatar
Hylkää

hello, dear is this automatically saving updated value in DB . or do I have to run the write function

Tekijä

yes the values updated after press the button automatically

Paras vastaus

Use lamda function

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
lokak. 23
10684
1
jouluk. 22
10558
2
jouluk. 22
2574
0
marrask. 23
1204
3
maalisk. 21
4866