def autoname_folio(self, shareholder, is_company=False): if is_company: doc = self.get_shareholder_doc(shareholder) else: doc = dataent.get_doc('Shareholder', shareholder) doc.folio_no = make_autoname('FN.#####') doc.save() return doc.folio_no
def get_name_from_naming_series(self): """ Get a name generated for a Batch from the Batch's naming series. :return: The string that was generated. """ naming_series_prefix = _get_batch_prefix() # validate_template(naming_series_prefix) naming_series_prefix = render_template(str(naming_series_prefix), self.__dict__) key = _make_naming_series_key(naming_series_prefix) name = make_autoname(key) return name
def test_serialize_status(self): from dataent.model.naming import make_autoname serial_no = dataent.get_doc({ "doctype": "Serial No", "item_code": "_Test Serialized Item With Series", "serial_no": make_autoname("SR", "Serial No") }) serial_no.save() dn = create_delivery_note(item_code="_Test Serialized Item With Series", serial_no=serial_no.name, do_not_submit=True) self.assertRaises(SerialNoWarehouseError, dn.submit)
def autoname(self): if not self.address_title: if self.links: self.address_title = self.links[0].link_name if self.address_title: self.name = (cstr(self.address_title).strip() + "-" + cstr(_(self.address_type)).strip()) if dataent.db.exists("Address", self.name): self.name = make_autoname( cstr(self.address_title).strip() + "-" + cstr(self.address_type).strip() + "-.#") else: throw(_("Address Title is mandatory."))
def autoname(self): """Generate random ID for batch if not specified""" if not self.batch_id: create_new_batch, batch_number_series = dataent.db.get_value('Item', self.item, ['create_new_batch', 'batch_number_series']) if create_new_batch: if batch_number_series: self.batch_id = make_autoname(batch_number_series) elif batch_uses_naming_series(): self.batch_id = self.get_name_from_naming_series() else: self.batch_id = get_name_from_hash() else: dataent.throw(_('Batch ID is mandatory'), dataent.MandatoryError) self.name = self.batch_id
def test_naming_series(self): data = ["TEST-", "TEST/17-18/.test_data./.####", "TEST.YYYY.MM.####"] for series in data: name = make_autoname(series) prefix = series if ".#" in series: prefix = series.rsplit('.', 1)[0] prefix = parse_naming_series(prefix) old_current = dataent.db.get_value('Series', prefix, "current", order_by="name") revert_series_if_last(series, name) new_current = cint( dataent.db.get_value('Series', prefix, "current", order_by="name")) self.assertEqual(cint(old_current) - 1, new_current)
def autoname(self): self.name = make_autoname( self.get(dataent.scrub(self.budget_against)) + "/" + self.fiscal_year + "/.###")
def autoname(self): self.name = make_autoname(self.series)
def get_auto_serial_nos(serial_no_series, qty): serial_nos = [] for i in range(cint(qty)): serial_nos.append(make_autoname(serial_no_series, "Serial No")) return "\n".join(serial_nos)
def autoname(self): prefix = re.sub('-+', '-', self.restaurant.replace(' ', '-')) self.name = make_autoname(prefix + '-.##')