当前位置: 首页>>代码示例>>Python>>正文


Python utils.update_bin函数代码示例

本文整理汇总了Python中stock.utils.update_bin函数的典型用法代码示例。如果您正苦于以下问题:Python update_bin函数的具体用法?Python update_bin怎么用?Python update_bin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了update_bin函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_production_order

	def update_production_order(self, is_submit):
		if self.doc.production_order:
			# first perform some validations
			# (they are here coz this fn is also called during on_cancel)
			pro_obj = get_obj("Production Order", self.doc.production_order)
			if flt(pro_obj.doc.docstatus) != 1:
				msgprint("""You cannot do any transaction against 
					Production Order : %s, as it's not submitted"""
					% (pro_obj.doc.name), raise_exception=1)
					
			if pro_obj.doc.status == 'Stopped':
				msgprint("""You cannot do any transaction against Production Order : %s, 
					as it's status is 'Stopped'"""% (pro_obj.doc.name), raise_exception=1)
					
			# update bin
			if self.doc.purpose == "Manufacture/Repack":
				from stock.utils import update_bin
				pro_obj.doc.produced_qty = flt(pro_obj.doc.produced_qty) + \
					(is_submit and 1 or -1 ) * flt(self.doc.fg_completed_qty)
				args = {
					"item_code": pro_obj.doc.production_item,
					"warehouse": pro_obj.doc.fg_warehouse,
					"posting_date": self.doc.posting_date,
					"planned_qty": (is_submit and -1 or 1 ) * flt(self.doc.fg_completed_qty)
				}
				update_bin(args)
			
			# update production order status
			pro_obj.doc.status = (flt(pro_obj.doc.qty)==flt(pro_obj.doc.produced_qty)) \
				and 'Completed' or 'In Process'
			pro_obj.doc.save()
开发者ID:mxmo-co,项目名称:erpnext,代码行数:31,代码来源:stock_entry.py

示例2: make_sl_entries

def make_sl_entries(sl_entries, is_amended=None):
	if sl_entries:
		from stock.utils import update_bin
	
		cancel = True if sl_entries[0].get("is_cancelled") == "Yes" else False
		if cancel:
			set_as_cancel(sl_entries[0].get('voucher_no'), sl_entries[0].get('voucher_type'))
	
		for sle in sl_entries:
			sle_id = None
			if sle.get('is_cancelled') == 'Yes':
				sle['actual_qty'] = -flt(sle['actual_qty'])
			
			#webnotes.errprint(sle.get('doctype')) 
			#webnotes.errprint(sle.get("actual_qty") or sle.get("doctype") != 'pm')	
			#if ((sle.get("actual_qty")) and (sle.get("doctype") != 'pm')):
			#	webnotes.errprint("if lop")
			#	sle_id = make_entry(sle)
			if sle.get("actual_qty"):
				sle_id = make_entry(sle)
			
			args = sle.copy()
			webnotes.errprint(['in_ copy',args])
			args.update({
				"sle_id": sle_id,
				"is_amended": is_amended
			})
			webnotes.errprint(args)
			update_bin(args)
			webnotes.errprint(['in sl_entries ',args])
		
		if cancel:
			delete_cancelled_entry(sl_entries[0].get('voucher_type'), 
				sl_entries[0].get('voucher_no'))
开发者ID:Tejal011089,项目名称:Medsyn2_app,代码行数:34,代码来源:stock_ledger.py

示例3: make_sl_entries

def make_sl_entries(sl_entries, is_amended=None):
	if sl_entries:
		from stock.utils import update_bin
	
		cancel = True if sl_entries[0].get("is_cancelled") == "Yes" else False
		if cancel:
			set_as_cancel(sl_entries[0].get('voucher_no'), sl_entries[0].get('voucher_type'))
	
		for sle in sl_entries:
			sle_id = None
			if sle.get('is_cancelled') == 'Yes':
				sle['actual_qty'] = -flt(sle['actual_qty'])
		
			if sle.get("actual_qty"):
				sle_id = make_entry(sle)
			
			args = sle.copy()
			args.update({
				"sle_id": sle_id,
				"is_amended": is_amended
			})
			update_bin(args)
		
		if cancel:
			delete_cancelled_entry(sl_entries[0].get('voucher_type'), 
				sl_entries[0].get('voucher_no'))
