Ejemplo n.º 1
0
    def autoname(self):
        if frappe.db.get_default("item_naming_by") == "Naming Series":
            if self.variant_of:
                if not self.item_code:
                    template_item_name = frappe.db.get_value(
                        "Item", self.variant_of, "item_name")
                    make_variant_item_code(self.variant_of, template_item_name,
                                           self)
            else:
                from frappe.model.naming import set_name_by_naming_series
                set_name_by_naming_series(self)
                self.item_code = self.name

        self.item_code = strip(self.item_code)
        self.name = self.item_code
Ejemplo n.º 2
0
	def autoname(self):
		override = get_override_naming_by(self.item_group, self.brand, self.item_naming_by)
		if override.override_naming_by:
			self.item_naming_by = override.override_naming_by
			if override.override_naming_series:
				self.naming_series = override.override_naming_series

		if self.item_naming_by == "Item Code" and not self.item_code:
			frappe.throw(_("Item Code is mandatory"))

		if self.item_naming_by == "Item Name" and not self.item_name:
			frappe.throw(_("Item Name is mandatory"))

		if self.item_naming_by == "Naming Series":
			if self.variant_of:
				if not self.item_code:
					template_item_name = frappe.db.get_value("Item", self.variant_of, "item_name")
					self.item_code = make_variant_item_code(self.variant_of, template_item_name, self)
			else:
				from frappe.model.naming import set_name_by_naming_series
				set_name_by_naming_series(self)
				self.item_code = self.name
		elif self.item_naming_by == "Item Code":
			self.item_code = self.clean_name(self.item_code)
			self.name = self.item_code
		elif self.item_naming_by == "Item Name":
			self.validate_item_name()
			self.name = self.item_code = self.item_name
Ejemplo n.º 3
0
def create_variant_with_tables(item, args):
	if isinstance(args, string_types):
		args = json.loads(args)

	qc_name = make_quality_inspection_template()
	template = frappe.get_doc("Item", item)
	template.quality_inspection_template = qc_name
	template.save()

	variant = frappe.new_doc("Item")
	variant.variant_based_on = "Item Attribute"
	variant_attributes = []

	for d in template.attributes:
		variant_attributes.append({"attribute": d.attribute, "attribute_value": args.get(d.attribute)})

	variant.set("attributes", variant_attributes)
	copy_attributes_to_variant(template, variant)
	make_variant_item_code(template.item_code, template.item_name, variant)

	return variant
Ejemplo n.º 4
0
	def autoname(self):
		if frappe.db.get_default("item_naming_by")=="Naming Series":
			if self.variant_of:
				if not self.item_code:
					self.item_code = make_variant_item_code(self.variant_of, self)
			else:
				from frappe.model.naming import make_autoname
				self.item_code = make_autoname(self.naming_series+'.#####')
		elif not self.item_code:
			msgprint(_("Item Code is mandatory because Item is not automatically numbered"), raise_exception=1)

		self.item_code = strip(self.item_code)
		self.name = self.item_code
Ejemplo n.º 5
0
	def autoname(self):
		if frappe.db.get_default("item_naming_by") == "Naming Series":
			if self.variant_of:
				if not self.item_code:
					template_item_name = frappe.db.get_value("Item", self.variant_of, "item_name")
					self.item_code = make_variant_item_code(self.variant_of, template_item_name, self)
			else:
				from frappe.model.naming import set_name_by_naming_series
				set_name_by_naming_series(self)
				self.item_code = self.name
		elif not self.item_code:
			msgprint(_("Item Code is mandatory because Item is not automatically numbered"), raise_exception=1)

		self.item_code = strip(self.item_code)
		self.name = self.item_code
Ejemplo n.º 6
0
def create_variant_with_tables(item, args):
	if isinstance(args, basestring):
		args = json.loads(args)

	template = frappe.get_doc("Item", item)
	template.quality_parameters.append({
		"specification": "Moisture",
		"value": "< 5%",
	})
	variant = frappe.new_doc("Item")
	variant.variant_based_on = 'Item Attribute'
	variant_attributes = []

	for d in template.attributes:
		variant_attributes.append({
			"attribute": d.attribute,
			"attribute_value": args.get(d.attribute)
		})

	variant.set("attributes", variant_attributes)
	copy_attributes_to_variant(template, variant)
	make_variant_item_code(template.item_code, template.item_name, variant)

	return variant
Ejemplo n.º 7
0
def create_variant_with_tables(item, args):
    if isinstance(args, basestring):
        args = json.loads(args)

    template = frappe.get_doc("Item", item)
    template.quality_parameters.append({
        "specification": "Moisture",
        "value": "< 5%",
    })
    variant = frappe.new_doc("Item")
    variant.variant_based_on = 'Item Attribute'
    variant_attributes = []

    for d in template.attributes:
        variant_attributes.append({
            "attribute": d.attribute,
            "attribute_value": args.get(d.attribute)
        })

    variant.set("attributes", variant_attributes)
    copy_attributes_to_variant(template, variant)
    make_variant_item_code(template.item_code, template.item_name, variant)

    return variant
Ejemplo n.º 8
0
def create_variant_with_tables(item, args):
	if isinstance(args, string_types):
		args = json.loads(args)

	qc_name = make_quality_inspection_template()
	template = frappe.get_doc("Item", item)
	template.quality_inspection_template = qc_name
	template.save()

	variant = frappe.new_doc("Item")
	variant.variant_based_on = 'Item Attribute'
	variant_attributes = []

	for d in template.attributes:
		variant_attributes.append({
			"attribute": d.attribute,
			"attribute_value": args.get(d.attribute)
		})

	variant.set("attributes", variant_attributes)
	copy_attributes_to_variant(template, variant)
	make_variant_item_code(template.item_code, template.item_name, variant)

	return variant