[REF] account_check_printing: refatoring to better inheritancy
* localized checks layout of US and CA introduced in enterprise * account settings now install account_check_printing instead of the US checks layout Wsa PR #18791. Was task 33298
This commit is contained in:
committed by
qdp-odoo
parent
aca61e3584
commit
32db86e3a0
@@ -35,7 +35,9 @@ def _auto_install_l10n(cr, registry):
|
||||
module_list.append('l10n_generic_coa')
|
||||
if country_code == 'US':
|
||||
module_list.append('account_plaid')
|
||||
module_list.append('account_check_printing')
|
||||
module_list.append('l10n_us_check_printing')
|
||||
if country_code == 'CA':
|
||||
module_list.append('l10n_ca_check_printing')
|
||||
if country_code in ['US', 'AU', 'NZ', 'CA', 'CO', 'EC', 'ES', 'FR', 'IN', 'MX', 'UK']:
|
||||
module_list.append('account_yodlee')
|
||||
if country_code in SYSCOHADA_LIST + [
|
||||
|
||||
@@ -37,7 +37,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
module_account_payment = fields.Boolean(string='Online Payment')
|
||||
module_account_reports = fields.Boolean("Dynamic Reports")
|
||||
module_account_reports_followup = fields.Boolean("Enable payment followup management")
|
||||
module_l10n_us_check_printing = fields.Boolean("Allow check printing and deposits")
|
||||
module_account_check_printing = fields.Boolean("Allow check printing and deposits")
|
||||
module_account_batch_deposit = fields.Boolean(string='Use batch deposit',
|
||||
help='This allows you to group received checks before you deposit them to the bank.\n'
|
||||
'-This installs the module account_batch_deposit.')
|
||||
|
||||
@@ -245,10 +245,10 @@
|
||||
<div class="row mt16 o_settings_container">
|
||||
<div class="col-xs-12 col-md-6 o_setting_box" groups="account.group_account_user">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="module_l10n_us_check_printing" widget="upgrade_boolean"/>
|
||||
<field name="module_account_check_printing" widget="upgrade_boolean"/>
|
||||
</div>
|
||||
<div class="o_setting_right_pane">
|
||||
<label string="Checks" for="module_l10n_us_check_printing"/>
|
||||
<label string="Checks" for="module_account_check_printing"/>
|
||||
<span class="fa fa-lg fa-building-o" title="Values set here are company-specific." groups="base.group_multi_company"/>
|
||||
<div class="text-muted" id="print_bills_payment">
|
||||
Print checks to pay your vendors
|
||||
|
||||
@@ -17,6 +17,7 @@ The check settings are located in the accounting journals configuration page.
|
||||
'data/account_check_printing_data.xml',
|
||||
'views/account_journal_views.xml',
|
||||
'views/account_payment_views.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'wizard/print_prenumbered_checks_views.xml'
|
||||
],
|
||||
'installable': True,
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_check_printing
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.0alpha1+e\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-01-31 09:57+0000\n"
|
||||
"PO-Revision-Date: 2018-01-31 09:57+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_journal.py:58
|
||||
#, python-format
|
||||
msgid " : Check Number Sequence"
|
||||
msgstr " : Cheque Number Sequence"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_payment.py:69
|
||||
#, python-format
|
||||
msgid "A check memo cannot exceed 60 characters."
|
||||
msgstr "A cheque memo cannot exceed 60 characters."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_company_account_check_printing_margin_left
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_company_account_check_printing_margin_right
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_company_account_check_printing_margin_top
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_config_settings_account_check_printing_margin_left
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_config_settings_account_check_printing_margin_right
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_config_settings_account_check_printing_margin_top
|
||||
msgid "Adjust the margins of generated checks to make it fit your printer's settings."
|
||||
msgstr "Adjust the margins of generated cheques to make it fit your printer's settings."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_company_account_check_printing_layout
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_config_settings_account_check_printing_layout
|
||||
msgid "Check Layout"
|
||||
msgstr "Cheque Layout"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_company_account_check_printing_margin_left
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_config_settings_account_check_printing_margin_left
|
||||
msgid "Check Left Margin"
|
||||
msgstr "Cheque Left Margin"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_account_payment_check_number
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_account_register_payments_check_number
|
||||
msgid "Check Number"
|
||||
msgstr "Cheque Number"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.view_account_journal_form_inherited
|
||||
msgid "Check Printing"
|
||||
msgstr "Cheque Printing"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_account_journal_check_printing_payment_method_selected
|
||||
msgid "Check Printing Payment Method Selected"
|
||||
msgstr "Cheque Printing Payment Method Selected"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_config_settings_account_check_printing_margin_right
|
||||
msgid "Check Right Margin"
|
||||
msgstr "Cheque Right Margin"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_account_journal_check_sequence_id
|
||||
msgid "Check Sequence"
|
||||
msgstr "Cheque Sequence"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_company_account_check_printing_margin_top
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_config_settings_account_check_printing_margin_top
|
||||
msgid "Check Top Margin"
|
||||
msgstr "Cheque Top Margin"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_journal_check_manual_sequencing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_payment_check_manual_sequencing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_register_payments_check_manual_sequencing
|
||||
msgid "Check this option if your pre-printed checks are not numbered."
|
||||
msgstr "Check this option if your pre-printed cheques are not numbered."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.account_journal_dashboard_kanban_view_inherited
|
||||
msgid "Check to print"
|
||||
msgstr "Cheque to print"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:account.payment.method,name:account_check_printing.account_payment_method_check
|
||||
msgid "Checks"
|
||||
msgstr "Cheques"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.view_payment_check_printing_search
|
||||
msgid "Checks To Print"
|
||||
msgstr "Cheques To Print"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_journal_check_sequence_id
|
||||
msgid "Checks numbering sequence."
|
||||
msgstr "Cheques numbering sequence."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_journal.py:97
|
||||
#, python-format
|
||||
msgid "Checks to Print"
|
||||
msgstr "Cheque to Print"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.account_journal_dashboard_kanban_view_inherited
|
||||
msgid "Checks to print"
|
||||
msgstr "Cheques to print"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_payment.py:89
|
||||
#, python-format
|
||||
msgid "In order to print multiple checks at once, they must belong to the same bank journal."
|
||||
msgstr "In order to print multiple cheques at once, they must belong to the same bank journal."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.view_account_bank_journal_form_inherited_check_printing
|
||||
msgid "Manual Numbering of check"
|
||||
msgstr "Manual Numbering of cheque"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_company_account_check_printing_multi_stub
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_res_config_settings_account_check_printing_multi_stub
|
||||
msgid "Multi-Pages Check Stub"
|
||||
msgstr "Multi-Pages Cheque Stub"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_account_journal_check_next_number
|
||||
#: model:ir.model.fields,field_description:account_check_printing.field_print_prenumbered_checks_next_check_number
|
||||
msgid "Next Check Number"
|
||||
msgstr "Next Cheque Number"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_register_payments_check_number
|
||||
msgid "Number of the check corresponding to this payment. If your pre-printed check are not already numbered, you can manage the numbering in the journal configuration page."
|
||||
msgstr "Number of the cheque corresponding to this payment. If your pre-printed cheque are not already numbered, you can manage the numbering in the journal configuration page."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_payment.py:86
|
||||
#, python-format
|
||||
msgid "Payments to print as a checks must have 'Check' selected as payment method and not have already been reconciled"
|
||||
msgstr "Payments to print as a cheques must have 'Cheque' selected as payment method and not have already been reconciled"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.print_pre_numbered_checks_view
|
||||
msgid "Please enter the number of the first pre-printed check that you are about to print on."
|
||||
msgstr "Please enter the number of the first pre-printed cheque that you are about to print on."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.view_account_payment_form_inherited
|
||||
msgid "Print Check"
|
||||
msgstr "Print Cheque"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.actions.server,name:account_check_printing.action_account_print_checks
|
||||
msgid "Print Checks"
|
||||
msgstr "Print Cheques"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_payment.py:99
|
||||
#: model:ir.model,name:account_check_printing.model_print_prenumbered_checks
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.print_pre_numbered_checks_view
|
||||
#, python-format
|
||||
msgid "Print Pre-numbered Checks"
|
||||
msgstr "Print Pre-numbered Cheques"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_company_account_check_printing_layout
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_config_settings_account_check_printing_layout
|
||||
msgid "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'."
|
||||
msgstr "Select the format corresponding to the cheque paper you will be printing your cheques on.\n"
|
||||
"In order to disable the printing feature, select 'None'."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_journal_check_next_number
|
||||
msgid "Sequence number of the next printed check."
|
||||
msgstr "Sequence number of the next printed cheque."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_journal_check_printing_payment_method_selected
|
||||
msgid "Technical feature used to know whether check printing was enabled as payment method."
|
||||
msgstr "Technical feature used to know whether cheque printing was enabled as payment method."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_journal.py:26
|
||||
#, python-format
|
||||
msgid "The last check number was %s. In order to avoid a check being rejected by the bank, you can only use a greater number."
|
||||
msgstr "The last cheque number was %s. In order to avoid a cheque being rejected by the bank, you can only use a greater number."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_account_payment_check_number
|
||||
msgid "The selected journal is configured to print check numbers. If your pre-printed check paper already has numbers or if the current numbering is wrong, you can change it in the journal configuration page."
|
||||
msgstr "The selected journal is configured to print cheque numbers. If your pre-printed cheque paper already has numbers or if the current numbering is wrong, you can change it in the journal configuration page."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: code:addons/account_check_printing/models/account_payment.py:121
|
||||
#, python-format
|
||||
msgid "There is no check layout configured.\n"
|
||||
"Make sure the proper check printing module is installed and its configuration (in company settings > 'Configuration' tab) is correct."
|
||||
msgstr "There is no cheque layout configured.\n"
|
||||
"Make sure the proper cheque printing module is installed and its configuration (in company settings > 'Configuration' tab) is correct."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_company_account_check_printing_multi_stub
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_config_settings_account_check_printing_multi_stub
|
||||
msgid "This option allows you to print check details (stub) on multiple pages if they don't fit on a single page."
|
||||
msgstr "This option allows you to print cheque details (stub) on multiple pages if they don't fit on a single page."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_company_account_check_printing_date_label
|
||||
#: model:ir.model.fields,help:account_check_printing.field_res_config_settings_account_check_printing_date_label
|
||||
msgid "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."
|
||||
msgstr "This option allows you to print the date label on the cheque as per CPA. Disable this if your pre-printed cheque includes the date label."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: model:ir.ui.view,arch_db:account_check_printing.print_pre_numbered_checks_view
|
||||
msgid "This will allow to save on payments the number of the corresponding check."
|
||||
msgstr "This will allow to save on payments the number of the corresponding cheque."
|
||||
|
||||
#. module: account_check_printing
|
||||
#: selection:res.company,account_check_printing_layout:0
|
||||
msgid "check in middle"
|
||||
msgstr "cheque in middle"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: selection:res.company,account_check_printing_layout:0
|
||||
msgid "check on bottom"
|
||||
msgstr "cheque on bottom"
|
||||
|
||||
#. module: account_check_printing
|
||||
#: selection:res.company,account_check_printing_layout:0
|
||||
msgid "check on top"
|
||||
msgstr "cheque on top"
|
||||
|
||||
@@ -4,3 +4,5 @@
|
||||
from . import account_journal
|
||||
from . import account_payment
|
||||
from . import chart_template
|
||||
from . import res_company
|
||||
from . import res_config_settings
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.tools.misc import formatLang, format_date
|
||||
|
||||
INV_LINES_PER_STUB = 9
|
||||
|
||||
class AccountRegisterPayments(models.TransientModel):
|
||||
_inherit = "account.register.payments"
|
||||
@@ -118,5 +120,104 @@ class AccountPayment(models.Model):
|
||||
@api.multi
|
||||
def do_print_checks(self):
|
||||
""" This method is a hook for l10n_xx_check_printing modules to implement actual check printing capabilities """
|
||||
raise UserError(_("There is no check layout configured.\nMake sure the proper check printing module is installed"
|
||||
" and its configuration (in company settings > 'Configuration' tab) is correct."))
|
||||
raise UserError(_("You have to choose a check layout. For this, go in Apps, search for 'Checks layout' and install one."))
|
||||
|
||||
#######################
|
||||
#CHECK PRINTING METHODS
|
||||
#######################
|
||||
def _check_fill_line(self, amount_str):
|
||||
return amount_str and (amount_str + ' ').ljust(200, '*') or ''
|
||||
|
||||
def _check_build_page_info(self, i, p):
|
||||
multi_stub = self.company_id.account_check_printing_multi_stub
|
||||
return {
|
||||
'sequence_number': self.check_number if (self.journal_id.check_manual_sequencing and self.check_number != 0) else False,
|
||||
'payment_date': format_date(self.env, self.payment_date),
|
||||
'partner_id': self.partner_id,
|
||||
'partner_name': self.partner_id.name,
|
||||
'currency': self.currency_id,
|
||||
'state': self.state,
|
||||
'amount': formatLang(self.env, self.amount, currency_obj=self.currency_id) if i == 0 else 'VOID',
|
||||
'amount_in_word': self._check_fill_line(self.check_amount_in_words) if i == 0 else 'VOID',
|
||||
'memo': self.communication,
|
||||
'stub_cropped': not multi_stub and len(self.invoice_ids) > INV_LINES_PER_STUB,
|
||||
# If the payment does not reference an invoice, there is no stub line to display
|
||||
'stub_lines': p,
|
||||
}
|
||||
|
||||
def _check_get_pages(self):
|
||||
""" Returns the data structure used by the template : a list of dicts containing what to print on pages.
|
||||
"""
|
||||
stub_pages = self._check_make_stub_pages() or [False]
|
||||
pages = []
|
||||
for i, p in enumerate(stub_pages):
|
||||
pages.append(self._check_build_page_info(i, p))
|
||||
return pages
|
||||
|
||||
def _check_make_stub_pages(self):
|
||||
""" The stub is the summary of paid invoices. It may spill on several pages, in which case only the check on
|
||||
first page is valid. This function returns a list of stub lines per page.
|
||||
"""
|
||||
if len(self.invoice_ids) == 0:
|
||||
return None
|
||||
|
||||
multi_stub = self.company_id.account_check_printing_multi_stub
|
||||
|
||||
invoices = self.invoice_ids.sorted(key=lambda r: r.date_due)
|
||||
debits = invoices.filtered(lambda r: r.type == 'in_invoice')
|
||||
credits = invoices.filtered(lambda r: r.type == 'in_refund')
|
||||
|
||||
# Prepare the stub lines
|
||||
if not credits:
|
||||
stub_lines = [self.make_stub_line(inv) for inv in invoices]
|
||||
else:
|
||||
stub_lines = [{'header': True, 'name': "Bills"}]
|
||||
stub_lines += [self.make_stub_line(inv) for inv in debits]
|
||||
stub_lines += [{'header': True, 'name': "Refunds"}]
|
||||
stub_lines += [self.make_stub_line(inv) for inv in credits]
|
||||
|
||||
# Crop the stub lines or split them on multiple pages
|
||||
if not multi_stub:
|
||||
# If we need to crop the stub, leave place for an ellipsis line
|
||||
num_stub_lines = len(stub_lines) > INV_LINES_PER_STUB and INV_LINES_PER_STUB - 1 or INV_LINES_PER_STUB
|
||||
stub_pages = [stub_lines[:num_stub_lines]]
|
||||
else:
|
||||
stub_pages = []
|
||||
i = 0
|
||||
while i < len(stub_lines):
|
||||
# Make sure we don't start the credit section at the end of a page
|
||||
if len(stub_lines) >= i + INV_LINES_PER_STUB and stub_lines[i + INV_LINES_PER_STUB - 1].get('header'):
|
||||
num_stub_lines = INV_LINES_PER_STUB - 1 or INV_LINES_PER_STUB
|
||||
else:
|
||||
num_stub_lines = INV_LINES_PER_STUB
|
||||
stub_pages.append(stub_lines[i:i + num_stub_lines])
|
||||
i += num_stub_lines
|
||||
|
||||
return stub_pages
|
||||
|
||||
def _check_make_stub_line(self, invoice):
|
||||
""" Return the dict used to display an invoice/refund in the stub
|
||||
"""
|
||||
# Find the account.partial.reconcile which are common to the invoice and the payment
|
||||
if invoice.type in ['in_invoice', 'out_refund']:
|
||||
invoice_sign = 1
|
||||
invoice_payment_reconcile = invoice.move_id.line_ids.mapped('matched_debit_ids').filtered(lambda r: r.debit_move_id in self.move_line_ids)
|
||||
else:
|
||||
invoice_sign = -1
|
||||
invoice_payment_reconcile = invoice.move_id.line_ids.mapped('matched_credit_ids').filtered(lambda r: r.credit_move_id in self.move_line_ids)
|
||||
|
||||
if self.currency_id != self.journal_id.company_id.currency_id:
|
||||
amount_paid = abs(sum(invoice_payment_reconcile.mapped('amount_currency')))
|
||||
else:
|
||||
amount_paid = abs(sum(invoice_payment_reconcile.mapped('amount')))
|
||||
|
||||
amount_residual = invoice_sign * invoice.residual
|
||||
|
||||
return {
|
||||
'due_date': format_date(self.env, invoice.date_due),
|
||||
'number': invoice.reference and invoice.number + ' - ' + invoice.reference or invoice.number,
|
||||
'amount_total': formatLang(self.env, invoice_sign * invoice.amount_total, currency_obj=invoice.currency_id),
|
||||
'amount_residual': formatLang(self.env, amount_residual, currency_obj=invoice.currency_id) if amount_residual * 10**4 != 0 else '-',
|
||||
'amount_paid': formatLang(self.env, invoice_sign * amount_paid, currency_obj=invoice.currency_id),
|
||||
'currency': invoice.currency_id,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp import models, api, fields
|
||||
|
||||
class res_company(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
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')
|
||||
],
|
||||
default="action_print_check_top")
|
||||
|
||||
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.")
|
||||
|
||||
account_check_printing_multi_stub = fields.Boolean('Multi-Pages Check Stub',
|
||||
help="This option allows you to print check details (stub) on multiple pages if they don't fit on a single page.")
|
||||
|
||||
account_check_printing_margin_top = fields.Float('Check Top Margin', default=0.25,
|
||||
help="Adjust the margins of generated checks to make it fit your printer's settings.")
|
||||
|
||||
account_check_printing_margin_left = fields.Float('Check Left Margin', default=0.25,
|
||||
help="Adjust the margins of generated checks to make it fit your printer's settings.")
|
||||
|
||||
account_check_printing_margin_right = fields.Float('Right Margin', default=0.25,
|
||||
help="Adjust the margins of generated checks to make it fit your printer's settings.")
|
||||
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
country_code = fields.Char(string="Company Country code", related='company_id.country_id.code', readonly=True)
|
||||
account_check_printing_layout = fields.Selection(related='company_id.account_check_printing_layout', 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'.")
|
||||
account_check_printing_date_label = fields.Boolean(related='company_id.account_check_printing_date_label', string="Print Date Label",
|
||||
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.")
|
||||
account_check_printing_multi_stub = fields.Boolean(related='company_id.account_check_printing_multi_stub', string='Multi-Pages Check Stub',
|
||||
help="This option allows you to print check details (stub) on multiple pages if they don't fit on a single page.")
|
||||
account_check_printing_margin_top = fields.Float(related='company_id.account_check_printing_margin_top', string='Check Top Margin',
|
||||
help="Adjust the margins of generated checks to make it fit your printer's settings.")
|
||||
account_check_printing_margin_left = fields.Float(related='company_id.account_check_printing_margin_left', string='Check Left Margin',
|
||||
help="Adjust the margins of generated checks to make it fit your printer's settings.")
|
||||
account_check_printing_margin_right = fields.Float(related='company_id.account_check_printing_margin_right', string='Check Right Margin',
|
||||
help="Adjust the margins of generated checks to make it fit your printer's settings.")
|
||||
@@ -0,0 +1,77 @@
|
||||
# Make sure / performs a floating point division even if environment is python 2
|
||||
from __future__ import division
|
||||
|
||||
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
|
||||
from odoo.addons.l10n_us_check_printing.report import print_check
|
||||
from odoo.tests import tagged
|
||||
import time
|
||||
|
||||
import math
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestPrintCheck(AccountingTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPrintCheck, self).setUp()
|
||||
|
||||
self.invoice_model = self.env['account.invoice']
|
||||
self.invoice_line_model = self.env['account.invoice.line']
|
||||
self.register_payments_model = self.env['account.register.payments']
|
||||
|
||||
self.partner_axelor = self.env.ref("base.res_partner_2")
|
||||
self.product = self.env.ref("product.product_product_4")
|
||||
self.payment_method_check = self.env.ref("account_check_printing.account_payment_method_check")
|
||||
|
||||
self.account_payable = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1)
|
||||
self.account_expenses = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1)
|
||||
|
||||
self.bank_journal = self.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'})
|
||||
self.bank_journal.check_manual_sequencing = True
|
||||
|
||||
def create_invoice(self, amount=100, is_refund=False):
|
||||
invoice = self.invoice_model.create({
|
||||
'partner_id': self.partner_axelor.id,
|
||||
'reference_type': 'none',
|
||||
'name': is_refund and "Supplier Refund" or "Supplier Invoice",
|
||||
'type': is_refund and "in_refund" or "in_invoice",
|
||||
'account_id': self.account_payable.id,
|
||||
'date_invoice': time.strftime('%Y') + '-06-26',
|
||||
})
|
||||
self.invoice_line_model.create({
|
||||
'product_id': self.product.id,
|
||||
'quantity': 1,
|
||||
'price_unit': is_refund and amount / 4 or amount,
|
||||
'invoice_id': invoice.id,
|
||||
'name': 'something',
|
||||
'account_id': self.account_expenses.id,
|
||||
})
|
||||
invoice.action_invoice_open()
|
||||
return invoice
|
||||
|
||||
def create_payment(self, invoices):
|
||||
register_payments = self.register_payments_model.with_context({
|
||||
'active_model': 'account.invoice',
|
||||
'active_ids': invoices.ids
|
||||
}).create({
|
||||
'payment_date': time.strftime('%Y') + '-07-15',
|
||||
'journal_id': self.bank_journal.id,
|
||||
'payment_method_id': self.payment_method_check.id,
|
||||
})
|
||||
register_payments.create_payments()
|
||||
return self.env['account.payment'].search([], order="id desc", limit=1)
|
||||
|
||||
def test_print_check(self):
|
||||
# Make a payment for 10 invoices and 5 credit notes
|
||||
invoices = self.env['account.invoice']
|
||||
for i in range(0,15):
|
||||
invoices |= self.create_invoice(is_refund=(i % 3 == 0))
|
||||
payment = self.create_payment(invoices)
|
||||
|
||||
# Check the data generated for the report
|
||||
self.env.ref('base.main_company').write({'account_check_printing_multi_stub': True})
|
||||
report_pages = payment._check_get_pages()
|
||||
self.assertEqual(len(report_pages), int(math.ceil(len(invoices.ids) / print_check.INV_LINES_PER_STUB)))
|
||||
self.env.ref('base.main_company').write({'account_check_printing_multi_stub': False})
|
||||
report_pages = payment._check_get_pages()
|
||||
self.assertEqual(len(report_pages), 1)
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.account.check.printing</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<div id="print_bills_payment" position="after">
|
||||
<div class="content-group">
|
||||
<div class="row mt16">
|
||||
<label for="account_check_printing_layout" class="col-md-4 o_light_label"/>
|
||||
<field name="account_check_printing_layout"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="account_check_printing_multi_stub" class="col-md-4 o_light_label"/>
|
||||
<field name="account_check_printing_multi_stub"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="account_check_printing_margin_top" class="col-md-4 o_light_label"/>
|
||||
<field name="account_check_printing_margin_top"/>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="account_check_printing_margin_left" class="col-md-4 o_light_label"/>
|
||||
<field name="account_check_printing_margin_left"/>
|
||||
</div>
|
||||
<field name="country_code" invisible="1" />
|
||||
<div class="row" attrs="{'invisible': [('country_code', '!=', 'CA')]}">
|
||||
<label for="account_check_printing_margin_right" class="col-md-4 o_light_label"/>
|
||||
<field name="account_check_printing_margin_right"/>
|
||||
</div>
|
||||
<div class="row" attrs="{'invisible': [('country_code', '!=', 'CA')]}">
|
||||
<label for="account_check_printing_date_label" class="col-md-4 o_light_label"/>
|
||||
<field name="account_check_printing_date_label"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user