python - Odoo: How to override original function -


in odoo, quantities of product calculated each time products form opened. happens in model product.product ==> function _product_available.

this function returns dictionary called res.

example:

res = {8: {'qty_available': 5000.0, 'outgoing_qty': 1778.5, 'virtual_available': 3221.5, 'incoming_qty': 0.0}} 

now want modify values. i've managed coding directly in original function _product_available.

since not correct way this, want in inheritted model. think need override function? or overwrite? not sure it's called.

everything read doing quite vague me. can't find information or examples. i'm struggling fact original function written in old style (osv) while i'm using new style (models).

from pieces of information collected on internet wrote (which doesn't work).

class product_product_inherit(models.model):      _inherit = 'product.product'      #api.v7 because of old style? tried .multi , .model...       @api.v7     def _product_available(self, cr, uid, ids, field_names=none, arg=false, context=none):         #example of modified values. made variable after working.         res = {8: {'qty_available': 200.222, 'outgoing_qty': 1778.5, 'virtual_available': 30205.263671875, 'incoming_qty': 0.0}}         result = super(c, self)._product_available(res)             return result 

does know correct way modify returned dictionary of original function _product_available?

how got working:

class product_product_inherit(models.model):      _inherit = 'product.product'      def _product_available(self, cr, uid, ids, field_names=none, arg=false, context=none):         product in self.browse(cr, uid, ids, context=context):             id = product.id             res = {id: {'qty_available': 200.222, 'outgoing_qty': 1778.5, 'virtual_available': 30205.263671875, 'incoming_qty': 0.0}}         return res 

just defined same method in original model.

i think can try this.

class productproductinherit(models.model):      _inherit = 'product.product'      @api.multi     def _product_available(self, field_names=none, arg=false):         #example of modified values. made variable after working.         res = {8: {'qty_available': 200.222, 'outgoing_qty': 1778.5, 'virtual_available': 30205.263671875, 'incoming_qty': 0.0}}         result = super(productproductinherit, self)._product_available(res)             return result 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -