fix: item price not fetching when customer is unset in item price (#21488)
* fix: item price not fetching when customer is unset in item price * fix: item price of selling type has hidden supplier value * fix: remove test variable * fix: test * patch: invalid customer/supplier based on item price type * fix: invalid query * fix: patch Co-authored-by: Marica <maricadsouza221197@gmail.com>
This commit is contained in:
parent
0fbc96cc8c
commit
41b47a68b3
@ -681,3 +681,4 @@ erpnext.patches.v12_0.retain_permission_rules_for_video_doctype
|
|||||||
erpnext.patches.v13_0.patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive
|
erpnext.patches.v13_0.patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive
|
||||||
execute:frappe.delete_doc_if_exists("Page", "appointment-analytic")
|
execute:frappe.delete_doc_if_exists("Page", "appointment-analytic")
|
||||||
execute:frappe.rename_doc("Desk Page", "Getting Started", "Home", force=True)
|
execute:frappe.rename_doc("Desk Page", "Getting Started", "Home", force=True)
|
||||||
|
erpnext.patches.v12_0.unset_customer_supplier_based_on_type_of_item_price
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
invalid_selling_item_price = frappe.db.sql(
|
||||||
|
"""SELECT name FROM `tabItem Price` WHERE selling = 1 and buying = 0 and (supplier IS NOT NULL or supplier = '')"""
|
||||||
|
)
|
||||||
|
invalid_buying_item_price = frappe.db.sql(
|
||||||
|
"""SELECT name FROM `tabItem Price` WHERE selling = 0 and buying = 1 and (customer IS NOT NULL or customer = '')"""
|
||||||
|
)
|
||||||
|
docs_to_modify = invalid_buying_item_price + invalid_selling_item_price
|
||||||
|
for d in docs_to_modify:
|
||||||
|
# saving the doc will auto reset invalid customer/supplier field
|
||||||
|
doc = frappe.get_doc("Item Price", d[0])
|
||||||
|
doc.save()
|
||||||
@ -69,3 +69,10 @@ class ItemPrice(Document):
|
|||||||
self.reference = self.customer
|
self.reference = self.customer
|
||||||
if self.buying:
|
if self.buying:
|
||||||
self.reference = self.supplier
|
self.reference = self.supplier
|
||||||
|
|
||||||
|
if self.selling and not self.buying:
|
||||||
|
# if only selling then remove supplier
|
||||||
|
self.supplier = None
|
||||||
|
if self.buying and not self.selling:
|
||||||
|
# if only buying then remove customer
|
||||||
|
self.customer = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user