Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3382 Vizualizări

Python Code:-

class product_available_stock(models.Model):
_name = "product.available.stock"


product_name = fields.Many2one("product.template")
variants = fields.Many2one("product.attribute.value")


def state_id_change(self, cr, uid, ids, product_name):
    values = {'variants': False}

    if product_name:
        state = self.product_name.ids
        values['variants'] = state.variants.id

    return {'value': values}

XML Code:-

<group>
   <field name="product_name" on_change="state_id_change(product_name)"/>
   <field name="variants"/>
</group>

May I get any help on the above topic?

Imagine profil
Abandonează
Cel mai bun răspuns

hello please find the minor change which I have made



def state_id_change(self, cr, uid, ids, product_name):
    values = {'variants': False}

    if product_name:
        state = self.product_name.ids
        values['variants'] = state.variants.id

    return {
value': {
        state : self.product_name.ids
        values['variants'] : state.variants.id
}}

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
iul. 17
2959
2
sept. 23
4920
12
oct. 23
36016
2
iul. 22
5807
2
iul. 21
6262