mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
fix: Update Received Qty in Material Request as per Stock UOM (#21055)
* fix: Update Received Qty in Material Request as per Stock UOM * fix: Process each PR only once * fix: minor suggested changes Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
@@ -651,3 +651,4 @@ erpnext.patches.v12_0.add_export_type_field_in_party_master
|
|||||||
erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22
|
erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22
|
||||||
erpnext.patches.v12_0.create_irs_1099_field_united_states
|
erpnext.patches.v12_0.create_irs_1099_field_united_states
|
||||||
erpnext.patches.v12_0.set_permission_einvoicing
|
erpnext.patches.v12_0.set_permission_einvoicing
|
||||||
|
erpnext.patches.v12_0.set_received_qty_in_material_request_as_per_stock_uom
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
purchase_receipts = frappe.db.sql("""
|
||||||
|
SELECT
|
||||||
|
parent from `tabPurchase Receipt Item`
|
||||||
|
WHERE
|
||||||
|
material_request is not null
|
||||||
|
AND docstatus=1
|
||||||
|
""",as_dict=1)
|
||||||
|
|
||||||
|
purchase_receipts = set([d.parent for d in purchase_receipts])
|
||||||
|
|
||||||
|
for pr in purchase_receipts:
|
||||||
|
doc = frappe.get_doc("Purchase Receipt", pr)
|
||||||
|
doc.status_updater = [
|
||||||
|
{
|
||||||
|
'source_dt': 'Purchase Receipt Item',
|
||||||
|
'target_dt': 'Material Request Item',
|
||||||
|
'join_field': 'material_request_item',
|
||||||
|
'target_field': 'received_qty',
|
||||||
|
'target_parent_dt': 'Material Request',
|
||||||
|
'target_parent_field': 'per_received',
|
||||||
|
'target_ref_field': 'stock_qty',
|
||||||
|
'source_field': 'stock_qty',
|
||||||
|
'percent_join_field': 'material_request'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
doc.update_qty()
|
||||||
@@ -49,8 +49,8 @@ class PurchaseReceipt(BuyingController):
|
|||||||
'target_field': 'received_qty',
|
'target_field': 'received_qty',
|
||||||
'target_parent_dt': 'Material Request',
|
'target_parent_dt': 'Material Request',
|
||||||
'target_parent_field': 'per_received',
|
'target_parent_field': 'per_received',
|
||||||
'target_ref_field': 'qty',
|
'target_ref_field': 'stock_qty',
|
||||||
'source_field': 'qty',
|
'source_field': 'stock_qty',
|
||||||
'percent_join_field': 'material_request'
|
'percent_join_field': 'material_request'
|
||||||
}]
|
}]
|
||||||
if cint(self.is_return):
|
if cint(self.is_return):
|
||||||
|
|||||||
Reference in New Issue
Block a user