Error when trying to create Sales order via custom app

Dear community,

I am currently trying to develop a pipedrive/erpnext connector using pipedrive’s webhooks and a custom erpnext app.
So far I can get all information from PD without an issue and I’m trying to create a sales order from a pipedrive deal.

I am getting errors when inserting the sales order into erpnext, here is the strack trace :

Traceback (most recent call last):

File “/home/erpnext/frappe_bench/apps/frappe/frappe/app.py”, line 67, in application

response = frappe.api.handle()

File “/home/erpnext/frappe_bench/apps/frappe/frappe/api.py”, line 59, in handle

return frappe.handler.handle()

File “/home/erpnext/frappe_bench/apps/frappe/frappe/handler.py”, line 24, in handle

data = execute_cmd(cmd)

File “/home/erpnext/frappe_bench/apps/frappe/frappe/handler.py”, line 64, in execute_cmd

return frappe.call(method, **frappe.form_dict)

File “/home/erpnext/frappe_bench/apps/frappe/frappe/init.py”, line 1074, in call

return fn(*args, **newargs)

File “/home/erpnext/frappe_bench/apps/pdconnector/pdconnector/pd_hook.py”, line 113, in print_data

so.insert()

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/document.py”, line 230, in insert

self.run_before_save_methods()

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/document.py”, line 896, in run_before_save_methods

self.run_method("validate")

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/document.py”, line 797, in run_method

out = Document.hook(fn)(self, *args, **kwargs)

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/document.py”, line 1073, in composer

return composed(self, method, *args, **kwargs)

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/document.py”, line 1056, in runner

add_to_return_value(self, fn(self, *args, **kwargs))

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/document.py”, line 791, in <lambda>

fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/selling/doctype/sales_order/sales_order.py”, line 36, in validate

super(SalesOrder, self).validate()

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/selling_controller.py”, line 40, in validate

super(SellingController, self).validate()

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 21, in validate

super(StockController, self).validate()

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/accounts_controller.py”, line 80, in validate

self.calculate_taxes_and_totals()

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/accounts_controller.py”, line 189, in calculate_taxes_and_totals

calculate_taxes_and_totals(self)

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/taxes_and_totals.py”, line 17, in init

self.calculate()

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/taxes_and_totals.py”, line 24, in calculate

self._calculate()

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/taxes_and_totals.py”, line 38, in _calculate

self.calculate_item_values()

File “/home/erpnext/frappe_bench/apps/erpnext/erpnext/controllers/taxes_and_totals.py”, line 96, in calculate_item_values

self.doc.round_floats_in(item)

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/document.py”, line 1128, in round_floats_in

doc.set(fieldname, flt(doc.get(fieldname), self.precision(fieldname, doc.parentfield)))

File “/home/erpnext/frappe_bench/apps/frappe/frappe/model/base_document.py”, line 732, in precision

if df.fieldtype in ("Currency", "Float", "Percent"):

AttributeError: ‘NoneType’ object has no attribute ‘fieldtype’

Due to the lack of information of this stack trace I have added some try/catch blocks and prints to frappe’s base_document.py#precision function to find which field is causing issues.
It seems there were missing fields in my sales order request, however these fields are not mandatory fields so I don’t understand why it does not work.
The missing fields were :
item.total_weight, item.opening_stock, item.stock_qty, item.discount_amount

However, after adding those fields to my item dict, I am now blocked by this method :
validate_sales_mntc_quotation(self)
found here in sales_order.py
the error is now : AttributeError: ‘Item’ object has no attribute "‘prevdoc_docname’"
It seems that erpnext tries to find an associated quotation in order to create a sales order. Can’t I create a sales order without a quotation?
Any help would be greatly appreciated, regarding the errors or the quotation.
I cant also provide some code if needed.

My version is :
ERPNext: v12.19.0 (version-12)
Frappe Framework: v12.16.3 (version-12)

Thank you!