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

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Merged at revision: 9881
Proposed branch: lp:~camptocamp/openobject-addons/7.0-fix_1281687-afe
Merge into: lp:openobject-addons/7.0
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/openobject-addons/7.0-fix_1281687-afe
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Review via email: mp+207115@code.launchpad.net

Description of the change

[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
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

branch is green on runbot.

Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello Alexis,

Thanks for your merge proposal.

To have the validation all the time, you need also to watch the field 'fees_lines' for mrp.repair objects. To see the problem, add an invoice line and then uncheck the box "to invoice", the total will not be updated accordingly.

review: Needs Fixing
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

I have created another branch merging your code and adding this field so no "needs fixing" anymore :)

revno: 9881 [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 'mrp_repair/__openerp__.py'
2--- mrp_repair/__openerp__.py 2012-11-29 22:26:45 +0000
3+++ mrp_repair/__openerp__.py 2014-02-19 08:55:06 +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-10-18 11:44:00 +0000
17+++ mrp_repair/mrp_repair.py 2014-02-19 08:55:06 +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:06 +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