{% extends "base.html" %} {% load static erp_tags bunny_images %} {% block title %}{{ page_title }} — Item Profile{% endblock %} {% block stylesheets %} {% endblock %} {% block content %}
{% csrf_token %} {# ── Header Bar ─────────────────────────────────────────────────────────── #}
{% if is_new %} New Product {% else %} {{ product.title }} {% endif %}
{% if not is_new %}

{{ product.part_number|default:"No SKU" }} · {{ product.get_product_type_display }} {% if product.brand %} · {{ product.brand.title }}{% endif %}

{% endif %}
{% if not is_new %} Locked {% endif %}
Cancel
{# ── Non-field errors ───────────────────────────────────────────────────── #} {% if form.non_field_errors %}
{% for error in form.non_field_errors %}

{{ error }}

{% endfor %}
{% endif %}
{# ── Product Image Preview (existing products) ──────────────────────── #} {% if not is_new and primary_image %}
{% bunny_image_url primary_image.cf_image_id 'thumbnail' as primary_thumb_url %} {{ product.title }}

{{ product.title }}

{{ images|length }} image{{ images|length|pluralize }} {% if categories %} · {{ categories|length }} categor{{ categories|length|pluralize:"y,ies" }}{% endif %}

{% if updated_at %}

Last updated {{ updated_at|date:"M j, Y g:i A" }}

{% endif %}
{% if product.is_active %} Active {% else %} Inactive {% endif %}
{% endif %} {# ── Parent Product Sections ────────────────────────────────────────── #} {% for section in parent_sections %}
{{ section.title }}
{% for field_name in section.fields %} {% with field=form|get_form_field:field_name %} {% if field %}
{% if field.field.widget.input_type == "checkbox" %}
{{ field }}
{% elif field.field.widget.template_name == "django/forms/widgets/textarea.html" %} {{ field|add_class:"form-control form-control-sm json-field" }} {% else %} {{ field|add_class:"form-control form-control-sm" }} {% endif %} {% if field.errors %}
{{ field.errors.0 }}
{% endif %} {% if field.help_text %} {{ field.help_text }} {% endif %}
{% endif %} {% endwith %} {% endfor %}
{% endfor %} {# ── Variants Section ───────────────────────────────────────────────── #}
Variants {{ formset.forms|length }}
{{ formset.management_form }} {% for vform in formset.forms %}
{% if vform.instance.pk %} {{ vform.instance.sku|default:"Variant" }} {% else %} New Variant {% endif %}
{% if vform.instance.pk %} ID: {{ vform.instance.pk|truncatechars:12 }} {% endif %}
{% if vform.non_field_errors %}
{% for error in vform.non_field_errors %}

{{ error }}

{% endfor %}
{% endif %} {% for vs in variant_sections %} {% if vs.collapsed %}
{{ vs.title }}
{% for fname in vs.fields %} {% with vf=vform|get_form_field:fname %} {% if vf %}
{% if vf.field.widget.input_type == "checkbox" %}
{{ vf|aria_label }}
{% else %} {{ vf|add_class:"form-control form-control-sm" }} {% endif %} {% if vf.errors %}
{{ vf.errors.0 }}
{% endif %}
{% endif %} {% endwith %} {% endfor %}
{% else %}

{{ vs.title }}

{% for fname in vs.fields %} {% with vf=vform|get_form_field:fname %} {% if vf %}
{% if vf.field.widget.input_type == "checkbox" %}
{{ vf|aria_label }}
{% else %} {{ vf|add_class:"form-control form-control-sm" }} {% endif %} {% if vf.errors %}
{{ vf.errors.0 }}
{% endif %}
{% endif %} {% endwith %} {% endfor %}
{% endif %} {% endfor %}
{% empty %}

No variants yet.

{% endfor %}
{# ── Supplier Costs ──────────────────────────────────────────────────── #} {% if not is_new %}
Supplier Costs {{ supplier_products|length }}
{% for sp in supplier_products %} {% empty %} {% endfor %}
Supplier Variant Supplier SKU Cost UOM Unit Cost Min Qty Lead Time Primary Actions
{{ sp.supplier.display_name|default:sp.supplier.company_name }} {% if sp.supplier.supplier_type == "warehouse" %} WH {% endif %} {{ sp.variant.sku }} {{ sp.supplier_sku|default:"—" }} {{ sp.cost|money }} {% if sp.qty_per_uom > 1 %} {{ sp.qty_per_uom }}/{{ sp.purchasing_uom }} {% else %} {{ sp.purchasing_uom }} {% endif %} {% if sp.qty_per_uom > 1 %} {{ sp.unit_cost|money }} {% else %} {{ sp.unit_cost|money }} {% endif %} {{ sp.minimum_order_qty }} {{ sp.lead_time_days|default:"—" }}{% if sp.lead_time_days %}d{% endif %} {% if sp.is_primary %}{% endif %}
No supplier costs configured.
{% endif %} {# ── Plugin panels (TemplateExtension slot; docs/plugins.md) ──────────── #} {# Inside the profile form: a panel must not contain a . #} {% if not is_new %}{% plugin_slot "product_profile_panels" %}{% endif %} {# ── Timestamps (existing products) ─────────────────────────────────── #} {% if not is_new %}

Created

{{ product.created_at|date:"M j, Y g:i A" }}

Last Modified

{{ product.updated_at|date:"M j, Y g:i A" }}

ID

{{ product.pk }}

{% endif %}
{# ── Supplier Cost Modal ─────────────────────────────────────────────── #} {% if not is_new %} {# ── Plugin modals (outside the profile form, so they may hold forms) ── #} {% plugin_slot "product_profile_modals" %} {% endif %} {% endblock %} {% block javascripts %} {# ── Plugin scripts (TemplateExtension slot) ──────────────────────────── #} {% if not is_new %}{% plugin_slot "product_profile_scripts" %}{% endif %} {% endblock %}