[enhancement] Multi-lingual print format

This commit is contained in:
rohitwaghchaure 2016-03-01 16:33:08 +05:30
commit 4151e3dc92
31 changed files with 3898 additions and 3304 deletions

View File

@ -1946,6 +1946,30 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,

View File

@ -2230,6 +2230,30 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,

View File

@ -92,9 +92,9 @@ def set_contact_details(out, party, party_type):
def set_other_values(out, party, party_type):
# copy
if party_type=="Customer":
to_copy = ["customer_name", "customer_group", "territory"]
to_copy = ["customer_name", "customer_group", "territory", "language"]
else:
to_copy = ["supplier_name", "supplier_type"]
to_copy = ["supplier_name", "supplier_type", "language"]
for f in to_copy:
out[f] = party.get(f)

View File

@ -2183,6 +2183,32 @@
"unique": 0,
"width": "50%"
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"default": "",
"fieldname": "language",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,

View File

@ -1,6 +1,8 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.require("assets/erpnext/js/controllers/load_languages.js")
frappe.ui.form.on("Supplier", {
refresh: function(frm) {
frm.cscript.make_dashboard(frm.doc);

File diff suppressed because it is too large Load Diff

View File

@ -1588,6 +1588,30 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,
@ -1783,7 +1807,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-02-22 09:36:33.641326",
"modified": "2016-02-22 16:30:39.776128",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier Quotation",
@ -1937,4 +1961,4 @@
"sort_order": "DESC",
"timeline_field": "supplier",
"title_field": "title"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -7,3 +7,4 @@ assignment
tags
articles
pos-view
multilingual_print_format

View File

@ -0,0 +1,50 @@
####What is Multlingual Print Format?
User can print the customer's and supplier's document in their local language. For an example if I have customers from germany, france who want quotation in german, french language will be possible with these feature.
####How does it work?
Set print language for customer, supplier on their respective form.
`Selling -> Customer -> Customer List -> Click on New`
Here user has set default language for customer Adalbert as <b>deutsch</b>.
<img src="{{ docs_base_url }}/assets/img/multilingual_print_format/set_customer_default_lang.png" class="screenshot">
`Buying -> Supplier -> Supplier List -> Click on New`
Here user has set default language for supplier Piero as <b>Italiano</b>.
<img src="{{ docs_base_url }}/assets/img/multilingual_print_format/set_supplier_default_lang.png" class="screenshot">
When user click on print icon on the document, system will load the print preview in their default language.
Customer quotation standard print preview in customer's default language.
<img src="{{ docs_base_url }}/assets/img/multilingual_print_format/customer_quotation.png" class="screenshot">
Supplier quotation standard print preview in supplier's default language.
<img src="{{ docs_base_url }}/assets/img/multilingual_print_format/supplier_quotation.png" class="screenshot">
####What to do if want to print with another language?
User can have option to select alternate language on print view.
<img src="{{ docs_base_url }}/assets/img/multilingual_print_format/alternate_language.png" class="screenshot">
####Custom Translation
User can set their custom translations using translation form. For example user want to set description of the product in customer's language(Italiano). For that create new translation with language as Italiano, enter source data and Translated information.
`Setup -> Settings -> Translation List -> Click on New`
<img src="{{ docs_base_url }}/assets/img/multilingual_print_format/translation.png" class="screenshot">
The translation is applied when user select language as Italiano on supplier quotation's print prieview.
<img src="{{ docs_base_url }}/assets/img/multilingual_print_format/custom_translation.png" class="screenshot">

View File

@ -0,0 +1,15 @@
frappe.provide("erpnext")
cur_frm.cscript.before_load = function(doc, dt, dn, callback) {
var update_language_select = function(user_language) {
cur_frm.set_df_property("language", "options", frappe.languages || ["", "English"]);
callback && callback();
}
if(!frappe.languages) {
frappe.languages = frappe.get_languages_dict();
update_language_select();
} else {
update_language_select();
}
}

View File

@ -1,5 +1,6 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.require("assets/erpnext/js/controllers/load_languages.js")
frappe.ui.form.on("Customer", {
refresh: function(frm) {

View File

@ -334,6 +334,54 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "column_break_14",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"options": "Loading...",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -819,7 +867,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-01-25 06:56:05.103168",
"modified": "2016-02-22 16:16:41.563405",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",
@ -1011,4 +1059,4 @@
"search_fields": "customer_name,customer_group,territory",
"sort_order": "ASC",
"title_field": "customer_name"
}
}

View File

@ -1828,6 +1828,30 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,

View File

@ -2168,6 +2168,30 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
from frappe import _
# test_records = frappe.get_test_records('Translation')
class TestTranslation(unittest.TestCase):
def test_doctype(self):
translation_data = {'hr': ['Test data', 'Testdaten'], 'ms':['Test Data','ujian Data'],
'et':['Test Data', 'testandmed']}
for key, val in translation_data.items():
frappe.local.lang = key
frappe.local.lang_full_dict=None
translation = create_translation(key, val)
self.assertEquals(_(translation.source_name), val[1])
frappe.delete_doc('Translation', translation.name)
def create_translation(key, val):
translation = frappe.new_doc('Translation')
translation.language_code = key
translation.source_name = val[0]
translation.target_name = val[1]
translation.save()
return translation

View File

@ -0,0 +1,21 @@
frappe.require("assets/erpnext/js/controllers/load_languages.js");
frappe.ui.form.on('Translation', {
language: function(frm, cdt, cdn) {
frm.cscript.update_language_code(frm)
}
});
frappe.ui.form.on('Translation', {
validate: function(frm, cdt, cdn) {
var doc = frm.doc;
if(!doc.language_code){
frm.cscript.update_language_code(frm)
}
}
});
cur_frm.cscript.update_language_code = function(frm){
var doc = frm.doc;
frm.set_value('language_code', doc.language)
}

View File

@ -0,0 +1,175 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "",
"creation": "2016-02-17 12:21:16.175465",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Language",
"length": 0,
"no_copy": 0,
"options": "Loading...",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "source_name",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Source Data",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "target_name",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Translated",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "column_break_3",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language_code",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Language Code",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-02-23 02:05:54.341357",
"modified_by": "Administrator",
"module": "Setup",
"name": "Translation",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "source_name"
}

View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class Translation(Document):
def on_update(self):
frappe.cache().hdel('lang_user_translations', self.language_code)

File diff suppressed because it is too large Load Diff

View File

@ -2116,6 +2116,30 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,

View File

@ -11,7 +11,7 @@
{% if doc.in_format_data("item_code") and not doc.is_print_hide("item_code") -%}
<div class="primary">
{% if compact %}<strong>{% endif %}
{{ doc.item_code }}
{{ _(doc.item_code) }}
{% if compact %}</strong>{% endif %}
</div>
{%- endif %}
@ -19,7 +19,7 @@
{% if (doc.in_format_data("item_name") and not doc.is_print_hide("item_name") and
(not doc.in_format_data("item_code") or doc.is_print_hide("item_code")
or doc.item_code != doc.item_name)) -%}
<div class="primary">{{ doc.get_formatted("item_name") }}</div>
<div class="primary">{{ _(doc.get_formatted("item_name")) }}</div>
{%- endif %}
{% if (doc.in_format_data("description") and doc.description and
@ -30,15 +30,15 @@
) or not (doc.item_code == doc.item_name == doc.description)
))
-%}
<p>{{ doc.get_formatted("description") }}</p>
<p>{{ _(doc.get_formatted("description")) }}</p>
{%- endif %}
{% if compact -%}
{%- for fieldname in doc.flags.show_in_description -%}
{% if doc.get(fieldname) -%}
<p>
<strong>{{ doc.meta.get_label(fieldname) }}:</strong>
{{ doc.get_formatted(fieldname) }}
<strong>{{ _(doc.meta.get_label(fieldname)) }}:</strong>
{{ _(doc.get_formatted(fieldname)) }}
</p>
{% endif %}
{%- endfor -%}

View File

@ -1,4 +1,4 @@
{% if (doc.stock_uom and not doc.is_print_hide("stock_uom")) or (doc.uom and not doc.is_print_hide("uom")) -%}
<small class="pull-left">{{ doc.uom or doc.stock_uom }}</small>
<small class="pull-left">{{ _(doc.uom or doc.stock_uom) }}</small>
{%- endif %}
{{ doc.get_formatted("qty", doc) }}

View File

@ -2,7 +2,7 @@
{%- if doc.discount_amount -%}
<div class="row">
<div class="col-xs-5 text-right">
<label>{{ "Discount Amount" }}</label></div>
<label>{{ _("Discount Amount") }}</label></div>
<div class="col-xs-7 text-right">
- {{ doc.get_formatted("discount_amount", doc) }}
</div>