Enhancement and bug fix in batch (#12753)

* merge shelf like and manufacturing date

* setting default manufacturing date as todays date

* setting default manufacturing date as todays date

* fix

* Improvements to batch auto naming (#12496)

* refactor:
add new function - batch_uses_naming_series
use batch_uses_naming_series in autoname method

* properly update naming series on delete:
- add new functions - get_batch_prefix, get_batch_naming_series_key, get_batch_naming_series
- refactor get_name_from_naming_series
- add after_delete method

* add documentation and rename some functions

* PEP 8 compliance

* test

* added support for jinja template and added validation if expiry date is set or not if item has_expiry_date is set

* bug fix, renamed item_code to item as in batch doctype we refer 'item code' by 'item'

* added manufacturing date wise sort

* added prefix to expiry date and manufacturing date
This commit is contained in:
sivankar
2018-02-12 14:33:40 +05:30
committed by Nabin Hait
parent 277935be79
commit 621740efd9
6 changed files with 558 additions and 480 deletions

View File

@@ -270,13 +270,14 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
}
if args.get('warehouse'):
batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom, batch.expiry_date
batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom, concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date)
from `tabStock Ledger Entry` sle
INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
where
sle.item_code = %(item_code)s
and sle.warehouse = %(warehouse)s
and sle.batch_no like %(txt)s
and (sle.batch_no like %(txt)s
or batch.manufacturing_date like %(txt)s)
and batch.docstatus < 2
{0}
{match_conditions}
@@ -287,9 +288,10 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
if batch_nos:
return batch_nos
else:
return frappe.db.sql("""select name, expiry_date from `tabBatch` batch
return frappe.db.sql("""select name, concat('MFG-', manufacturing_date), concat('EXP-',expiry_date) from `tabBatch` batch
where item = %(item_code)s
and name like %(txt)s
and (name like %(txt)s
or manufacturing_date like %(txt)s)
and docstatus < 2
{0}
{match_conditions}