fix: Update Received Qty in Material Request as per Stock UOM (#21054)

* 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:
Marica 2020-04-03 10:07:06 +05:30 committed by GitHub
parent 438e0433a3
commit 66c4a08703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 4 deletions

View File

@ -660,3 +660,4 @@ erpnext.patches.v12_0.set_job_offer_applicant_email
erpnext.patches.v12_0.create_irs_1099_field_united_states
erpnext.patches.v12_0.move_bank_account_swift_number_to_bank
erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22
erpnext.patches.v12_0.set_received_qty_in_material_request_as_per_stock_uom

View File

@ -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()

View File

@ -50,8 +50,8 @@ class PurchaseReceipt(BuyingController):
'target_field': 'received_qty',
'target_parent_dt': 'Material Request',
'target_parent_field': 'per_received',
'target_ref_field': 'qty',
'source_field': 'qty',
'target_ref_field': 'stock_qty',
'source_field': 'stock_qty',
'percent_join_field': 'material_request'
}]
if cint(self.is_return):
@ -357,7 +357,7 @@ class PurchaseReceipt(BuyingController):
if warehouse_with_no_account:
frappe.msgprint(_("No accounting entries for the following warehouses") + ": \n" +
"\n".join(warehouse_with_no_account))
return process_gl_map(gl_entries)
def get_asset_gl_entry(self, gl_entries):
@ -628,7 +628,7 @@ def get_item_account_wise_additional_cost(purchase_document):
if not landed_cost_vouchers:
return
item_account_wise_cost = {}
for lcv in landed_cost_vouchers: