Merge lp:~camptocamp/openerp-rma/rma-fix-lp1311509_rde into lp:~openerprma/openerp-rma/7.0

Proposed by Romain Deheele - Camptocamp
Status: Merged
Approved by: Alexandre Fayolle - camptocamp
Approved revision: 78
Merged at revision: 78
Proposed branch: lp:~camptocamp/openerp-rma/rma-fix-lp1311509_rde
Merge into: lp:~openerprma/openerp-rma/7.0
Diff against target: 87 lines (+58/-1)
3 files modified
crm_claim_rma/__openerp__.py (+1/-0)
crm_claim_rma/account_invoice.py (+1/-1)
crm_claim_rma/test/test_invoice_refund.yml (+56/-0)
To merge this branch: bzr merge lp:~camptocamp/openerp-rma/rma-fix-lp1311509_rde
Reviewer Review Type Date Requested Status
Benoit Guillot - http://www.akretion.com Approve
Yannick Vaucher @ Camptocamp code review, no test Approve
Pedro Manuel Baeza code review Approve
Review via email: mp+216824@code.launchpad.net

Description of the change

Hi,

It fixes https://bugs.launchpad.net/openerp-rma/+bug/1311509 : error at refund generation.

Line records in context are in this form : [[4, 1, False], [4, 2, False]].
We need to take in account the third element in each list when we fetch lines.

Regards,

Romain

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM

Regards.

review: Approve (code review)
78. By Romain Deheele - Camptocamp

[ADD] add test to check invoice refund action

Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

Just add a test to check invoice refund action

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :
review: Approve (code review, no test)
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

Thanks Yannick to point out that.

Revision history for this message
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote :

Looks good.

Thanks for the fix!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'crm_claim_rma/__openerp__.py'
2--- crm_claim_rma/__openerp__.py 2014-02-20 13:49:50 +0000
3+++ crm_claim_rma/__openerp__.py 2014-04-23 15:08:32 +0000
4@@ -83,6 +83,7 @@
5 'res_partner_view.xml',
6 'crm_claim_rma_data.xml',
7 ],
8+ 'test': ['test/test_invoice_refund.yml'],
9 'images': ['images/product_return.png',
10 'images/claim.png',
11 'images/return_line.png',
12
13=== modified file 'crm_claim_rma/account_invoice.py'
14--- crm_claim_rma/account_invoice.py 2014-02-18 10:34:22 +0000
15+++ crm_claim_rma/account_invoice.py 2014-04-23 15:08:32 +0000
16@@ -46,7 +46,7 @@
17 return super(account_invoice, self)._refund_cleanup_lines(
18 cr, uid, lines, context=None)
19
20- for __, claim_line_id in context.get('claim_line_ids'):
21+ for __, claim_line_id, __ in context.get('claim_line_ids'):
22 line = claim_line_obj.browse(cr, uid, claim_line_id,
23 context=context)
24 if not line.refund_line_id:
25
26=== added directory 'crm_claim_rma/test'
27=== added file 'crm_claim_rma/test/test_invoice_refund.yml'
28--- crm_claim_rma/test/test_invoice_refund.yml 1970-01-01 00:00:00 +0000
29+++ crm_claim_rma/test/test_invoice_refund.yml 2014-04-23 15:08:32 +0000
30@@ -0,0 +1,56 @@
31+-
32+ In order to test the refund creation from a claim
33+-
34+ I create a customer invoice
35+-
36+ !record {model: account.invoice, id: account_invoice_claim_refund, view: account.invoice_form}:
37+ payment_term: account.account_payment_term_advance
38+ journal_id: account.sales_journal
39+ partner_id: base.res_partner_3
40+ name: 'Test Customer Invoice'
41+ invoice_line:
42+ - product_id: product.product_product_5
43+ quantity: 10.0
44+ - product_id: product.product_product_4
45+ quantity: 5.0
46+-
47+ I confirm the invoice
48+-
49+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_claim_refund}
50+-
51+ I create a claim
52+-
53+ !record {model: crm.claim, id: claim_refund}:
54+ name: 'Angry Customer'
55+ claim_type: customer
56+ partner_id: base.res_partner_3
57+ invoice_id: account_invoice_claim_refund
58+ state: open
59+-
60+ I prepare the wizard context.
61+-
62+ !python {model: account.invoice.refund}: |
63+ claim_lines = self.pool.get('claim.line').search(cr, uid, [('claim_id','=',ref('claim_refund'))])
64+ context.update({'active_model': 'crm_claim', 'active_id': ref('claim_refund'), 'claim_id': ref('claim_refund'), 'claim_line_ids': [[4, claim_lines[0], False], [4, claim_lines[1], False]], 'invoice_ids':[ref('account_invoice_claim_refund')] })
65+-
66+ I create a refund wizard
67+-
68+ !record {model: account.invoice.refund, id: wizard_claim_refund}:
69+ filter_refund: refund
70+ description: 'claim refund'
71+-
72+ I launch the refund wizard
73+-
74+ !python {model: account.invoice.refund}: |
75+ self.compute_refund(cr, uid, [ref('wizard_claim_refund')], 'refund', context=context)
76+-
77+ I check that a refund linked to the claim has been created.
78+-
79+ !python {model: account.invoice}: |
80+ refund = self.search(cr, uid, [('type', '=', 'out_refund'),('claim_id', '=', ref('claim_refund'))])
81+ assert refund, "The refund is created"
82+ refund_line_ids = self.pool.get('account.invoice.line').search(cr, uid, [('invoice_id','=',refund[0])])
83+ assert len(refund_line_ids) == 2, "It contains 2 lines, as excepted"
84+ refund_lines = self.pool.get('account.invoice.line').browse(cr, uid, refund_line_ids)
85+ assert ref('product.product_product_4') in [refund_lines[0].product_id.id, refund_lines[1].product_id.id], "First line is checked"
86+ assert ref('product.product_product_5') in [refund_lines[0].product_id.id, refund_lines[1].product_id.id], "Second line is checked"
87\ No newline at end of file

Subscribers

People subscribed via source and target branches