Error on update - 'BaseDocument' object has no attribute 'precision'

Hi All,

I did a dry run update to the latest 4.X in a sandbox. I got a bunch of errors (logs below). I searched the forums, but found no mention.

Is this a known issue? Thanks,
-Jev

Running latest for foo
--------------------------------------------------
Executing frappe.patches.v4_3.remove_allow_on_submit_customization in foo (foo)
Success
Executing erpnext.patches.v4_2.cost_of_production_cycle in foo (foo)
Success
Executing erpnext.patches.v4_2.seprate_manufacture_and_repack in foo (foo)
Success
Executing execute:frappe.delete_doc("Report", "Warehouse-Wise Stock Balance") in foo (foo)
Success
Executing execute:frappe.delete_doc("DocType", "Purchase Request") in foo (foo)
Success
Executing execute:frappe.delete_doc("DocType", "Purchase Request Item") in foo (foo)
Success
Executing erpnext.patches.v4_2.recalculate_bom_cost in foo (foo)
Success
Executing erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions in foo (foo)
Purchase Receipt GRN01216 683.4 733.4
Traceback (innermost last):
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py", line 44, in execute
    voucher.make_gl_entries(repost_future_gle=False)
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py", line 22, in make_gl_entries
    gl_entries = self.get_gl_entries(warehouse_account)
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py", line 298, in get_gl_entries
    self.precision("valuation_rate", d))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 576, in precision
    self._precision[cache_key][fieldname] = get_field_precision(df, self)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 261, in get_field_precision
    if cint(df.precision):
 AttributeError: 'BaseDocument' object has no attribute 'precision'

Purchase Receipt GRN01235 1010.0 1278.9
Traceback (innermost last):
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py", line 44, in execute
    voucher.make_gl_entries(repost_future_gle=False)
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py", line 22, in make_gl_entries
    gl_entries = self.get_gl_entries(warehouse_account)
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py", line 298, in get_gl_entries
    self.precision("valuation_rate", d))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/document.py", line 576, in precision
    self._precision[cache_key][fieldname] = get_field_precision(df, self)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/model/meta.py", line 261, in get_field_precision
    if cint(df.precision):
 AttributeError: 'BaseDocument' object has no attribute 'precision'

[..SNIPPED MANY REPEATED ERRORS..]

Failed to repost:
[[u'Purchase Receipt', u'GRN01216'], [u'Purchase Receipt', u'GRN01235'], [u'Purchase Receipt', u'GRN01425'], [u'Purchase Receipt', u'GRN01373-1'], [u'Purchase Receipt', u'GRN01432'], [u'Purchase Receipt', u'GRN01387'], [u'Purchase Receipt', u'GRN01388'], [u'Purchase Receipt', u'GRN01392'], [u'Purchase Receipt', u'GRN01416'], [u'Purchase Receipt', u'GRN01406'], [u'Purchase Receipt', u'GRN01410'], [u'Purchase Receipt', u'GRN01412'], [u'Purchase Receipt', u'GRN01418'], [u'Purchase Receipt', u'GRN01422'], [u'Purchase Receipt', u'GRN01424'], [u'Purchase Receipt', u'GRN01426'], [u'Purchase Receipt', u'GRN01434'], [u'Purchase Receipt', u'GRN01436'], [u'Purchase Receipt', u'GRN01448'], [u'Purchase Receipt', u'GRN01449'], [u'Purchase Receipt', u'GRN01450'], [u'Purchase Receipt', u'GRN01458'], [u'Purchase Receipt', u'GRN01459'], [u'Purchase Receipt', u'GRN01466'], [u'Purchase Receipt', u'GRN01465'], [u'Purchase Receipt', u'GRN01470'], [u'Purchase Receipt', u'GRN01472'], [u'Purchase Receipt', u'GRN01475'], [u'Purchase Receipt', u'GRN01477'], [u'Purchase Receipt', u'GRN01483'], [u'Purchase Receipt', u'GRN01486'], [u'Purchase Receipt', u'GRN01492'], [u'Purchase Receipt', u'GRN01494-1'], [u'Purchase Receipt', u'GRN01500'], [u'Purchase Receipt', u'GRN01514'], [u'Purchase Receipt', u'GRN01516'], [u'Purchase Receipt', u'GRN01517'], [u'Purchase Receipt', u'GRN01523'], [u'Purchase Receipt', u'GRN01524'], [u'Purchase Receipt', u'GRN01525'], [u'Purchase Receipt', u'GRN01536'], [u'Purchase Receipt', u'GRN01548']]
Success
Executing erpnext.patches.v4_2.update_requested_and_ordered_qty in foo (foo)
Success
Executing execute:frappe.delete_doc("DocType", "Contact Control") in foo (foo)
Success
Executing erpnext.patches.v4_2.recalculate_bom_costs in foo (foo)
Success
Updating frappe                     : [========================================]
Updating erpnext                    : [========================================]

Are you updating after a long time? precision property has been around for a while. Can you check if running latest again will fix this issue?

The last update was from Sep 4, 2014

The specific commits for frappe and erpnext are linked below. The update I ran was on a cloned image (digitalocean snapshots FTW). I was doing a dry run update. I can prep another and re-do it, or I can also give you guys access if you are interested.

Commit hash’s that I’m updating from;
https://github.com/frappe/frappe/commit/442a09d3d5bb790586516925699b753002d376d4
https://github.com/frappe/erpnext/commit/4c93f35c2b48bc448fce71e9e66a2766ad458ad2

I took a fresh snapshot, and re-ran bench update. I got the same errors, repeating bench update afterwards runs fine.

But the I don’t think the erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py patch has correctly processed 42 Purchase Receipts (GRN####) that caused errors in the first place.

I presume the update has now added the precision property, so is there a way to manually run that patch to ensure all records are consistent?

It is worth noting that there was more than 42 Purchase Receipts in the system. I’m not sure why these 42 caused errors, and the others appear to have processed just fine.

-Jev

Just a comment from a lurker :wink: It would be really great if command lines were included for the benefit of us not as familiar with the upgrade process (and troubleshooting). Still makes very interesting reading as-is though.

Change the date to current one on this line:

It will sync the DocField table (with the precision column) before running th patches.

To be clear,
I should change the date on L3 to today’s date, and the re-run bench update?

Yes - that is correct.

Ok, I created a new instance of my production system that has not been updated since Sep 4th.

I ran bench update --pull
Modified the date on patches.txt as per @rmehta instructions
ran bench update --patch which ran with no errors. :smile:
ran bench update --build

and I’m done, system updated successfully with no errors. Thanks guys.