Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3205 มุมมอง

My module should prevent mass mailing to send email to users that don't comply in the GDPR settings. I created a constrain on res.partner that prevents to set opt_out to be set to True. Now the problem becomes that it prevents users to signup on the website portal because it wants to set opt_out to False.

@api.constrains('opt_out')
def _check_gdpr(self):
    if not self.email_notifications:
        if not self.opt_out:
            raise ValidationError('ERROR: Can't set "Mailing Opt-Out" because GDPR')

Does anyone have any idea how to keep the constrain but ignore it on create? Or does anyone have any better but simple solution?

I tried with setting opt_out to True in the constrain but I just got a maximum recursion error because the constrain was calling the constrain :)

อวตาร
ละทิ้ง
ผู้เขียน

can be closed... overrided create for res partner with

if 'opt_out' in vals:

vals['opt_out'] = True

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 17
11207
5
ก.พ. 24
24358
0
ก.ค. 18
2771
2
ก.ค. 18
3162
2
พ.ย. 17
4694