From e883b15c485a3bbf535e709dbf69848b6ab82188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 18 Dec 2013 14:19:42 +0100 Subject: [PATCH] [FIX] sale, delivery: _amount_all function used in function field is now wrapper. Indeed as we give the function pointer when creating the fields, inheritance is not taken into account. This is done by adding a wrapper that calls _amount_all, using this time correct inheritance. bzr revid: tde@openerp.com-20131218131942-9lzrxbscb4lu4rj8 --- addons/delivery/sale.py | 11 +++++++++-- addons/sale/sale.py | 10 +++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/addons/delivery/sale.py b/addons/delivery/sale.py index 5b9f6fbf595..f60e37c4ebf 100644 --- a/addons/delivery/sale.py +++ b/addons/delivery/sale.py @@ -42,6 +42,10 @@ class sale_order_line(osv.osv): class sale_order(osv.Model): _inherit = 'sale.order' + def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None): + """ Wrapper because of direct method passing as parameter for function fields """ + return self._amount_all(cr, uid, ids, field_name, arg, context=context) + def _amount_all(self, cr, uid, ids, field_name, arg, context=None): res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context=context) Currency = self.pool.get('res.currency') @@ -62,7 +66,8 @@ class sale_order(osv.Model): "delivery.carrier", string="Delivery Method", help="Complete this field if you plan to invoice the shipping based on picking."), 'amount_delivery': fields.function( - _amount_all, type='float', digits_compute=decimal_precision.get_precision('Account'), string='Delivery Amount', + _amount_all_wrapper, type='float', digits_compute=decimal_precision.get_precision('Account'), + string='Delivery Amount', store={ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10), @@ -75,7 +80,9 @@ class sale_order(osv.Model): result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part, context=context) if part: dtype = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_delivery_carrier.id - result['value']['carrier_id'] = dtype + # TDE NOTE: not sure the aded 'if dtype' is valid + if dtype: + result['value']['carrier_id'] = dtype return result def _prepare_order_picking(self, cr, uid, order, context=None): diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 88cd20bd786..14e5cae3ad6 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -58,6 +58,10 @@ class sale_order(osv.osv): val += c.get('amount', 0.0) return val + def _amount_all_wrapper(self, cr, uid, ids, field_name, arg, context=None): + """ Wrapper because of direct method passing as parameter for function fields """ + return self._amount_all(cr, uid, ids, field_name, arg, context=context) + def _amount_all(self, cr, uid, ids, field_name, arg, context=None): cur_obj = self.pool.get('res.currency') res = {} @@ -199,19 +203,19 @@ class sale_order(osv.osv): fnct_search=_invoiced_search, type='boolean', help="It indicates that sales order has at least one invoice."), 'note': fields.text('Terms and conditions'), - 'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Untaxed Amount', + 'amount_untaxed': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Untaxed Amount', store={ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10), }, multi='sums', help="The amount without tax.", track_visibility='always'), - 'amount_tax': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Taxes', + 'amount_tax': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Taxes', store={ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10), }, multi='sums', help="The tax amount."), - 'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Total', + 'amount_total': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Total', store={ 'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10), 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),