[optimize]: bin updates (#15108)
This commit is contained in:
parent
708e47aadf
commit
f56aac65e1
@ -8,19 +8,11 @@ import frappe.defaults
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class Bin(Document):
|
class Bin(Document):
|
||||||
def validate(self):
|
def before_save(self):
|
||||||
if self.get("__islocal") or not self.stock_uom:
|
if self.get("__islocal") or not self.stock_uom:
|
||||||
self.stock_uom = frappe.db.get_value('Item', self.item_code, 'stock_uom')
|
self.stock_uom = frappe.get_cached_value('Item', self.item_code, 'stock_uom')
|
||||||
|
|
||||||
self.validate_mandatory()
|
|
||||||
self.set_projected_qty()
|
self.set_projected_qty()
|
||||||
|
|
||||||
def validate_mandatory(self):
|
|
||||||
qf = ['actual_qty', 'reserved_qty', 'ordered_qty', 'indented_qty']
|
|
||||||
for f in qf:
|
|
||||||
if (not getattr(self, f, None)) or (not self.get(f)):
|
|
||||||
self.set(f, 0.0)
|
|
||||||
|
|
||||||
def update_stock(self, args, allow_negative_stock=False, via_landed_cost_voucher=False):
|
def update_stock(self, args, allow_negative_stock=False, via_landed_cost_voucher=False):
|
||||||
'''Called from erpnext.stock.utils.update_bin'''
|
'''Called from erpnext.stock.utils.update_bin'''
|
||||||
self.update_qty(args)
|
self.update_qty(args)
|
||||||
|
@ -148,11 +148,9 @@ def update_bin_qty(item_code, warehouse, qty_dict=None):
|
|||||||
mismatch = True
|
mismatch = True
|
||||||
|
|
||||||
if mismatch:
|
if mismatch:
|
||||||
bin.projected_qty = (flt(bin.actual_qty) + flt(bin.ordered_qty) +
|
bin.set_projected_qty()
|
||||||
flt(bin.indented_qty) + flt(bin.planned_qty) - flt(bin.reserved_qty)
|
bin.db_update()
|
||||||
- flt(bin.reserved_qty_for_production)) - flt(bin.reserved_qty_for_sub_contract)
|
bin.clear_cache()
|
||||||
|
|
||||||
bin.save()
|
|
||||||
|
|
||||||
def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, posting_time=None,
|
def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, posting_time=None,
|
||||||
fiscal_year=None):
|
fiscal_year=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user