From 1b03b4b4f1f8490e222dd1a636456a68173a3eef Mon Sep 17 00:00:00 2001 From: vrenaville Date: Mon, 15 Jun 2015 13:49:21 +0200 Subject: [PATCH] [FIX] change layout --- .../__init__.py | 1 + .../__openerp__.py | 7 +- .../models/__init__.py | 22 ++++++ .../models/account_statement_from_invoice.py | 76 +++++++++++++++++++ .../models/bank_statement.py | 28 +++++++ .../account_statement_from_invoice_view.xml | 0 .../view/bank_statement_view.xml | 19 +++++ .../{ => view}/payment_view.xml | 0 8 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 account_import_line_multicurrency_extension/models/__init__.py create mode 100644 account_import_line_multicurrency_extension/models/account_statement_from_invoice.py create mode 100644 account_import_line_multicurrency_extension/models/bank_statement.py rename account_import_line_multicurrency_extension/{ => view}/account_statement_from_invoice_view.xml (100%) create mode 100644 account_import_line_multicurrency_extension/view/bank_statement_view.xml rename account_import_line_multicurrency_extension/{ => view}/payment_view.xml (100%) diff --git a/account_import_line_multicurrency_extension/__init__.py b/account_import_line_multicurrency_extension/__init__.py index 6dcc7ddba..563ca038e 100644 --- a/account_import_line_multicurrency_extension/__init__.py +++ b/account_import_line_multicurrency_extension/__init__.py @@ -18,3 +18,4 @@ # along with this program. If not, see . # ############################################################################## +from . import models diff --git a/account_import_line_multicurrency_extension/__openerp__.py b/account_import_line_multicurrency_extension/__openerp__.py index 6eec6852a..52c7dff99 100644 --- a/account_import_line_multicurrency_extension/__openerp__.py +++ b/account_import_line_multicurrency_extension/__openerp__.py @@ -24,7 +24,7 @@ 'author': "Camptocamp,Odoo Community Association (OCA)", 'maintainter': 'Camptocamp', 'category': 'Accounting', - 'depends': ['account_payment'], + 'depends': ['account_payment','account'], 'description': """ Payment Order ================== @@ -37,8 +37,9 @@ Contributors * Vincent revaville """, 'website': 'http://www.camptocamp.com', - 'data': ['payment_view.xml', - 'account_statement_from_invoice_view.xml', + 'data': ['view/payment_view.xml', + 'view/account_statement_from_invoice_view.xml', + 'view/bank_statement_view.xml', ], 'tests': [], 'installable': True, diff --git a/account_import_line_multicurrency_extension/models/__init__.py b/account_import_line_multicurrency_extension/models/__init__.py new file mode 100644 index 000000000..38ae6104b --- /dev/null +++ b/account_import_line_multicurrency_extension/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Vincent Renaville (Camptocamp) +# Copyright 2015 Camptocamp SA +# +# 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 . import bank_statement +from . import account_statement_from_invoice diff --git a/account_import_line_multicurrency_extension/models/account_statement_from_invoice.py b/account_import_line_multicurrency_extension/models/account_statement_from_invoice.py new file mode 100644 index 000000000..b7ea1a23b --- /dev/null +++ b/account_import_line_multicurrency_extension/models/account_statement_from_invoice.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Vincent Renaville (Camptocamp) +# Copyright 2015 Camptocamp SA +# +# 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 . +# +############################################################################## +import time + +from openerp.osv import fields, osv + +class account_statement_from_invoice_lines(osv.osv_memory): + """ + Generate Entries by Statement from Invoices + """ + _inherit = "account.statement.from.invoice.lines" + + + def populate_statement(self, cr, uid, ids, context=None): + context = dict(context or {}) + statement_id = context.get('statement_id', False) + if not statement_id: + return {'type': 'ir.actions.act_window_close'} + data = self.read(cr, uid, ids, context=context)[0] + line_ids = data['line_ids'] + if not line_ids: + return {'type': 'ir.actions.act_window_close'} + + line_obj = self.pool.get('account.move.line') + statement_obj = self.pool.get('account.bank.statement') + statement_line_obj = self.pool.get('account.bank.statement.line') + currency_obj = self.pool.get('res.currency') + statement = statement_obj.browse(cr, uid, statement_id, context=context) + line_date = statement.date + + # for each selected move lines + for line in line_obj.browse(cr, uid, line_ids, context=context): + ctx = context.copy() + # take the date for computation of currency => use payment date + ctx['date'] = line_date + amount = 0.0 + amount_currency = 0.0 + if line.invoice and line.invoice.currency_id == statement.currency_id: + amount = line.amount_residual_currency + amount_currency = 0.0 + else: + amount = 0.0 + amount_currency = line.amount_residual_currency + + context.update({'move_line_ids': [line.id], + 'invoice_id': line.invoice.id}) + + statement_line_obj.create(cr, uid, { + 'name': line.name or '?', + 'amount': amount, + 'partner_id': line.partner_id.id, + 'statement_id': statement_id, + 'ref': line.ref, + 'date': statement.date, + 'amount_currency': amount_currency, + 'currency_id': line.currency_id.id, + }, context=context) + return {'type': 'ir.actions.act_window_close'} diff --git a/account_import_line_multicurrency_extension/models/bank_statement.py b/account_import_line_multicurrency_extension/models/bank_statement.py new file mode 100644 index 000000000..20ecd12c8 --- /dev/null +++ b/account_import_line_multicurrency_extension/models/bank_statement.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Vincent Renaville (Camptocamp) +# Copyright 2015 Camptocamp SA +# +# 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 + + +class AccountBankStatementLine(models.Model): + _inherit = "account.bank.statement.line" + + currency_symbol = fields.Char( + related='statement_id.currency.symbol', readonly=True) diff --git a/account_import_line_multicurrency_extension/account_statement_from_invoice_view.xml b/account_import_line_multicurrency_extension/view/account_statement_from_invoice_view.xml similarity index 100% rename from account_import_line_multicurrency_extension/account_statement_from_invoice_view.xml rename to account_import_line_multicurrency_extension/view/account_statement_from_invoice_view.xml diff --git a/account_import_line_multicurrency_extension/view/bank_statement_view.xml b/account_import_line_multicurrency_extension/view/bank_statement_view.xml new file mode 100644 index 000000000..e57765805 --- /dev/null +++ b/account_import_line_multicurrency_extension/view/bank_statement_view.xml @@ -0,0 +1,19 @@ + + + + + + account.bank.statement.form.inherit + account.bank.statement + form + + + + + + + + + + + diff --git a/account_import_line_multicurrency_extension/payment_view.xml b/account_import_line_multicurrency_extension/view/payment_view.xml similarity index 100% rename from account_import_line_multicurrency_extension/payment_view.xml rename to account_import_line_multicurrency_extension/view/payment_view.xml