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

Dear All,

    I'm learning to develop something with ODOO 11CE.

   I'd like to filling the "filelds.Selection" with the condition.

   

   So for example: 

       If I change the stage of CRM lead the x_status select field will also change. 



Here is my tried, But I does not working. 


class MYLead(models.Model):

    _inherit = ['crm.lead']

    

    

    def _get_status_list(self):

        vals = []

        for rec in self:

            #New

            if rec.stage_id == 1:

                vals.extend([('0', 'Pending'), ('1', 'Ready')])

            #Qualified 

            elif rec.stage_id == 2:

                vals.extend([('0', 'Pending'), ('1', 'Waiting])

            #Proposition    

            elif rec.stage_id == 3:    

            else:

                vals.extend([('0', 'Processing'), ('1', 'Approve'), ('2', 'Pending'), ('-1', 'Reject')])

    return vals             

   

    x_status = fields.Selection(selection=_get_status_list, string='Status')

الصورة الرمزية
إهمال

Hi,

instead, isn't it better to show all values that the selection field can take and add a script to hide some values based on your conditions ?

if this does sound good for you, let me know

@Ibrahim Boudmir can you give an example ?

أفضل إجابة

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

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

Hi Methee,

Fields are initialized when you restart the server. So dynamic selection is not possible to add. As Ibrahim suggested, you can put restrictions using orm methods.

Thanks,

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
4
ديسمبر 23
21855
5
يوليو 24
15134
9
يونيو 23
12564
1
يونيو 22
26607
9
مايو 22
52793