Sales order web form

Hi,

we are making a webform for incoming sales orders. We selected “Sales Order” as DocType and included the following fields (the ones mandatory in a sales order):
naming_series
company
customer
transaction_date
delivery_date

The form is published and without login required, but is not recording the Sales Order. Any ideas?

Can you check if there is an error in your JS console or your request. I am pushing new updates to web form if you want to try:

https://github.com/frappe/frappe/pull/883

Here is the JS console output:

(innermost last):
  File "/root/frappe-bench/apps/frappe/frappe/app.py", line 49, in application
    response = frappe.handler.handle()
  File "/root/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/root/frappe-bench/apps/frappe/frappe/handler.py", line 89, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/root/frappe-bench/apps/frappe/frappe/__init__.py", line 531, in call
    return fn(*args, **newargs)
  File "/root/frappe-bench/apps/frappe/frappe/website/doctype/web_form/web_form.py", line 82, in accept
    doc.insert(ignore_permissions = True)
  File "/root/frappe-bench/apps/frappe/frappe/model/document.py", line 144, in insert
    self.run_before_save_methods()
  File "/root/frappe-bench/apps/frappe/frappe/model/document.py", line 430, in run_before_save_methods
    self.run_method("validate")
  File "/root/frappe-bench/apps/frappe/frappe/model/document.py", line 412, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/root/frappe-bench/apps/frappe/frappe/model/document.py", line 493, in composer
    return composed(self, method, *args, **kwargs)
  File "/root/frappe-bench/apps/frappe/frappe/model/document.py", line 476, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/root/frappe-bench/apps/frappe/frappe/model/document.py", line 406, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/root/frappe-bench/apps/erpnext/erpnext/selling/doctype/sales_order/sales_order.py", line 95, in validate
    super(SalesOrder, self).validate()
  File "/root/frappe-bench/apps/erpnext/erpnext/controllers/selling_controller.py", line 28, in validate
    super(SellingController, self).validate()
  File "/root/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py", line 18, in validate
    self.validate_date_with_fiscal_year()
  File "/root/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py", line 62, in validate_date_with_fiscal_year
    label=self.meta.get_label(date_field))
  File "/root/frappe-bench/apps/erpnext/erpnext/accounts/utils.py", line 38, in validate_fiscal_year
    years = [f[0] for f in get_fiscal_years(date, label=label)]
  File "/root/frappe-bench/apps/erpnext/erpnext/accounts/utils.py", line 31, in get_fiscal_years
    error_msg = _("""{0} {1} not in any Fiscal Year""").format(label, formatdate(date))
  File "/root/frappe-bench/apps/frappe/frappe/utils/data.py", line 158, in formatdate
    date = getdate(string_date) if string_date else now_datetime().date()
  File "/root/frappe-bench/apps/frappe/frappe/utils/data.py", line 26, in getdate
    return datetime.datetime.strptime(string_date, "%Y-%m-%d").date()
  File "/usr/lib/python2.7/_strptime.py", line 325, in _strptime
    (data_string, format))
 ValueError: time data '15-10-2014' does not match format '%Y-%m-%d'

I’m guessing there’s some issue with the date formats - format specified in the doctype must be different from your entered/server/machine format.

ValueError: time data ‘15-10-2014’ does not match format ‘%Y-%m-%d’

Hi, the date is introduced directly with the calendar, so there should be a mistake in the insertion calendar->field.

We tried with the format 2014-10-15 and we receive the following error but we do not find sales_order_details in the Fieldname options for Sales Order Doctype:

File “/root/frappe-bench/apps/frappe/frappe/app.py”, line 49, in application
response = frappe.handler.handle()
File “/root/frappe-bench/apps/frappe/frappe/handler.py”, line 66, in handle
execute_cmd(cmd)
File “/root/frappe-bench/apps/frappe/frappe/handler.py”, line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/root/frappe-bench/apps/frappe/frappe/init.py”, line 531, in call
return fn(*args, **newargs)
File “/root/frappe-bench/apps/frappe/frappe/website/doctype/web_form/web_form.py”, line 82, in accept
doc.insert(ignore_permissions = True)
File “/root/frappe-bench/apps/frappe/frappe/model/document.py”, line 145, in insert
self._validate()
File “/root/frappe-bench/apps/frappe/frappe/model/document.py”, line 254, in _validate
self._validate_mandatory()
File “/root/frappe-bench/apps/frappe/frappe/model/document.py”, line 363, in _validate_mandatory
raise frappe.MandatoryError(", ".join((each[0] for each in missing)))
MandatoryError: sales_order_details

Fixed date formatting:

https://github.com/rmehta/frappe/commit/7d10e60892ae5f3c859eebb645897b1bbf626f4a

Thanks!

Thank you, the fix is already available? I tried bench update but still the same date format problem.

And how about the sales_order_details not available in the Fieldname options for Sales Order Doctype? Should we raise a Github issue?

Not yet merged in develop. Might be done tomorrow or next week. You can still update from the pull-request - you might have to switch the branch and test.

OK, thanks… about the sales_order_details not available in the Fieldname
options for Sales Order Doctype?

Should we raise a Github issue?

Ah - tables are not part of web forms. I think that will be too complicated at the moment, but yes no harm in adding a request :smile:

Yes, but i was meaning more that if sales_order_details is not available, just make it not mandatory, otherwise it is impossible to insert a Sales Order with web forms.

Thats why we have shopping cart! No point in having an order if there are no items!

this topic its great matter for me , so please advice , how can i let customer make sales order through web form ? with problem in table