开发者ID:CarlosAnt,项目名称:erpnext,代码行数:26,代码来源:stock_ledger.py

示例4: _update_requested_qty

def _update_requested_qty(controller, mr_obj, mr_items):
	"""update requested qty (before ordered_qty is updated)"""
	from stock.utils import update_bin
	for mr_item_name in mr_items:
		mr_item = mr_obj.doclist.getone({"parentfield": "indent_details", "name": mr_item_name})
		se_detail = controller.doclist.getone({"parentfield": "mtn_details",
			"material_request": mr_obj.doc.name, "material_request_item": mr_item_name})
	
		mr_item.ordered_qty = flt(mr_item.ordered_qty)
		mr_item.qty = flt(mr_item.qty)
		se_detail.transfer_qty = flt(se_detail.transfer_qty)
	
		if se_detail.docstatus == 2 and mr_item.ordered_qty > mr_item.qty \
				and se_detail.transfer_qty == mr_item.ordered_qty:
			add_indented_qty = mr_item.qty
		elif se_detail.docstatus == 1 and \
				mr_item.ordered_qty + se_detail.transfer_qty > mr_item.qty:
			add_indented_qty = mr_item.qty - mr_item.ordered_qty
		else:
			add_indented_qty = se_detail.transfer_qty
	
		update_bin({
			"item_code": se_detail.item_code,
			"warehouse": se_detail.t_warehouse,
			"indented_qty": (se_detail.docstatus==2 and 1 or -1) * add_indented_qty,
			"posting_date": controller.doc.posting_date,
		})
开发者ID:LPlusPlus,项目名称:erpnext,代码行数:27,代码来源:material_request.py

示例5: update_planned_qty

	def update_planned_qty(self, pro_bean):
		from stock.utils import update_bin
		update_bin({
			"item_code": pro_bean.doc.production_item,
			"warehouse": pro_bean.doc.fg_warehouse,
			"posting_date": self.doc.posting_date,
			"planned_qty": (self.doc.docstatus==1 and -1 or 1 ) * flt(self.doc.fg_completed_qty)
		})
开发者ID:Jdfkat,项目名称:erpnext,代码行数:8,代码来源:stock_entry.py

示例6: update_planned_qty

	def update_planned_qty(self, qty):
		"""update planned qty in bin"""
		args = {
			"item_code": self.doc.production_item,
			"warehouse": self.doc.fg_warehouse,
			"posting_date": nowdate(),
			"planned_qty": flt(qty)
		}
		from stock.utils import update_bin
		update_bin(args)
开发者ID:Anirudh887,项目名称:erpnext,代码行数:10,代码来源:production_order.py

示例7: repost_stock

def repost_stock(item_code, warehouse):
	repost_actual_qty(item_code, warehouse)
	
	if item_code and warehouse:
		update_bin(item_code, warehouse, {
			"reserved_qty": get_reserved_qty(item_code, warehouse),
			"indented_qty": get_indented_qty(item_code, warehouse),
			"ordered_qty": get_ordered_qty(item_code, warehouse),
			"planned_qty": get_planned_qty(item_code, warehouse)
		})
开发者ID:aproxp,项目名称:erpnext,代码行数:10,代码来源:repost_stock.py

示例8: update_stock_ledger

	def update_stock_ledger(self, update_stock, is_stopped = 0):
		from stock.utils import update_bin
		for d in self.get_item_list(is_stopped):
			if webnotes.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
				args = {
					"item_code": d['item_code'],
					"warehouse": d['reserved_warehouse'], 
					"reserved_qty": flt(update_stock) * flt(d['reserved_qty']),
					"posting_date": self.doc.transaction_date,
					"voucher_type": self.doc.doctype,
					"voucher_no": self.doc.name,
					"is_amended": self.doc.amended_from and 'Yes' or 'No'
				}
				update_bin(args)
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:14,代码来源:sales_order.py

