Skip to Content
Menu
This question has been flagged
3 Replies
5035 Views

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


Avatar
Discard

Contact created... Thanks!!

Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
1
Feb 21
3099
3
Jun 20
3816
0
Jun 20
1749
0
Feb 16
2850
0
Aug 23
1831