Hi all,
I am trying to automate the creation of a sales order from my incoming mailbox.
I have tested that the function works fine when creating a record for lead/opportunity, however have failed when I changed to Sales order.
I have also verified that this sender is a record in Contacts.
Error found in the log:
odoo.sql_db: bad query: INSERT INTO "sale_order" ("id", "create_uid", "create_date", "write_uid", "write_date", "company_id", "date_order", "name", "note", "partner_invoice_id", "partner_shipping_id", "picking_policy", "pricelist_id", "report_grids", "require_payment", "require_signature", "sale_order_template_id", "state", "team_id", "user_id", "validity_date", "warehouse_id") VALUES (nextval('sale_order_id_seq'), 14, (now() at time zone 'UTC'), 14, (now() at time zone 'UTC'), 1, '2021-05-26 00:16:49', 'Try to create a sales order automatically from this email', 'Terms and Conditions note here', NULL, NULL, 'direct', NULL, true, true, true, NULL, 'draft', 5, 14, '2021-06-09', 9) RETURNING id
ERROR: null value in column "partner_id" violates not-null constraint
DETAIL: Failing row contains (17, Try to create a sales order automatically from this email, null, null, null, draft, 2021-05-26 00:16:49, 2021-06-09, t, t, 2021-05-26 00:16:48.306329, 14, null, null, null, null, null, null, Terms and Conditions note here, null, null, null, null, null, null, 1, 5, null, null, null, null, null, null, null, null, 14, 14, 2021-05-26 00:16:48.306329, null, null, direct, 9, null, null, null, null, null, null, null, null, f, null, null, null, null, null, t, null, null, null, null).
2021-05-26 00:16:49,805 6 INFO odoo.addons.fetchmail.models.fetchmail: Failed to process mail from imap server Office 365 Test.
Traceback (most recent call last):
File "/home/odoo/src/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/odoo/src/odoo/addons/mail/models/mail_thread.py", line 1141, in message_process
thread_id = self._message_route_process(message, msg_dict, routes)
File "/home/odoo/src/odoo/addons/mass_mailing/models/mail_thread.py", line 28, in _message_route_process
return super(MailThread, self)._message_route_process(message, message_dict, routes)
File "/home/odoo/src/odoo/addons/mail/models/mail_thread.py", line 1052, in _message_route_process
thread = ModelCtx.message_new(message_dict, custom_values)
File "/home/odoo/src/odoo/addons/mass_mailing/models/mail_thread.py", line 87, in message_new
return super(MailThread, self).message_new(msg_dict, custom_values=defaults)
File "/home/odoo/src/odoo/addons/mail/models/mail_thread.py", line 1171, in message_new
return self.create(data)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 323, in _model_create_single
return create(self, arg)
File "/home/odoo/src/odoo/addons/sale_stock/models/sale_order.py", line 98, in create
return super().create(vals)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 323, in _model_create_single
return create(self, arg)
File "/home/odoo/src/odoo/addons/sale/models/sale.py", line 495, in create
result = super(SaleOrder, self).create(vals)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 344, in _model_create_multi
return create(self, [arg])
File "/home/odoo/src/odoo/addons/mail/models/mail_thread.py", line 264, in create
threads = super(MailThread, self).create(vals_list)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_fields.py", line 533, in create
recs = super().create(vals_list)
File "", line 2, in create
File "/home/odoo/src/odoo/odoo/api.py", line 345, in _model_create_multi
return create(self, arg)
File "/home/odoo/src/odoo/odoo/models.py", line 3868, in create
records = self._create(data_list)
File "/home/odoo/src/odoo/odoo/models.py", line 3974, in _create
cr.execute(query, params)
File "", line 2, in execute
File "/home/odoo/src/odoo/odoo/sql_db.py", line 101, in check
return f(self, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/sql_db.py", line 298, in execute
res = self._obj.execute(query, params)
psycopg2.IntegrityError: null value in column "partner_id" violates not-null constraint
Obviously you are trying to create a sales order from empty data. Please show your code or other context, if you are looking for help.
Hi There, I am not using any code.
Basically I want to create a flow whereby my users can send email to an email address to create a sales order.
I have read that this can done via the Incoming mail server configuration when Odoo reads the inbox, it perform a create record action. (Configured in Settings > Technical > Incoming mail servers)
I have tried using the same flow to create record action in Leads/Opportunity.
However am facing issue with the sales order.
Does the email need to have certain content for Odoo to read it and create the sales order successfully?