restrict dates less than the current date
This commit is contained in:
parent
3cb38bb310
commit
445cfb6c37
|
@ -6,5 +6,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<record model="ir.message" id="msg_no_parties">
|
||||
<field name="text">There is not parties.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_birthday">
|
||||
<field name="text">The birthdate shouldn't be greater than today's date.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
10
party.py
10
party.py
|
@ -1,6 +1,6 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import fields, ModelSQL, ModelView
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
|
@ -89,6 +89,14 @@ class Party(metaclass=PoolMeta):
|
|||
second_family_name = fields.Char('Segundo Apellido')
|
||||
city_document_exp = fields.Char('City of Document Expedition ID')
|
||||
|
||||
@classmethod
|
||||
def validate(cls, parties):
|
||||
for party in parties:
|
||||
if party.birthday and party.birthday > date.today():
|
||||
raise UserError(gettext('party_personal.msg_birthday'))
|
||||
parties = super(Party, cls).validate(parties)
|
||||
return parties
|
||||
|
||||
@fields.depends('bmi', 'bmi_category')
|
||||
def on_change_bmi(self):
|
||||
if self.bmi:
|
||||
|
|
Loading…
Reference in New Issue