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

I have a model with clickable selection field

py

state = fields.Selection([('new', 'New'), ('in_progress', 'In Progress'), ('done', 'Done')], default='new')

xml

<field name="state" widget="statusbar" clickable="True" />

function

@api.onchange('state')

    def onchange_state(self):

        print self

notes

it  printes like this

<odoo.models.NewId object at 0x7f624b7b7b90>,

questions

1)is it possible to get the id of the record based on this clickable selection field in onchange event?

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

Hello Acha aslam,

Hope you are doing well.

If you write onchange method on any field and you have to print the self, then it always get the virtual ID. So, if you have to get the record or ID, you have to print self._origin or self._origin.id.

@api.onchange('state')
    def onchange_state(self):
        print self._origin or 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
5
مايو 22
25940
0
فبراير 18
5302
2
سبتمبر 23
12935
3
يونيو 19
6906
1
يوليو 17
5235