Merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_1281687-afe into lp:ocb-addons

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Approved by: Pedro Manuel Baeza
Approved revision: no longer in the source branch.
Merged at revision: 9947
Proposed branch: lp:~camptocamp/ocb-addons/ocb-7.0-fix_1281687-afe
Merge into: lp:ocb-addons
Diff against target: 82 lines (+34/-5)
3 files modified
mrp_repair/__openerp__.py (+2/-1)
mrp_repair/mrp_repair.py (+9/-4)
mrp_repair/test/test_mrp_repair_fee.yml (+23/-0)
To merge this branch: bzr merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_1281687-afe
Reviewer Review Type Date Requested Status
Alexis de Lattre (community) code review and tests Approve
Nicolas Bessi - Camptocamp (community) no test, code review Approve
Romain Deheele - Camptocamp (community) code review Approve
Guewen Baconnier @ Camptocamp code review Approve
Leonardo Pistone code review Approve
Review via email: mp+207116@code.launchpad.net

Commit message

[FIX] mrp_repair: add missing invalidation functions for stored field amount_total

To post a comment you must log in.
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks Alexis and Alexandre.

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

LTGM

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

LGTM,

Romain

review: Approve (code review)
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

LGTM

review: Approve (no test, code review)
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

Thanks Alexandre for the MP and the additionnal test.

review: Approve (code review and tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mrp_repair/__openerp__.py'
2--- mrp_repair/__openerp__.py 2012-10-23 16:05:04 +0000
3+++ mrp_repair/__openerp__.py 2014-02-19 08:55:50 +0000
4@@ -56,7 +56,8 @@
5 'test/test_mrp_repair_b4inv.yml',
6 'test/test_mrp_repair_afterinv.yml',
7 'test/test_mrp_repair_cancel.yml',
8- 'test/mrp_repair_report.yml'
9+ 'test/mrp_repair_report.yml',
10+ 'test/test_mrp_repair_fee.yml',
11 ],
12 'installable': True,
13 'auto_install': False,
14
15=== modified file 'mrp_repair/mrp_repair.py'
16--- mrp_repair/mrp_repair.py 2013-12-18 16:52:56 +0000
17+++ mrp_repair/mrp_repair.py 2014-02-19 08:55:50 +0000
18@@ -109,10 +109,12 @@
19 return res
20
21 def _get_lines(self, cr, uid, ids, context=None):
22- result = {}
23- for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context):
24- result[line.repair_id.id] = True
25- return result.keys()
26+ return self.pool['mrp.repair'].search(
27+ cr, uid, [('operations', 'in', ids)], context=context)
28+
29+ def _get_fee_lines(self, cr, uid, ids, context=None):
30+ return self.pool['mrp.repair'].search(
31+ cr, uid, [('fees_lines', 'in', ids)], context=context)
32
33 _columns = {
34 'name': fields.char('Repair Reference',size=24, required=True, states={'confirmed':[('readonly',True)]}),
35@@ -163,16 +165,19 @@
36 store={
37 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
38 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
39+ 'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
40 }),
41 'amount_tax': fields.function(_amount_tax, string='Taxes',
42 store={
43 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
44 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
45+ 'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
46 }),
47 'amount_total': fields.function(_amount_total, string='Total',
48 store={
49 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
50 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
51+ 'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
52 }),
53 }
54
55
56=== added file 'mrp_repair/test/test_mrp_repair_fee.yml'
57--- mrp_repair/test/test_mrp_repair_fee.yml 1970-01-01 00:00:00 +0000
58+++ mrp_repair/test/test_mrp_repair_fee.yml 2014-02-19 08:55:50 +0000
59@@ -0,0 +1,23 @@
60+-
61+ Testing total amount update function
62+-
63+ I check the total amount of mrp_repair_rmrp1 is 100
64+-
65+ !assert {model: mrp.repair, id: mrp_repair_rmrp1, string=amount_total should be 100}:
66+ - amount_total == 100
67+-
68+ I add a new fee line
69+-
70+ !record {model: mrp.repair, id: mrp_repair_rmrp1}:
71+ fees_lines:
72+ - name: 'Assembly Service Cost'
73+ product_id: product.product_assembly
74+ product_uom_qty: 1.0
75+ product_uom: product.product_uom_hour
76+ price_unit: 12.0
77+ to_invoice: True
78+-
79+ I check the total amount of mrp_repair_rmrp1 is now 112
80+-
81+ !assert {model: mrp.repair, id: mrp_repair_rmrp1, string=amount_total should be 112}:
82+ - amount_total == 112