Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
6272 Lượt xem

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


Ảnh đại diện
Huỷ bỏ

Contact created... Thanks!!

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 21
4584
3
thg 6 20
5215
0
thg 6 20
2806
0
thg 2 16
3873
0
thg 8 23
3567