Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acb148c
commit 464e586
Showing
24 changed files
with
690 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
================================== | ||
Account Check Printing Report Base | ||
================================== | ||
|
||
This module provides the basic framework for check printing, and a sample | ||
layout. | ||
|
||
|
||
Configuration | ||
============= | ||
|
||
Go to 'Settings / Users / Companies' and assign the desired check format. | ||
This module proposes a basic layout, but other modues such as | ||
"account_check_printing_report_dlt103" provide formats adjusted to known | ||
check formats such as DLT103. | ||
|
||
|
||
Usage | ||
===== | ||
|
||
* Go to 'Invoicing / Purchases / Payments'. Select one of the payments with | ||
type 'Check' and print the check. | ||
|
||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/96/9.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/account-payment/issues>`_. In case of | ||
trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Jordi Ballester Alomar <jordi.ballester@eficent.com> | ||
|
||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import report | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'Account Check Printing Report Base', | ||
'version': '9.0.1.0.0', | ||
"author": "Eficent, " | ||
"Serpent Consulting Services Pvt. Ltd.,", | ||
'category': 'Generic Modules/Accounting', | ||
"website": "https://github.com/OCA/account-payment", | ||
'depends': ['account_check_printing'], | ||
'data': [ | ||
'data/report_paperformat.xml', | ||
'data/account_payment_check_report_data.xml', | ||
'views/report_check_base.xml', | ||
'views/res_company_view.xml', | ||
'views/account_payment_check_report_view.xml', | ||
'report/account_check_writing_report.xml', | ||
], | ||
'installable': True, | ||
'active': False, | ||
} |
10 changes: 10 additions & 0 deletions
10
account_check_printing_report_base/data/account_payment_check_report_data.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<record id="account_payment_check_report_base" | ||
model="account.payment.check.report"> | ||
<field name="name">base</field> | ||
<field name="report">account_check_printing_report_base.report_check_base</field> | ||
</record> | ||
</data> | ||
</openerp> |
20 changes: 20 additions & 0 deletions
20
account_check_printing_report_base/data/report_paperformat.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
<record id="paperformat_check" model="report.paperformat"> | ||
<field name="name"> US Bank Check</field> | ||
<field name="default" eval="True"/> | ||
<field name="format">custom</field> | ||
<field name="page_height">297</field> | ||
<field name="page_width">210</field> | ||
<field name="orientation">Portrait</field> | ||
<field name="margin_top">3</field> | ||
<field name="margin_bottom">3</field> | ||
<field name="margin_left">3</field> | ||
<field name="margin_right">3</field> | ||
<field name="header_line" eval="False" /> | ||
<field name="header_spacing">3</field> | ||
<field name="dpi">80</field> | ||
</record> | ||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
import account_payment | ||
import res_company | ||
import account_payment_check_report | ||
|
19 changes: 19 additions & 0 deletions
19
account_check_printing_report_base/models/account_payment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, api | ||
|
||
|
||
class AccountPayment(models.Model): | ||
_inherit = "account.payment" | ||
|
||
@api.multi | ||
def do_print_checks(self): | ||
for rec in self: | ||
if rec.company_id.check_layout_id: | ||
return self.env['report'].get_action( | ||
rec, rec.company_id.check_layout_id.report) | ||
return super(AccountPayment, self).do_print_checks() |
14 changes: 14 additions & 0 deletions
14
account_check_printing_report_base/models/account_payment_check_report.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import api, fields, models | ||
|
||
|
||
class AccountPaymentCheckReport(models.Model): | ||
_name = "account.payment.check.report" | ||
|
||
name = fields.Char(string='Name', required=True) | ||
report = fields.Char(string='Report name', required=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import models, fields | ||
|
||
|
||
class ResCompany(models.Model): | ||
|
||
_inherit = "res.company" | ||
|
||
check_layout_id = fields.Many2one( | ||
comodel_name='account.payment.check.report', | ||
string="Check format") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import check_print |
17 changes: 17 additions & 0 deletions
17
account_check_printing_report_base/report/account_check_writing_report.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<openerp> | ||
<data> | ||
<report | ||
id="action_report_check_base" | ||
model="account.payment" | ||
string="Payment Check Base" | ||
report_type="qweb-pdf" | ||
name="account_check_printing_report_base.report_check_base" | ||
file="account_check_printing_report_base.report_check_base" | ||
/> | ||
|
||
<record id="action_report_check_base" model="ir.actions.report.xml"> | ||
<field name="paperformat_id" ref="account_check_printing_report_base.paperformat_check"/> | ||
</record> | ||
</data> | ||
</openerp> |
102 changes: 102 additions & 0 deletions
102
account_check_printing_report_base/report/check_print.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Eficent Business and IT Consulting Services S.L. | ||
# (http://www.eficent.com) | ||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp import api, exceptions, models, _ | ||
import time | ||
from openerp.tools import float_is_zero | ||
|
||
|
||
class ReportCheckPrint(models.AbstractModel): | ||
_name = 'report.account_check_printing_report_base.report_check_base' | ||
|
||
def fill_stars(self, amount_in_word): | ||
if amount_in_word and len(amount_in_word) < 100: | ||
stars = 100 - len(amount_in_word) | ||
return ' '.join([amount_in_word, '*' * stars]) | ||
else: | ||
return amount_in_word | ||
|
||
@api.multi | ||
def get_paid_lines(self, payments): | ||
lines = {} | ||
for payment in payments: | ||
lines[payment.id] = [] | ||
for invoice in payment.invoice_ids: | ||
amount_currency = 0.0 | ||
amount = 0.0 | ||
line = { | ||
'date_due': invoice.date_due, | ||
'reference': invoice.reference, | ||
'number': invoice.number, | ||
'amount_total': invoice.amount_total, | ||
'residual': invoice.residual, | ||
'paid_amount': 0.0 | ||
} | ||
for pay in invoice.payment_move_line_ids: | ||
payment_currency_id = False | ||
if invoice.type in ('out_invoice', 'in_refund'): | ||
amount = sum( | ||
[p.amount for p in pay.matched_debit_ids if | ||
p.debit_move_id in invoice.move_id.line_ids]) | ||
amount_currency = sum([p.amount_currency for p in | ||
pay.matched_debit_ids if | ||
p.debit_move_id in | ||
invoice.move_id.line_ids]) | ||
if pay.matched_debit_ids: | ||
payment_currency_id = all( | ||
[p.currency_id == | ||
pay.matched_debit_ids[0].currency_id | ||
for p in pay.matched_debit_ids]) \ | ||
and pay.matched_debit_ids[0].\ | ||
currency_id or False | ||
elif invoice.type in ('in_invoice', 'out_refund'): | ||
amount = sum( | ||
[p.amount for p in pay.matched_credit_ids if | ||
p.credit_move_id in invoice.move_id.line_ids]) | ||
amount_currency = sum([p.amount_currency for p in | ||
pay.matched_credit_ids if | ||
p.credit_move_id in | ||
invoice.move_id.line_ids]) | ||
if pay.matched_credit_ids: | ||
payment_currency_id = all( | ||
[p.currency_id == | ||
pay.matched_credit_ids[0].currency_id | ||
for p in pay.matched_credit_ids]) \ | ||
and pay.matched_credit_ids[0].\ | ||
currency_id or False | ||
|
||
if payment_currency_id and payment_currency_id == \ | ||
invoice.currency_id: | ||
amount_to_show = amount_currency | ||
else: | ||
amount_to_show = pay.company_id.currency_id.\ | ||
with_context(date=pay.date).compute( | ||
amount, invoice.currency_id) | ||
if not float_is_zero( | ||
amount_to_show, | ||
precision_rounding=invoice.currency_id.rounding): | ||
line['paid_amount'] = amount_to_show | ||
lines[payment.id].append(line) | ||
return lines | ||
|
||
@api.multi | ||
def render_html(self, data): | ||
payments = self.env['account.payment'].browse(self.ids) | ||
paid_lines = self.get_paid_lines(payments) | ||
docargs = { | ||
'doc_ids': self.ids, | ||
'doc_model': 'account.payment', | ||
'docs': payments, | ||
'time': time, | ||
'fill_stars': self.fill_stars, | ||
'paid_lines': paid_lines | ||
} | ||
|
||
if self.env.user.company_id.check_layout_id: | ||
return self.env['report'].render( | ||
self.env.user.company_id.check_layout_id.report, | ||
docargs) | ||
raise exceptions.Warning(_('You must define a check layout')) |
61 changes: 61 additions & 0 deletions
61
account_check_printing_report_base/views/account_payment_check_report_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="account_payment_check_report_form" | ||
model="ir.ui.view"> | ||
<field name="name">account.payment.check.report.form</field> | ||
<field name="model">account.payment.check.report</field> | ||
<field name="arch" type="xml"> | ||
<form string="Check Layout"> | ||
<sheet> | ||
<group> | ||
<field name="name"/> | ||
<field name="report"/> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="account_payment_check_report_tree" | ||
model="ir.ui.view"> | ||
<field name="name">account.payment.check.report.tree</field> | ||
<field name="model">account.payment.check.report</field> | ||
<field name="arch" type="xml"> | ||
<tree string="Check Layout"> | ||
<field name="name"/> | ||
<field name="report"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="account_payment_check_report_search" | ||
model="ir.ui.view"> | ||
<field name="name">account.payment.check.report.search</field> | ||
<field name="model">account.payment.check.report</field> | ||
<field name="arch" type="xml"> | ||
<search> | ||
<field name="name"/> | ||
<field name="report"/> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
<record id="action_account_payment_check_report" model="ir.actions.act_window"> | ||
<field name="name">Check Layouts</field> | ||
<field name="res_model">account.payment.check.report</field> | ||
<field name='view_type'>form</field> | ||
<field name='view_mode'>tree,form</field> | ||
</record> | ||
|
||
<menuitem | ||
action='action_account_payment_check_report' | ||
id='account_payment_check_report_menu' | ||
name="Check Layouts" | ||
parent='account.account_management_menu' | ||
groups="account.group_account_manager" | ||
sequence="30" /> | ||
|
||
</data> | ||
</openerp> |
Oops, something went wrong.