Merge pull request #7576 from RobertSchouten/compact_dev
[fix] compact print format not longer ignores format builder
This commit is contained in:
commit
2bcacec5c6
@ -16,14 +16,13 @@ def print_settings_for_item_table(doc):
|
|||||||
|
|
||||||
if doc.flags.compact_item_print:
|
if doc.flags.compact_item_print:
|
||||||
doc.print_templates["description"] = "templates/print_formats/includes/item_table_description.html"
|
doc.print_templates["description"] = "templates/print_formats/includes/item_table_description.html"
|
||||||
doc.hide_in_print_layout += ["item_code", "item_name", "image"]
|
|
||||||
|
|
||||||
doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"]
|
doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"]
|
||||||
doc.flags.show_in_description = []
|
doc.flags.format_columns = format_columns
|
||||||
|
|
||||||
for df in doc.meta.fields:
|
def format_columns(display_columns, compact_fields):
|
||||||
if df.fieldtype not in ("Section Break", "Column Break", "Button"):
|
compact_fields = compact_fields + ["image", "item_code", "item_name"]
|
||||||
if not doc.is_print_hide(df.fieldname):
|
final_columns = []
|
||||||
if df.fieldname not in doc.hide_in_print_layout and df.fieldname not in doc.flags.compact_item_fields:
|
for column in display_columns:
|
||||||
doc.hide_in_print_layout.append(df.fieldname)
|
if column not in compact_fields:
|
||||||
doc.flags.show_in_description.append(df.fieldname)
|
final_columns.append(column)
|
||||||
|
return final_columns
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
{%- set compact = doc.flags.compact_item_print -%}
|
{%- set compact = doc.flags.compact_item_print -%}
|
||||||
{%- set compact_fields = doc.flags.compact_item_fields -%}
|
{%- set compact_fields = doc.flags.compact_item_fields -%}
|
||||||
|
{%- set display_columns = visible_columns|map(attribute="fieldname")| list -%}
|
||||||
|
{%- set columns = doc.flags.format_columns(display_columns, compact_fields) -%}
|
||||||
|
|
||||||
{% if doc.in_format_data("image") and doc.get("image") and not doc.is_print_hide("image")-%}
|
{% if doc.in_format_data("image") and doc.get("image") and "image" in display_columns -%}
|
||||||
<div class="pull-left" style="max-width: 40%; margin-right: 10px;">
|
<div class="pull-left" style="max-width: 40%; margin-right: 10px;">
|
||||||
<img class="print-item-image" src="{{ doc.image }}" alt="">
|
<img class="print-item-image" src="{{ doc.image }}" alt="">
|
||||||
</div>
|
</div>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% if doc.in_format_data("item_code") and not doc.is_print_hide("item_code") -%}
|
{% if doc.in_format_data("item_code") and "item_code" in display_columns -%}
|
||||||
<div class="primary">
|
<div class="primary">
|
||||||
{% if compact %}<strong>{% endif %}
|
{% if compact %}<strong>{% endif %}
|
||||||
{{ _(doc.item_code) }}
|
{{ _(doc.item_code) }}
|
||||||
@ -16,9 +18,8 @@
|
|||||||
</div>
|
</div>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{% if (doc.in_format_data("item_name") and not doc.is_print_hide("item_name") and
|
{%- if doc.in_format_data("item_name") and "item_name" in display_columns and
|
||||||
(not doc.in_format_data("item_code") or doc.is_print_hide("item_code")
|
not (doc.in_format_data("item_code") and doc.item_code == doc.item_name) -%}
|
||||||
or doc.item_code != doc.item_name)) -%}
|
|
||||||
<div class="primary">{{ doc.get_formatted("item_name", translated=True) }}</div>
|
<div class="primary">{{ doc.get_formatted("item_name", translated=True) }}</div>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
@ -34,7 +35,7 @@
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{% if compact -%}
|
{% if compact -%}
|
||||||
{%- for fieldname in doc.flags.show_in_description -%}
|
{%- for fieldname in columns -%}
|
||||||
{% if doc.get(fieldname) and doc.in_format_data(fieldname) -%}
|
{% if doc.get(fieldname) and doc.in_format_data(fieldname) -%}
|
||||||
<p>
|
<p>
|
||||||
<strong>{{ _(doc.meta.get_label(fieldname)) }}:</strong>
|
<strong>{{ _(doc.meta.get_label(fieldname)) }}:</strong>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user