Merge lp:~camptocamp/banking-addons/7.0-bank-statement-reconcile-transaction_id-imp into lp:banking-addons/bank-statement-reconcile-70

Proposed by Guewen Baconnier @ Camptocamp
Status: Superseded
Proposed branch: lp:~camptocamp/banking-addons/7.0-bank-statement-reconcile-transaction_id-imp
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 710 lines (+396/-92)
21 files modified
account_advanced_reconcile_transaction_ref/__init__.py (+0/-1)
account_advanced_reconcile_transaction_ref/__openerp__.py (+2/-2)
account_advanced_reconcile_transaction_ref/account.py (+0/-54)
account_advanced_reconcile_transaction_ref/advanced_reconciliation.py (+24/-1)
account_advanced_reconcile_transaction_ref/easy_reconcile.py (+2/-0)
account_advanced_reconcile_transaction_ref/easy_reconcile_view.xml (+6/-1)
account_easy_reconcile/easy_reconcile.xml (+2/-2)
account_payment_transaction_id/__init__.py (+3/-0)
account_payment_transaction_id/__openerp__.py (+43/-0)
account_payment_transaction_id/account_payment.py (+47/-0)
account_statement_transactionid_completion/__openerp__.py (+2/-0)
account_statement_transactionid_completion/data.xml (+7/-1)
account_statement_transactionid_completion/statement.py (+87/-2)
account_statement_transactionid_completion/statement_view.xml (+6/-6)
account_statement_transactionid_completion/test/completion_invoice_transactionid_test.yml (+49/-0)
account_statement_transactionid_completion/test/completion_transactionid_test.yml (+1/-1)
account_statement_transactionid_completion/test/invoice.yml (+30/-0)
base_transaction_id/__init__.py (+1/-0)
base_transaction_id/account_move.py (+37/-0)
base_transaction_id/invoice.py (+17/-3)
statement_voucher_killer/voucher.py (+30/-18)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/7.0-bank-statement-reconcile-transaction_id-imp
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Review via email: mp+202806@code.launchpad.net

This proposal has been superseded by a proposal from 2014-03-21.

Description of the change

Improvement around the Transaction IDs modules
==============================================

This proposal aims to improve the modules using transaction ids, I will start by summarizing what are they used for, then what are the existing problems and what changes I propose.

Transaction IDs?
----------------

The transaction IDs are a technical reference for a move line. They are to differentiate from the usual reference that are a reference for humans firstly (more about that here [0]). Usually, the transaction IDs are defined by external systems such as payment gateways and are a way to streamline the reconciliations between the invoices, bank statements...

Changes
-------

1) account_move_line.transaction_ref is defined in 'account_advanced_reconcile_transaction_ref' which adds a reconciliation method with transaction id.
It makes much sense to add the field in 'base_transaction_id' so we can use the field in other modules such as the bank statement completion modules. It is a pity that the field on the invoice and the sale order is 'transaction_id' and in move lines 'transaction_ref' but I prefer to keep the backward-compatibility.

So I moved these things from 'account_advanced_reconcile_transaction_ref' to 'base_transaction_id'

2) In account_advanced_reconcile_transaction_ref there is an inherit of the bank statement that copies the line's ref in the move line's transaction_id. I think this is a mismatch between the ref and the transaction_id that we have to avoid. In fact, only the transaction id of the statement lines should be copied if any, or left empty if the statement line has no transaction id.

3) A consequence of the change 2) is that the automatic reconcile from transaction ref will no longer work for those not using the transaction ids in the bank statement but only the ref. So I added a new reconciliation rule that matches 'ref' vs 'transaction id'. The only drawback is that they will need to change their configuration, but at least the rules will be clear on their intentions.

4) completion rules: 'base_transaction_id' adds a transaction_id on sales order and invoices. There is actually a completion rule that searches the bank statement information from a matching invoice with the same transaction_id. I added the same rule that searches for an invoice with the same transaction id. This is the logical continuation and a good complement when an invoice / refund was not generated by a sales order and we still need to autocomplete the bank statement.

[0] https://code.launchpad.net/~camptocamp/banking-addons/7.0-bank-statement-reconcile-account_invoice_reference/+merge/202689

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Thanks for the good job. LGTM

