diff --git a/hr/doctype/holiday_list/holiday_list.py b/hr/doctype/holiday_list/holiday_list.py index e5504fac03..7ca519fc00 100644 --- a/hr/doctype/holiday_list/holiday_list.py +++ b/hr/doctype/holiday_list/holiday_list.py @@ -42,10 +42,13 @@ class DocType: self.validate_values() yr_start_date, yr_end_date = self.get_fy_start_end_dates() date_list = self.get_weekly_off_date_list(yr_start_date, yr_end_date) - for d in date_list: + last_idx = max([cint(d.idx) for d in self.doclist.get( + {"parentfield": "holiday_list_details"})] or [0,]) + for i, d in enumerate(date_list): ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist) ch.description = self.doc.weekly_off ch.holiday_date = d + ch.idx = last_idx + i + 1 def validate_values(self): if not self.doc.fiscal_year: diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index e10defdebf..00ae0e0433 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -172,7 +172,7 @@ class DocType(TransactionBase): d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0 # get incoming rate - if not flt(d.incoming_rate) or self.doc.purpose == "Sales Return": + if not flt(d.incoming_rate): d.incoming_rate = self.get_incoming_rate(args) d.amount = flt(d.qty) * flt(d.incoming_rate) @@ -182,7 +182,7 @@ class DocType(TransactionBase): if self.doc.purpose == "Sales Return" and \ (self.doc.delivery_note_no or self.doc.sales_invoice_no): sle = webnotes.conn.sql("""select name, posting_date, posting_time, - actual_qty, stock_value from `tabStock Ledger Entry` + actual_qty, stock_value, warehouse from `tabStock Ledger Entry` where voucher_type = %s and voucher_no = %s and item_code = %s and ifnull(is_cancelled, 'No') = 'No' limit 1""", ((self.doc.delivery_note_no and "Delivery Note" or "Sales Invoice"), @@ -191,7 +191,8 @@ class DocType(TransactionBase): args.update({ "posting_date": sle[0].posting_date, "posting_time": sle[0].posting_time, - "sle": sle[0].name + "sle": sle[0].name, + "warehouse": sle[0].warehouse, }) previous_sle = get_previous_sle(args) incoming_rate = (flt(sle[0].stock_value) - flt(previous_sle.get("stock_value"))) / \