mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Merge pull request #187 from vrenaville/add_import_line_multicurrency_module
Add import line multicurrency module
This commit is contained in:
56
account_import_line_multicurrency_extension/README.rst
Normal file
56
account_import_line_multicurrency_extension/README.rst
Normal file
@@ -0,0 +1,56 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License: AGPL-3
|
||||
|
||||
Account Import Line Multi Currency Extension
|
||||
============================================
|
||||
|
||||
* Improve the view of the import invoice wizard in the bank statement form in order to display more relevant columns. Especially if you work in multi-currency and handle partial payment.
|
||||
|
||||
* A column 'Journal currency symbol' has been added just after the amount column to avoid confusion from end-users -> When the bank journal is in foreign currency then the amount column must be filled in that currency.
|
||||
|
||||
* When importing lines in currencies amount, amount currency and currency are now correctly handled
|
||||
|
||||
A check has been added when pressing 'Reconcile' button: no zero amount are accepted. (since it is obviously an user error)
|
||||
|
||||
|
||||
The following feature have been moved in `bank_statement_import_invoices_fix`
|
||||
* When lines are imported the reference goes to the communication field (instead of reference of the bank statement line) in order to have a default proposal from the system during the reconciliation process.
|
||||
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Nothing
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
|
||||
`here <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_import_line_multicurrency_extension%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Vincent renaville <vincent.renaville@camptocamp.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: http://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit http://odoo-community.org.
|
||||
21
account_import_line_multicurrency_extension/__init__.py
Normal file
21
account_import_line_multicurrency_extension/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import models
|
||||
35
account_import_line_multicurrency_extension/__openerp__.py
Normal file
35
account_import_line_multicurrency_extension/__openerp__.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{'name': 'Bank Statement Multi currency Extension',
|
||||
'summary': 'Add an improved view for move line import in bank statement',
|
||||
'version': '1.1',
|
||||
'author': "Camptocamp,Odoo Community Association (OCA)",
|
||||
'maintainter': 'Camptocamp',
|
||||
'category': 'Accounting',
|
||||
'depends': ['account'],
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'data': ['view/account_statement_from_invoice_view.xml',
|
||||
'view/bank_statement_view.xml',
|
||||
],
|
||||
'tests': [],
|
||||
'installable': True,
|
||||
'license': 'AGPL-3',
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * account_import_line_multicurrency_extension
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-07-14 14:13+0000\n"
|
||||
"PO-Revision-Date: 2015-07-14 14:13+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: account_import_line_multicurrency_extension
|
||||
#: code:addons/account_import_line_multicurrency_extension/models/bank_statement.py:41
|
||||
#, python-format
|
||||
msgid "Amount on line %s is not set. \n"
|
||||
""
|
||||
msgstr ""
|
||||
|
||||
#. module: account_import_line_multicurrency_extension
|
||||
#: model:ir.model,name:account_import_line_multicurrency_extension.model_account_bank_statement
|
||||
msgid "Bank Statement"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_import_line_multicurrency_extension
|
||||
#: model:ir.model,name:account_import_line_multicurrency_extension.model_account_bank_statement_line
|
||||
msgid "Bank Statement Line"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_import_line_multicurrency_extension
|
||||
#: model:ir.model,name:account_import_line_multicurrency_extension.model_account_statement_from_invoice_lines
|
||||
msgid "Entries by Statement from Invoices"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_import_line_multicurrency_extension
|
||||
#: code:addons/account_import_line_multicurrency_extension/models/bank_statement.py:44
|
||||
#, python-format
|
||||
msgid "Error on bank statement: \n"
|
||||
" %s"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_import_line_multicurrency_extension
|
||||
#: view:account.move.line:account_import_line_multicurrency_extension.view_move_line_tree_bank_statement
|
||||
#: view:account.statement.from.invoice.lines:account_import_line_multicurrency_extension.view_account_statement_from_invoice_lines_over
|
||||
msgid "Move lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_import_line_multicurrency_extension
|
||||
#: view:account.bank.statement:account_import_line_multicurrency_extension.view_bank_statement_form
|
||||
msgid "Reconcile"
|
||||
msgstr ""
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import bank_statement
|
||||
from . import account_statement_from_invoice
|
||||
@@ -0,0 +1,78 @@
|
||||
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp import models, api
|
||||
|
||||
|
||||
class account_statement_from_invoice_lines(models.TransientModel):
|
||||
"""
|
||||
Generate Entries by Statement from Invoices
|
||||
"""
|
||||
_inherit = "account.statement.from.invoice.lines"
|
||||
|
||||
@api.multi
|
||||
def populate_statement(self):
|
||||
statement_id = self.env.context.get('statement_id', False)
|
||||
if not statement_id or not self.line_ids:
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
statement_obj = self.env['account.bank.statement']
|
||||
statement_line_obj = self.env['account.bank.statement.line']
|
||||
statement = statement_obj.browse(statement_id)
|
||||
line_date = statement.date
|
||||
# Get the currency on the company if not set on the journal
|
||||
if statement.journal_id.currency:
|
||||
from_currency_id = statement.journal_id.currency
|
||||
else:
|
||||
from_currency_id = self.env.user.company_id.currency_id
|
||||
|
||||
# for each selected move lines
|
||||
for line in self.line_ids:
|
||||
if line.invoice and line.invoice.currency_id == from_currency_id:
|
||||
amount = line.amount_residual_currency
|
||||
amount_currency = 0.0
|
||||
else:
|
||||
if statement.journal_id.currency:
|
||||
from_currency_id = statement.journal_id.currency
|
||||
else:
|
||||
from_currency_id = self.env.user.company_id.currency_id
|
||||
amount = from_currency_id.with_context(date=line_date).compute(
|
||||
line.amount_residual_currency,
|
||||
line.invoice.currency_id)
|
||||
amount_currency = line.amount_residual_currency
|
||||
# we test how to apply sign
|
||||
if line.journal_id.type in ['sale_refund', 'purchase']:
|
||||
amount_currency = -amount_currency
|
||||
amount = -amount
|
||||
ctx = {}
|
||||
ctx.update({'move_line_ids': [line.id],
|
||||
'invoice_id': line.invoice.id})
|
||||
|
||||
statement_line_obj.with_context(ctx).create({
|
||||
'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,
|
||||
})
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
@@ -0,0 +1,55 @@
|
||||
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp import models, fields, api, exceptions, _
|
||||
|
||||
|
||||
class AccountBankStatementLine(models.Model):
|
||||
_inherit = "account.bank.statement.line"
|
||||
|
||||
currency_symbol = fields.Char(
|
||||
string='Journal Currency',
|
||||
related='statement_id.currency.symbol', readonly=True)
|
||||
|
||||
|
||||
class AccountBankStatement(models.Model):
|
||||
_inherit = "account.bank.statement"
|
||||
|
||||
@api.multi
|
||||
def check_line_amount_zero(self):
|
||||
self.ensure_one()
|
||||
msg = ''
|
||||
for line in self.line_ids:
|
||||
if not line.amount:
|
||||
msg += _('Amount on line %s is not set. \n') % (line.name)
|
||||
if msg:
|
||||
raise exceptions.Warning(
|
||||
_("Error on bank statement: \n %s") % msg)
|
||||
# dispatch to reconciliation interface
|
||||
action = self.env.ref(
|
||||
'account.action_bank_reconcile_bank_statements')
|
||||
return {
|
||||
'name': action.name,
|
||||
'tag': action.tag,
|
||||
'context': {
|
||||
'statement_ids': self.ids,
|
||||
},
|
||||
'type': 'ir.actions.client',
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_move_line_tree_bank_statement" model="ir.ui.view">
|
||||
<field name="name">account.move.line.tree.bank.statement</field>
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Move lines">
|
||||
<field name="journal_id"/>
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="ref"/>
|
||||
<field name="amount_residual_currency"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="date_maturity"/>
|
||||
<field name="reconcile_partial_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_account_statement_from_invoice_lines_over" model="ir.ui.view">
|
||||
<field name="name">account.statement.from.invoice.lines.form.over</field>
|
||||
<field name="model">account.statement.from.invoice.lines</field>
|
||||
<field name="inherit_id" ref="account.view_account_statement_from_invoice_lines"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="line_ids" position="replace">
|
||||
<field name="line_ids"
|
||||
context="{'currency':True, 'tree_view_ref': 'account_import_line_multicurrency_extension.view_move_line_tree_bank_statement'}"
|
||||
domain="[('account_id.type','in',['receivable','payable']),('journal_id.type','in',['sale','purchase','sale_refund','purchase_refund']), ('reconcile_id','=',False), ('state', '=', 'valid')]">
|
||||
<tree string="Move lines">
|
||||
<field name="journal_id"/>
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id" />
|
||||
<field name="ref" />
|
||||
<field name="amount_residual_currency"/>
|
||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||
<field name="date_maturity"/>
|
||||
<field name="reconcile_partial_id"/>
|
||||
</tree>
|
||||
|
||||
</field>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="0">
|
||||
|
||||
<record model="ir.ui.view" id="view_bank_statement_form">
|
||||
<field name="name">account.bank.statement.form.inherit</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="amount" position="after">
|
||||
<field name="currency_symbol"/>
|
||||
</field>
|
||||
<xpath expr="//button[@string='Reconcile']" position="replace">
|
||||
<button name="check_line_amount_zero" states="draft" string="Reconcile" type="object" class="oe_highlight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user