Beispiel #1
0
def get_item_attributes_values(item_code):
    #template_item_code = frappe.db.get_value("Item", {"item_code":item_code}, "variant_of")
    args = {'item_code': item_code}

    from radplusplus.radplusplus.controllers.configurator import update_user_translations
    update_user_translations(
        frappe.db.get_value("User", frappe.session.user, "language"))

    query = frappe.db.sql("""
			SELECT
				`tabItem Variant Attribute`.attribute,	
				`tabItem Variant Attribute`.attribute as attribute_name_key,				
				`tabItem Variant Attribute`.attribute_value,
				`tabItem Variant Attribute`.attribute_value as item_attribute_value_key
			FROM
				`tabItem Variant Attribute`
			WHERE
				`tabItem Variant Attribute`.parent = %(item_code)s
			ORDER BY
				`tabItem Variant Attribute`.idx ASC""",
                          args,
                          as_dict=1)

    for attribute in query:
        if print_debug: frappe.logger().debug("attribute : " + cstr(attribute))
        attribute["attribute"] = _(attribute["attribute"])
        attribute["attribute_value"] = _(attribute["attribute_value"])

    if print_debug: frappe.logger().debug("attribute : " + cstr(attribute))
    return query
Beispiel #2
0
def boot_session(bootinfo):
    """boot session - add custom translate"""

    lang = frappe.db.get_value("User", frappe.session.user, "language")

    if print_debug: frappe.logger().debug("lang : " + lang)

    from radplusplus.radplusplus.controllers.configurator import update_user_translations
    update_user_translations(lang)
Beispiel #3
0
	def item_attribute_value_list(self):
		from radplusplus.radplusplus.controllers.configurator import update_user_translations 
		update_user_translations(frappe.db.get_value("User", frappe.session.user, "language"))
		
		validate = True
		template = frappe.get_doc("Item", self.template)
		for attribute in template.get("attributes"):
			attribute_validated = False
			for row in self.get("item_attribute_values"):
				if attribute_validated:
					continue
				if row.attribute_name_key == attribute.attribute and row.selected:
					attribute_validated = True
			if not attribute_validated:
				frappe.throw(_("No value selected for {0}").format(_(attribute.attribute)))