[ADD] account_payment_multicurrency module

This commit is contained in:
vrenaville
2014-11-24 11:47:50 +01:00
parent d4b0595f1b
commit 86a2c22dde
4 changed files with 195 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Vincent Renaville (Camptocamp)
# Copyright 2010-2014 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 payment

View File

@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Vincent Renaville (Camptocamp)
# Copyright 2010-2014 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': 'Payment Order Extension',
'summary': 'Add an improved view for payment order',
'version': '1.1',
'author': 'Camptocamp',
'maintainter': 'Camptocamp',
'category': 'Accounting',
'depends': ['account_payment'],
'description': """
Payment Order
==================
Add improved move line selection for multi-currency
Contributors
------------
* Vincent revaville <vincent.renaville@camptocamp.com>
""",
'website': 'http://www.camptocamp.com',
'data': ['payment_view.xml'],
'tests': [],
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
'application': False,
}

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Vincent Renaville
# Copyright 2014 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.osv import orm
class payment_order_create(orm.TransientModel):
_inherit = 'payment.order.create'
def create_payment(self, cr, uid, ids, context=None):
"""
We recreate function to be able set
'amount_currency': line.amount_residual_currency
instead of
'amount_currency': line.amount_to_pay
To be compliant with multi currency
Allready corrected in V8 but will not be corrected in V7
"""
order_obj = self.pool.get('payment.order')
line_obj = self.pool.get('account.move.line')
payment_obj = self.pool.get('payment.line')
if context is None:
context = {}
data = self.browse(cr, uid, ids, context=context)[0]
line_ids = [entry.id for entry in data.entries]
if not line_ids:
return {'type': 'ir.actions.act_window_close'}
payment = order_obj.browse(cr, uid, context['active_id'],
context=context)
line2bank = line_obj.line2bank(cr, uid, line_ids, None, context)
# Finally populate the current payment with new lines:
for line in line_obj.browse(cr, uid, line_ids, context=context):
if payment.date_prefered == "now":
# no payment date => immediate payment
date_to_pay = False
elif payment.date_prefered == 'due':
date_to_pay = line.date_maturity
elif payment.date_prefered == 'fixed':
date_to_pay = payment.date_scheduled
state = 'normal'
if line.invoice and line.invoice.reference_type != 'none':
state = 'structured'
currency_id = line.invoice.currency_id.id if line.invoice else None
if not currency_id:
currency_id = line.journal_id.currency.id
if not currency_id:
currency_id = line.journal_id.company_id.currency_id.id
payment_obj.create(
cr, uid, {
'move_line_id': line.id,
'amount_currency': line.amount_residual_currency,
'bank_id': line2bank.get(line.id),
'order_id': payment.id,
'partner_id': line.partner_id.id,
'communication': line.ref or '/',
'state': state,
'date': date_to_pay,
'currency': currency_id,
}, context=context)
return {'type': 'ir.actions.act_window_close'}

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record id="view_move_line_tree_payment" model="ir.ui.view">
<field name="name">account.move.line.tree.payment</field>
<field name="model">account.move.line</field>
<field name="arch" type="xml">
<tree string="Move lines">
<field name="date" readonly="True"/>
<field name="name" readonly="True"/>
<field name="partner_id" readonly="True" />
<field name="ref" readonly="True" />
<field name="amount_residual_currency" readonly="True"/>
<field name="currency_id" readonly="True" />
<field name="date_maturity" readonly="True"/>
<field name="reconcile_partial_id" readonly="True"/>
</tree>
</field>
</record>
<record id="view_create_payment_order_lines_over" model="ir.ui.view">
<field name="name">payment.order.create.form.over</field>
<field name="model">payment.order.create</field>
<field name="inherit_id" ref="account_payment.view_create_payment_order_lines"/>
<field name="arch" type="xml">
<field name="entries" position="replace">
<field name="entries" context="{'tree_view_ref': 'account_payment_multicurrency_extension.view_move_line_tree_payment'}">
<tree string="Move lines">
<field name="date"/>
<field name="name"/>
<field name="partner_id" />
<field name="ref" />
<field name="amount_residual_currency"/>
<field name="currency_id"/>
<field name="date_maturity"/>
<field name="reconcile_partial_id"/>
</tree>
</field>
</field>
</field>
</record>
</data>
</openerp>