From e9b32978b44216ea1acb5d5fa10dbd495587ddbe Mon Sep 17 00:00:00 2001 From: "Gilles Meyomesse (ACSONE)" Date: Tue, 10 Oct 2017 17:24:55 +0200 Subject: [PATCH] [ADD] report for payment order (#370) --- account_payment_order/README.rst | 3 + account_payment_order/__init__.py | 1 + account_payment_order/__manifest__.py | 2 + .../models/account_payment_line.py | 4 +- .../models/account_payment_order.py | 12 +- account_payment_order/report/__init__.py | 1 + .../report/account_payment_order.py | 48 +++++++ .../report/account_payment_order.xml | 126 ++++++++++++++++++ .../report/print_account_payment_order.xml | 16 +++ ...ccount_invoice_payment_line_multi_view.xml | 4 - 10 files changed, 206 insertions(+), 11 deletions(-) create mode 100644 account_payment_order/report/__init__.py create mode 100644 account_payment_order/report/account_payment_order.py create mode 100644 account_payment_order/report/account_payment_order.xml create mode 100644 account_payment_order/report/print_account_payment_order.xml diff --git a/account_payment_order/README.rst b/account_payment_order/README.rst index b546bfb07..26e94fdfa 100644 --- a/account_payment_order/README.rst +++ b/account_payment_order/README.rst @@ -32,6 +32,8 @@ You can create a Debit Order via the menu Accounting > Payments > Debit Orders a This module also adds a button *Add to Payment Order* on supplier invoices and a button *Add to Debit Order* on customer invoices. +You can print a Payment Order via the menu Accounting > Payments > Payment Orders and then select the payment oder to print. + .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/173/10.0 @@ -68,6 +70,7 @@ Contributors * Sandy Carter * Angel Moya * Jose María Alzaga +* Meyomesse Gilles Maintainer ---------- diff --git a/account_payment_order/__init__.py b/account_payment_order/__init__.py index 408a6001b..fc07b7248 100644 --- a/account_payment_order/__init__.py +++ b/account_payment_order/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from . import models +from . import report from . import wizard diff --git a/account_payment_order/__manifest__.py b/account_payment_order/__manifest__.py index 34d75aab6..a9767234f 100644 --- a/account_payment_order/__manifest__.py +++ b/account_payment_order/__manifest__.py @@ -36,6 +36,8 @@ 'views/ir_attachment.xml', 'views/account_invoice_view.xml', 'data/payment_seq.xml', + 'report/print_account_payment_order.xml', + 'report/account_payment_order.xml', ], 'demo': ['demo/payment_demo.xml'], 'installable': True, diff --git a/account_payment_order/models/account_payment_line.py b/account_payment_order/models/account_payment_line.py index 9208b49fb..08ffa9002 100644 --- a/account_payment_order/models/account_payment_line.py +++ b/account_payment_order/models/account_payment_line.py @@ -39,7 +39,7 @@ class AccountPaymentLine(models.Model): amount_currency = fields.Monetary( string="Amount", currency_field='currency_id') amount_company_currency = fields.Monetary( - compute='compute_amount_company_currency', + compute='_compute_amount_company_currency', string='Amount in Company Currency', readonly=True, currency_field='company_currency_id') # v8 field : amount partner_id = fields.Many2one( @@ -76,7 +76,7 @@ class AccountPaymentLine(models.Model): @api.multi @api.depends( 'amount_currency', 'currency_id', 'company_currency_id', 'date') - def compute_amount_company_currency(self): + def _compute_amount_company_currency(self): for line in self: if line.currency_id and line.company_currency_id: line.amount_company_currency = line.currency_id.with_context( diff --git a/account_payment_order/models/account_payment_order.py b/account_payment_order/models/account_payment_order.py index 7cf975b74..8736b5283 100644 --- a/account_payment_order/models/account_payment_order.py +++ b/account_payment_order/models/account_payment_order.py @@ -86,7 +86,7 @@ class AccountPaymentOrder(models.Model): compute='_compute_total', store=True, readonly=True, currency_field='company_currency_id') bank_line_count = fields.Integer( - compute='_bank_line_count', string='Number of Bank Lines', + compute='_compute_bank_line_count', string='Number of Bank Lines', readonly=True) move_ids = fields.One2many( 'account.move', 'payment_order_id', string='Journal Entries', @@ -127,16 +127,18 @@ class AccountPaymentOrder(models.Model): "is in the past (%s).") % (order.name, order.date_scheduled)) - @api.one + @api.multi @api.depends( 'payment_line_ids', 'payment_line_ids.amount_company_currency') def _compute_total(self): - self.total_company_currency = sum( - self.mapped('payment_line_ids.amount_company_currency') or [0.0]) + for rec in self: + rec.total_company_currency = sum( + rec.mapped('payment_line_ids.amount_company_currency') or + [0.0]) @api.multi @api.depends('bank_line_ids') - def _bank_line_count(self): + def _compute_bank_line_count(self): for order in self: order.bank_line_count = len(order.bank_line_ids) diff --git a/account_payment_order/report/__init__.py b/account_payment_order/report/__init__.py new file mode 100644 index 000000000..429f03273 --- /dev/null +++ b/account_payment_order/report/__init__.py @@ -0,0 +1 @@ +from . import account_payment_order diff --git a/account_payment_order/report/account_payment_order.py b/account_payment_order/report/account_payment_order.py new file mode 100644 index 000000000..1674137e8 --- /dev/null +++ b/account_payment_order/report/account_payment_order.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# © 2017 Acsone SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models +from odoo.tools.misc import formatLang + + +class AccountPaymentOrderReport(models.AbstractModel): + _name = 'report.account_payment_order.print_account_payment_order_main' + + @api.model + def render_html(self, docids, data=None): + AccountPaymentOrderObj = self.env['account.payment.order'] + docs = AccountPaymentOrderObj.browse(docids) + + docargs = { + 'doc_ids': docids, + 'doc_model': 'account.payment.order', + 'docs': docs, + 'data': data, + 'env': self.env, + 'get_bank_account_name': self.get_bank_account_name, + 'formatLang': formatLang, + } + return self.env['report'].render( + 'account_payment_order.print_account_payment_order_main', docargs) + + @api.model + def get_bank_account_name(self, partner_bank): + """ + + :param partner_bank: + :return: + """ + if partner_bank: + name = '' + if partner_bank.bank_name: + name = '%s: ' % partner_bank.bank_id.name + if partner_bank.acc_number: + name = '%s %s' % (name, partner_bank.acc_number) + if partner_bank.bank_bic: + name = '%s - ' % (name) + if partner_bank.bank_bic: + name = '%s BIC %s' % (name, partner_bank.bank_bic) + return name + else: + return False diff --git a/account_payment_order/report/account_payment_order.xml b/account_payment_order/report/account_payment_order.xml new file mode 100644 index 000000000..53264b030 --- /dev/null +++ b/account_payment_order/report/account_payment_order.xml @@ -0,0 +1,126 @@ + + + + + + + + + diff --git a/account_payment_order/report/print_account_payment_order.xml b/account_payment_order/report/print_account_payment_order.xml new file mode 100644 index 000000000..a9ae6d049 --- /dev/null +++ b/account_payment_order/report/print_account_payment_order.xml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/account_payment_order/wizard/account_invoice_payment_line_multi_view.xml b/account_payment_order/wizard/account_invoice_payment_line_multi_view.xml index b8a0447f2..bc3dc769f 100644 --- a/account_payment_order/wizard/account_invoice_payment_line_multi_view.xml +++ b/account_payment_order/wizard/account_invoice_payment_line_multi_view.xml @@ -5,8 +5,6 @@ --> - - account_invoice_payment_line_multi.form @@ -26,6 +24,4 @@ - -