Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
cea0e795b0
@ -5,7 +5,7 @@
|
|||||||
<h4><a href="#!List/Purchase Request">Purchase Request</a></h4>
|
<h4><a href="#!List/Purchase Request">Purchase Request</a></h4>
|
||||||
<p class="help">Request for purchase</p>
|
<p class="help">Request for purchase</p>
|
||||||
<br>
|
<br>
|
||||||
<h4><a href="#!List/Supplier Quotation">Supplier Quotation</a></h4>
|
<h4><a href="#!List/Supplier Quotation">Supplier Quotation (beta)</a></h4>
|
||||||
<p class="help">Track Quotations received from Suppliers</p>
|
<p class="help">Track Quotations received from Suppliers</p>
|
||||||
<br>
|
<br>
|
||||||
<h4><a href="#!List/Purchase Order">Purchase Order</a></h4>
|
<h4><a href="#!List/Purchase Order">Purchase Order</a></h4>
|
||||||
|
@ -1,23 +1,47 @@
|
|||||||
|
import webnotes
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
# add index
|
||||||
|
webnotes.conn.commit()
|
||||||
|
try:
|
||||||
|
webnotes.conn.sql("""create index item_code_warehouse
|
||||||
|
on `tabDelivery Note Packing Item` (item_code, warehouse)""")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
webnotes.conn.begin()
|
||||||
|
|
||||||
|
repost_reserved_qty()
|
||||||
|
cleanup_wrong_sle()
|
||||||
|
|
||||||
def repost_reserved_qty():
|
def repost_reserved_qty():
|
||||||
import webnotes
|
|
||||||
from webnotes.utils import flt
|
from webnotes.utils import flt
|
||||||
bins = webnotes.conn.sql("select item_code, warehouse, name, reserved_qty from `tabBin`")
|
bins = webnotes.conn.sql("select item_code, warehouse, name, reserved_qty from `tabBin`")
|
||||||
|
i = 0
|
||||||
for d in bins:
|
for d in bins:
|
||||||
|
i += 1
|
||||||
|
print i
|
||||||
reserved_qty = webnotes.conn.sql("""
|
reserved_qty = webnotes.conn.sql("""
|
||||||
select sum((dnpi.qty/so_item.qty)*(so_item.qty - ifnull(so_item.delivered_qty, 0)))
|
select sum((dnpi_qty / so_item_qty) * (so_item_qty - so_item_delivered_qty))
|
||||||
|
from (select
|
||||||
from `tabDelivery Note Packing Item` dnpi, `tabSales Order Item` so_item, `tabSales Order` so
|
qty as dnpi_qty,
|
||||||
|
(
|
||||||
where dnpi.item_code = %s
|
select qty from `tabSales Order Item`
|
||||||
and dnpi.warehouse = %s
|
where name = dnpi.parent_detail_docname
|
||||||
and dnpi.parent = so.name
|
) as so_item_qty,
|
||||||
and so_item.parent = so.name
|
(
|
||||||
and dnpi.parenttype = 'Sales Order'
|
select ifnull(delivered_qty, 0) from `tabSales Order Item`
|
||||||
and dnpi.parent_detail_docname = so_item.name
|
where name = dnpi.parent_detail_docname
|
||||||
and dnpi.parent_item = so_item.item_code
|
) as so_item_delivered_qty
|
||||||
and so.docstatus = 1
|
from
|
||||||
and so.status != 'Stopped'
|
(
|
||||||
""", (d[0], d[1]))
|
select qty, parent_detail_docname
|
||||||
|
from `tabDelivery Note Packing Item` dnpi_in
|
||||||
|
where item_code = %s and warehouse = %s
|
||||||
|
and parenttype="Sales Order"
|
||||||
|
and exists (select * from `tabSales Order` so
|
||||||
|
where name = dnpi_in.parent and docstatus = 1 and status != 'Stopped')
|
||||||
|
) dnpi) tab""", (d[0], d[1]))
|
||||||
|
|
||||||
if flt(d[3]) != flt(reserved_qty[0][0]):
|
if flt(d[3]) != flt(reserved_qty[0][0]):
|
||||||
print d[3], reserved_qty[0][0]
|
print d[3], reserved_qty[0][0]
|
||||||
webnotes.conn.sql("""
|
webnotes.conn.sql("""
|
||||||
@ -51,9 +75,6 @@ def cleanup_wrong_sle():
|
|||||||
def create_comment(dn):
|
def create_comment(dn):
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
cmt = Document('Comment')
|
cmt = Document('Comment')
|
||||||
for arg in ['comment', 'comment_by', 'comment_by_fullname', 'comment_doctype', \
|
|
||||||
'comment_docname']:
|
|
||||||
cmt.fields[arg] = args[arg]
|
|
||||||
cmt.comment = 'Cancelled by administrator due to wrong entry in packing list'
|
cmt.comment = 'Cancelled by administrator due to wrong entry in packing list'
|
||||||
cmt.comment_by = 'Administrator'
|
cmt.comment_by = 'Administrator'
|
||||||
cmt.comment_by_fullname = 'Administrator'
|
cmt.comment_by_fullname = 'Administrator'
|
||||||
@ -67,9 +88,4 @@ def repost_bin(item, wh):
|
|||||||
bin = webnotes.conn.sql("select name from `tabBin` \
|
bin = webnotes.conn.sql("select name from `tabBin` \
|
||||||
where item_code = %s and warehouse = %s", (item, wh))
|
where item_code = %s and warehouse = %s", (item, wh))
|
||||||
|
|
||||||
get_obj('Bin', bin[0][0]).update_entries_after(posting_date = '2012-07-01', posting_time = '12:05')
|
get_obj('Bin', bin[0][0]).update_entries_after(posting_date = '2012-07-01', posting_time = '12:05')
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
|
||||||
repost_reserved_qty()
|
|
||||||
cleanup_wrong_sle()
|
|
@ -509,4 +509,8 @@ patch_list = [
|
|||||||
'patch_module': 'patches.july_2012',
|
'patch_module': 'patches.july_2012',
|
||||||
'patch_file': 'project_patch_repeat',
|
'patch_file': 'project_patch_repeat',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'patch_module': 'patches.july_2012',
|
||||||
|
'patch_file': 'repost_stock_due_to_wrong_packing_list',
|
||||||
|
},
|
||||||
]
|
]
|
@ -66,7 +66,7 @@ class DocType:
|
|||||||
|
|
||||||
if cstr(d.uom) == cstr(self.doc.stock_uom):
|
if cstr(d.uom) == cstr(self.doc.stock_uom):
|
||||||
if flt(d.conversion_factor) != 1:
|
if flt(d.conversion_factor) != 1:
|
||||||
msgprint("Conversion Fator of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
|
msgprint("Conversion Factor of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
|
||||||
raise Exception
|
raise Exception
|
||||||
# else set uom_exist as true
|
# else set uom_exist as true
|
||||||
uom_exist='true'
|
uom_exist='true'
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Please edit this list and import only required elements
|
# Please edit this list and import only required elements
|
||||||
import webnotes
|
import webnotes
|
||||||
@ -34,88 +34,86 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
|||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl=[]):
|
def __init__(self, d, dl=[]):
|
||||||
self.doc, self.doclist = d,dl
|
self.doc, self.doclist = d,dl
|
||||||
|
|
||||||
def get_stock_uom(self, item_code):
|
def get_stock_uom(self, item_code):
|
||||||
return {'current_stock_uom': cstr(get_value('Item', item_code, 'stock_uom'))}
|
return {'current_stock_uom': cstr(get_value('Item', item_code, 'stock_uom'))}
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
if not cstr(self.doc.item_code):
|
if not cstr(self.doc.item_code):
|
||||||
msgprint("Please Enter an Item.")
|
msgprint("Please Enter an Item.")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
if not cstr(self.doc.new_stock_uom):
|
||||||
|
msgprint("Please Enter New Stock UOM.")
|
||||||
|
raise Exception
|
||||||
|
|
||||||
if not cstr(self.doc.current_stock_uom):
|
if cstr(self.doc.current_stock_uom) == cstr(self.doc.new_stock_uom):
|
||||||
msgprint("There is no Current Stock UOM for Item Code" + cstr(self.doc.item_code))
|
msgprint("Current Stock UOM and Stock UOM are same.")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
if not cstr(self.doc.new_stock_uom):
|
# check conversion factor
|
||||||
msgprint("Please Enter New Stock UOM.")
|
if not flt(self.doc.conversion_factor):
|
||||||
raise Exception
|
msgprint("Please Enter Conversion Factor.")
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
stock_uom = sql("select stock_uom from `tabItem` where name = '%s'" % self.doc.item_code)
|
||||||
|
stock_uom = stock_uom and stock_uom[0][0]
|
||||||
|
if cstr(self.doc.new_stock_uom) == cstr(stock_uom):
|
||||||
|
msgprint("Item Master is already updated with New Stock UOM " + cstr(self.doc.new_stock_uom))
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
def update_item_master(self):
|
||||||
|
# update stock uom in item master
|
||||||
|
sql("update `tabItem` set stock_uom = '%s' where name = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
||||||
|
|
||||||
|
# acknowledge user
|
||||||
|
msgprint("New Stock UOM : " + cstr(self.doc.new_stock_uom) + " updated in Item : " + cstr(self.doc.item_code))
|
||||||
|
|
||||||
|
def update_bin(self):
|
||||||
|
# update bin
|
||||||
|
if flt(self.doc.conversion_factor) != flt(1):
|
||||||
|
sql("update `tabBin` set stock_uom = '%s' , indented_qty = ifnull(indented_qty,0) * %s, ordered_qty = ifnull(ordered_qty,0) * %s, reserved_qty = ifnull(reserved_qty,0) * %s, planned_qty = ifnull(planned_qty,0) * %s, projected_qty = actual_qty + ordered_qty + indented_qty + planned_qty - reserved_qty where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.item_code) )
|
||||||
|
else:
|
||||||
|
sql("update `tabBin` set stock_uom = '%s' where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.item_code) )
|
||||||
|
|
||||||
if cstr(self.doc.current_stock_uom) == cstr(self.doc.new_stock_uom):
|
# acknowledge user
|
||||||
msgprint("Current Stock UOM and Stock UOM are same.")
|
msgprint(" All Bin's Updated Successfully.")
|
||||||
raise Exception
|
|
||||||
|
def update_stock_ledger_entry(self):
|
||||||
# check conversion factor
|
# update stock ledger entry
|
||||||
if not flt(self.doc.conversion_factor):
|
if flt(self.doc.conversion_factor) != flt(1):
|
||||||
msgprint("Please Enter Conversion Factor.")
|
sql("update `tabStock Ledger Entry` set stock_uom = '%s', actual_qty = ifnull(actual_qty,0) * '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.item_code))
|
||||||
raise Exception
|
else:
|
||||||
|
sql("update `tabStock Ledger Entry` set stock_uom = '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
||||||
stock_uom = sql("select stock_uom from `tabItem` where name = '%s'" % self.doc.item_code)
|
|
||||||
stock_uom = stock_uom and stock_uom[0][0]
|
# acknowledge user
|
||||||
if cstr(self.doc.new_stock_uom) == cstr(stock_uom):
|
msgprint("Stock Ledger Entries Updated Successfully.")
|
||||||
msgprint("Item Master is already updated with New Stock UOM " + cstr(self.doc.new_stock_uom))
|
|
||||||
raise Exception
|
# update item valuation
|
||||||
|
if flt(self.doc.conversion_factor) != flt(1):
|
||||||
def update_item_master(self):
|
wh = sql("select name from `tabWarehouse`")
|
||||||
# update stock uom in item master
|
for w in wh:
|
||||||
sql("update `tabItem` set stock_uom = '%s' where name = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
bin = sql("select name from `tabBin` where item_code = '%s' and warehouse = '%s'" % (self.doc.item_code, w[0]))
|
||||||
|
if bin and bin[0][0]:
|
||||||
# acknowledge user
|
get_obj("Bin", bin[0][0]).update_entries_after(posting_date = '', posting_time = '')
|
||||||
msgprint("New Stock UOM : " + cstr(self.doc.new_stock_uom) + " updated in Item : " + cstr(self.doc.item_code))
|
|
||||||
|
|
||||||
def update_bin(self):
|
|
||||||
# update bin
|
|
||||||
if flt(self.doc.conversion_factor) != flt(1):
|
|
||||||
sql("update `tabBin` set stock_uom = '%s' , indented_qty = ifnull(indented_qty,0) * %s, ordered_qty = ifnull(ordered_qty,0) * %s, reserved_qty = ifnull(reserved_qty,0) * %s, planned_qty = ifnull(planned_qty,0) * %s, projected_qty = actual_qty + ordered_qty + indented_qty + planned_qty - reserved_qty where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.conversion_factor, self.doc.item_code) )
|
|
||||||
else:
|
|
||||||
sql("update `tabBin` set stock_uom = '%s' where item_code = '%s'" % (self.doc.new_stock_uom, self.doc.item_code) )
|
|
||||||
|
|
||||||
# acknowledge user
|
# acknowledge user
|
||||||
msgprint(" All Bin's Updated Successfully.")
|
msgprint("Item Valuation Updated Successfully.")
|
||||||
|
|
||||||
def update_stock_ledger_entry(self):
|
|
||||||
# update stock ledger entry
|
|
||||||
if flt(self.doc.conversion_factor) != flt(1):
|
|
||||||
sql("update `tabStock Ledger Entry` set stock_uom = '%s', actual_qty = ifnull(actual_qty,0) * '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.conversion_factor, self.doc.item_code))
|
|
||||||
else:
|
|
||||||
sql("update `tabStock Ledger Entry` set stock_uom = '%s' where item_code = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
|
||||||
|
|
||||||
# acknowledge user
|
|
||||||
msgprint("Stock Ledger Entries Updated Successfully.")
|
|
||||||
|
|
||||||
# update item valuation
|
|
||||||
if flt(self.doc.conversion_factor) != flt(1):
|
|
||||||
wh = sql("select name from `tabWarehouse`")
|
|
||||||
for w in wh:
|
|
||||||
bin = sql("select name from `tabBin` where item_code = '%s' and warehouse = '%s'" % (self.doc.item_code, w[0]))
|
|
||||||
if bin and bin[0][0]:
|
|
||||||
get_obj("Bin", bin[0][0]).update_entries_after(posting_date = '', posting_time = '')
|
|
||||||
|
|
||||||
# acknowledge user
|
# Update Stock UOM
|
||||||
msgprint("Item Valuation Updated Successfully.")
|
def update_stock_uom(self):
|
||||||
|
# validate mandatory
|
||||||
|
self.validate_mandatory()
|
||||||
|
|
||||||
|
# update item master
|
||||||
|
self.update_item_master()
|
||||||
|
|
||||||
|
# update stock ledger entry
|
||||||
|
self.update_stock_ledger_entry()
|
||||||
|
|
||||||
|
# update bin
|
||||||
|
self.update_bin()
|
||||||
|
|
||||||
# Update Stock UOM
|
get_obj("Item", self.doc.item_code).on_update()
|
||||||
def update_stock_uom(self):
|
|
||||||
# validate mandatory
|
|
||||||
self.validate_mandatory()
|
|
||||||
|
|
||||||
# update item master
|
|
||||||
self.update_item_master()
|
|
||||||
|
|
||||||
# update stock ledger entry
|
|
||||||
self.update_stock_ledger_entry()
|
|
||||||
|
|
||||||
# update bin
|
|
||||||
self.update_bin()
|
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-06-07 11:02:55',
|
'creation': '2012-06-26 11:58:13',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-06-07 11:24:20',
|
'modified': '2012-08-03 16:10:35',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'Administrator'
|
'owner': u'Administrator'
|
||||||
},
|
},
|
||||||
@ -15,6 +15,7 @@
|
|||||||
'allow_attach': 1,
|
'allow_attach': 1,
|
||||||
'description': u'Keep a track of all communications',
|
'description': u'Keep a track of all communications',
|
||||||
'doctype': 'DocType',
|
'doctype': 'DocType',
|
||||||
|
'document_type': u'Master',
|
||||||
'module': u'Support',
|
'module': u'Support',
|
||||||
'name': '__common__',
|
'name': '__common__',
|
||||||
'version': 1
|
'version': 1
|
||||||
@ -86,7 +87,7 @@
|
|||||||
|
|
||||||
# DocPerm
|
# DocPerm
|
||||||
{
|
{
|
||||||
'cancel': 0,
|
'cancel': 1,
|
||||||
'create': 0,
|
'create': 0,
|
||||||
'doctype': u'DocPerm',
|
'doctype': u'DocPerm',
|
||||||
'permlevel': 1,
|
'permlevel': 1,
|
||||||
@ -99,16 +100,7 @@
|
|||||||
'create': 1,
|
'create': 1,
|
||||||
'doctype': u'DocPerm',
|
'doctype': u'DocPerm',
|
||||||
'permlevel': 0,
|
'permlevel': 0,
|
||||||
'role': u'Administrator'
|
'role': u'Support Manager'
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'cancel': 0,
|
|
||||||
'create': 0,
|
|
||||||
'doctype': u'DocPerm',
|
|
||||||
'permlevel': 1,
|
|
||||||
'role': u'Administrator'
|
|
||||||
},
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
|
Loading…
Reference in New Issue
Block a user