From 3476a457ad8448cc5648d3027d76fb0a97cc4c5c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 25 Jan 2019 16:22:36 +0530 Subject: [PATCH 1/3] fix: minor --- erpnext/accounts/deferred_revenue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index 2ff2644d18..9ff8b04281 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -29,7 +29,7 @@ def validate_service_stop_date(doc): if date_diff(item.service_stop_date, item.service_end_date) > 0: frappe.throw(_("Service Stop Date cannot be after Service End Date")) - if old_stop_dates and old_stop_dates[item.name] and item.service_stop_date!=old_stop_dates[item.name]: + if old_stop_dates and old_stop_dates.get(item.name) and item.service_stop_date!=old_stop_dates[item.name]: frappe.throw(_("Cannot change Service Stop Date for item in row {0}".format(item.idx))) def convert_deferred_expense_to_expense(start_date=None, end_date=None): From 01ca3e5e362f05bc80884ce5c2198f00f1d9a2d1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 25 Jan 2019 16:25:15 +0530 Subject: [PATCH 2/3] fix(manufacturing): Get raw materials rate from price list ignoring party --- erpnext/manufacturing/doctype/bom/bom.py | 7 +++++-- erpnext/stock/get_item_details.py | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 57a1cc2593..2317634cfc 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -189,7 +189,8 @@ class BOM(WebsiteGenerator): "currency": self.currency, "conversion_rate": self.conversion_rate or 1, "conversion_factor": arg.get("conversion_factor") or 1, - "plc_conversion_rate": 1 + "plc_conversion_rate": 1, + "ignore_party": True }) item_doc = frappe.get_doc("Item", arg.get("item_code")) out = frappe._dict() @@ -213,7 +214,7 @@ class BOM(WebsiteGenerator): existing_bom_cost = self.total_cost for d in self.get("items"): - d.rate = self.get_rm_rate({ + rate = self.get_rm_rate({ "item_code": d.item_code, "bom_no": d.bom_no, "qty": d.qty, @@ -221,6 +222,8 @@ class BOM(WebsiteGenerator): "stock_uom": d.stock_uom, "conversion_factor": d.conversion_factor }) + if rate: + d.rate = rate d.amount = flt(d.rate) * flt(d.qty) if self.docstatus == 1: diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 9db04cd0ab..e1607a927f 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -424,7 +424,7 @@ def insert_item_price(args): frappe.msgprint(_("Item Price added for {0} in Price List {1}").format(args.item_code, args.price_list), alert=True) -def get_item_price(args, item_code): +def get_item_price(args, item_code, ignore_party=False): """ Get name, price_list_rate from Item Price based on conditions Check if the Derised qty is within the increment of the packing list. @@ -434,17 +434,20 @@ def get_item_price(args, item_code): """ args['item_code'] = item_code - conditions = "where (customer is null or customer = '') and (supplier is null or supplier = '')" - if args.get("customer"): - conditions = "where customer=%(customer)s" - if args.get("supplier"): - conditions = "where supplier=%(supplier)s" - - conditions += """ and item_code=%(item_code)s + conditions = """where item_code=%(item_code)s and price_list=%(price_list)s and ifnull(uom, '') in ('', %(uom)s)""" + if not ignore_party: + conditions += " and (customer is null or customer = '') and (supplier is null or supplier = '')" + if args.get("customer"): + conditions += " and customer=%(customer)s" + + if args.get("supplier"): + conditions += " and supplier=%(supplier)s" + + if args.get('min_qty'): conditions += " and ifnull(min_qty, 0) <= %(min_qty)s" @@ -490,10 +493,10 @@ def get_price_list_rate_for(args, item_code): for field in ["customer", "supplier", "min_qty"]: del item_price_args[field] - general_price_list_rate = get_item_price(item_price_args, item_code) + general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party")) if not general_price_list_rate and args.get("uom") != args.get("stock_uom"): item_price_args["args"] = args.get("stock_uom") - general_price_list_rate = get_item_price(item_price_args, item_code) + general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party")) if general_price_list_rate: item_price_data = general_price_list_rate From 4e45663297d01d2621e2ed2cdd6aa9702481cc67 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 29 Jan 2019 14:02:08 +0530 Subject: [PATCH 3/3] fix(stock): get item price based on party --- erpnext/stock/get_item_details.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index e1607a927f..ec1031c70f 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -440,13 +440,12 @@ def get_item_price(args, item_code, ignore_party=False): and ifnull(uom, '') in ('', %(uom)s)""" if not ignore_party: - conditions += " and (customer is null or customer = '') and (supplier is null or supplier = '')" if args.get("customer"): conditions += " and customer=%(customer)s" - - if args.get("supplier"): + elif args.get("supplier"): conditions += " and supplier=%(supplier)s" - + else: + conditions += " and (customer is null or customer = '') and (supplier is null or supplier = '')" if args.get('min_qty'): conditions += " and ifnull(min_qty, 0) <= %(min_qty)s"