{% extends "base.html" %}
{% from "_macros.html" import approval_panel, order_badge, progress_badge, picking_badge, state_badge, attachments_card with context %}
{% block title %}{{ o.number }}{% endblock %}
{% block content %}
{% set cur = branch.currency %}
{% set sale = kind == 'sale' %}
{{ t(info.title) }}
{{ o.number }} {{ order_badge(o.state, kind) }}{% if po_type %} {{ t(po_type) }}{% endif %}
{% if o.ack_state == 'awaiting' %}{{ t('Awaiting vendor confirmation') }}{% elif o.ack_state == 'accepted' %}{{ t('Accepted by vendor') }}{% elif o.ack_state == 'rejected' %}{{ t('Rejected by vendor') }}{% endif %}
{% if o.state == 'confirmed' %}
{{ t('Delivery') if sale else t('Receipt') }}: {{ progress_badge(deliv) if deliv else '—' }} · {{ t('Invoicing') }}: {{ progress_badge(inv_status) }}{% endif %}
{% if mr %}
{{ mr.number }}{% endif %}
{% if pr %}
{{ pr.number }}{% endif %}
{% if po_type and o.state == 'confirmed' %}
{{ icon('file') }}PDF{% endif %}
{% if rfq %}
{{ rfq.number }}{% endif %}
{{ t('Print') }}
{% if can_write %}
{% if o.state == 'draft' %}
{{ t('Edit') }}
{% elif o.state == 'to_approve' %}
{% elif o.state == 'confirmed' %}
{% if inv_status != 'full' %}
{% endif %}
{% if (stock_open if not sale else (deliv and deliv != 'full')) and not open_picking %}
{% endif %}
{% if sale and has('manufacturing') %}
{% endif %}
{% if grn_open and can_grn %}
{{ t('Receive (GRN)') }}{% endif %}
{% if po_type and not o.sent_at %}
{% endif %}
{% elif o.state == 'cancelled' %}
{% endif %}
{% endif %}
{% if o.kind == 'sale' and o.state == 'draft' %}{% set ci = credit_issues(o.partner_id, o.amount_total, branch.currency if branch else company.currency) %}
{% if ci %}
- {{ t('Branch') }}
- {{ branch.code }} — {{ nm(branch) }}
- {{ t('Warehouse') }}
- {{ o.wcode or '—' }}
- {{ t('Order Date') }}
- {{ o.date }}
- {{ t('Delivery Date') if sale else t('Expected Arrival') }}
- {{ o.expected_date or '—' }}
- {{ t('Reference') }}
- {{ o.ref or '—' }}
{% if has('projects') and o.project_id %}{% endif %}
{% if o.cc_code %}- {{ t('Cost Centre') }}
- {{ o.cc_code }} — {{ nm({'name_en': o.cc_name_en, 'name_ar': o.cc_name_ar}) }}
{% endif %}
{{ t('Vendor acknowledgement') }}
{% if o.sent_at %}
{{ t('Sent to the vendor') }}: {{ o.sent_at[:16].replace('T', ' ') }}
{% endif %}
{% if o.ack_state in ('accepted', 'rejected') %}
- {{ t('Status') }}
- {{ t('Accepted by vendor') if o.ack_state == 'accepted' else t('Rejected by vendor') }}
- {{ t('Vendor reference') }}
- {{ o.ack_ref or '—' }}
- {{ t('Promised delivery') }}
- {{ o.ack_date or '—' }}
- {{ t('Recorded') }}
- {{ o.ack_at[:16].replace('T', ' ') }}
{% if o.ack_note %}- {{ t('Note') }}
- {{ o.ack_note }}
{% endif %}
{% endif %}
{% if can_write %}
{% endif %}
{% endif %}
{% if grns %}