跳至内容
菜单
此问题已终结
3 回复
6143 查看

I am trying to create a new customer contact within Studio's automated action with the following python code..

env['res.partner'].create({'name':'Ba bu', 'property_account_payable_id':env['account.account'].search([('code', '=', '200010')]).id, 'property_account_receivable_id':env['account.account'].search([('code', '=', '100010')]).id})

It is throwing the following error...

File "/home/odoo/src/odoo/12.0/odoo/api.py", line 452, in _model_create_multi

return create(self, arg)

File "/home/odoo/src/odoo/12.0/odoo/models.py", line 3560, in create

records = self._create(data_list)

File "/home/odoo/src/odoo/12.0/odoo/models.py", line 3646, in _create

col_val = field.convert_to_column(val, self, stored)

File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1954, in convert_to_column

value = self.convert_to_cache(value, record)

File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1966, in convert_to_cache

raise ValueError("Wrong value for %s: %r" % (self, value))

ValueError: <class 'ValueError'>: "Wrong value for res.partner.type: 'opportunity'" while evaluating

"#record.write({'x_studio_debug' : time.time()})\n#record.write({'x_studio_debug' : env['res.partner'].search_count([('email', '=', 'boonboh@gmail.com')])})\n#record.write({'x_studio_debug' : env['account.account'].search([('code', '=', '100010')]).id})\n\n\nif env['res.partner'].search_count([('email', '=', 'babu@gmail.com')]) > 0: \n target = env['res.partner'].search([('email', '=', 'babu@gmail.com')])[0]\n record.write({'x_studio_debug' : target.name})\n record.write({'partner_id' : target.id})\nelse:\n env['res.partner'].create({'name':'Ba bu', 'property_account_payable_id':env['account.account'].search([('code', '=', '200010')]).id, 'property_account_receivable_id':env['account.account'].search([('code', '=', '100010')]).id})"

Any idea?

Thanks


形象
丢弃

Contact created... Thanks!!

最佳答案

res.partner.type should be "Contact" or "Private Address".

形象
丢弃
相关帖文 回复 查看 活动
1
2月 21
4445
3
6月 20
5160
0
6月 20
2717
0
2月 16
3804
0
8月 23
3466