Merge lp:~openerp-dev/openobject-addons/7.0-opw-605632-rgo into lp:openobject-addons/7.0

Proposed by Martin Trigaux (OpenERP)
Status: Merged
Merged at revision: 10008
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-605632-rgo
Merge into: lp:openobject-addons/7.0
Diff against target: 48 lines (+6/-2)
2 files modified
account_voucher/account_voucher.py (+3/-2)
account_voucher/test/sales_payment.yml (+3/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-605632-rgo
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Review via email: mp+216714@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Thanks for the patch and the additional test, merged in 7.0

revno: 10008 [merge]
revision-id: <email address hidden>

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_voucher/account_voucher.py'
2--- account_voucher/account_voucher.py 2014-04-22 10:11:28 +0000
3+++ account_voucher/account_voucher.py 2014-04-23 06:52:06 +0000
4@@ -792,6 +792,7 @@
5 total_credit += line.credit and line.amount_currency or 0.0
6 total_debit += line.debit and line.amount_currency or 0.0
7
8+ remaining_amount = price
9 #voucher line creation
10 for line in account_move_lines:
11
12@@ -812,13 +813,13 @@
13 'move_line_id':line.id,
14 'account_id':line.account_id.id,
15 'amount_original': amount_original,
16- 'amount': (line.id in move_lines_found) and min(abs(price), amount_unreconciled) or 0.0,
17+ 'amount': (line.id in move_lines_found) and min(abs(remaining_amount), amount_unreconciled) or 0.0,
18 'date_original':line.date,
19 'date_due':line.date_maturity,
20 'amount_unreconciled': amount_unreconciled,
21 'currency_id': line_currency_id,
22 }
23- price -= rs['amount']
24+ remaining_amount -= rs['amount']
25 #in case a corresponding move_line hasn't been found, we now try to assign the voucher amount
26 #on existing invoices: we split voucher amount by most old first, but only for lines in the same currency
27 if not move_lines_found:
28
29=== modified file 'account_voucher/test/sales_payment.yml'
30--- account_voucher/test/sales_payment.yml 2012-11-29 22:26:45 +0000
31+++ account_voucher/test/sales_payment.yml 2014-04-23 06:52:06 +0000
32@@ -40,6 +40,8 @@
33 import netsvc
34 vals = {}
35 journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
36+ voucher = self.recompute_voucher_lines(cr, uid, [], ref("base.res_partner_19"), journal_id, 450.0, ref('base.EUR'), 'receipt', False)
37+ assert (voucher['value'].get('writeoff_amount') == 0.0), "Writeoff amount calculated by recompute_voucher_lines() is not 0.0"
38 res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), journal_id, 0.0, 1, ttype='receipt', date=False)
39 vals = {
40 'account_id': ref('account.cash'),
41@@ -60,6 +62,7 @@
42 vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
43 id = self.create(cr, uid, vals)
44 voucher_id = self.browse(cr, uid, id)
45+ assert (voucher_id.writeoff_amount == 0.0), "Writeoff amount is not 0.0"
46 assert (voucher_id.state=='draft'), "Voucher is not in draft state"
47 wf_service = netsvc.LocalService("workflow")
48 wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)