diff --git a/__manifest__.py b/__manifest__.py index d026b4ce57142c0fd29bc8c581fba604473cf6ab..06892d89ec0e5af4ca51d76b6aa42a3c3e55303c 100755 --- a/__manifest__.py +++ b/__manifest__.py @@ -24,5 +24,8 @@ "views/res_partner.xml", "views/scop_cotisation_task.xml", ], + "qweb": [ + "static/src/xml/*.xml", + ], 'post_init_hook': '_configure_journals', } diff --git a/models/account_invoice.py b/models/account_invoice.py index 86d2d2bf58c0a99d9b0ddcfede910133fbda9dd1..263076cab85c86691deca55bd2da207cb9438e89 100755 --- a/models/account_invoice.py +++ b/models/account_invoice.py @@ -1,6 +1,9 @@ # © 2020 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from datetime import datetime +import json + from odoo import models, fields, api, _ from odoo.exceptions import UserError @@ -207,6 +210,39 @@ class ScopAccountInvoice(models.Model): inv.write(vals) return True + @api.one + def _get_outstanding_info_JSON(self): + super(ScopAccountInvoice, self)._get_outstanding_info_JSON() + info = json.loads(self.outstanding_credits_debits_widget) + if info: + values = info.get('content', False) + if self.state == 'open' and values: + domain = [('account_id', '=', self.account_id.id), + ('partner_id', '=', + self.env['res.partner']._find_accounting_partner( + self.partner_id).id), + ('reconciled', '=', False), + ('move_id.state', '=', 'posted'), + '|', + '&', ('amount_residual_currency', '!=', 0.0), + ('currency_id', '!=', None), + '&', ('amount_residual_currency', '=', 0.0), '&', + ('currency_id', '=', None), + ('amount_residual', '!=', 0.0)] + if self.type in ('out_invoice', 'in_refund'): + domain.extend([('credit', '>', 0), ('debit', '=', 0)]) + else: + domain.extend([('credit', '=', 0), ('debit', '>', 0)]) + lines = self.env['account.move.line'].search(domain) + for value in values: + for line in lines: + if value.get('id') == line.id: + value.update({ + 'date_maturity': datetime.strftime(line.date_maturity, "%d/%m/%Y"), + 'invoice': line.invoice_id.number + }) + self.outstanding_credits_debits_widget = json.dumps(info) + # ------------------------------------------------------ # Common Function # ------------------------------------------------------ diff --git a/static/src/xml/account_payment.xml b/static/src/xml/account_payment.xml new file mode 100644 index 0000000000000000000000000000000000000000..5cc4c24ae4a60696f5f2057a5748ab1a69f39f8e --- /dev/null +++ b/static/src/xml/account_payment.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<templates xml:space="preserve"> + + <!-- Copyright 2020 Le Filament + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> + + <t t-extend="ShowPaymentInfo"> + <t t-jquery='div.oe_form_field' t-operation='replace'> + <div class="oe_form_field" + style="margin-right: 10px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;" + t-att-title="line.date_maturity + ' - ' + line.title"> + <t t-esc="line.date_maturity"></t> - <t t-esc="line.invoice"></t> + </div> + </t> + </t> + +</templates> \ No newline at end of file