[IMP] l10n_ar: extend constraint on pos number to ensure max 5 digits
Before this change we were letting the user to create a journal with a AFIP POS Number they like, and where they try to post an invoice in that jounrals they receive an error message telling that the document has not valid POS Number. In order to avoid this we add as part of the constraint where we check the validity of the AFIP POS Number which is: should be greater that 0, and should be 5 digits max. closes odoo/odoo#44433 X-original-commit: 3e991fb4ceb02eeb41ed6579ac409f9595663c41 Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
@@ -167,11 +167,15 @@ class AccountJournal(models.Model):
|
||||
|
||||
@api.constrains('l10n_ar_afip_pos_number')
|
||||
def _check_afip_pos_number(self):
|
||||
missing_pos_number = self.filtered(
|
||||
lambda x: x.type == 'sale' and x.l10n_latam_use_documents and x.company_id.country_id == self.env.ref('base.ar')
|
||||
and x.l10n_ar_afip_pos_number == 0)
|
||||
if missing_pos_number:
|
||||
raise ValidationError(_('Please define a valid AFIP POS number'))
|
||||
to_review = self.filtered(
|
||||
lambda x: x.type == 'sale' and x.l10n_latam_use_documents and
|
||||
x.company_id.country_id == self.env.ref('base.ar'))
|
||||
|
||||
if to_review.filtered(lambda x: x.l10n_ar_afip_pos_number == 0):
|
||||
raise ValidationError(_('Please define an AFIP POS number'))
|
||||
|
||||
if to_review.filtered(lambda x: x.l10n_ar_afip_pos_number > 99999):
|
||||
raise ValidationError(_('Please define a valid AFIP POS number (5 digits max)'))
|
||||
|
||||
@api.onchange('l10n_ar_afip_pos_system')
|
||||
def _onchange_l10n_ar_afip_pos_system(self):
|
||||
|
||||
Reference in New Issue
Block a user