Purnendu Singh (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-788686-psi into 
lp:openobject-addons.

Requested reviews:
  Purnendu Singh (OpenERP) (psi-tinyerp)
  qdp (OpenERP) (qdp)
  Mustufa Rangwala (Open ERP) (mra-tinyerp)
Related bugs:
  Bug #788686 in OpenERP Addons: "Problem with override function module: 
sale_layout"
  https://bugs.launchpad.net/openobject-addons/+bug/788686

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-788686-psi/+merge/62875

Hello,

Fixes:
https://bugs.launchpad.net/openobject-addons/+bug/788686
     Problem with override function module: sale_layout

We need to override the field also to override any function which is being 
called by function field. (framework limitation).

Thanks
Purnendu Singh
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-788686-psi/+merge/62875
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-788686-psi.
=== modified file 'sale_layout/sale_layout.py'
--- sale_layout/sale_layout.py	2011-01-14 00:11:01 +0000
+++ sale_layout/sale_layout.py	2011-06-06 11:29:26 +0000
@@ -27,9 +27,15 @@
 
     def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
         res = {}
+        line_ids = []
+        for id in ids:
+            res[id] = 0.0
         for line in self.browse(cr, uid, ids, context=context):
             if line.layout_type == 'article':
-                return super(sale_order_line, self)._amount_line(cr, uid, ids, field_name, arg, context)
+                line_ids.append(line.id)
+        if line_ids:
+            res_article = super(sale_order_line, self)._amount_line(cr, uid, line_ids, field_name, arg, context)
+            res.update(res_article)
         return res
 
     def invoice_line_create(self, cr, uid, ids, context=None):
@@ -116,6 +122,8 @@
         'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price'), readonly=True, states={'draft': [('readonly', False)]}),
         'product_uom_qty': fields.float('Quantity (UoM)', digits=(16,2)),
         'product_uom': fields.many2one('product.uom', 'Product UoM'),
+        # Override the field to call the overridden _amount_line function
+        'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal', digits_compute= dp.get_precision('Sale Price')),
     }
 
     _defaults = {

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to