Ir al contenido
Menú
Se marcó esta pregunta

I have overridden the message_new process and in that i have kept condition that if there is no attachment the it will call Super but it shows error as it tries to create Sale Order but i don't wanted to create Sale Order in else condition i just want to continue the base process if i don't get attachments. But it shows error as i have not null constraint in database.


Error:

2022-01-31 05:29:53,665 42399 ERROR bv_shurhold odoo.sql_db: bad query: INSERT INTO "sale_order" ("id", "create_uid", "create_date", "write_uid", "write_date", "canceled_in_shopify", "company_id", "date_order", "discount_type", "invoice_created", "invoice_delivery_method", "is_allocated", "is_pos_order", "is_risky_order", "is_service_tracking_updated", "is_status_updated", "name", "note", "order_source_id", "order_type", "partner_invoice_id", "partner_shipping_id", "picking_policy", "pricelist_id", "printnode_printed", "require_payment", "require_signature", "reservation_status", "sale_delivery_method", "sale_order_template_id", "state", "sub_status", "team_id", "user_id", "validity_date", "warehouse_id") VALUES (nextval('sale_order_id_seq'), 2, (now() at time zone 'UTC'), 2, (now() at time zone 'UTC'), false, 1, '2022-01-31 05:29:53', 'percent', false, 'none', false, false, false, false, false, 'Fwd: No attachments', '', 2, 'ground_order', NULL, NULL, 'direct', NULL, false, false, true, 'unallocated', 'none', NULL, 'draft', 'pending', 1, 2, NULL, 1) RETURNING id
ERROR: null value in column "partner_id" of relation "sale_order" violates not-null constraint
DETAIL: Failing row contains (1801, null, null, null, null, null, Fwd: No attachments, null, null, null, draft, 2022-01-31 05:29:53, null, t, f, 2022-01-31 05:29:50.451351, 2, null, null, null, null, null, null, null, , null, null, null, null, null, null, 1, 1, null, null, null, null, 2, 2, 2022-01-31 05:29:50.451351, null, null, direct, 1, null, null, null, null, null, null, null, null, null, f, percent, null, null, null, null, null, null, null, null, null, null, f, null, f, f, f, null, null, null, null, null, none, none, null, null, null, null, null, null, unallocated, pending, ground_order, null, null, f, f, null, null, null, f, null, null, null, null, 2, null).

2022-01-31 05:29:53,666 42399 INFO bv_shurhold odoo.addons.fetchmail.models.fetchmail: Failed to process mail from imap server Gmail.
Traceback (most recent call last):
File "/home/honey_patel/workspace/odoo14/odoo/addons/fetchmail/models/fetchmail.py", line 177, in fetch_mail
res_id = MailThread.with_context(**additionnal_context).message_process(server.object_id.model, data[0][1], save_original=server.original, strip_attachments=(not server.attach))
File "/home/honey_patel/workspace/odoo14/odoo/addons/mail/models/mail_thread.py", line 1168, in message_process
thread_id = self._message_route_process(message, msg_dict, routes)
File "/home/honey_patel/workspace/odoo14/odoo/addons/mail/models/mail_thread.py", line 1071, in _message_route_process
thread = ModelCtx.message_new(message_dict, custom_values)
File "Here is my file_path"
return super(SaleOrderInherit, self).message_new(msg_dict, custom_values)
File "/home/honey_patel/workspace/odoo14/odoo/addons/mail/models/mail_thread.py", line 1199, in message_new
return self.create(data)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 347, in _model_create_multi
return create(self, [arg])
File "/home/honey_patel/workspace/odoo14/odoo/addons/base_automation/models/base_automation.py", line 320, in create
records = create.origin(self.with_env(actions.env), vals_list, **kw)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 329, in _model_create_single
return self.browse().concat(*(create(self, vals) for vals in arg))
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 329, in
return self.browse().concat(*(create(self, vals) for vals in arg))
File"Hereis my file_path"
return super(SaleOrderInherit, self).create(vals)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 326, in _model_create_single
return create(self, arg)
File "/home/honey_patel/workspace/odoo14/odoo/addons/sale_stock/models/sale_order.py", line 98, in create
return super().create(vals)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 326, in _model_create_single
return create(self, arg)
File "/home/honey_patel/workspace/odoo14/odoo/addons/sale/models/sale.py", line 511, in create
result = super(SaleOrder, self).create(vals)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 347, in _model_create_multi
return create(self, [arg])
File "/home/honey_patel/workspace/odoo14/odoo/addons/mail/models/mail_thread.py", line 266, in create
threads = super(MailThread, self).create(vals_list)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 348, in _model_create_multi
return create(self, arg)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/addons/base/models/ir_fields.py", line 534, in create
recs = super().create(vals_list)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/api.py", line 348, in _model_create_multi
return create(self, arg)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/models.py", line 3877, in create
records = self._create(data_list)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/models.py", line 3983, in _create
cr.execute(query, params)
File "/home/honey_patel/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/sql_db.py", line 101, in check
return f(self, *args, **kwargs)
File "/home/honey_patel/workspace/odoo14/odoo/odoo/sql_db.py", line 298, in execute
res = self._obj.execute(query, params)
psycopg2.errors.NotNullViolation: null value in column "partner_id" of relation "sale_order" violates not-null constraint
DETAIL: Failing row contains (1801, null, null, null, null, null, Fwd: No attachments, null, null, null, draft, 2022-01-31 05:29:53, null, t, f, 2022-01-31 05:29:50.451351, 2, null, null, null, null, null, null, null, , null, null, null, null, null, null, 1, 1, null, null, null, null, 2, 2, 2022-01-31 05:29:50.451351, null, null, direct, 1, null, null, null, null, null, null, null, null, null, f, percent, null, null, null, null, null, null, null, null, null, null, f, null, f, f, f, null, null, null, null, null, none, none, null, null, null, null, null, null, unallocated, pending, ground_order, null, null, f, f, null, null, null, f, null, null, null, null, 2, null).

Avatar
Descartar
Mejor respuesta

Hi Hp,

you cannot Create sale order without partner_id. so you should first create res.partner record and then sale order with this record from the email.

Sale Order allways needs a pre defined res.partner record to be created.

if you already have a pre defined res.partner then send the partner_id with the mail and insert it in the partner_id field in sale order and then youll get no errors anymore.


hope that this solve your problem.

Avatar
Descartar
Autor

Thank you

Publicaciones relacionadas Respuestas Vistas Actividad
2
abr 25
1079
0
sept 17
4006
0
mar 15
5137
2
jul 25
4016
5
jun 21
15691