示例9: update_reserved_qty

	def update_reserved_qty(self, d):
		if d['reserved_qty'] < 0 :
			# Reduce reserved qty from reserved warehouse mentioned in so
			if not d["reserved_warehouse"]:
				webnotes.throw(_("Reserved Warehouse is missing in Sales Order"))
				
			args = {
				"item_code": d['item_code'],
				"warehouse": d["reserved_warehouse"],
				"voucher_type": self.doc.doctype,
				"voucher_no": self.doc.name,
				"reserved_qty": (self.doc.docstatus==1 and 1 or -1)*flt(d['reserved_qty']),
				"posting_date": self.doc.posting_date,
				"is_amended": self.doc.amended_from and 'Yes' or 'No'
			}
			update_bin(args)
开发者ID:LPlusPlus,项目名称:erpnext,代码行数:16,代码来源:delivery_note.py

示例10: update_bin

	def update_bin(self, is_submit, is_stopped = 0):
		from stock.utils import update_bin
		pc_obj = get_obj('Purchase Common')
		for d in getlist(self.doclist, 'po_details'):
			#1. Check if is_stock_item == 'Yes'
			if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
				# this happens when item is changed from non-stock to stock item
				if not d.warehouse:
					continue
				
				ind_qty, po_qty = 0, flt(d.qty) * flt(d.conversion_factor)
				if is_stopped:
					po_qty = flt(d.qty) > flt(d.received_qty) and \
						flt( flt(flt(d.qty) - flt(d.received_qty))*flt(d.conversion_factor)) or 0 
				
				# No updates in Material Request on Stop / Unstop
				if cstr(d.prevdoc_doctype) == 'Material Request' and not is_stopped:
					# get qty and pending_qty of prevdoc 
					curr_ref_qty = pc_obj.get_qty(d.doctype, 'prevdoc_detail_docname',
					 	d.prevdoc_detail_docname, 'Material Request Item', 
						'Material Request - Purchase Order', self.doc.name)
					max_qty, qty, curr_qty = flt(curr_ref_qty.split('~~~')[1]), \
					 	flt(curr_ref_qty.split('~~~')[0]), 0
					
					if flt(qty) + flt(po_qty) > flt(max_qty):
						curr_qty = flt(max_qty) - flt(qty)
						# special case as there is no restriction 
						# for Material Request - Purchase Order 
						curr_qty = curr_qty > 0 and curr_qty or 0
					else:
						curr_qty = flt(po_qty)
					
					ind_qty = -flt(curr_qty)

				# Update ordered_qty and indented_qty in bin
				args = {
					"item_code": d.item_code,
					"warehouse": d.warehouse,
					"ordered_qty": (is_submit and 1 or -1) * flt(po_qty),
					"indented_qty": (is_submit and 1 or -1) * flt(ind_qty),
					"posting_date": self.doc.transaction_date
				}
				update_bin(args)
开发者ID:CarlosAnt,项目名称:erpnext,代码行数:43,代码来源:purchase_order.py

示例11: update_bin

	def update_bin(self, is_submit, is_stopped):
		""" Update Quantity Requested for Purchase in Bin for Material Request of type 'Purchase'"""
		
		from stock.utils import update_bin
		for d in getlist(self.doclist, 'indent_details'):
			if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
				if not d.warehouse:
					msgprint("Please Enter Warehouse for Item %s as it is stock item" 
						% cstr(d.item_code), raise_exception=1)
					
				qty =flt(d.qty)
				if is_stopped:
					qty = (d.qty > d.ordered_qty) and flt(flt(d.qty) - flt(d.ordered_qty)) or 0
			
				args = {
					"item_code": d.item_code,
					"warehouse": d.warehouse,
					"indented_qty": (is_submit and 1 or -1) * flt(qty),
					"posting_date": self.doc.transaction_date
				}
				update_bin(args)		
开发者ID:LPlusPlus,项目名称:erpnext,代码行数:21,代码来源:material_request.py

