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

I have added a one2many field in sale.order.line and want to use an onchange function to update it whenever product_id changes. The onchange function works, but only when the product changes from sale order line form view. What I want is to change product from the tree nested in sale order form view. The new records are being created but the values specified in the dict are not passed to the records. Can anyone point me in the right direction? Maybe it's a problem with the tree view? Here is the onchange function:

 api.onchange('product_id')

    def _onchange_prod_id(self):

        if self.product_id:

            task_list = [(5,0,0)]

            for task in self.product_id.task_lines:

                vals = {

                    'sol_id':self.id,

                    'task_tmpl_id': task.task_tmpl_id.id,

                    'task_name': task.task_name,

                    'description': task.description,

                    'work': task.work

                }

                task_list.append((0, 0, vals))

            self.task_lines = task_list      

            

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

Found it!!

Add

api.constrains('product_id')

Above

api.onchange('product_id')
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
سبتمبر 20
2840
4
ديسمبر 23
17680
1
سبتمبر 16
7402
0
أبريل 16
3196
3
مارس 16
13975