← Back to team overview

openerp-community-reviewer team mailing list archive

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

 

Alexandre Fayolle - camptocamp has proposed merging lp:~camptocamp/ocb-addons/ocb-7.0-fix_1281687-afe into lp:ocb-addons.

Requested reviews:
  Alexis de Lattre (alexis-via)
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1281687 in OpenERP Community Backports (Addons): "mrp_repair: missing invalidation on fees"
  https://bugs.launchpad.net/ocb-addons/+bug/1281687

For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-7.0-fix_1281687-afe/+merge/207116

port of https://code.launchpad.net/~camptocamp/openobject-addons/7.0-fix_1281687-afe/+merge/207115 to ocb
-- 
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-7.0-fix_1281687-afe/+merge/207116
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~camptocamp/ocb-addons/ocb-7.0-fix_1281687-afe into lp:ocb-addons.
=== modified file 'mrp_repair/__openerp__.py'
--- mrp_repair/__openerp__.py	2012-10-23 16:05:04 +0000
+++ mrp_repair/__openerp__.py	2014-02-19 08:55:50 +0000
@@ -56,7 +56,8 @@
              'test/test_mrp_repair_b4inv.yml',
              'test/test_mrp_repair_afterinv.yml',
              'test/test_mrp_repair_cancel.yml',
-             'test/mrp_repair_report.yml'
+             'test/mrp_repair_report.yml',
+             'test/test_mrp_repair_fee.yml',
     ],
     'installable': True,
     'auto_install': False,

=== modified file 'mrp_repair/mrp_repair.py'
--- mrp_repair/mrp_repair.py	2013-12-18 16:52:56 +0000
+++ mrp_repair/mrp_repair.py	2014-02-19 08:55:50 +0000
@@ -109,10 +109,12 @@
         return res
 
     def _get_lines(self, cr, uid, ids, context=None):
-        result = {}
-        for line in self.pool.get('mrp.repair.line').browse(cr, uid, ids, context=context):
-            result[line.repair_id.id] = True
-        return result.keys()
+        return self.pool['mrp.repair'].search(
+            cr, uid, [('operations', 'in', ids)], context=context)
+
+    def _get_fee_lines(self, cr, uid, ids, context=None):
+        return self.pool['mrp.repair'].search(
+            cr, uid, [('fees_lines', 'in', ids)], context=context)
 
     _columns = {
         'name': fields.char('Repair Reference',size=24, required=True, states={'confirmed':[('readonly',True)]}),
@@ -163,16 +165,19 @@
             store={
                 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
                 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
+                'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
             }),
         'amount_tax': fields.function(_amount_tax, string='Taxes',
             store={
                 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
                 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
+                'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
             }),
         'amount_total': fields.function(_amount_total, string='Total',
             store={
                 'mrp.repair': (lambda self, cr, uid, ids, c={}: ids, ['operations'], 10),
                 'mrp.repair.line': (_get_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
+                'mrp.repair.fee': (_get_fee_lines, ['price_unit', 'price_subtotal', 'product_id', 'tax_id', 'product_uom_qty', 'product_uom'], 10),
             }),
     }
 

=== 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:50 +0000
@@ -0,0 +1,23 @@
+-
+  Testing total amount update function
+-
+  I check the total amount of mrp_repair_rmrp1 is 100
+-
+  !assert {model: mrp.repair, id: mrp_repair_rmrp1, string=amount_total should be 100}:
+    - amount_total == 100
+-
+  I add a new fee line
+-
+  !record {model: mrp.repair, id: mrp_repair_rmrp1}:
+    fees_lines:
+      - name: 'Assembly Service Cost'
+        product_id: product.product_assembly
+        product_uom_qty: 1.0
+        product_uom: product.product_uom_hour
+        price_unit: 12.0
+        to_invoice: True
+-
+  I check the total amount of mrp_repair_rmrp1 is now 112
+-
+  !assert {model: mrp.repair, id: mrp_repair_rmrp1, string=amount_total should be 112}:
+    - amount_total == 112