From 06a02ae4c22fe91c47702712420134e06c4d35d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 19 Dec 2017 13:36:25 +0100 Subject: [PATCH] [FIX][IMP] account: set invoice_warn as non required When reinitializing modules it is impossible to create partners if account is installed because invoice_warn field has a required column but no default value if the module does not depend from account. Use case is trying to run test_mail tests with account installed. As this field is not business critical it is now not required. As there is a default value behavior should not change for users. --- addons/account/models/account_invoice.py | 2 +- addons/account/models/partner.py | 2 +- addons/account/views/partner_view.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 229abf31409..cd84001bc3f 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -662,7 +662,7 @@ class AccountInvoice(models.Model): # If partner has no warning, check its company if p.invoice_warn == 'no-message' and p.parent_id: p = p.parent_id - if p.invoice_warn != 'no-message': + if p.invoice_warn and p.invoice_warn != 'no-message': # Block if partner only has warning but parent company is blocked if p.invoice_warn != 'block' and p.parent_id and p.parent_id.invoice_warn == 'block': p = p.parent_id diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index b9d0d181664..246c402a23c 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -414,7 +414,7 @@ class ResPartner(models.Model): contract_ids = fields.One2many('account.analytic.account', 'partner_id', string='Contracts', readonly=True) bank_account_count = fields.Integer(compute='_compute_bank_count', string="Bank") trust = fields.Selection([('good', 'Good Debtor'), ('normal', 'Normal Debtor'), ('bad', 'Bad Debtor')], string='Degree of trust you have in this debtor', default='normal', company_dependent=True) - invoice_warn = fields.Selection(WARNING_MESSAGE, 'Invoice', help=WARNING_HELP, required=True, default="no-message") + invoice_warn = fields.Selection(WARNING_MESSAGE, 'Invoice', help=WARNING_HELP, default="no-message") invoice_warn_msg = fields.Text('Message for Invoice') @api.multi diff --git a/addons/account/views/partner_view.xml b/addons/account/views/partner_view.xml index ec9de2e7f31..f46c1e206bd 100644 --- a/addons/account/views/partner_view.xml +++ b/addons/account/views/partner_view.xml @@ -151,7 +151,7 @@ + attrs="{'required':[('invoice_warn', '!=', False), ('invoice_warn','!=','no-message')],'readonly':[('invoice_warn','=','no-message')]}"/>