mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-16 13:32:13 +00:00
fix: Added patch and fallback code to prevent future issues similiar to helpdesk ticket 28246
(cherry picked from commit 65dc3505c4)
# Conflicts:
# erpnext/patches.txt
This commit is contained in:
@@ -103,6 +103,16 @@ class SubcontractingController(StockController):
|
|||||||
_("Row {0}: Item {1} must be a subcontracted item.").format(item.idx, item.item_name)
|
_("Row {0}: Item {1} must be a subcontracted item.").format(item.idx, item.item_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
not item.sc_conversion_factor
|
||||||
|
): # this condition will only be true if user has recently updated from develop branch
|
||||||
|
service_item_qty = frappe.get_value(
|
||||||
|
"Subcontracting Order Service Item",
|
||||||
|
filters={"purchase_order_item": item.purchase_order_item, "parent": self.name},
|
||||||
|
fieldname=["qty"],
|
||||||
|
)
|
||||||
|
item.sc_conversion_factor = service_item_qty / item.qty
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.doctype not in "Subcontracting Receipt"
|
self.doctype not in "Subcontracting Receipt"
|
||||||
and item.qty
|
and item.qty
|
||||||
|
|||||||
@@ -386,3 +386,8 @@ erpnext.patches.v14_0.update_stock_uom_in_work_order_item
|
|||||||
erpnext.patches.v15_0.set_is_exchange_gain_loss_in_payment_entry_deductions
|
erpnext.patches.v15_0.set_is_exchange_gain_loss_in_payment_entry_deductions
|
||||||
erpnext.patches.v15_0.enable_allow_existing_serial_no
|
erpnext.patches.v15_0.enable_allow_existing_serial_no
|
||||||
erpnext.patches.v15_0.update_cc_in_process_statement_of_accounts
|
erpnext.patches.v15_0.update_cc_in_process_statement_of_accounts
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
erpnext.patches.v15_0.refactor_closing_stock_balance #5
|
||||||
|
erpnext.subcontracting.doctype.subcontracting_order.patches.set_sc_conversion_factor
|
||||||
|
>>>>>>> 65dc3505c4 (fix: Added patch and fallback code to prevent future issues similiar to helpdesk ticket 28246)
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
# Calculate and set sc_conversion_factor for draft Subcontracting Orders if value is 0
|
||||||
|
|
||||||
|
subcontracting_order_items = frappe.get_all(
|
||||||
|
"Subcontracting Order Item",
|
||||||
|
filters={"docstatus": 0, "sc_conversion_factor": 0},
|
||||||
|
fields=["name", "parent", "purchase_order_item", "qty"],
|
||||||
|
)
|
||||||
|
for subcontracting_order_item in subcontracting_order_items:
|
||||||
|
service_item_qty = frappe.get_value(
|
||||||
|
"Subcontracting Order Service Item",
|
||||||
|
filters={
|
||||||
|
"purchase_order_item": subcontracting_order_item.purchase_order_item,
|
||||||
|
"parent": subcontracting_order_item.parent,
|
||||||
|
},
|
||||||
|
fieldname=["qty"],
|
||||||
|
)
|
||||||
|
frappe.set_value(
|
||||||
|
"Subcontracting Order Item",
|
||||||
|
subcontracting_order_item.name,
|
||||||
|
"sc_conversion_factor",
|
||||||
|
service_item_qty / subcontracting_order_item.qty,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user