12.0 stage

Merged Gastón Bertolani requested to merge 12.0-stage into 12.0
Compare and
1 file
+ 16
10
Preferences
File browser
Compare changes
+ 16
10
@@ -168,16 +168,22 @@ class AccountInvoice(models.Model):
}
@api.onchange('partner_id')
def cons_partner(self):
for rec in self:
lst = [1, 2, 3, 51, 52, 53, 201, 202, 203, 206, 207, 208]
voucher_type = rec._get_voucher_type()
if int(voucher_type) in lst:
if rec.partner_id.document_type_id.name != 'CUIT'\
or not rec.partner_id.vat:
raise exceptions.UserError(
_("The client has a type of document other than CUIT")
)
def _onchange_partner_id(self):
res = super(AccountInvoice, self)._onchange_partner_id()
if not self.partner_id:
return res
caea_lst = [1, 2, 3, 51, 52, 53, 201, 202, 203, 206, 207, 208]
try:
voucher_type = self._get_voucher_type()
except Exception:
return res
if int(voucher_type) in caea_lst:
cuit_type = self.env.ref('base_vat_ar.document_cuit')
if self.partner_id.document_type_id != cuit_type or not self.partner_id.vat:
raise exceptions.UserError(
_("The client has a type of document other than CUIT")
)
return res
# Constraints
@api.multi