我不是程序员,所以我真的很感激是否有人可以修改模块的代码,以便在为openerp 6.1& 7 该模块应从供应商处检索incoterms并将其显示在采购订单上。
这是module.py的代码:
import time
from openerp.osv import fields, osv
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'incoterm_id': fields.many2one(
'stock.incoterms',
'Incoterms',
help="Incoterm which stands for 'International Commercial"
"terms' implies its a series of sales terms which are"
"used in the commercial transaction."
),
}
res_partner()
class purchase_order(osv.osv):
_inherit = 'purchase.order'
_columns = {
'incoterm_id': fields.many2one(
'stock.incoterms',
'Incoterms',
help="Incoterm which stands for 'International Commercial"
"terms' implies its a series of sales terms which are"
"used in the commercial transaction."
),
}
def onchange_partner_id(self, cr, uid, ids, part):
res = super(purchase_order,self).onchange_partner_id(cr, uid, ids, part)
if not part:
return res
part = self.pool.get('res.partner').browse(cr, uid, part)
res['value'].update({'incoterm_id':part.incoterm_id.id or False})
return res
purchase_order()`
这是我在odoo 8中得到的错误消息:
Traceback (most recent call last):
File "/opt/odoo/openerp/http.py", line 500, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/openerp/http.py", line 517, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/openerp/http.py", line 283, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/openerp/http.py", line 280, in checked_call
return self.endpoint(*a, **kw)
File "/opt/odoo/openerp/http.py", line 733, in __call__
return self.method(*args, **kw)
File "/opt/odoo/openerp/http.py", line 376, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/addons/web/controllers/main.py", line 948, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/addons/web/controllers/main.py", line 940, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/opt/odoo/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/openerp/api.py", line 360, in old_api
result = method(recs, *args, **kwargs)
File "/opt/odoo/openerp/models.py", line 5727, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "/opt/odoo/openerp/models.py", line 5661, in _onchange_eval
method_res = getattr(self._model, method)(*args)
File "/opt/odoo/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/addons/warning/warning.py", line 101, in onchange_partner_id
result = super(purchase_order, self).onchange_partner_id(cr, uid, ids, part, context=context)
File "/opt/odoo/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
TypeError: onchange_partner_id() got an unexpected keyword argument 'context'
答案 0 :(得分:1)
你可以继续在odoo v8中用旧的api风格书写,这完全没问题。 尝试改变" onchange"方法如下:
def onchange_partner_id(self, cr, uid, ids, part,context=None):
res = super(purchase_order,self).onchange_partner_id(
cr, uid, ids, part, context=context,
)
我认为您错过了context
视图中视频文件中提供的最后一个参数purchase_order_form
。 on_change
方法接收两个参数:
并且您没有在定义中包含最后一个参数context
。