fix(product-listing): fix variant selection in website
This commit is contained in:
parent
7e36aa4162
commit
8705371ef0
@ -178,7 +178,7 @@ def create_variant(item, args):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def enqueue_multiple_variant_creation(item, args):
|
def enqueue_multiple_variant_creation(item, args):
|
||||||
# There can be innumerable attribute combinations, enqueue
|
# There can be innumerable attribute combinations, enqueue
|
||||||
if isinstance(args, basestring):
|
if isinstance(args, frappe.string_types):
|
||||||
variants = json.loads(args)
|
variants = json.loads(args)
|
||||||
total_variants = 1
|
total_variants = 1
|
||||||
for key in variants:
|
for key in variants:
|
||||||
@ -186,10 +186,15 @@ def enqueue_multiple_variant_creation(item, args):
|
|||||||
if total_variants >= 600:
|
if total_variants >= 600:
|
||||||
frappe.msgprint("Please do not create more than 500 items at a time", raise_exception=1)
|
frappe.msgprint("Please do not create more than 500 items at a time", raise_exception=1)
|
||||||
return
|
return
|
||||||
frappe.enqueue("erpnext.controllers.item_variant.create_multiple_variants",
|
if total_variants < 10:
|
||||||
item=item, args=args, now=frappe.flags.in_test);
|
return create_multiple_variants(item, args)
|
||||||
|
else:
|
||||||
|
frappe.enqueue("erpnext.controllers.item_variant.create_multiple_variants",
|
||||||
|
item=item, args=args, now=frappe.flags.in_test);
|
||||||
|
return 'queued'
|
||||||
|
|
||||||
def create_multiple_variants(item, args):
|
def create_multiple_variants(item, args):
|
||||||
|
count = 0
|
||||||
if isinstance(args, string_types):
|
if isinstance(args, string_types):
|
||||||
args = json.loads(args)
|
args = json.loads(args)
|
||||||
|
|
||||||
@ -199,6 +204,9 @@ def create_multiple_variants(item, args):
|
|||||||
if not get_variant(item, args=attribute_values):
|
if not get_variant(item, args=attribute_values):
|
||||||
variant = create_variant(item, attribute_values)
|
variant = create_variant(item, attribute_values)
|
||||||
variant.save()
|
variant.save()
|
||||||
|
count +=1
|
||||||
|
|
||||||
|
return count
|
||||||
|
|
||||||
def generate_keyed_value_combinations(args):
|
def generate_keyed_value_combinations(args):
|
||||||
"""
|
"""
|
||||||
|
@ -117,11 +117,11 @@ def update_disbursement_status(doc):
|
|||||||
if disbursement.disbursed_amount > 0:
|
if disbursement.disbursed_amount > 0:
|
||||||
frappe.db.set_value("Loan", doc.name , "disbursement_date", disbursement.posting_date)
|
frappe.db.set_value("Loan", doc.name , "disbursement_date", disbursement.posting_date)
|
||||||
frappe.db.set_value("Loan", doc.name , "repayment_start_date", disbursement.posting_date)
|
frappe.db.set_value("Loan", doc.name , "repayment_start_date", disbursement.posting_date)
|
||||||
|
|
||||||
def check_repayment_method(repayment_method, loan_amount, monthly_repayment_amount, repayment_periods):
|
def check_repayment_method(repayment_method, loan_amount, monthly_repayment_amount, repayment_periods):
|
||||||
if repayment_method == "Repay Over Number of Periods" and not repayment_periods:
|
if repayment_method == "Repay Over Number of Periods" and not repayment_periods:
|
||||||
frappe.throw(_("Please enter Repayment Periods"))
|
frappe.throw(_("Please enter Repayment Periods"))
|
||||||
|
|
||||||
if repayment_method == "Repay Fixed Amount per Period":
|
if repayment_method == "Repay Fixed Amount per Period":
|
||||||
if not monthly_repayment_amount:
|
if not monthly_repayment_amount:
|
||||||
frappe.throw(_("Please enter repayment Amount"))
|
frappe.throw(_("Please enter repayment Amount"))
|
||||||
@ -148,7 +148,7 @@ def get_loan_application(loan_application):
|
|||||||
def make_repayment_entry(payment_rows, loan, company, loan_account, applicant_type, applicant, \
|
def make_repayment_entry(payment_rows, loan, company, loan_account, applicant_type, applicant, \
|
||||||
payment_account=None, interest_income_account=None):
|
payment_account=None, interest_income_account=None):
|
||||||
|
|
||||||
if isinstance(payment_rows, basestring):
|
if isinstance(payment_rows, frappe.string_types):
|
||||||
payment_rows_list = json.loads(payment_rows)
|
payment_rows_list = json.loads(payment_rows)
|
||||||
else:
|
else:
|
||||||
frappe.throw(_("No repayments available for Journal Entry"))
|
frappe.throw(_("No repayments available for Journal Entry"))
|
||||||
|
@ -73,7 +73,7 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({
|
|||||||
if (me.after_insert) {
|
if (me.after_insert) {
|
||||||
me.after_insert(me.dialog.doc);
|
me.after_insert(me.dialog.doc);
|
||||||
} else {
|
} else {
|
||||||
me.open_from_if_not_list();
|
me.open_form_if_not_list();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -303,8 +303,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.product-text {
|
.product-text {
|
||||||
border-top: 1px solid @light-border-color;
|
|
||||||
padding: 15px;
|
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
height: 75px;
|
height: 75px;
|
||||||
display: block; /* Fallback for non-webkit */
|
display: block; /* Fallback for non-webkit */
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -80,6 +80,12 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
|||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_product_list_for_group(product_group=None, start=0, limit=10, search=None):
|
def get_product_list_for_group(product_group=None, start=0, limit=10, search=None):
|
||||||
|
if product_group:
|
||||||
|
item_group = frappe.get_cached_doc('Item Group', product_group)
|
||||||
|
if item_group.is_group:
|
||||||
|
# return child item groups if the type is of "Is Group"
|
||||||
|
return get_child_groups_for_list_in_html(item_group, start, limit, search)
|
||||||
|
|
||||||
child_groups = ", ".join(['"' + frappe.db.escape(i[0]) + '"' for i in get_child_groups(product_group)])
|
child_groups = ", ".join(['"' + frappe.db.escape(i[0]) + '"' for i in get_child_groups(product_group)])
|
||||||
|
|
||||||
# base query
|
# base query
|
||||||
@ -113,6 +119,23 @@ def get_product_list_for_group(product_group=None, start=0, limit=10, search=Non
|
|||||||
|
|
||||||
return [get_item_for_list_in_html(r) for r in data]
|
return [get_item_for_list_in_html(r) for r in data]
|
||||||
|
|
||||||
|
def get_child_groups_for_list_in_html(item_group, start, limit, search):
|
||||||
|
search_filters = None
|
||||||
|
if search_filters:
|
||||||
|
search_filters = [
|
||||||
|
dict(name = ('like', '%{}%'.format(search))),
|
||||||
|
dict(description = ('like', '%{}%'.format(search)))
|
||||||
|
]
|
||||||
|
data = frappe.db.get_all('Item Group',
|
||||||
|
fields = ['name', 'route', 'description', 'image'],
|
||||||
|
filters = dict(
|
||||||
|
show_in_website = 1,
|
||||||
|
lft = ('>', item_group.lft),
|
||||||
|
rgt = ('<', item_group.rgt),
|
||||||
|
),
|
||||||
|
or_filters = search_filters)
|
||||||
|
|
||||||
|
return [get_item_for_list_in_html(r) for r in data]
|
||||||
|
|
||||||
def adjust_qty_for_expired_items(data):
|
def adjust_qty_for_expired_items(data):
|
||||||
adjusted_data = []
|
adjusted_data = []
|
||||||
@ -128,7 +151,6 @@ def adjust_qty_for_expired_items(data):
|
|||||||
return adjusted_data
|
return adjusted_data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_child_groups(item_group_name):
|
def get_child_groups(item_group_name):
|
||||||
item_group = frappe.get_doc("Item Group", item_group_name)
|
item_group = frappe.get_doc("Item Group", item_group_name)
|
||||||
return frappe.db.sql("""select name
|
return frappe.db.sql("""select name
|
||||||
@ -160,12 +182,13 @@ def get_parent_item_groups(item_group_name):
|
|||||||
if not item_group_name:
|
if not item_group_name:
|
||||||
return [{"name": frappe._("Home"), "route":"/"}]
|
return [{"name": frappe._("Home"), "route":"/"}]
|
||||||
item_group = frappe.get_doc("Item Group", item_group_name)
|
item_group = frappe.get_doc("Item Group", item_group_name)
|
||||||
return [{"name": frappe._("Home"), "route":"/"}]+\
|
parent_groups = frappe.db.sql("""select name, route from `tabItem Group`
|
||||||
frappe.db.sql("""select name, route from `tabItem Group`
|
|
||||||
where lft <= %s and rgt >= %s
|
where lft <= %s and rgt >= %s
|
||||||
and show_in_website=1
|
and show_in_website=1
|
||||||
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
|
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
|
||||||
|
|
||||||
|
return [{"name": frappe._("Home"), "route":"/"}] + parent_groups
|
||||||
|
|
||||||
def invalidate_cache_for(doc, item_group=None):
|
def invalidate_cache_for(doc, item_group=None):
|
||||||
if not item_group:
|
if not item_group:
|
||||||
item_group = doc.name
|
item_group = doc.name
|
||||||
|
@ -235,7 +235,7 @@ $.extend(erpnext.item, {
|
|||||||
frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) {
|
frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) {
|
||||||
const row = locals[cdt][cdn];
|
const row = locals[cdt][cdn];
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
"is_group": 0,
|
"is_group": 0,
|
||||||
"company": row.company
|
"company": row.company
|
||||||
}
|
}
|
||||||
@ -441,11 +441,18 @@ $.extend(erpnext.item, {
|
|||||||
"item": frm.doc.name,
|
"item": frm.doc.name,
|
||||||
"args": selected_attributes
|
"args": selected_attributes
|
||||||
},
|
},
|
||||||
callback: function() {
|
callback: function(r) {
|
||||||
frappe.show_alert({
|
if (r.message==='queued') {
|
||||||
message: __("Variant creation has been queued."),
|
frappe.show_alert({
|
||||||
indicator: 'orange'
|
message: __("Variant creation has been queued."),
|
||||||
});
|
indicator: 'orange'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
frappe.show_alert({
|
||||||
|
message: __("{0} variants created.", [r.message]),
|
||||||
|
indicator: 'green'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -309,8 +309,8 @@ class Item(WebsiteGenerator):
|
|||||||
# load variants
|
# load variants
|
||||||
# also used in set_attribute_context
|
# also used in set_attribute_context
|
||||||
context.variants = frappe.get_all("Item",
|
context.variants = frappe.get_all("Item",
|
||||||
filters={"variant_of": self.name, "show_variant_in_website": 1},
|
filters={"variant_of": self.name, "show_variant_in_website": 1},
|
||||||
order_by="name asc")
|
order_by="name asc")
|
||||||
|
|
||||||
variant = frappe.form_dict.variant
|
variant = frappe.form_dict.variant
|
||||||
if not variant and context.variants:
|
if not variant and context.variants:
|
||||||
@ -344,7 +344,8 @@ class Item(WebsiteGenerator):
|
|||||||
# load attributes
|
# load attributes
|
||||||
for v in context.variants:
|
for v in context.variants:
|
||||||
v.attributes = frappe.get_all("Item Variant Attribute",
|
v.attributes = frappe.get_all("Item Variant Attribute",
|
||||||
fields=["attribute", "attribute_value"], filters={"parent": v.name})
|
fields=["attribute", "attribute_value"],
|
||||||
|
filters={"parent": v.name})
|
||||||
|
|
||||||
for attr in v.attributes:
|
for attr in v.attributes:
|
||||||
values = attribute_values_available.setdefault(attr.attribute, [])
|
values = attribute_values_available.setdefault(attr.attribute, [])
|
||||||
@ -365,7 +366,8 @@ class Item(WebsiteGenerator):
|
|||||||
else:
|
else:
|
||||||
# get list of values defined (for sequence)
|
# get list of values defined (for sequence)
|
||||||
for attr_value in frappe.db.get_all("Item Attribute Value",
|
for attr_value in frappe.db.get_all("Item Attribute Value",
|
||||||
fields=["attribute_value"], filters={"parent": attr.attribute}, order_by="idx asc"):
|
fields=["attribute_value"],
|
||||||
|
filters={"parent": attr.attribute}, order_by="idx asc"):
|
||||||
|
|
||||||
if attr_value.attribute_value in attribute_values_available.get(attr.attribute, []):
|
if attr_value.attribute_value in attribute_values_available.get(attr.attribute, []):
|
||||||
values.append(attr_value.attribute_value)
|
values.append(attr_value.attribute_value)
|
||||||
@ -441,7 +443,7 @@ class Item(WebsiteGenerator):
|
|||||||
for d in template.get("reorder_levels"):
|
for d in template.get("reorder_levels"):
|
||||||
n = {}
|
n = {}
|
||||||
for k in ("warehouse", "warehouse_reorder_level",
|
for k in ("warehouse", "warehouse_reorder_level",
|
||||||
"warehouse_reorder_qty", "material_request_type"):
|
"warehouse_reorder_qty", "material_request_type"):
|
||||||
n[k] = d.get(k)
|
n[k] = d.get(k)
|
||||||
self.append("reorder_levels", n)
|
self.append("reorder_levels", n)
|
||||||
|
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
<br>
|
<br>
|
||||||
<div class="item-attribute-selectors">
|
<div class="item-attribute-selectors">
|
||||||
{% if has_variants and attributes %}
|
{% if has_variants and attributes %}
|
||||||
{{ attributes }}
|
|
||||||
{#
|
|
||||||
|
|
||||||
{% for d in attributes %}
|
{% for d in attributes %}
|
||||||
{% if attribute_values[d.attribute] -%}
|
{% if attribute_values[d.attribute] -%}
|
||||||
@ -69,7 +67,6 @@
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
#}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
@ -1,16 +1,6 @@
|
|||||||
{% extends "templates/web.html" %}
|
{% extends "templates/web.html" %}
|
||||||
|
|
||||||
{% block header %}<h1>{{ _("Products") }}</h1>{% endblock %}
|
{% block header %}<h1>{{ name }}</h1>{% endblock %}
|
||||||
{% block breadcrumbs %}
|
|
||||||
<div class="page-breadcrumbs" data-html-block="breadcrumbs">
|
|
||||||
<ul class="breadcrumb">
|
|
||||||
<li>
|
|
||||||
<span class="fa fa-angle-left"></span>
|
|
||||||
<a href="/me">{{ _("My Account") }}</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<div class="item-group-content" itemscope itemtype="http://schema.org/Product">
|
<div class="item-group-content" itemscope itemtype="http://schema.org/Product">
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
<a class="product-link product-list-link" href="{{ route|abs_url }}">
|
<a class="product-link product-list-link" href="{{ route|abs_url }}">
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<div class='col-xs-3 col-sm-2 product-image-wrapper'>
|
<div class='col-xs-3 col-sm-2 product-image-wrapper'>
|
||||||
{{ product_image_square(thumbnail or website_image) }}
|
{{ product_image_square(thumbnail or website_image or image) }}
|
||||||
</div>
|
</div>
|
||||||
<div class='col-xs-9 col-sm-10 text-left'>
|
<div class='col-xs-9 col-sm-10 text-left'>
|
||||||
<div class="product-text strong">{{ item_name }}</div>
|
<div class="product-text strong">{{ item_name or name }}</div>
|
||||||
{% set website_description = website_description or description %}
|
{% set website_description = website_description or description %}
|
||||||
{% if website_description != item_name %}
|
{% if website_description != item_name %}
|
||||||
<div class="text-muted">{{ website_description or description }}</div>
|
<div class="text-muted">{{ website_description or description }}</div>
|
||||||
{% elif item_code != item_name %}
|
{% elif item_code and item_code != item_name %}
|
||||||
<div class="text-muted">{{ _('Item Code') }}: {{ item_code }}</div>
|
<div class="text-muted">{{ _('Item Code') }}: {{ item_code }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,8 +24,9 @@ def get_product_list(search=None, start=0, limit=12):
|
|||||||
I.has_batch_no
|
I.has_batch_no
|
||||||
from `tabItem` I
|
from `tabItem` I
|
||||||
left join tabBin S on I.item_code = S.item_code and I.website_warehouse = S.warehouse
|
left join tabBin S on I.item_code = S.item_code and I.website_warehouse = S.warehouse
|
||||||
where (I.show_in_website = 1 or I.show_variant_in_website = 1)
|
where (I.show_in_website = 1)
|
||||||
and I.disabled = 0
|
and I.disabled = 0
|
||||||
|
and (I.variant_of is null or I.variant_of='')
|
||||||
and (I.end_of_life is null or I.end_of_life='0000-00-00' or I.end_of_life > %(today)s)"""
|
and (I.end_of_life is null or I.end_of_life='0000-00-00' or I.end_of_life > %(today)s)"""
|
||||||
|
|
||||||
# search term condition
|
# search term condition
|
||||||
|
Loading…
x
Reference in New Issue
Block a user