def make_serial_nos_for_asset(self, asset_items): items_data = get_asset_item_details(asset_items) for d in self.items: if d.is_fixed_asset: item_data = items_data.get(d.item_code) if not d.asset: asset = self.make_asset(d) d.db_set('asset', asset) if item_data.get('has_serial_no'): # If item has serial no if item_data.get('serial_no_series') and not d.serial_no: serial_nos = get_auto_serial_nos(item_data.get('serial_no_series'), d.qty) elif d.serial_no: serial_nos = d.serial_no elif not d.serial_no: frappe.throw(_("Serial no is mandatory for the item {0}").format(d.item_code)) auto_make_serial_nos({ 'serial_no': serial_nos, 'item_code': d.item_code, 'via_stock_ledger': False, 'company': self.company, 'actual_qty': d.qty, 'purchase_document_type': self.doctype, 'purchase_document_no': self.name, 'asset': d.asset, 'location': d.asset_location }) d.db_set('serial_no', serial_nos) if d.asset: self.make_asset_movement(d)
def make_serial_nos_for_asset(self, asset_items): items_data = get_asset_item_details(asset_items) for d in self.items: if d.is_fixed_asset: item_data = items_data.get(d.item_code) if not d.asset: asset = self.make_asset(d) d.db_set('asset', asset) if item_data.get('has_serial_no'): # If item has serial no if item_data.get('serial_no_series') and not d.serial_no: serial_nos = get_auto_serial_nos(item_data.get('serial_no_series'), d.qty) elif d.serial_no: serial_nos = d.serial_no elif not d.serial_no: frappe.throw(_("Serial no is mandatory for the item {0}").format(d.item_code)) auto_make_serial_nos({ 'serial_no': serial_nos, 'item_code': d.item_code, 'via_stock_ledger': False, 'company': self.company, 'actual_qty': d.qty, 'purchase_document_type': self.doctype, 'purchase_document_no': self.name, 'asset': d.asset, 'location': d.asset_location }) d.db_set('serial_no', serial_nos) if d.asset: self.make_asset_movement(d)
def make_serial_nos(self, args): serial_no_series = frappe.get_cached_value("Item", self.production_item, "serial_no_series") if serial_no_series: self.serial_no = get_auto_serial_nos(serial_no_series, self.qty) if self.serial_no: args.update({"serial_no": self.serial_no, "actual_qty": self.qty}) auto_make_serial_nos(args) serial_nos_length = len(get_serial_nos(self.serial_no)) if serial_nos_length != self.qty: frappe.throw(_("{0} Serial Numbers required for Item {1}. You have provided {2}.") .format(self.qty, self.production_item, serial_nos_length), SerialNoQtyError)