تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3390 أدوات العرض

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?

الصورة الرمزية
إهمال
أفضل إجابة

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
}}

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
يوليو 17
2972
2
سبتمبر 23
4949
12
أكتوبر 23
36021
2
يوليو 22
5818
2
يوليو 21
6264