示例12: update_ordered_qty

	def update_ordered_qty(self):
		stock_items = self.get_stock_items()
		for d in self.doclist.get({"parentfield": "purchase_receipt_details"}):
			if d.item_code in stock_items and d.warehouse \
					and cstr(d.prevdoc_doctype) == 'Purchase Order':
									
				already_received_qty = self.get_already_received_qty(d.prevdoc_docname, 
					d.prevdoc_detail_docname)
				po_qty, ordered_warehouse = self.get_po_qty_and_warehouse(d.prevdoc_detail_docname)
				
				if not ordered_warehouse:
					webnotes.throw(_("Warehouse is missing in Purchase Order"))
				
				if already_received_qty + d.qty > po_qty:
					ordered_qty = - (po_qty - already_received_qty) * flt(d.conversion_factor)
				else:
					ordered_qty = - flt(d.qty) * flt(d.conversion_factor)
				
				update_bin({
					"item_code": d.item_code,
					"warehouse": ordered_warehouse,
					"posting_date": self.doc.posting_date,
					"ordered_qty": flt(ordered_qty) if self.doc.docstatus==1 else -flt(ordered_qty)
				})
开发者ID:rohitw1991,项目名称:innoworth-app,代码行数:24,代码来源:purchase_receipt.py

示例13: set_stock_balance_as_per_serial_no

def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, posting_time=None,
	 	fiscal_year=None):
	from webnotes.utils import flt, cstr
	from webnotes.model.doc import Document
	from stock.utils import update_bin
	from stock.stock_ledger import update_entries_after
	from accounts.utils import get_fiscal_year
	
	if not posting_date: posting_date = nowdate()
	if not posting_time: posting_time = nowtime()
	if not fiscal_year: fiscal_year = get_fiscal_year(posting_date)[0]
	
	condition = " and item.name='%s'" % item_code.replace("'", "\'") if item_code else ""
		
	bin = webnotes.conn.sql("""select bin.item_code, bin.warehouse, bin.actual_qty, item.stock_uom 
		from `tabBin` bin, tabItem item 
		where bin.item_code = item.name and item.has_serial_no = 'Yes' %s""" % condition)

	for d in bin:
		serial_nos = webnotes.conn.sql("""select count(name) from `tabSerial No` 
			where item_code=%s and warehouse=%s and status = 'Available' and docstatus < 2""", (d[0], d[1]))

		if serial_nos and flt(serial_nos[0][0]) != flt(d[2]):
			print d[0], d[1], d[2], serial_nos[0][0]

		sle = webnotes.conn.sql("""select valuation_rate, company from `tabStock Ledger Entry`
			where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' 
			order by posting_date desc limit 1""", (d[0], d[1]))

		sl_entries = {
			'doctype'					: 'Stock Ledger Entry',
			'item_code'					: d[0],
			'warehouse'					: d[1],
			'transaction_date'	 		: nowdate(),
			'posting_date'				: posting_date,
			'posting_time'			 	: posting_time,
			'voucher_type'			 	: 'Stock Reconciliation (Manual)',
			'voucher_no'				: '',
			'voucher_detail_no'			: '',
			'actual_qty'				: flt(serial_nos[0][0]) - flt(d[2]),
			'stock_uom'					: d[3],
			'incoming_rate'				: sle and flt(serial_nos[0][0]) > flt(d[2]) and flt(sle[0][0]) or 0,
			'company'					: sle and cstr(sle[0][1]) or 0,
			'fiscal_year'				: fiscal_year,
			'is_cancelled'			 	: 'No',
			'batch_no'					: '',
			'serial_no'					: ''
		}
		
		sle = Document(fielddata=sl_entries)
		sle = sle.insert()
		
		args = sl_entries.copy()
		args.update({
			"sle_id": sle.name,
			"is_amended": 'No'
		})
		
		update_bin(args)
		update_entries_after({
			"item_code": d[0],
			"warehouse": d[1],
			"posting_date": posting_date,
			"posting_time": posting_time
		})
开发者ID:aproxp,项目名称:erpnext,代码行数:65,代码来源:repost_stock.py


注:本文中的stock.utils.update_bin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。