review: Approve (code review, no tests)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_advanced_reconcile_transaction_ref/__init__.py'
2--- account_advanced_reconcile_transaction_ref/__init__.py 2013-08-13 10:04:31 +0000
3+++ account_advanced_reconcile_transaction_ref/__init__.py 2014-03-10 12:41:01 +0000
4@@ -18,7 +18,6 @@
5 #
6 ##############################################################################
7
8-from . import account
9 from . import easy_reconcile
10 from . import base_advanced_reconciliation
11 from . import advanced_reconciliation
12
13=== modified file 'account_advanced_reconcile_transaction_ref/__openerp__.py'
14--- account_advanced_reconcile_transaction_ref/__openerp__.py 2014-02-21 18:18:26 +0000
15+++ account_advanced_reconcile_transaction_ref/__openerp__.py 2014-03-10 12:41:01 +0000
16@@ -20,8 +20,8 @@
17
18 {'name': 'Advanced Reconcile Transaction Ref',
19 'description': """
20-Advanced reconciliation method for the module account_easy_reconcile
21-=================================================
22+Advanced reconciliation method for the module account_advanced_reconcile
23+========================================================================
24 Reconcile rules with transaction_ref
25
26 """,
27
28=== removed file 'account_advanced_reconcile_transaction_ref/account.py'
29--- account_advanced_reconcile_transaction_ref/account.py 2013-12-04 16:25:04 +0000
30+++ account_advanced_reconcile_transaction_ref/account.py 1970-01-01 00:00:00 +0000
31@@ -1,54 +0,0 @@
32-# -*- coding: utf-8 -*-
33-##############################################################################
34-#
35-# Author: Romain Deheele
36-# Copyright 2013 Camptocamp SA
37-#
38-# This program is free software: you can redistribute it and/or modify
39-# it under the terms of the GNU Affero General Public License as
40-# published by the Free Software Foundation, either version 3 of the
41-# License, or (at your option) any later version.
42-#
43-# This program is distributed in the hope that it will be useful,
44-# but WITHOUT ANY WARRANTY; without even the implied warranty of
45-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46-# GNU Affero General Public License for more details.
47-#
48-# You should have received a copy of the GNU Affero General Public License
49-# along with this program. If not, see <http://www.gnu.org/licenses/>.
50-#
51-##############################################################################
52-
53-from openerp.osv.orm import Model, fields
54-
55-class AccountMoveLine(Model):
56- """
57- Inherit account.move.line class in order to add transaction_ref field
58- """
59- _inherit = "account.move.line"
60- _columns = {
61- 'transaction_ref': fields.char('Transaction Ref.', size=128),
62- }
63-
64-class AccountBankStatement(Model):
65- """
66- Inherit account.bank.statement class in order to set transaction_ref info on account.move.line
67- """
68- _inherit = "account.bank.statement"
69-
70- def _prepare_move_line_vals(
71- self, cr, uid, st_line, move_id, debit, credit, currency_id=False,
72- amount_currency=False, account_id=False, analytic_id=False,
73- partner_id=False, context=None):
74-
75- if context is None:
76- context = {}
77- res = super(AccountBankStatement, self)._prepare_move_line_vals(
78- cr, uid, st_line, move_id, debit, credit,
79- currency_id=currency_id,
80- amount_currency=amount_currency,
81- account_id=account_id,
82- analytic_id=analytic_id,
83- partner_id=partner_id, context=context)
84- res.update({'transaction_ref': st_line.ref})
85- return res
86
87=== modified file 'account_advanced_reconcile_transaction_ref/advanced_reconciliation.py'
88--- account_advanced_reconcile_transaction_ref/advanced_reconciliation.py 2013-08-13 15:10:05 +0000
89+++ account_advanced_reconcile_transaction_ref/advanced_reconciliation.py 2014-03-10 12:41:01 +0000
90@@ -32,7 +32,8 @@
91 will be skipped for reconciliation. Can be inherited to
92 skip on some conditions. ie: ref or partner_id is empty.
93 """
94- return not (move_line.get('ref') and move_line.get('partner_id'))
95+ return not (move_line.get('transaction_ref') and
96+ move_line.get('partner_id'))
97
98 def _matchers(self, cr, uid, rec, move_line, context=None):
99 return (('partner_id', move_line['partner_id']),
100@@ -41,3 +42,25 @@
101 def _opposite_matchers(self, cr, uid, rec, move_line, context=None):
102 yield ('partner_id', move_line['partner_id'])
103 yield ('ref', (move_line['transaction_ref'] or '').lower().strip())
104+
105+
106+class easy_reconcile_advanced_transaction_ref_vs_ref(orm.TransientModel):
107+
108+ _name = 'easy.reconcile.advanced.trans_ref_vs_ref'
109+ _inherit = 'easy.reconcile.advanced'
110+
111+ def _skip_line(self, cr, uid, rec, move_line, context=None):
112+ """
113+ When True is returned on some conditions, the credit move line
114+ will be skipped for reconciliation. Can be inherited to
115+ skip on some conditions. ie: ref or partner_id is empty.
116+ """
117+ return not (move_line.get('ref') and move_line.get('partner_id'))
118+
119+ def _matchers(self, cr, uid, rec, move_line, context=None):
120+ return (('partner_id', move_line['partner_id']),
121+ ('ref', move_line['ref'].lower().strip()))
122+
123+ def _opposite_matchers(self, cr, uid, rec, move_line, context=None):
124+ yield ('partner_id', move_line['partner_id'])
125+ yield ('ref', (move_line['transaction_ref'] or '').lower().strip())
126
127=== modified file 'account_advanced_reconcile_transaction_ref/easy_reconcile.py'
128--- account_advanced_reconcile_transaction_ref/easy_reconcile.py 2013-08-13 10:04:31 +0000
129+++ account_advanced_reconcile_transaction_ref/easy_reconcile.py 2014-03-10 12:41:01 +0000
130@@ -32,6 +32,8 @@
131 methods += [
132 ('easy.reconcile.advanced.transaction_ref',
133 'Advanced. Partner and Transaction Ref.'),
134+ ('easy.reconcile.advanced.trans_ref_vs_ref',
135+ 'Advanced. Partner and Transaction Ref. vs Ref.'),
136 ]
137 return methods
138
139
140=== modified file 'account_advanced_reconcile_transaction_ref/easy_reconcile_view.xml'
141--- account_advanced_reconcile_transaction_ref/easy_reconcile_view.xml 2013-08-13 10:04:31 +0000
142+++ account_advanced_reconcile_transaction_ref/easy_reconcile_view.xml 2014-03-10 12:41:01 +0000
143@@ -10,7 +10,12 @@
144 <group colspan="2" col="2">
145 <separator colspan="4" string="Advanced. Partner and Transaction Ref"/>
146 <label string="Match multiple debit vs multiple credit entries. Allow partial reconciliation.
147-The lines should have the partner, the credit entry transaction ref. is matched vs the debit entry transaction ref. or name." colspan="4"/>
148+The lines should have the partner, the credit entry transaction ref. is matched vs the debit entry transaction ref." colspan="4"/>
149+ </group>
150+ <group colspan="2" col="2">
151+ <separator colspan="4" string="Advanced. Partner and Transaction Ref. vs Ref."/>
152+ <label string="Match multiple debit vs multiple credit entries. Allow partial reconciliation.
153+The lines should have the partner, the credit entry reference is matched vs the debit entry transaction reference." colspan="4"/>
154 </group>
155 </page>
156 </field>
157
158=== modified file 'account_easy_reconcile/easy_reconcile.xml'
159--- account_easy_reconcile/easy_reconcile.xml 2013-02-13 15:54:48 +0000
160+++ account_easy_reconcile/easy_reconcile.xml 2014-03-10 12:41:01 +0000
161@@ -118,7 +118,7 @@
162 <field name="model">account.easy.reconcile.method</field>
163 <field name="arch" type="xml">
164 <form string="Automatic Easy Reconcile Method">
165- <field name="sequence"/>
166+ <field name="sequence" widget="handle"/>
167 <field name="name"/>
168 <field name="write_off"/>
169 <field name="account_lost_id" attrs="{'required':[('write_off','>',0)]}"/>
170@@ -135,7 +135,7 @@
171 <field name="model">account.easy.reconcile.method</field>
172 <field name="arch" type="xml">
173 <tree editable="top" string="Automatic Easy Reconcile Method">
174- <field name="sequence"/>
175+ <field name="sequence" widget="handle"/>
176 <field name="name"/>
177 <field name="write_off"/>
178 <field name="account_lost_id" attrs="{'required':[('write_off','>',0)]}"/>
179
180=== added directory 'account_payment_transaction_id'
181=== added file 'account_payment_transaction_id/__init__.py'
182--- account_payment_transaction_id/__init__.py 1970-01-01 00:00:00 +0000
183+++ account_payment_transaction_id/__init__.py 2014-03-10 12:41:01 +0000
184@@ -0,0 +1,3 @@
185+# -*- coding: utf-8 -*-
186+
187+from . import account_payment
188
189=== added file 'account_payment_transaction_id/__openerp__.py'
190--- account_payment_transaction_id/__openerp__.py 1970-01-01 00:00:00 +0000
191+++ account_payment_transaction_id/__openerp__.py 2014-03-10 12:41:01 +0000
192@@ -0,0 +1,43 @@
193+# -*- coding: utf-8 -*-
194+##############################################################################
195+#
196+# Author: Guewen Baconnier
197+# Copyright 2014 Camptocamp SA
198+#
199+# This program is free software: you can redistribute it and/or modify
200+# it under the terms of the GNU Affero General Public License as
201+# published by the Free Software Foundation, either version 3 of the
202+# License, or (at your option) any later version.
203+#
204+# This program is distributed in the hope that it will be useful,
205+# but WITHOUT ANY WARRANTY; without even the implied warranty of
206+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
207+# GNU Affero General Public License for more details.
208+#
209+# You should have received a copy of the GNU Affero General Public License
210+# along with this program. If not, see <http://www.gnu.org/licenses/>.
211+#
212+##############################################################################
213+
214+
215+{'name': 'Account Payment - Transaction ID',
216+ 'version': '1.0',
217+ 'author': 'Camptocamp',
218+ 'maintainer': 'Camptocamp',
219+ 'license': 'AGPL-3',
220+ 'category': 'Hidden',
221+ 'depends': ['base_transaction_id',
222+ 'account_payment',
223+ 'statement_voucher_killer',
224+ ],
225+ 'description': """
226+Compatibility module between Account Payment and Base Transaction ID.
227+
228+Needs `statement_voucher_killer`
229+ """,
230+ 'website': 'http://www.camptocamp.com',
231+ 'data': [],
232+ 'test': [],
233+ 'installable': True,
234+ 'auto_install': True,
235+}
236
237=== added file 'account_payment_transaction_id/account_payment.py'
238--- account_payment_transaction_id/account_payment.py 1970-01-01 00:00:00 +0000
239+++ account_payment_transaction_id/account_payment.py 2014-03-10 12:41:01 +0000
240@@ -0,0 +1,47 @@
241+# -*- coding: utf-8 -*-
242+##############################################################################
243+#
244+# Author: Guewen Baconnier
245+# Copyright 2014 Camptocamp SA
246+#
247+# This program is free software: you can redistribute it and/or modify
248+# it under the terms of the GNU Affero General Public License as
249+# published by the Free Software Foundation, either version 3 of the
250+# License, or (at your option) any later version.
251+#
252+# This program is distributed in the hope that it will be useful,
253+# but WITHOUT ANY WARRANTY; without even the implied warranty of
254+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
255+# GNU Affero General Public License for more details.
256+#
257+# You should have received a copy of the GNU Affero General Public License
258+# along with this program. If not, see <http://www.gnu.org/licenses/>.
259+#
260+##############################################################################
261+
262+from openerp.osv import orm
263+
264+
265+class AccountPaymentPopulateStatement(orm.TransientModel):
266+ _inherit = "account.payment.populate.statement"
267+
268+ def _prepare_statement_line_vals(self, cr, uid, payment_line, amount,
269+ statement, context=None):
270+ superself = super(AccountPaymentPopulateStatement, self)
271+ vals = superself._prepare_statement_line_vals(
272+ cr, uid, payment_line, amount, statement, context=context)
273+ if payment_line.move_line_id:
274+ vals['transaction_id'] = payment_line.move_line_id.transaction_ref
275+ return vals
276+
277+
278+class account_statement_from_invoice_lines(orm.TransientModel):
279+ _inherit = "account.statement.from.invoice.lines"
280+
281+ def _prepare_statement_line_vals(self, cr, uid, move_line, s_type,
282+ statement_id, amount, context=None):
283+ superself = super(account_statement_from_invoice_lines, self)
284+ vals = superself._prepare_statement_line_vals(
285+ cr, uid, move_line, s_type, statement_id, amount, context=context)
286+ vals['transaction_id'] = move_line.transaction_ref
287+ return vals
288
289=== modified file 'account_statement_transactionid_completion/__openerp__.py'
290--- account_statement_transactionid_completion/__openerp__.py 2014-01-07 11:27:26 +0000
291+++ account_statement_transactionid_completion/__openerp__.py 2014-03-10 12:41:01 +0000
292@@ -51,6 +51,8 @@
293 'test': [
294 'test/sale.yml',
295 'test/completion_transactionid_test.yml',
296+ 'test/invoice.yml',
297+ 'test/completion_invoice_transactionid_test.yml',
298 ],
299 'installable': True,
300 'images': [],
301
302=== modified file 'account_statement_transactionid_completion/data.xml'
303--- account_statement_transactionid_completion/data.xml 2012-06-26 09:21:35 +0000
304+++ account_statement_transactionid_completion/data.xml 2014-03-10 12:41:01 +0000
305@@ -3,10 +3,16 @@
306 <data noupdate="1">
307
308 <record id="bank_statement_completion_rule_4" model="account.statement.completion.rule">
309- <field name="name">Match from line reference (based on transaction ID)</field>
310+ <field name="name">Match from Sales Order using transaction ID</field>
311 <field name="sequence">30</field>
312 <field name="function_to_call">get_from_transaction_id_and_so</field>
313 </record>
314+
315+ <record id="bank_statement_completion_rule_trans_id_invoice" model="account.statement.completion.rule">
316+ <field name="name">Match from Invoice using transaction ID</field>
317+ <field name="sequence">40</field>
318+ <field name="function_to_call">get_from_transaction_id_and_invoice</field>
319+ </record>
320
321 </data>
322 </openerp>
323
324=== modified file 'account_statement_transactionid_completion/statement.py'
325--- account_statement_transactionid_completion/statement.py 2013-09-11 09:12:14 +0000
326+++ account_statement_transactionid_completion/statement.py 2014-03-10 12:41:01 +0000
327@@ -33,8 +33,12 @@
328 def _get_functions(self, cr, uid, context=None):
329 res = super(AccountStatementCompletionRule, self)._get_functions(
330 cr, uid, context=context)
331- res.append(('get_from_transaction_id_and_so',
332- 'From line reference (based on SO transaction ID)'))
333+ res += [
334+ ('get_from_transaction_id_and_so',
335+ 'Match Sales Order using transaction ID'),
336+ ('get_from_transaction_id_and_invoice',
337+ 'Match Invoice using transaction ID'),
338+ ]
339 return res
340
341 _columns = {
342@@ -79,6 +83,52 @@
343 res.update(st_vals)
344 return res
345
346+ def get_from_transaction_id_and_invoice(self, cr, uid, st_line, context=None):
347+ """
348+ Match the partner based on the transaction ID field of the invoice.
349+ Then, call the generic st_line method to complete other values.
350+
351+ In that case, we always fullfill the reference of the line with the invoice name.
352+
353+ :param dict st_line: read of the concerned account.bank.statement.line
354+ :return:
355+ A dict of value that can be passed directly to the write method of
356+ the statement line or {}
357+ {'partner_id': value,
358+ 'account_id' : value,
359+ ...}
360+ """
361+ st_obj = self.pool.get('account.bank.statement.line')
362+ res = {}
363+ invoice_obj = self.pool.get('account.invoice')
364+ invoice_id = invoice_obj.search(
365+ cr, uid,
366+ [('transaction_id', '=', st_line['transaction_id'])],
367+ context=context)
368+ if len(invoice_id) > 1:
369+ raise ErrorTooManyPartner(
370+ _('Line named "%s" (Ref:%s) was matched by more than '
371+ 'one partner.') % (st_line['name'], st_line['ref']))
372+ elif len(invoice_id) == 1:
373+ invoice = invoice_obj.browse(cr, uid, invoice_id[0],
374+ context=context)
375+ res['partner_id'] = invoice.partner_id.id
376+ # we want the move to have the same ref than the found
377+ # invoice's move, thus it will be easier to link them for the
378+ # accountants
379+ if invoice.move_id:
380+ res['ref'] = invoice.move_id.ref
381+ st_vals = st_obj.get_values_for_line(
382+ cr, uid,
383+ profile_id=st_line['profile_id'],
384+ master_account_id=st_line['master_account_id'],
385+ partner_id=res.get('partner_id', False),
386+ line_type=st_line['type'],
387+ amount=st_line['amount'] if st_line['amount'] else 0.0,
388+ context=context)
389+ res.update(st_vals)
390+ return res
391+
392
393 class AccountStatementLine(Model):
394 _inherit = "account.bank.statement.line"
395@@ -92,3 +142,38 @@
396 serialization_field='additionnal_bank_fields',
397 help="Transaction id from the financial institute"),
398 }
399+
400+
401+class AccountBankStatement(Model):
402+ _inherit = "account.bank.statement"
403+
404+ def _prepare_move_line_vals(
405+ self, cr, uid, st_line, move_id, debit, credit, currency_id=False,
406+ amount_currency=False, account_id=False, analytic_id=False,
407+ partner_id=False, context=None):
408+ """Add the period_id from the statement line date to the move preparation.
409+ Originaly, it was taken from the statement period_id
410+
411+ :param browse_record st_line: account.bank.statement.line record to
412+ create the move from.
413+ :param int/long move_id: ID of the account.move to link the move line
414+ :param float debit: debit amount of the move line
415+ :param float credit: credit amount of the move line
416+ :param int/long currency_id: ID of currency of the move line to create
417+ :param float amount_currency: amount of the debit/credit expressed in the currency_id
418+ :param int/long account_id: ID of the account to use in the move line if different
419+ from the statement line account ID
420+ :param int/long analytic_id: ID of analytic account to put on the move line
421+ :param int/long partner_id: ID of the partner to put on the move line
422+ :return: dict of value to create() the account.move.line
423+ """
424+ res = super(AccountBankStatement, self)._prepare_move_line_vals(
425+ cr, uid, st_line, move_id, debit, credit,
426+ currency_id=currency_id,
427+ amount_currency=amount_currency,
428+ account_id=account_id,
429+ analytic_id=analytic_id,
430+ partner_id=partner_id, context=context)
431+ if st_line.transaction_id:
432+ res['transaction_ref'] = st_line.transaction_id
433+ return res
434
435=== modified file 'account_statement_transactionid_completion/statement_view.xml'
436--- account_statement_transactionid_completion/statement_view.xml 2012-12-18 21:06:21 +0000
437+++ account_statement_transactionid_completion/statement_view.xml 2014-03-10 12:41:01 +0000
438@@ -7,13 +7,13 @@
439 <field name="model">account.bank.statement</field>
440 <field name="inherit_id" ref="account.view_bank_statement_form" />
441 <field eval="20" name="priority"/>
442- <field name="type">form</field>
443 <field name="arch" type="xml">
444- <data>
445- <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='label']" position="after">
446- <field name="transaction_id" />
447- </xpath>
448- </data>
449+ <xpath expr="//field[@name='line_ids']/form//field[@name='label']" position="after">
450+ <field name="transaction_id" />
451+ </xpath>
452+ <xpath expr="//field[@name='line_ids']/tree/field[@name='ref']" position="after">
453+ <field name="transaction_id" />
454+ </xpath>
455 </field>
456 </record>
457
458
459=== added file 'account_statement_transactionid_completion/test/completion_invoice_transactionid_test.yml'
460--- account_statement_transactionid_completion/test/completion_invoice_transactionid_test.yml 1970-01-01 00:00:00 +0000
461+++ account_statement_transactionid_completion/test/completion_invoice_transactionid_test.yml 2014-03-10 12:41:01 +0000
462@@ -0,0 +1,49 @@
463+-
464+ In order to test the banking framework, I first need to create a profile
465+-
466+ !record {model: account.statement.profile, id: statement_profile_invoice_transactionid}:
467+ name: Bank EUR Profile (invoice transaction ID)
468+ journal_id: account.bank_journal
469+ commission_account_id: account.a_expense
470+ company_id: base.main_company
471+ balance_check: True
472+ rule_ids:
473+ - bank_statement_completion_rule_trans_id_invoice
474+-
475+ Now I create a statement. I create statment lines separately because I need
476+ to find each one by XML id
477+-
478+ !record {model: account.bank.statement, id: statement_invoice_transactionid_test1}:
479+ name: Statement with transaction ID
480+ profile_id: statement_profile_invoice_transactionid
481+ company_id: base.main_company
482+-
483+ I create a statement line for an invoice with transaction ID
484+-
485+ !record {model: account.bank.statement.line, id: statement_line_invoice_transactionid}:
486+ name: Test autocompletion based on invoice with transaction ID
487+ statement_id: statement_invoice_transactionid_test1
488+ transaction_id: XXX77Z
489+ ref: 6
490+ date: !eval time.strftime('%Y-%m-%d')
491+ amount: 450
492+-
493+ I run the auto complete
494+-
495+ !python {model: account.bank.statement}: |
496+ result = self.button_auto_completion(cr, uid, [ref("statement_invoice_transactionid_test1")])
497+-
498+ Now I can check that all is nice and shiny, line 1. I expect the invoice has been
499+ recognised from the transaction ID.
500+-
501+ !assert {model: account.bank.statement.line, id: statement_line_invoice_transactionid, string: Check completion by Invoice transaction ID}:
502+ - partner_id.name == u'Agrolait'
503+-
504+ I verify if the reference of the move has been copied to the statement line
505+-
506+ !python {model: account.bank.statement.line}: |
507+ statement_line = self.browse(cr, uid, ref('statement_line_invoice_transactionid'))
508+ invoice_obj = self.pool['account.invoice']
509+ invoice = invoice_obj.browse(cr, uid, ref('invoice_with_transaction_id'))
510+ reference = invoice.move_id.ref
511+ assert statement_line.ref == reference
512
513=== modified file 'account_statement_transactionid_completion/test/completion_transactionid_test.yml'
514--- account_statement_transactionid_completion/test/completion_transactionid_test.yml 2014-01-07 11:27:26 +0000
515+++ account_statement_transactionid_completion/test/completion_transactionid_test.yml 2014-03-10 12:41:01 +0000
516@@ -35,7 +35,7 @@
517 I run the auto complete
518 -
519 !python {model: account.bank.statement}: |
520- result = self.button_auto_completion(cr, uid, [ref("statement_profile_transactionid")])
521+ result = self.button_auto_completion(cr, uid, [ref("statement_transactionid_test1")])
522 -
523 Now I can check that all is nice and shiny, line 1. I expect the SO has been
524 recognised from the transaction ID.
525
526=== added file 'account_statement_transactionid_completion/test/invoice.yml'
527--- account_statement_transactionid_completion/test/invoice.yml 1970-01-01 00:00:00 +0000
528+++ account_statement_transactionid_completion/test/invoice.yml 2014-03-10 12:41:01 +0000
529@@ -0,0 +1,30 @@
530+-
531+ I create a new invoice with transaction ID
532+-
533+ !record {model: account.invoice, id: invoice_with_transaction_id}:
534+ account_id: account.a_recv
535+ company_id: base.main_company
536+ currency_id: base.EUR
537+ partner_id: base.res_partner_2
538+ transaction_id: XXX77Z
539+ invoice_line:
540+ - account_id: account.a_sale
541+ name: '[PCSC234] PC Assemble SC234'
542+ price_unit: 450.0
543+ quantity: 1.0
544+ product_id: product.product_product_3
545+ uos_id: product.product_uom_unit
546+ journal_id: account.bank_journal
547+ reference_type: none
548+-
549+ I called the "Confirm Draft Invoices" wizard
550+-
551+ !record {model: account.invoice.confirm, id: invoice_transaction_id_confirm}:
552+ {}
553+-
554+ I clicked on Confirm Invoices Button
555+-
556+ !python {model: account.invoice.confirm}: |
557+ self.invoice_confirm(cr, uid, [ref("invoice_transaction_id_confirm")], {"lang": 'en_US',
558+ "tz": False, "active_model": "account.invoice", "active_ids": [ref("invoice_with_transaction_id")],
559+ "type": "out_invoice", "active_id": ref("invoice_with_transaction_id"), })
560
561=== modified file 'base_transaction_id/__init__.py'
562--- base_transaction_id/__init__.py 2012-05-16 14:09:21 +0000
563+++ base_transaction_id/__init__.py 2014-03-10 12:41:01 +0000
564@@ -22,3 +22,4 @@
565 from . import invoice
566 from . import sale
567 from . import stock
568+from . import account_move
569
570=== added file 'base_transaction_id/account_move.py'
571--- base_transaction_id/account_move.py 1970-01-01 00:00:00 +0000
572+++ base_transaction_id/account_move.py 2014-03-10 12:41:01 +0000
573@@ -0,0 +1,37 @@
574+# -*- coding: utf-8 -*-
575+##############################################################################
576+#
577+# Author: Guewen Baconnier
578+# Copyright 2014 Camptocamp SA
579+#
580+# This program is free software: you can redistribute it and/or modify
581+# it under the terms of the GNU Affero General Public License as
582+# published by the Free Software Foundation, either version 3 of the
583+# License, or (at your option) any later version.
584+#
585+# This program is distributed in the hope that it will be useful,
586+# but WITHOUT ANY WARRANTY; without even the implied warranty of
587+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
588+# GNU Affero General Public License for more details.
589+#
590+# You should have received a copy of the GNU Affero General Public License
591+# along with this program. If not, see <http://www.gnu.org/licenses/>.
592+#
593+##############################################################################
594+from openerp.osv import orm, fields
595+
596+
597+class account_move_line(orm.Model):
598+ _inherit = 'account.move.line'
599+
600+ _columns = {
601+ 'transaction_ref': fields.char('Transaction Ref.',
602+ select=True),
603+ }
604+
605+ def copy_data(self, cr, uid, id, default=None, context=None):
606+ if default is None:
607+ default = {}
608+ default['transaction_ref'] = False
609+ return super(account_move_line, self).\
610+ copy_data(cr, uid, id, default=default, context=context)
611
612=== modified file 'base_transaction_id/invoice.py'
613--- base_transaction_id/invoice.py 2012-12-20 13:37:01 +0000
614+++ base_transaction_id/invoice.py 2014-03-10 12:41:01 +0000
615@@ -29,8 +29,22 @@
616 _columns = {
617 'transaction_id': fields.char(
618 'Transaction id',
619- size=128,
620- required=False,
621 select=1,
622- help="Transction id from the financial institute"),
623+ help="Transaction id from the financial institute"),
624 }
625+
626+ def copy_data(self, cr, uid, id, default=None, context=None):
627+ if default is None:
628+ default = {}
629+ default['transaction_id'] = False
630+ return super(AccountInvoice, self).\
631+ copy_data(cr, uid, id, default=default, context=context)
632+
633+ def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines):
634+ if invoice_browse.transaction_id:
635+ invoice_account_id = invoice_browse.account_id.id
636+ for line in move_lines:
637+ # tuple (0, 0, {values})
638+ if invoice_account_id == line[2]['account_id']:
639+ line[2]['transaction_ref'] = invoice_browse.transaction_id
640+ return move_lines
641
642=== modified file 'statement_voucher_killer/voucher.py'
643--- statement_voucher_killer/voucher.py 2013-08-27 06:20:04 +0000
644+++ statement_voucher_killer/voucher.py 2014-03-10 12:41:01 +0000
645@@ -72,18 +72,23 @@
646 s_type = 'customer'
647 elif line.journal_id.type in ('purchase', 'purhcase_refund'):
648 s_type = 'supplier'
649- statement_line_obj.create(cr, uid, {
650- 'name': line.name or '?',
651+ vals = self._prepare_statement_line_vals(
652+ cr, uid, line, s_type, statement_id, amount, context=context)
653+ statement_line_obj.create(cr, uid, vals, context=context)
654+ return {'type': 'ir.actions.act_window_close'}
655+
656+ def _prepare_statement_line_vals(self, cr, uid, move_line, s_type,
657+ statement_id, amount, context=None):
658+ return {'name': move_line.name or '?',
659 'amount': amount,
660 'type': s_type,
661- 'partner_id': line.partner_id.id,
662- 'account_id': line.account_id.id,
663+ 'partner_id': move_line.partner_id.id,
664+ 'account_id': move_line.account_id.id,
665 'statement_id': statement_id,
666- 'ref': line.ref,
667+ 'ref': move_line.ref,
668 'voucher_id': False,
669 'date': time.strftime('%Y-%m-%d'),
670- }, context=context)
671- return {'type': 'ir.actions.act_window_close'}
672+ }
673
674
675 class AccountPaymentPopulateStatement(orm.TransientModel):
676@@ -114,16 +119,23 @@
677 if not line.move_line_id.id:
678 continue
679 context.update({'move_line_ids': [line.move_line_id.id]})
680- st_line_id = statement_line_obj.create(cr, uid, {
681- 'name': line.order_id.reference or '?',
682- 'amount': - amount,
683+ vals = self._prepare_statement_line_vals(
684+ cr, uid, line, -amount, statement, context=context)
685+ st_line_id = statement_line_obj.create(cr, uid, vals,
686+ context=context)
687+
688+ line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
689+ return {'type': 'ir.actions.act_window_close'}
690+
691+ def _prepare_statement_line_vals(self, cr, uid, payment_line, amount,
692+ statement, context=None):
693+ return {'name': payment_line.order_id.reference or '?',
694+ 'amount': amount,
695 'type': 'supplier',
696- 'partner_id': line.partner_id.id,
697- 'account_id': line.move_line_id.account_id.id,
698+ 'partner_id': payment_line.partner_id.id,
699+ 'account_id': payment_line.move_line_id.account_id.id,
700 'statement_id': statement.id,
701- 'ref': line.communication,
702- 'date': line.date or line.ml_maturity_date or statement.date,
703- }, context=context)
704-
705- line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
706- return {'type': 'ir.actions.act_window_close'}
707+ 'ref': payment_line.communication,
708+ 'date': (payment_line.date or payment_line.ml_maturity_date or
709+ statement.date)
710+ }

Subscribers

People subscribed via source and target branches