Skip to content

Commit

Permalink
[IMP] base_transaction_id: Add transaction_id on account.payment
Browse files Browse the repository at this point in the history
This change is required to ease the reconciliation of the account.move
created from the account.payment.
  • Loading branch information
lmignon committed Sep 13, 2017
1 parent 0ecebd8 commit 5db60be
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 1 deletion.
1 change: 1 addition & 0 deletions base_transaction_id/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import models
from . import models
4 changes: 3 additions & 1 deletion base_transaction_id/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*
# -*- coding: utf-8 -*-
# © 2012 Yannick Vaucher, Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{'name': 'Base transaction id for financial institutes',
Expand All @@ -8,9 +8,11 @@
'category': 'Hidden/Dependency',
'depends': [
'sale',
'account',
],
'website': 'https://www.odoo-community.org/',
'data': [
'views/account_payment.xml',
'views/invoice.xml',
'views/sale.xml',
'views/account_move_line.xml',
Expand Down
1 change: 1 addition & 0 deletions base_transaction_id/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import sale
from . import account_move
from . import account_bank_statement_line
from . import account_payment
26 changes: 26 additions & 0 deletions base_transaction_id/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountPayment(models.Model):

_inherit = 'account.payment'

transaction_id = fields.Char(
'Transaction ID',
required=False,
copy=False,
help="Transaction id from the financial institute"
)

@api.multi
def _get_liquidity_move_line_vals(self, amount):
self.ensure_one()
vals = super(AccountPayment, self)._get_liquidity_move_line_vals(
amount)
if self.transaction_id:
vals['name'] = self.transaction_id
return vals
2 changes: 2 additions & 0 deletions base_transaction_id/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import test_account_payment
26 changes: 26 additions & 0 deletions base_transaction_id/tests/test_account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import odoo.tests.common as common


class TestAccountPayment(common.TransactionCase):

def test_transaction_id_on_move_line(self):
account_payment = self.env['account.payment'].new({
'name': 'payment_name'
})
vals = account_payment._get_liquidity_move_line_vals(10)
self.assertEqual(
vals.get('name'),
'payment_name',
'The name of the move line is the name of the payment if no '
'transaction_id is specified on the payment')
account_payment.transaction_id = 'transaction id'
vals = account_payment._get_liquidity_move_line_vals(10)
self.assertEqual(
vals.get('name'),
'transaction id',
'The name of the move line is the transaction if of the payment '
'if specified on the payment')
40 changes: 40 additions & 0 deletions base_transaction_id/views/account_payment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<record model="ir.ui.view" id="account_payment_form_view">
<field name="name">account.payment.form (in base_transaction_id)</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="arch" type="xml">
<field name="payment_date" position="after">
<field name="transaction_id" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
</field>
</field>
</record>

<record model="ir.ui.view" id="account_payment_tree_view">
<field name="name">account.payment.tree (in base_transaction_id)</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_supplier_payment_tree"/>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="transaction_id"/>
</field>
</field>
</record>

<record model="ir.ui.view" id="account_payment_search_view">
<field name="name">account.payment.search (in base_transaction_id)</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_search"/>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="transaction_id"/>
</field>
</field>
</record>

</odoo>

0 comments on commit 5db60be

Please sign in to comment.