From 1a9126d9a1185376d2be830c2f3cde039049b3fc Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 18 Jun 2018 18:11:43 +0200 Subject: [PATCH] [MIG] port partner_aged_open_invoices to v10 and rename it to account_aged_balance_from_partner --- account_aged_balance_from_partner/__init__.py | 3 + .../__manifest__.py | 25 +++++++ account_aged_balance_from_partner/partner.py | 30 ++++++++ .../partner_view.xml | 31 ++++++++ partner_aged_open_invoices/__init__.py | 3 - partner_aged_open_invoices/__manifest__.py | 45 ----------- partner_aged_open_invoices/partner.py | 74 ------------------- partner_aged_open_invoices/partner_view.xml | 41 ---------- 8 files changed, 89 insertions(+), 163 deletions(-) create mode 100644 account_aged_balance_from_partner/__init__.py create mode 100644 account_aged_balance_from_partner/__manifest__.py create mode 100644 account_aged_balance_from_partner/partner.py create mode 100644 account_aged_balance_from_partner/partner_view.xml delete mode 100644 partner_aged_open_invoices/__init__.py delete mode 100644 partner_aged_open_invoices/__manifest__.py delete mode 100644 partner_aged_open_invoices/partner.py delete mode 100644 partner_aged_open_invoices/partner_view.xml diff --git a/account_aged_balance_from_partner/__init__.py b/account_aged_balance_from_partner/__init__.py new file mode 100644 index 0000000..61cf8b2 --- /dev/null +++ b/account_aged_balance_from_partner/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import partner diff --git a/account_aged_balance_from_partner/__manifest__.py b/account_aged_balance_from_partner/__manifest__.py new file mode 100644 index 0000000..9dead52 --- /dev/null +++ b/account_aged_balance_from_partner/__manifest__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright 2015-2018 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Aged Partner Balance from Partner', + 'version': '10.0.0.1.0', + 'category': 'Accounting', + 'license': 'AGPL-3', + 'summary': 'Direct access to the aged partner balance report from the partner form', + 'description': """ +Aged Partner Balance from Partner +================================= + +This module adds a button on the partner form view (the icon on the button is a banknote) to easily open the detailed aged partner balance of the partner in PDF format. + +This module has been written by Alexis de Lattre from Akretion . + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['account_financial_report_qweb'], + 'data': ['partner_view.xml'], + 'installable': True, +} diff --git a/account_aged_balance_from_partner/partner.py b/account_aged_balance_from_partner/partner.py new file mode 100644 index 0000000..74f248c --- /dev/null +++ b/account_aged_balance_from_partner/partner.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2015-2018 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import models, fields, api + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.depends('credit', 'debit') + def _compute_balance(self): + for partner in self: + partner.balance = partner.credit - partner.debit + + # The field 'currency_id' defined in the account module + # is a computed field that gets the company currency + balance = fields.Monetary( + compute='_compute_balance', readonly=True, + string="Account Balance") + + def open_aged_open_invoices_report(self): + wiz = self.env['aged.partner.balance.wizard'].create({ + 'show_move_line_details': True, + 'partner_ids': [(6, 0, self.ids)], + }) + action = wiz.button_export_pdf() + return action diff --git a/account_aged_balance_from_partner/partner_view.xml b/account_aged_balance_from_partner/partner_view.xml new file mode 100644 index 0000000..1bf6534 --- /dev/null +++ b/account_aged_balance_from_partner/partner_view.xml @@ -0,0 +1,31 @@ + + + + + + + + account.balance.button.partner.form + res.partner + + + + + + + + + diff --git a/partner_aged_open_invoices/__init__.py b/partner_aged_open_invoices/__init__.py deleted file mode 100644 index 84d775d..0000000 --- a/partner_aged_open_invoices/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- encoding: utf-8 -*- - -from . import partner diff --git a/partner_aged_open_invoices/__manifest__.py b/partner_aged_open_invoices/__manifest__.py deleted file mode 100644 index 51f493d..0000000 --- a/partner_aged_open_invoices/__manifest__.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Partner Aged Open Invoices module for Odoo -# Copyright (C) 2015-2016 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# 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 . -# -############################################################################## - - -{ - 'name': 'Partner Aged Open Invoices', - 'version': '10.0.0.1.0', - '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 the partner. - -It requires the updated version of the module **account_financial_report_webkit** that has the aged open invoice report ; you can find it in this pull request https://github.com/OCA/account-financial-reporting/pull/102 - -This module has been written by Alexis de Lattre from Akretion . - """, - 'author': 'Akretion', - 'website': 'http://www.akretion.com', - 'depends': ['account_financial_report_webkit'], - 'data': ['partner_view.xml'], - 'installable': False, -} diff --git a/partner_aged_open_invoices/partner.py b/partner_aged_open_invoices/partner.py deleted file mode 100644 index 4010d86..0000000 --- a/partner_aged_open_invoices/partner.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Partner Aged Open Invoices module for Odoo -# Copyright (C) 2015 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# 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 . -# -############################################################################## - -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'] - afo = self.env['account.fiscalyear'] - # Force 'date_from' to the first day of the company's life - # in order to get the full picture of the partner's account - # (we could also do that via a filter by period, but, in this case, - # account_financial_report_webkit doesn't accept "until_date = today" ; - # until_date has to be the end date of the last period - fy_years = afo.search([], order='date_start') - date_from = fy_years[0].date_start - 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']) - vals['date_from'] = date_from - wizard = aoiwo.create(vals) - data = {'form': { - 'chart_account_id': wizard.chart_account_id.id, - 'filter': vals['filter'], - 'date_from': vals['date_from'], - 'date_to': vals['date_to'], - 'period_to': False, - 'fiscalyear_id': vals['fiscalyear_id'], - 'partner_ids': vals['partner_ids'][0][2], - 'target_move': vals['target_move'], - } - } - action = wizard._print_report(data) - return action diff --git a/partner_aged_open_invoices/partner_view.xml b/partner_aged_open_invoices/partner_view.xml deleted file mode 100644 index a270328..0000000 --- a/partner_aged_open_invoices/partner_view.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - account.balance.button.partner.form - res.partner - - - - - - - - - - - -