[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
This commit is contained in:
parent
ba73588c6c
commit
e883b15c48
|
@ -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,6 +80,8 @@ 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
|
||||
# TDE NOTE: not sure the aded 'if dtype' is valid
|
||||
if dtype:
|
||||
result['value']['carrier_id'] = dtype
|
||||
return result
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue