Add new module partner_aged_open_invoices

This commit is contained in:
Alexis de Lattre
2015-07-10 19:36:04 +02:00
parent 4e40393b14
commit 4e8f9bbf97
4 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# -*- encoding: utf-8 -*-
from . import partner

View File

@@ -0,0 +1,44 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Partner Aged Open Invoices module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Partner Aged Open Invoices',
'version': '0.1',
'category': 'Accounting & Finance',
'license': 'AGPL-3',
'summary': 'Direct access to the aged open invoice report from the partner form',
'description': """
Partner Aged Open Invoices
==========================
This module adds a button on the partner form view (the icon on the button is a banknote) to easily open the aged open invoices report of this partner.
It requires the updated version of the account_financial_report_webkit module that has the aged open invoice report.
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['account_financial_report_webkit'],
'data': ['partner_view.xml'],
}

View File

@@ -0,0 +1,65 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Partner Aged Open Invoices module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
import openerp.addons.decimal_precision as dp
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.one
@api.depends('credit', 'debit')
def _compute_balance(self):
self.balance = self.credit - self.debit
balance = fields.Float(
compute='_compute_balance', readonly=True,
digits=dp.get_precision('Account'), string="Account Balance")
@api.multi
def open_aged_open_invoices_report(self):
aoiwo = self.env['aged.open.invoices.webkit']
fy_id = aoiwo._get_fiscalyear()
filter_change = aoiwo.onchange_filter(
filter='filter_date', fiscalyear_id=fy_id)
vals = {
'fiscalyear_id': fy_id,
'filter': 'filter_date',
'partner_ids': [(6, 0, [self.commercial_partner_id.id])],
'target_move': 'all',
}
vals.update(filter_change['value'])
wizard = self.env['aged.open.invoices.webkit'].create(vals)
data = {'form': {
'chart_account_id': wizard.chart_account_id.id,
'filter': 'filter_date',
'date_from': vals['date_from'],
'date_to': vals['date_to'],
'period_to': False,
'fiscalyear_id': fy_id,
'partner_ids': [self.commercial_partner_id.id],
'target_move': 'all',
}
}
action = wizard._print_report(data)
return action

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">account.balance.button.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_stat_button" type="object"
name="open_aged_open_invoices_report"
attrs="{'invisible': [('parent_id', '!=', False)]}"
icon="fa-money"
>
<div>
<strong>
<field string="Account Balance" name="balance"
widget="monetary"/>
</strong>
<br/>
Account Balance
</div>
</button>
</xpath>
</field>
</record>
</data>
</openerp>