diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json index af030d6203..bfbbce8e99 100644 --- a/erpnext/manufacturing/doctype/bom/bom.json +++ b/erpnext/manufacturing/doctype/bom/bom.json @@ -1230,7 +1230,7 @@ "label": "Website", "length": 0, "no_copy": 0, - "options": "fa fa-globe", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -1248,7 +1248,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "eval:!doc.variant_of", + "depends_on": "", "fieldname": "show_in_website", "fieldtype": "Check", "hidden": 0, @@ -1299,7 +1299,7 @@ "unique": 0 }, { - "allow_on_submit": 0, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "columns": 0, @@ -1328,7 +1328,7 @@ "unique": 0 }, { - "allow_on_submit": 0, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "columns": 0, @@ -1358,7 +1358,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, - "collapsible_depends_on": "", + "collapsible_depends_on": "website_items", "columns": 0, "depends_on": "show_in_website", "fieldname": "sb_web_spec", @@ -1384,7 +1384,7 @@ "unique": 0 }, { - "allow_on_submit": 0, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "columns": 0, @@ -1412,7 +1412,7 @@ "unique": 0 }, { - "allow_on_submit": 0, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "columns": 0, @@ -1440,7 +1440,7 @@ "unique": 0 }, { - "allow_on_submit": 1, + "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, @@ -1469,11 +1469,11 @@ "unique": 0 }, { - "allow_on_submit": 0, + "allow_on_submit": 1, "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "show_in_website", + "depends_on": "eval:(doc.show_in_website && doc.with_operations)", "fieldname": "show_operations", "fieldtype": "Check", "hidden": 0, @@ -1497,7 +1497,7 @@ "unique": 0 }, { - "allow_on_submit": 1, + "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, @@ -1537,7 +1537,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-02-10 07:52:53.599831", + "modified": "2017-02-12 23:16:15.994194", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM", diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index bdd76aaf5c..d9f35d8e00 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -54,6 +54,8 @@ class BOM(WebsiteGenerator): self.set_bom_material_details() self.validate_operations() self.calculate_cost() + self.validate_website_image() + self.make_thumbnail() def get_context(self, context): context.parents = [{'name': 'boms', 'title': _('All BOMs') }] @@ -452,6 +454,7 @@ class BOM(WebsiteGenerator): 'item_code' : d.item_code, 'item_name' : d.item_name, 'description' : d.description, + 'qty' : d.qty, 'website_image' : d.image })) @@ -495,6 +498,86 @@ class BOM(WebsiteGenerator): ch.docstatus = self.docstatus ch.db_insert() + def validate_website_image(self): + """Validate if the website image is a public file""" + auto_set_website_image = False + if not self.website_image and self.image: + auto_set_website_image = True + self.website_image = self.image + + if not self.website_image: + return + + # find if website image url exists as public + file_doc = frappe.get_all("File", filters={ + "file_url": self.website_image + }, fields=["name", "is_private"], order_by="is_private asc", limit_page_length=1) + + + if file_doc: + file_doc = file_doc[0] + + if not file_doc: + if not auto_set_website_image: + frappe.msgprint(_("Website Image {0} attached to Item {1} cannot be found") + .format(self.website_image, self.name)) + + self.website_image = None + + elif file_doc.is_private: + if not auto_set_website_image: + frappe.msgprint(_("Website Image should be a public file or website URL")) + + self.website_image = None + + def make_thumbnail(self): + """Make a thumbnail of `website_image`""" + import requests.exceptions + + if not self.is_new() and self.website_image != frappe.db.get_value(self.doctype, self.name, "website_image"): + self.thumbnail = None + + if self.website_image and not self.thumbnail: + file_doc = None + + try: + file_doc = frappe.get_doc("File", { + "file_url": self.website_image, + "attached_to_doctype": "Item", + "attached_to_name": self.name + }) + except frappe.DoesNotExistError: + pass + # cleanup + frappe.local.message_log.pop() + + except requests.exceptions.HTTPError: + frappe.msgprint(_("Warning: Invalid attachment {0}").format(self.website_image)) + self.website_image = None + + except requests.exceptions.SSLError: + frappe.msgprint(_("Warning: Invalid SSL certificate on attachment {0}").format(self.website_image)) + self.website_image = None + + # for CSV import + if self.website_image and not file_doc: + try: + file_doc = frappe.get_doc({ + "doctype": "File", + "file_url": self.website_image, + "attached_to_doctype": "Item", + "attached_to_name": self.name + }).insert() + + except IOError: + self.website_image = None + + if file_doc: + if not file_doc.thumbnail_url: + file_doc.make_thumbnail() + + self.thumbnail = file_doc.thumbnail_url + def get_list_context(context): context.title = _("Bill of Materials") # context.introduction = _('Boms') diff --git a/erpnext/manufacturing/doctype/bom_website_item/bom_website_item.json b/erpnext/manufacturing/doctype/bom_website_item/bom_website_item.json index 3e605dbc5e..7df728b1cd 100644 --- a/erpnext/manufacturing/doctype/bom_website_item/bom_website_item.json +++ b/erpnext/manufacturing/doctype/bom_website_item/bom_website_item.json @@ -159,7 +159,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-02-10 07:34:33.625474", + "modified": "2017-02-12 12:48:56.949861", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM Website Item", diff --git a/erpnext/manufacturing/doctype/bom_website_operation/bom_website_operation.json b/erpnext/manufacturing/doctype/bom_website_operation/bom_website_operation.json index 1a8d4fe4cb..8f28dd7c45 100644 --- a/erpnext/manufacturing/doctype/bom_website_operation/bom_website_operation.json +++ b/erpnext/manufacturing/doctype/bom_website_operation/bom_website_operation.json @@ -120,6 +120,33 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "thumbnail", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Thumbnail", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "hide_heading": 0, @@ -132,7 +159,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-02-10 07:34:30.479443", + "modified": "2017-02-12 16:32:44.316447", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM Website Operation", diff --git a/erpnext/public/css/website.css b/erpnext/public/css/website.css index 1617ea7bd1..1d30e78382 100644 --- a/erpnext/public/css/website.css +++ b/erpnext/public/css/website.css @@ -250,3 +250,27 @@ .product-image-wrapper { padding-bottom: 40px; } +.duration-bar { + display: inline-block; + color: white; + /* border-right: 2px solid green; */ + background: #8FD288; + padding: 3px; +} +.duration-invisible { + visibility: hidden; +} +.duration-value { + float: right; +} +.bar-outer-text { + color: #8FD288; + background: none; + float: none; + border: none; +} +.thumbsize { + width: 200px; + height: 200px; + padding: 0; +} \ No newline at end of file diff --git a/erpnext/public/less/website.less b/erpnext/public/less/website.less index a645f28d71..b816354458 100644 --- a/erpnext/public/less/website.less +++ b/erpnext/public/less/website.less @@ -320,4 +320,33 @@ .product-image-wrapper { padding-bottom: 40px; +} + +.duration-bar { + display: inline-block; + color: white; + /* border-right: 2px solid green; */ + background: #8FD288; + padding: 3px; +} + +.duration-invisible { + visibility: hidden; +} + +.duration-value { + float: right; +} + +.bar-outer-text { + color: #8FD288; + background: none; + float: none; + border: none; +} + +.thumbsize { + width: 200px; + height: 200px; + padding: 0; } \ No newline at end of file diff --git a/erpnext/templates/generators/bom.html b/erpnext/templates/generators/bom.html index 46dea6e2a6..f514f2dd8e 100644 --- a/erpnext/templates/generators/bom.html +++ b/erpnext/templates/generators/bom.html @@ -8,48 +8,50 @@ {% block page_content %} {% from "erpnext/templates/includes/macros.html" import product_image %} -
-
+{% from "erpnext/templates/includes/macros.html" import media_image %} +
+
-
- {% if slideshow %} - {% include "templates/includes/slideshow.html" %} - {% else %} - {{ product_image(website_image, "product-full-image") }} - {% endif %} -
-
-

{{ name }}

+
+

{{ name }}

- {{ _("Item Name") }}: {{ item_name }}

-
- -
{{ _("Description") }}
-
- {{ web_long_description or description or _("No description given") }}
-
-
{{ _("Quantity") }}
-
{{ quantity }}
+ {{ _("Item") }}: {{ item_name }}


- -
+
+
+ {{ product_image(website_image, "product-full-image") }} +
+

{{ _("Quantity") }}: {{ quantity }}

+
+
{% if show_items -%}
-
{{ _("Items") }}
- +

{{ _("Items") }}

- {% for d in website_items -%} - - - + + + + + {% for d in items -%} + + + {%- endfor %} @@ -61,15 +63,25 @@ {% if show_operations -%}
-
{{ _("Operations") }}
- +

{{ _("Operations") }}

{{ d.item_name }}{{ d.item_code }}{{ d.description }}{{ _("Qty") }}
{{ media_image(d.image, "product-full-image") }}
{{ d.item_name }}
+ {% if d.item_name != d.item_code -%} +
{{ d.item_code }}
+ {% else -%} + + {%- endif %} +
+ {{ d.description }} +
{{ d.qty }}
- {% for d in website_operations -%} - + + + + + + + {% for d in operations -%} + + + + - - + {%- endfor %}
{{ d.operation }}{{ _("Workstation") }}{{ _("Time(in mins)") }}
{{ media_image(d.image, d.operation, "product-full-image") }}
{{ d.operation }}
+
{{ d.description }}
+
{{ d.workstation }}{{ d.time_in_mins }}{{ d.website_image }} + {{ d.time_in_mins }}
@@ -77,6 +89,39 @@
{%- endif %} +
+
+
+
{{ _("Description") }}
+
+ {{ web_long_description or _("No description given") }}
+
+ +
+
+
+ + {% endblock %} diff --git a/erpnext/templates/includes/macros.html b/erpnext/templates/includes/macros.html index 675b7afeea..db194b2c52 100644 --- a/erpnext/templates/includes/macros.html +++ b/erpnext/templates/includes/macros.html @@ -19,3 +19,26 @@ {%- endif %}
{% endmacro %} + +{% macro media_image(website_image, name, css_class="") %} +{% if website_image -%} + +{%- endif %} +
+
+{% endmacro %} + +{% macro bom_image(website_image, name, css_class="") %} +
+ {% if not website_image -%}{{ name }}{%- endif %} + {% if website_image -%} + + + + {%- endif %} +
+{% endmacro %} diff --git a/erpnext/templates/pages/home.html b/erpnext/templates/pages/home.html index b91cd73c7e..750fa3849f 100644 --- a/erpnext/templates/pages/home.html +++ b/erpnext/templates/pages/home.html @@ -18,7 +18,7 @@
- {{ product_image_square(item.thumbnail or item.image) }} + {{ product_image_square(item.thumbnail or item.image) }}
{{ item.item_name }}