frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.83k stars 7.33k forks source link

Data Import failing where there are more than one child table in the same tab #33221

Closed hari-madhavan closed 1 year ago

hari-madhavan commented 1 year ago

Description of the issue

When executing data import for sales invoice on an instance with just the latest version of frappe 14 and erpnext 14, and the sales invoice does not have taxes the data import fails with

Error: Sales Taxes and Charges Row frappe/frappe#1: Value missing for: Type Error: Sales Taxes and Charges Row frappe/frappe#1: Value missing for: Account Head

Context information (for bug reports)

Tried with a fresh site with just frappe and erpnext . It seems to be related to a second child table under the same tab which does not have any data ( not sure ) as it goes through if some tax details are provided .

Output of bench version

erpnext 14.7.0
frappe 14.15.0
hrms 1.0.0
india_compliance 14.0.2
payments 0.0.1
promantia 0.0.1

Output of bench list-apps

frappe   14.15.0 version-14
payments 0.0.1   develop
erpnext  14.7.0  version-14

Steps to reproduce the issue

  1. Create a new site with only erpnext included along with frappe
  2. Run through the new site wizard to create a company and then create a customer and item
  3. Create a sales invoice without taxes and in draft stage , save it. export it through "Data Import" template option.
  4. Delete the sales invoice and try to reimport the exported invoice through "Data Import "

The error is reproduced

Observed result

Import seems to fail when a doctype has multiple child tables in the same tab having different number of records

Expected result

Import should allow both child tables to have different sets of records . Btw this functionality worked fine in 13

Stacktrace / full error message

Traceback (most recent call last):
  File "apps/frappe/frappe/core/doctype/data_import/importer.py", line 147, in import_data
    doc = self.process_doc(doc)
  File "apps/frappe/frappe/core/doctype/data_import/importer.py", line 240, in process_doc
    return self.insert_record(doc)
  File "apps/frappe/frappe/core/doctype/data_import/importer.py", line 259, in insert_record
    new_doc.insert()
  File "apps/frappe/frappe/model/document.py", line 258, in insert
    self._validate()
  File "apps/frappe/frappe/model/document.py", line 526, in _validate
    self._validate_mandatory()
  File "apps/frappe/frappe/model/document.py", line 879, in _validate_mandatory
    raise frappe.MandatoryError(
frappe.exceptions.MandatoryError: [Sales Invoice, PBS-SRVF-22-002]: charge_type, account_head, charge_type, account_head

Additional information

OS version / distribution, Frappe install method, etc.

ruthra-kumar commented 1 year ago

@hari-madhavan What columns does the template file has? Can you post the template file here?

hari-madhavan commented 1 year ago

Hi @ruthra-kumar ,

I downloaded the file from the "Download Template: options of "Data Import" for Sales Invoice doctype and then selected all fields except the ids of the child doctypes and then changed just the Sales Invoice "ID" so that I get a unique record to import. Sample attached. Sales_Invoice.xlsx