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
=== modified file 'mrp_repair/__openerp__.py'
--- mrp_repair/__openerp__.py 2012-11-29 22:26:45 +0000
+++ mrp_repair/__openerp__.py 2014-02-19 08:55:06 +0000
@@ -56,7 +56,8 @@
56 'test/test_mrp_repair_b4inv.yml',56 'test/test_mrp_repair_b4inv.yml',
57 'test/test_mrp_repair_afterinv.yml',57 'test/test_mrp_repair_afterinv.yml',
58 'test/test_mrp_repair_cancel.yml',58 'test/test_mrp_repair_cancel.yml',
59 'test/mrp_repair_report.yml'59 'test/mrp_repair_report.yml',
60 'test/test_mrp_repair_fee.yml',
60 ],61 ],
61 'installable': True,62 'installable': True,
62 'auto_install': False,63 'auto_install': False,
6364
=== modified file 'mrp_repair/mrp_repair.py'
--- mrp_repair/mrp_repair.py 2013-10-18 11:44:00 +0000
+++ mrp_repair/mrp_repair.py 2014-02-19 08:55:06 +0000
@@ -109,10 +109,12 @@
109 return res109 return res
110110
111 def _get_lines(self, cr, uid, ids, context=None):111 def _get_lines(self, cr, uid, ids, context=None):
112 result = {}112 return self.pool['mrp.repair'].search(
113 for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context):113 cr, uid, [('operations', 'in', ids)], context=context)
114 result[line.repair_id.id] = True114
115 return result.keys()115 def _get_fee_lines(self, cr, uid, ids, context=None):
116 return self.pool['mrp.repair'].search(
117 cr, uid, [('fees_lines', 'in', ids)], context=context)
116118
117 _columns = {119 _columns = {
118 'name': fields.char('Repair Reference',size=24, required=True, states={'confirmed':[('readonly',True)]}),120 'name': fields.char('Repair Reference',size=24, required=True, states={'confirmed':[('readonly',True)]}),
@@ -163,16 +165,19 @@
163 store={165 store={
164 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),166 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
165 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),167 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
168 'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
166 }),169 }),
167 'amount_tax': fields.function(_amount_tax, string='Taxes',170 'amount_tax': fields.function(_amount_tax, string='Taxes',
168 store={171 store={
169 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),172 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
170 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),173 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
174 'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
171 }),175 }),
172 'amount_total': fields.function(_amount_total, string='Total',176 'amount_total': fields.function(_amount_total, string='Total',
173 store={177 store={
174 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),178 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
175 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),179 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
180 'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
176 }),181 }),
177 }182 }
178183
179184
=== added file 'mrp_repair/test/test_mrp_repair_fee.yml'
--- mrp_repair/test/test_mrp_repair_fee.yml 1970-01-01 00:00:00 +0000
+++ mrp_repair/test/test_mrp_repair_fee.yml 2014-02-19 08:55:06 +0000
@@ -0,0 +1,23 @@
1-
2 Testing total amount update function
3-
4 I check the total amount of mrp_repair_rmrp1 is 100
5-
6 !assert {model: mrp.repair, id: mrp_repair_rmrp1, string=amount_total should be 100}:
7 - amount_total == 100
8-
9 I add a new fee line
10-
11 !record {model: mrp.repair, id: mrp_repair_rmrp1}:
12 fees_lines:
13 - name: 'Assembly Service Cost'
14 product_id: product.product_assembly
15 product_uom_qty: 1.0
16 product_uom: product.product_uom_hour
17 price_unit: 12.0
18 to_invoice: True
19-
20 I check the total amount of mrp_repair_rmrp1 is now 112
21-
22 !assert {model: mrp.repair, id: mrp_repair_rmrp1, string=amount_total should be 112}:
23 - amount_total == 112