Skip to content

Commit

Permalink
fix(patch): sle.serial_no = "\n" causes incorrect queue (#29306)
Browse files Browse the repository at this point in the history
This happens due to old data.
  • Loading branch information
ankush committed Jan 16, 2022
1 parent 82ea958 commit 66bf21f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ erpnext.patches.v13_0.add_custom_field_for_south_africa #2
erpnext.patches.v13_0.update_recipient_email_digest
erpnext.patches.v13_0.shopify_deprecation_warning
erpnext.patches.v13_0.remove_bad_selling_defaults
erpnext.patches.v13_0.trim_whitespace_from_serial_nos
erpnext.patches.v13_0.trim_whitespace_from_serial_nos # 16-01-2022
erpnext.patches.v13_0.migrate_stripe_api
erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries
erpnext.patches.v13_0.einvoicing_deprecation_warning
Expand Down
4 changes: 3 additions & 1 deletion erpnext/patches/v13_0/trim_whitespace_from_serial_nos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ def execute():
from `tabStock Ledger Entry`
where
is_cancelled = 0
and (serial_no like %s or serial_no like %s or serial_no like %s or serial_no like %s)
and ( serial_no like %s or serial_no like %s or serial_no like %s or serial_no like %s
or serial_no = %s )
""",
(
" %", # leading whitespace
"% ", # trailing whitespace
"%\n %", # leading whitespace on newline
"% \n%", # trailing whitespace on newline
"\n", # just new line
),
as_dict=True,
)
Expand Down
5 changes: 4 additions & 1 deletion erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def get_args_for_future_sle(row):

def validate_serial_no(sle):
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos

for sn in get_serial_nos(sle.serial_no):
args = copy.deepcopy(sle)
args.serial_no = sn
Expand Down Expand Up @@ -423,6 +424,8 @@ def append_future_sle_for_dependant(self, dependant_sle, entries_to_fix):
return sorted(entries_to_fix, key=lambda k: k['timestamp'])

def process_sle(self, sle):
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos

# previous sle data for this warehouse
self.wh_data = self.data[sle.warehouse]

Expand All @@ -437,7 +440,7 @@ def process_sle(self, sle):
if not self.args.get("sle_id"):
self.get_dynamic_incoming_outgoing_rate(sle)

if sle.serial_no:
if get_serial_nos(sle.serial_no):
self.get_serialized_values(sle)
self.wh_data.qty_after_transaction += flt(sle.actual_qty)
if sle.voucher_type == "Stock Reconciliation":
Expand Down

0 comments on commit 66bf21f

Please sign in to comment.