[Solved] Purchase Invoice Import fails with incorrect UOM after upgrade to v13.49.14

EDIT: Solved

After placing some debugging print statements in importer.py, I determined that the field stock_uom was being set to Nos by the import scripts. This column is not included as a mandatory column and was not required in prior versions. Adding a Stock UOM (Items) column to the CSV with value of Dollars corrected the problem.

I would strongly suggest the devs either fix this regression, or add Stock UOM to the list of mandatory fields.

END EDIT


I just updated my V13 installation to the latest V13 minor version, and seem to have encountered a bug with PI importing. The version change was:

ERPNext: v13.27.1 -> v13.49.14
Frappe:  v13.27.0 -> v13.56.0 

CSV purchase invoice importing was working fine with v13.27, but after the update, attempting to import results in the error:

Row 1: Quantity (1183.74) cannot be a fraction. To allow this, disable 'Must be Whole Number' in UOM Nos.

This occurs for any row that contains a decimal rather than whole number. The UOM are set to “Dollars”, which are setup to allow fractional values. Entering the PI manually using exactly the same values present in the CSV file works. Importing the same CSV file into v13.27 works fine, with the same UOM setup.

I’ve checked that there were no column name changes between the versions (using the “Download Template” function), so I’m at a bit of a loss.

For some reason, the import is not reading the UOM specified in the CSV and is instead defaulting to Items (No.).

Edit: Screenshot of error showing UOM (Items) column correctly set at Dollars:

Dollars UOM

Below is the data from the test CSV file, which works fine on v13.27, but fails on v.13.49:

Date                              2021-04-01
Supplier Invoice Date             2021-04-01
Supplier Invoice No	              inv123
Supplier                          MYSUPPLIER
Item Name (Items)	                warehousing
Expense Head (Items)              5224 - Warehousing and Fulfilment - EL
Against Expense Account	          5224 - Warehousing and Fulfilment - EL
Paid Amount	                      1183.74
Accepted Qty (Items)              1183.74
Accepted Qty in Stock UOM (Items) 1183.74
Amount (Items)                    1183.74
Amount (Company Currency) (Items) 1183.74
ID
Series                            ACC-PINV-.YYYY.-
Is Paid                           1
Mode of Payment                   Cash
Cash/Bank Account                 1110 - Cash - EL
UOM (Items)                       Dollars
UOM Conversion Factor (Items)     0
Rate (Items)                      1
Rate (Company Currency) (Items)   1
Credit To                         2110 - Creditors - EL
ID (Items)

And the full error trace:

Traceback (most recent call last):
  File "apps/frappe/frappe/core/doctype/data_import/importer.py", line 126, in import_data
    doc = self.process_doc(doc)
  File "apps/frappe/frappe/core/doctype/data_import/importer.py", line 193, in process_doc
    return self.insert_record(doc)
  File "apps/frappe/frappe/core/doctype/data_import/importer.py", line 212, in insert_record
    new_doc.insert()
  File "apps/frappe/frappe/model/document.py", line 263, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1054, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 943, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1264, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1246, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 940, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py", line 110, in validate
    self.validate_uom_is_integer("stock_uom", "stock_qty")
  File "apps/erpnext/erpnext/utilities/transaction_base.py", line 93, in validate_uom_is_integer
    validate_uom_is_integer(self, uom_field, qty_fields)
  File "apps/erpnext/erpnext/utilities/transaction_base.py", line 246, in validate_uom_is_integer
    frappe.throw(
  File "apps/frappe/frappe/__init__.py", line 504, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 434, in _raise_exception
    raise raise_exception(msg)
erpnext.utilities.transaction_base.UOMMustBeIntegerError: Row 1: Quantity (1183.74) cannot be a fraction. To allow this, disable 'Must be Whole Number' in UOM Nos.

please check item master default uom what to be set in perticular item.

Thanks for the suggestion, but the UOM for the item is also set to Dollars.

As mentioned, the file imports perfectly in the prior v13 version (I have both installed), but fails in the latest. It seems that a regression bug was introduced at some point where the stock_uom field was no longer being set based on the UOM (Items) column in the CSV, but instead defaults to Nos.