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

Hello All,

I have a One2many field. In this field i have check box field. And, I already applied a validation for check-box selection. And function work very well. Now, When i selected check then value is returning and if not selected then no problem. But, now I want that if any of the row check-box from One2many field is selected then value return else it show warning. Means, Single row check-box from overall One2many is sufficient for value returning.

My code is here:

@api.multi
    def action_salepack_add(self):
        rec = self._context.get('active_ids', [])
        wiz = [q.id for q in self.wizard]
        res_wiz=  []
        for s in self.wizard:
            if s.check_box==True:
                res_wiz.append(s.id)
        if rec:
            line_values = {'product_id': self.product_id.id,
                           'wizards': [(6, 0, res_wiz)],
                           }
            sale_order_line = self.env['sale.order.line'].create(line_values)


Thanks in Advance

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

Problem Solved.

I added constrain, that return a warning;

from openerp.exceptions import ValidationError

    @api.constrains('wizard')  # wizard is the one2many field
    def _check_grade_choisi(self):
        for record in self:
            l = []
            if not any([s.check_box for s in record.wizard]) : #Here i check if all checkbox field is False
                raise ValidationError("Your warning")

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يوليو 19
6689
2
أغسطس 22
11788
2
مايو 21
8634
2
أغسطس 25
12082
5
سبتمبر 20
6374