[ADD] report for payment order (#370)

This commit is contained in:
Gilles Meyomesse (ACSONE)
2017-10-10 17:24:55 +02:00
committed by Pedro M. Baeza
parent a66448cc2c
commit 0bb431baac
10 changed files with 206 additions and 11 deletions

View File

@@ -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 <angel.moya@domatix.com>
* Jose María Alzaga <jose.alzaga@aselcis.com>
* Meyomesse Gilles <meyomesse.gilles@gmail.com>
Maintainer
----------

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import models
from . import report
from . import wizard

View File

@@ -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,

View File

@@ -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(

View File

@@ -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)

View File

@@ -0,0 +1 @@
from . import account_payment_order

View File

@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# © 2017 Acsone SA/NV (<https://www.acsone.eu>)
# 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

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="print_account_payment_order_document">
<t t-set="doc" t-value="doc.with_context({'lang':doc.generated_user_id.lang})" />
<t t-call="report.external_layout">
<div class="page">
<div class="oe_structure"/>
<div class="row">
<div class="col-xs-4 col-xs-offset-8">
<span t-raw="'%s &lt;br&gt;' % doc.journal_id.bank_id.name if doc.journal_id.bank_id.name else ''"/>
<span t-raw="'%s &lt;br&gt;' % doc.journal_id.bank_id.street if doc.journal_id.bank_id.street else ''"/>
<span t-raw="'%s &lt;br&gt;' % doc.journal_id.bank_id.street2 if doc.journal_id.bank_id.street2 else ''"/>
<span t-raw="'%s &lt;br&gt;' % doc.journal_id.bank_id.zip if doc.journal_id.bank_id.zip else ''"/>
<span t-raw="'%s &lt;br&gt;' % doc.journal_id.bank_id.city if doc.journal_id.bank_id.city else ''"/>
<span t-raw="'%s &lt;br&gt;' % doc.journal_id.bank_id.state.name if doc.journal_id.bank_id.state.name else ''"/>
<span t-raw="'%s &lt;br&gt;' % doc.journal_id.bank_id.country.name if doc.journal_id.bank_id.country.name else ''"/>
</div>
</div>
<h2>Payment Order / Payment</h2>
<div class="row mt32 mb32">
<div t-if="doc.payment_mode_id.name" class="col-xs-2">
<strong>Payment Type:</strong>
<p t-field="doc.payment_mode_id.name"/>
</div>
<div t-if="doc.name" class="col-xs-2">
<strong>Reference</strong>
<p t-field="doc.name"/>
</div>
<div t-if="doc.company_partner_bank_id.bank_id.id" class="col-xs-2">
<strong>Used Account:</strong>
<p>
<span t-esc="get_bank_account_name(doc.company_partner_bank_id)"/>
</p>
</div>
<div t-if="doc.date_prefered" class="col-xs-2">
<strong>Execution:</strong>
<p t-field="doc.date_prefered"/>
</div>
<div t-if="doc.company_id.currency_id.name" class="col-xs-2">
<strong>Company Currency:</strong>
<p t-field="doc.company_id.currency_id.name"/>
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Partner</th>
<th class="text-center">Bank Account</th>
<th class="text-center">Invoice Ref</th>
<th class="text-center">Value Date</th>
<th class="text-right">Amount</th>
<th class="text-right">Currency</th>
</tr>
</thead>
<tbody>
<!-- Total amount on lines
see _get_amount_total v8
-->
<t t-set="total_amount" t-value="0"/>
<tr t-foreach="doc.payment_line_ids" t-as="line">
<!-- compute total amount -->
<t t-set="total_amount" t-value="total_amount+line.amount_currency"/>
<td>
<span t-field="line.partner_id.name"/>
</td>
<td class="text-center">
<span t-esc="get_bank_account_name(line.partner_bank_id)"/>
</td>
<td class="text-center">
<span t-raw="'%s &lt;br&gt;' % line.move_line_id.move_id.name if line.move_line_id.move_id else ''"/>
</td>
<td class="text-center">
<span t-field="line.date"/>
</td>
<td class="text-right">
<span t-field="line.amount_currency"/>
</td>
<td class="text-right">
<span t-field="line.amount_company_currency"/>
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-esc="formatLang(env, total_amount, currency_obj=doc.company_currency_id)"/>
</td>
</tr>
<tr>
<td>Total (Currency)</td>
<td class="text-right">
<span t-field="doc.total_company_currency"/>
</td>
</tr>
</table>
</div>
</div>
<div class="oe_structure"/>
</div>
</t>
</template>
<template id="print_account_payment_order_main">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="account_payment_order.print_account_payment_order_document" t-lang="doc.generated_user_id.lang"/>
</t>
</t>
</template>
</odoo>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<!-- QWeb Report -->
<report
id="action_print_payment_order"
model="account.payment.order"
string="Payment Order"
report_type="qweb-pdf"
name="account_payment_order.print_account_payment_order_main"
file="account_payment_order.print_account_payment_order_main"
/>
</odoo>

View File

@@ -5,8 +5,6 @@
-->
<odoo>
<data>
<record id="account_invoice_payment_line_multi_form" model="ir.ui.view">
<field name="name">account_invoice_payment_line_multi.form</field>
@@ -26,6 +24,4 @@
</field>
</record>
</data>
</odoo>