这是我的课程和方法。我只是为获取记录而写,需要打印它们。但是在调试模式下运行 openerp 时。它不起作用,也不适用该方法。& 还需要澄清 OpenERP 7 的获取方法
class namelistupdate(osv.osv):
def _mytest_query(self, cr, uid, ids, name, args, context=None):
print ('here is demo sql query function result ')
cr.execute("""SELECT module,(id*5000)as result FROM ir_model_data WHERE id=1""")
res = cr.dictfetchall()
print ('here is demo sql query function result ')
print (res)
def _invoiced_rate(self, cr, uid, ids, name, args, context):
self._mytest_query(self, cr, uid, ids, name, args, context)
amount_untaxed = 1
record_id = ids[0]
res = {record_id: 0.0}
if amount_untaxed == 0:
res[record_id] = 100.0
else:
res[record_id] = 50.0
return res
_name = "checkroll.namelist.update"
_description = "This table is for keeping Name list updates"
_columns = {
'date': fields.date("Date"),
'val': fields.function(_invoiced_rate, method=True, type='float', string='Test', store=True),
}
名单更新()
错误如下
客户端回溯(最近一次通话最后一次):文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/web/http.py”,第 203 行,在调度中 响应[“结果”] = 方法(自我,**self.params)文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/web/controllers/main.py”,第 1074 行,在 call_kw return self._call_kw(req, model, method, args, kwargs) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/web/controllers/main.py”,第 1066 行,在 _call_kw 返回 getattr(req.session.model(model), method)(*args, **kwargs) 文件 "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/web/session.py",第 43 行,在代理中 结果=self.proxy.execute_kw(self.session._db,self.session._uid,self.session._password,self.model,方法,args,kw)文件“/home/priyan/Software/openerp-7.0-20130309 -002120/openerp/addons/web/session.py”,第 31 行,在 proxy_method 中 结果 = self.session.send(self.service_name, method, *args) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/web/session.py”,第 104 行,在发送中 引发 xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info) 服务器回溯(最近一次通话最后一次):文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/web/session.py”,第 90 行,在发送中 返回 openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/netsvc.py", line 293, in dispatch_rpc 结果 = ExportService.getService(service_name).dispatch(method, params) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/service/web_services.py”,第 618 行,在调度中 res = fn(db, uid, *params) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/osv.py”,第 188 行,在 execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/osv.py", line 131,在包装中 返回 f(self, dbname, *args, **kwargs) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/osv.py”,第 197 行,执行 res = self.execute_cr(cr, uid, obj, method, *args, **kw) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/osv.py”,第 185 行,在执行_cr 返回 getattr(object, method)(cr, uid, *args, **kw) File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/orm.py", line 4479, in create self.pool.get(object)._store_set_values(cr, user, ids, fields2, context) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/orm.py”,第 4627 行,在 _store_set_values 结果 = self._columns[f].get(cr, self, ids, f, SUPERUSER_ID, context=context) 文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/osv/fields.py” ,第 1131 行,在获取 结果= self._fnct(obj,cr,uid,ids,名称,self._arg,上下文)文件“/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/checkroll/checkroll.py”,第 55 行,在 _invoiced_rate self._mytest_query(self, cr, uid, ids, name, args, context) TypeError: _mytest_query() 需要 7 个参数(给定 8 个)