diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-09-13 19:32:35 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-09-13 19:32:35 +0200 |
| commit | 1e17035f71f1b01c3694e4eaa92cb4baac528305 (patch) | |
| tree | bc34d29869decd861b7c9f7d6e8e4e1fa49a5e94 /addons/base_vat | |
| parent | 0f9302af1facd0c5872a377782300e55206301e8 (diff) | |
| parent | 268cf9d04ab5144446cb010aeda3715460126e65 (diff) | |
[MERGE] forward port branch saas-16 up to 268cf9d04ab
Diffstat (limited to 'addons/base_vat')
| -rw-r--r-- | addons/base_vat/models/res_partner.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index 3b6b648a9bd..b2525706da5 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -98,7 +98,11 @@ class ResPartner(models.Model): @api.constrains('vat', 'commercial_partner_country_id') def check_vat(self): - if self.env.user.company_id.vat_check_vies: + if self.env.context.get('company_id'): + company = self.env['res.company'].browse(self.env.context['company_id']) + else: + company = self.env.user.company_id + if company.vat_check_vies: # force full VIES online check check_func = self.vies_vat_check else: @@ -121,7 +125,11 @@ class ResPartner(models.Model): self.ensure_one() vat_no = "'CC##' (CC=Country Code, ##=VAT Number)" vat_no = _ref_vat.get(country_code) or vat_no - if self.env.user.company_id.vat_check_vies: + if self.env.context.get('company_id'): + company = self.env['res.company'].browse(self.env.context['company_id']) + else: + company = self.env.user.company_id + if company.vat_check_vies: return '\n' + _('The VAT number [%s] for partner [%s] either failed the VIES VAT validation check or did not respect the expected format %s.') % (self.vat, self.name, vat_no) return '\n' + _('The VAT number [%s] for partner [%s] does not seem to be valid. \nNote: the expected format is %s') % (self.vat, self.name, vat_no) |
