[print] item tables - override description and uom
This commit is contained in:
parent
b736443e3f
commit
0e13221338
@ -6,5 +6,8 @@ import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class PurchaseInvoiceItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
@ -5,6 +5,8 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class SalesInvoiceItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
@ -6,5 +6,8 @@ import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class PurchaseOrderItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
@ -6,5 +6,8 @@ import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class SupplierQuotationItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
9
erpnext/controllers/print_settings.py
Normal file
9
erpnext/controllers/print_settings.py
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
def print_settings_for_item_table(doc):
|
||||
doc.print_templates = {
|
||||
"description": "templates/print_formats/includes/item_table_description.html",
|
||||
"qty": "templates/print_formats/includes/item_table_qty.html"
|
||||
}
|
||||
doc.hide_in_print_layout = ["item_code", "item_name", "image", "uom", "stock_uom"]
|
@ -5,6 +5,8 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class QuotationItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
@ -5,6 +5,8 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class SalesOrderItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
@ -5,6 +5,8 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class DeliveryNoteItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
@ -5,6 +5,8 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
from erpnext.controllers.print_settings import print_settings_for_item_table
|
||||
|
||||
class PurchaseReceiptItem(Document):
|
||||
pass
|
||||
def __setup__(self):
|
||||
print_settings_for_item_table(self)
|
||||
|
@ -1,47 +0,0 @@
|
||||
{%- from "templates/print_formats/standard_macros.html" import print_value -%}
|
||||
{%- set std_fields = ("item_code", "item_name", "description", "qty", "rate", "amount", "stock_uom", "uom") -%}
|
||||
{%- set visible_columns = get_visible_columns(doc.get(df.fieldname), table_meta) -%}
|
||||
{%- set hide_rate = data[0].meta.is_print_hide("rate") if data|length else False-%}
|
||||
{%- set hide_amount = data[0].meta.is_print_hide("amount") if data|length else False-%}
|
||||
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th style="width: 3%">{{ _("Sr") }}</th>
|
||||
<th style="width: 57%">{{ _("Item") }}</th>
|
||||
<th style="width: 10%;" class="text-right">{{ _("Qty") }}</th>
|
||||
{% if not hide_rate -%}<th style="width: 15%;" class="text-right">{{ _("Rate") }}</th>{%- endif %}
|
||||
{% if not hide_amount -%}<th style="width: 15%;" class="text-right">{{ _("Amount") }}</th>{%- endif %}
|
||||
</tr>
|
||||
{%- for row in data -%}
|
||||
<tr>
|
||||
<td>{{ row.idx }}</td>
|
||||
<td>
|
||||
{% if not row.meta.is_print_hide("item_code") -%}
|
||||
<div class="primary">{{ row.item_code }}</div>
|
||||
{%- endif %}
|
||||
{% if (not row.meta.is_print_hide("item_name") and
|
||||
(row.meta.is_print_hide("item_code") or row.item_code != row.item_name)) -%}
|
||||
<div class="primary">{{ row.get_formatted("item_name") }}</div>
|
||||
{%- endif %}
|
||||
{% if (not row.meta.is_print_hide("description") and row.description and
|
||||
((row.meta.is_print_hide("item_code") and row.meta.is_print_hide("item_name"))
|
||||
or not (row.item_code == row.item_name == row.description))) -%}
|
||||
<p>{{ row.get_formatted("description") }}</p>
|
||||
{%- endif %}
|
||||
{%- for field in visible_columns -%}
|
||||
{%- if (field.fieldname not in std_fields) and
|
||||
(row[field.fieldname] not in (None, "", 0)) -%}
|
||||
<div><strong>{{ _(field.label) }}:</strong>
|
||||
{{ row.get_formatted(field.fieldname, doc) }}</div>
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
</td>
|
||||
<td style="text-align: right;">{{ row.get_formatted("qty", doc) }}<br>
|
||||
<small>{{ row.uom or row.stock_uom }}</small></td>
|
||||
{% if not hide_rate -%}<td style="text-align: right;">{{ row.get_formatted("rate", doc) }}</td>{%- endif %}
|
||||
{% if not hide_amount -%}<td style="text-align: right;">{{ row.get_formatted("amount", doc) }}</td>{%- endif %}
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
</table>
|
@ -0,0 +1,19 @@
|
||||
{% if doc.in_format_data("image") and doc.get("image") -%}
|
||||
<div class="pull-left" style="max-width: 20%; margin-right: 10px;">
|
||||
<img src="{{ doc.image }}" style="max-width: 100%">
|
||||
</div>
|
||||
{%- endif %}
|
||||
<div>
|
||||
{% if doc.in_format_data("item_code") -%}
|
||||
<div class="primary">{{ doc.item_code }}</div>
|
||||
{%- endif %}
|
||||
{% if (doc.in_format_data("item_name") and
|
||||
(not doc.in_format_data("item_code") or doc.item_code != doc.item_name)) -%}
|
||||
<div class="primary">{{ doc.get_formatted("item_name") }}</div>
|
||||
{%- endif %}
|
||||
{% if (doc.in_format_data("description") and doc.description and
|
||||
((not doc.in_format_data("item_code") and not doc.in_format_data("item_name"))
|
||||
or not (doc.item_code == doc.item_name == doc.description))) -%}
|
||||
<p>{{ doc.get_formatted("description") }}</p>
|
||||
{%- endif %}
|
||||
</div>
|
@ -0,0 +1,2 @@
|
||||
{{ doc.get_formatted("qty", doc) }}<br>
|
||||
<small>{{ doc.uom or doc.stock_uom }}</small>
|
@ -11,15 +11,15 @@ class Contact(StatusUpdater):
|
||||
|
||||
def autoname(self):
|
||||
# concat first and last name
|
||||
self.name = " ".join(filter(None,
|
||||
self.name = " ".join(filter(None,
|
||||
[cstr(self.get(f)).strip() for f in ["first_name", "last_name"]]))
|
||||
|
||||
|
||||
# concat party name if reqd
|
||||
for fieldname in ("customer", "supplier", "sales_partner"):
|
||||
if self.get(fieldname):
|
||||
self.name = self.name + "-" + cstr(self.get(fieldname)).strip()
|
||||
break
|
||||
|
||||
|
||||
def validate(self):
|
||||
self.set_status()
|
||||
self.validate_primary_contact()
|
||||
@ -27,13 +27,13 @@ class Contact(StatusUpdater):
|
||||
def validate_primary_contact(self):
|
||||
if self.is_primary_contact == 1:
|
||||
if self.customer:
|
||||
frappe.db.sql("update tabContact set is_primary_contact=0 where customer = %s",
|
||||
frappe.db.sql("update tabContact set is_primary_contact=0 where customer = %s",
|
||||
(self.customer))
|
||||
elif self.supplier:
|
||||
frappe.db.sql("update tabContact set is_primary_contact=0 where supplier = %s",
|
||||
(self.supplier))
|
||||
frappe.db.sql("update tabContact set is_primary_contact=0 where supplier = %s",
|
||||
(self.supplier))
|
||||
elif self.sales_partner:
|
||||
frappe.db.sql("""update tabContact set is_primary_contact=0
|
||||
frappe.db.sql("""update tabContact set is_primary_contact=0
|
||||
where sales_partner = %s""", (self.sales_partner))
|
||||
else:
|
||||
if self.customer:
|
||||
@ -46,7 +46,7 @@ class Contact(StatusUpdater):
|
||||
self.is_primary_contact = 1
|
||||
elif self.sales_partner:
|
||||
if not frappe.db.sql("select name from tabContact \
|
||||
where is_primary_contact=1 and sales_partner = %s",
|
||||
where is_primary_contact=1 and sales_partner = %s",
|
||||
self.sales_partner):
|
||||
self.is_primary_contact = 1
|
||||
|
||||
@ -59,7 +59,7 @@ def get_contact_details(contact):
|
||||
contact = frappe.get_doc("Contact", contact)
|
||||
out = {
|
||||
"contact_person": contact.get("name"),
|
||||
"contact_display": " ".join(filter(None,
|
||||
"contact_display": " ".join(filter(None,
|
||||
[contact.get("first_name"), contact.get("last_name")])),
|
||||
"contact_email": contact.get("email_id"),
|
||||
"contact_mobile": contact.get("mobile_no"),
|
||||
@ -67,5 +67,5 @@ def get_contact_details(contact):
|
||||
"contact_designation": contact.get("designation"),
|
||||
"contact_department": contact.get("department")
|
||||
}
|
||||
|
||||
return out
|
||||
|
||||
return out
|
||||
|
Loading…
x
Reference in New Issue
Block a user