Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
3 Respostas
6227 Visualizações

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
Cancelar

Contact created... Thanks!!

Melhor resposta

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

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
fev. 21
4565
3
jun. 20
5208
0
jun. 20
2794
0
fev. 16
3859
0
ago. 23
3540