refactor: update project costing based on frequency
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index e83525d..c6ae937 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -527,7 +527,11 @@
if self.update_stock == 1:
self.repost_future_sle_and_gle()
- self.update_project()
+ if (
+ frappe.db.get_single_value("Buying Settings", "project_update_frequency") == "Each Transaction"
+ ):
+ self.update_project()
+
update_linked_doc(self.doctype, self.name, self.inter_company_invoice_reference)
self.update_advance_tax_references()
@@ -1262,7 +1266,10 @@
if self.update_stock == 1:
self.repost_future_sle_and_gle()
- self.update_project()
+ if (
+ frappe.db.get_single_value("Buying Settings", "project_update_frequency") == "Each Transaction"
+ ):
+ self.update_project()
self.db_set("status", "Cancelled")
unlink_inter_company_doc(self.doctype, self.name, self.inter_company_invoice_reference)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index a71d71b..4991b48 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -351,5 +351,6 @@
erpnext.patches.v15_0.set_reserved_stock_in_bin
erpnext.patches.v14_0.create_accounting_dimensions_in_supplier_quotation
erpnext.patches.v14_0.update_zero_asset_quantity_field
+execute:frappe.db.set_single_value("Buying Settings", "project_update_frequency", "Each Transaction")
# below migration patch should always run last
erpnext.patches.v14_0.migrate_gl_to_payment_ledger