Ejemplo n.º 1
0
def update_variants(variants, template, publish_progress=True):
	count=0
	for d in variants:
		variant = frappe.get_doc("Item", d)
		copy_attributes_to_variant(template, variant)
		variant.save()
		count+=1
		if publish_progress:
				frappe.publish_progress(count*100/len(variants), title = _("Updating Variants..."))
Ejemplo n.º 2
0
def update_variants(variants, template, publish_progress=True):
    total = len(variants)
    for count, d in enumerate(variants, start=1):
        variant = frappe.get_doc("Item", d)
        copy_attributes_to_variant(template, variant)
        variant.save()
        if publish_progress:
            frappe.publish_progress(count / total * 100,
                                    title=_("Updating Variants..."))
Ejemplo n.º 3
0
def update_variants(variants, template, publish_progress=True):
	count=0
	for d in variants:
		variant = frappe.get_doc("Item", d)
		copy_attributes_to_variant(template, variant)
		variant.save()
		count+=1
		if publish_progress:
				frappe.publish_progress(count*100/len(variants), title = _("Updating Variants..."))
Ejemplo n.º 4
0
	def update_variants(self):
		if self.has_variants and not self.flags.dont_update_variants:
			updated = []
			variants = frappe.db.get_all("Item", fields=["item_code"], filters={"variant_of": self.name })
			for d in variants:
				variant = frappe.get_doc("Item", d)
				copy_attributes_to_variant(self, variant)
				variant.save()
				updated.append(d.item_code)
			if updated:
				frappe.msgprint(_("Item Variants {0} updated").format(", ".join(updated)))
Ejemplo n.º 5
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.º 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
Ejemplo n.º 9
0
 def copy_variant_attributes(self):
     '''Copy attributes from template (if they have been changed before saving)'''
     if self.variant_of:
         template = frappe.get_doc('Item', self.variant_of)
         copy_attributes_to_variant(template, self)