コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
11225 ビュー

Hello, Odoo community,

What is the best way in Odoo 11 Saas to add date validation? if I have an end_date field and start_date field, I would like to ensure that end_date is greater than start_end. How can I do that?

if it helps

view_type=form

model=account.invoice

アバター
破棄
最善の回答

Dear Shaheryar,

Try This:

from odoo.exceptions import  ValidationError

    @api.multi
    @api.constrains('end_date', 'start_date')
    def date_constrains(self):

              for rec in self:

                      if rec.end_date < rec.start_date:

                           raise ValidationError(_('Sorry, End Date Must be greater Than Start Date...'))


I hope I help you...

アバター
破棄
著作者 最善の回答

Hello Ayman,

Thanks for replying. How can I do this on Odoo Studio, the online Saas version?

I tried to use the following in Automated actions but that did not work.

def date_constrains(self):

              for rec in self:

                      if rec.end_date < rec.start_date:

                           raise ValidationError(_('Sorry, End Date Must be greater Than Start Date...'))

アバター
破棄
関連投稿 返信 ビュー 活動
4
1月 20
5074
3
3月 22
26378
2
7月 24
2623
1
6月 24
5092
1
10月 23
10782