serial no fixes: sle creation through import data
This commit is contained in:
parent
04a276c934
commit
aa577ed82e
6
erpnext/patches/april_2012/serial_no_fixes.py
Normal file
6
erpnext/patches/april_2012/serial_no_fixes.py
Normal file
@ -0,0 +1,6 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
from webnotes.modules.module_manager import reload_doc
|
||||
reload_doc('stock', 'doctype', 'serial_no')
|
||||
|
||||
webnotes.conn.sql("update `tabSerial No` set sle_exists = 1")
|
@ -247,5 +247,10 @@ patch_list = [
|
||||
'patch_file': 'update_appraisal_permission',
|
||||
'description': 'updated permission in appraisal'
|
||||
},
|
||||
{
|
||||
'patch_module': 'patches.april_2012',
|
||||
'patch_file': 'serial_no_fixes',
|
||||
'description': 'fixes for sle creation while import'
|
||||
},
|
||||
|
||||
]
|
||||
|
@ -71,10 +71,13 @@ class DocType(TransactionBase):
|
||||
self.validate_warehouse()
|
||||
self.validate_item()
|
||||
|
||||
def on_update(self):
|
||||
if self.doc.warehouse and self.doc.status == 'In Store' and cint(self.doc.sle_exists) == 0 and \
|
||||
not sql("select name from `tabStock Ledger Entry` where serial_no = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name):
|
||||
self.make_stock_ledger_entry(1)
|
||||
webnotes.conn.set(self.doc, 'sle_exists', 1)
|
||||
|
||||
|
||||
# ------------------------
|
||||
# make stock ledger entry
|
||||
# ------------------------
|
||||
def make_stock_ledger_entry(self, qty):
|
||||
from webnotes.model.code import get_obj
|
||||
values = [{
|
||||
@ -91,21 +94,13 @@ class DocType(TransactionBase):
|
||||
'incoming_rate' : self.doc.purchase_rate,
|
||||
'company' : self.doc.company,
|
||||
'fiscal_year' : self.doc.fiscal_year,
|
||||
'is_cancelled' : 'No', # is_cancelled is always 'No' because while deleted it can not find creation entry if it not created directly, voucher no != serial no.
|
||||
'is_cancelled' : 'No', # is_cancelled is always 'No' because while deleted it can not find creation entry if it not created directly, voucher no != serial no
|
||||
'batch_no' : '',
|
||||
'serial_no' : self.doc.name
|
||||
}]
|
||||
get_obj('Stock Ledger', 'Stock Ledger').update_stock(values)
|
||||
|
||||
|
||||
# ----------
|
||||
# on update
|
||||
# ----------
|
||||
def on_update(self):
|
||||
if self.doc.localname and self.doc.warehouse and self.doc.status == 'In Store' and not sql("select name from `tabStock Ledger Entry` where serial_no = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name)):
|
||||
self.make_stock_ledger_entry(1)
|
||||
|
||||
|
||||
# ---------
|
||||
# on trash
|
||||
# ---------
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -128,6 +128,7 @@ class DocType:
|
||||
s.modified = nowdate()
|
||||
s.modified_by = session['user']
|
||||
s.serial_no = serial_no
|
||||
s.sle_exists = 1
|
||||
s.fiscal_year = obj.doc.fiscal_year
|
||||
s.company = obj.doc.company
|
||||
s.save(new_rec)
|
||||
|
Loading…
x
Reference in New Issue
Block a user