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:
Saqib 2020-05-15 04:24:36 +05:30 committed by GitHub
parent 0fbc96cc8c
commit 41b47a68b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View File

@ -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
execute:frappe.delete_doc_if_exists("Page", "appointment-analytic")
execute:frappe.rename_doc("Desk Page", "Getting Started", "Home", force=True)
erpnext.patches.v12_0.unset_customer_supplier_based_on_type_of_item_price

View File

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

View File

@ -69,3 +69,10 @@ class ItemPrice(Document):
self.reference = self.customer
if self.buying:
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

View File

@ -630,7 +630,7 @@ def get_item_price(args, item_code, ignore_party=False):
elif args.get("supplier"):
conditions += " and supplier=%(supplier)s"
else:
conditions += " and (customer is null or customer = '') and (supplier is null or supplier = '')"
conditions += "and (customer is null or customer = '') and (supplier is null or supplier = '')"
if args.get('transaction_date'):
conditions += """ and %(transaction_date)s between