summaryrefslogtreecommitdiff
path: root/addons/account_check_printing
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-03-19 15:52:48 +0000
committerThibault Delavallée <tde@odoo.com>2020-03-19 17:13:30 +0000
commit215b2fffa23409ab91729bf926d6a8ed9a2e6f35 (patch)
treec83cd6c9ca385f26e522dec7a724c349d0ec2767 /addons/account_check_printing
parent86691b1379ebb470c73030926a118e9f3770bf70 (diff)
[FIX] account_check_printing: do not set account_check_printing_layout as required
Adding required fields on company model is annoying for tests. Indeed multi company tests may run during module installation, notably in CRM. Those tests generally require to create a new company which is not possible if the column is required but module not already loaded in registry. This is the case if for example account_invoice_extract is installed and updating CRM when testing website_crm_score. When possible, avoid required fields on a such used model as company. In this case we simply make the field required in the view, and handle a void value as the default disabled one, leading to no functional change. closes odoo/odoo#48059 Related: odoo/enterprise#9381 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/account_check_printing')
-rw-r--r--addons/account_check_printing/models/account_payment.py3
-rw-r--r--addons/account_check_printing/models/res_company.py5
-rw-r--r--addons/account_check_printing/views/res_config_settings_views.xml2
3 files changed, 5 insertions, 5 deletions
diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py
index 5423d1c7af9..eeb098c2f45 100644
--- a/addons/account_check_printing/models/account_payment.py
+++ b/addons/account_check_printing/models/account_payment.py
@@ -110,7 +110,7 @@ class AccountPayment(models.Model):
def do_print_checks(self):
check_layout = self[0].company_id.account_check_printing_layout
- if check_layout == 'disabled':
+ if not check_layout or check_layout == 'disabled':
raise UserError(_("You have to choose a check layout. For this, go in Invoicing/Accounting Settings, search for 'Checks layout' and set one."))
report_action = self.env.ref(check_layout, False)
if not report_action:
@@ -118,7 +118,6 @@ class AccountPayment(models.Model):
self.write({'state': 'sent'})
return report_action.report_action(self)
-
def set_check_amount_in_words(self):
for payment in self:
payment.check_amount_in_words = payment.currency_id.amount_to_text(payment.amount) if payment.currency_id else ''
diff --git a/addons/account_check_printing/models/res_company.py b/addons/account_check_printing/models/res_company.py
index bf6c584ae06..45d22854d88 100644
--- a/addons/account_check_printing/models/res_company.py
+++ b/addons/account_check_printing/models/res_company.py
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
-from odoo import models, api, fields
+from odoo import models, fields
+
class res_company(models.Model):
_inherit = "res.company"
# This field needs to be overridden with `selection_add` in the modules which intends to add report layouts.
# The xmlID of all the report actions which are actually Check Layouts has to be kept as key of the selection.
- account_check_printing_layout = fields.Selection(string="Check Layout", required=True,
+ account_check_printing_layout = fields.Selection(string="Check Layout",
help="Select the format corresponding to the check paper you will be printing your checks on.\n"
"In order to disable the printing feature, select 'None'.",
selection=[
diff --git a/addons/account_check_printing/views/res_config_settings_views.xml b/addons/account_check_printing/views/res_config_settings_views.xml
index ef5e5f8f8c6..e3325ae3c84 100644
--- a/addons/account_check_printing/views/res_config_settings_views.xml
+++ b/addons/account_check_printing/views/res_config_settings_views.xml
@@ -9,7 +9,7 @@
<div class="content-group">
<div class="row mt16">
<label for="account_check_printing_layout" class="col-lg-4 o_light_label"/>
- <field name="account_check_printing_layout"/>
+ <field name="account_check_printing_layout" required="True"/>
</div>
<div class="row">
<label for="account_check_printing_multi_stub" class="col-lg-4 o_light_label"/>