How to inherit a function from stock module wizard?
here is the function which i want to inherit in my custom module:-
def default_get(self, cr, uid, fields, context):
res = super(stock_change_product_qty, self).default_get(cr, uid, fields, context=context)
if context.get('active_model') == 'product.template':
product_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', '=', context.get('active_id'))], context=context)
if product_ids:
res['product_id'] = product_ids[0]
if 'location_id' in fields:
location_id = res.get('location_id', False)
if not location_id:
try:
model, location_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock')
except (AccessError):
pass
if location_id:
try:
self.pool.get('stock.location').check_access_rule(cr, uid, [location_id], 'read', context=context)
except (AccessError):
location_id = False
res['location_id'] = location_id
return res
I tried but it gave a error:-
Traceback (most recent call last):
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/registry.py", line 386, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/loading.py", line 340, in load_modules
loaded_modules, update_module)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/loading.py", line 239, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/loading.py", line 132, in load_module_graph
models = registry.load(cr, package)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/registry.py", line 169, in load
model = cls._build_model(self, cr)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/models.py", line 602, in _build_model
hierarchy = type(name, (hierarchy, parent_class), {'_register': False})
TypeError: type() argument 1 must be string, not tuple 2017-07-31 08:40:27,997 12506 ERROR bitnami_openerp openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/http.py", line 648, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/http.py", line 685, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/http.py", line 321, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/http.py", line 314, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/http.py", line 964, in __call__
return self.method(*args, **kw)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/http.py", line 514, in response_wrap
response = f(*args, **kw)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/addons/web/controllers/main.py", line 899, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/addons/web/controllers/main.py", line 887, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/addons/base/module/module.py", line 459, in button_immediate_install
return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/addons/base/module/module.py", line 534, in _button_immediate_function
registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/registry.py", line 386, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/loading.py", line 340, in load_modules
loaded_modules, update_module)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/loading.py", line 239, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/loading.py", line 132, in load_module_graph
models = registry.load(cr, package)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/modules/registry.py", line 169, in load
model = cls._build_model(self, cr)
File "/opt/odoo-9.0/apps/odoo/lib/odoo-9.0rc20170615-py2.7.egg/openerp/models.py", line 602, in _build_model
hierarchy = type(name, (hierarchy, parent_class), {'_register': False})
TypeError: type() argument 1 must be string, not tuple
Can anyone help how to inherit a default module function?