gpt4 book ai didi

odoo - odoo10中点击打开新表单按钮时出现错误如何解决?

转载 作者:行者123 更新时间:2023-12-02 12:05:20 25 4
gpt4 key购买 nike

def create_file(self):

opportunity_id = self.convert_to_file()
return self.env['trademark.process'].view_file(opportunity_id)

我使用转换文件函数将当前模型的一些值传递给trademark.process

def convert_to_file(self, partner_id=False):

tm_process_obj = self.env['trademark.process']
tm_search_record = self.env['trademark.search'].browse(self.id)
for rec in tm_search_record:
opportunity_id = tm_process_obj.create({
'search_name_char': rec.search_name or False,
'classification_no_id':rec.classification_no_id.id or False,
'partner_id': rec.partner_id.id or False,
'user_id': rec.user_id.id or False,
'search_date': rec.search_date or False,
'search_seq_no': rec.seq_no or False,
})
vals = {
'file_no': opportunity_id.seq_no,
}
self.write(vals)
return opportunity_id

最后我返回机会ID并传递给查看文件函数

def view_file(self, opportunity_id):
view_id=self.env.ref('trademark_services.trademark_process_form_view').id
return {
'name': _('File Details'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'trademark.process',
'view_id': view_id,
'res_id': opportunity_id,
'target':'current'
}

但是当我点击按钮时发生了错误。

Traceback (most recent call last):
File "/home/ubuntu/workspace/amzsys_erp/odoo/http.py", line 638, in
_handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/ubuntu/workspace/amzsys_erp/odoo/http.py", line 689, in
dispatch
return self._json_response(result)
File "/home/ubuntu/workspace/amzsys_erp/odoo/http.py", line 627, in
_json_response
body = json.dumps(response)
File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: trademark.process(131,) is not JSON serializable

如何解决这个问题。如何在单击按钮时打开新表单。

我想将一些值传递给该表单。

我的代码有什么错误?

注意:使用odoo10

最佳答案

此方法在传递 res_id 时出现问题。

使用 opportunity_id.id。

def view_file(self, opportunity_id):
view_id=self.env.ref('trademark_services.trademark_process_form_view').id
return {
'name': _('File Details'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'trademark.process',
'view_id': view_id,
'res_id': opportunity_id.id,
'target':'current'
}

关于odoo - odoo10中点击打开新表单按钮时出现错误如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45231478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com