diff options
| author | Ravi Gohil <rgo@odoo.com> | 2019-08-05 06:58:27 +0000 |
|---|---|---|
| committer | Ravi Gohil <rgo@odoo.com> | 2019-12-03 05:44:04 +0000 |
| commit | 3b4592acfcd67f2b3e467c5e3f82d7b524b96843 (patch) | |
| tree | 9864584e994665cc0cccb9985b4e44fa8c707106 | |
| parent | 42de9e129f0832c57ad3845bcbfc9c5b3b1bb301 (diff) | |
[IMP] account_check_printing: make check printing generic
Now, if user intends to add a check layout for it's own country then he/she
will need to define a layout template and a report action associated to it.
The xmlID(s) of this report action(s) needs to set as key of
'account_check_printing_layout' selection field after redifining
it in it's own module.
Refer l10n_{ca/us}_check_printing modules.
closes odoo/odoo#35438
Task: 2030714
Closes: 35438
Related: odoo/enterprise#5007
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
| -rw-r--r-- | addons/account_check_printing/models/account_payment.py | 10 | ||||
| -rw-r--r-- | addons/account_check_printing/models/res_company.py | 9 |
2 files changed, 12 insertions, 7 deletions
diff --git a/addons/account_check_printing/models/account_payment.py b/addons/account_check_printing/models/account_payment.py index 52bd7dc6149..85b01c5491e 100644 --- a/addons/account_check_printing/models/account_payment.py +++ b/addons/account_check_printing/models/account_payment.py @@ -96,8 +96,14 @@ class AccountPayment(models.Model): self.write({'state': 'posted'}) def do_print_checks(self): - """ This method is a hook for l10n_xx_check_printing modules to implement actual check printing capabilities """ - raise UserError(_("You have to choose a check layout. For this, go in Apps, search for 'Checks layout' and install one.")) + check_layout = self[0].company_id.account_check_printing_layout + if 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: + raise UserError(_("Something went wrong with Check Layout, please select another layout in Invoicing/Accounting Settings and try again.")) + self.write({'state': 'sent'}) + return report_action.report_action(self) def set_check_amount_in_words(self): diff --git a/addons/account_check_printing/models/res_company.py b/addons/account_check_printing/models/res_company.py index fb985473744..bf6c584ae06 100644 --- a/addons/account_check_printing/models/res_company.py +++ b/addons/account_check_printing/models/res_company.py @@ -5,16 +5,15 @@ from odoo import models, api, 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, 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=[ - ('disabled', 'None'), - ('action_print_check_top', 'check on top'), - ('action_print_check_middle', 'check in middle'), - ('action_print_check_bottom', 'check on bottom') + ('disabled', 'None') ], - default="action_print_check_top") + default='disabled') account_check_printing_date_label = fields.Boolean('Print Date Label', default=True, help="This option allows you to print the date label on the check as per CPA. Disable this if your pre-printed check includes the date label.") |
