Browse Source

Translation reports code formatting

version2
venkata akhil 11 months ago
parent
commit
484a989f1b
  1. 50
      smart_service/masters/report/drive_translation/drive_translation.py
  2. 32
      smart_service/masters/report/fuel_translation/fuel_translation.py
  3. 60
      smart_service/masters/report/sub_systems_translation/sub_systems_translation.py
  4. 51
      smart_service/masters/report/systems_translation/systems_translation.py
  5. 52
      smart_service/masters/report/transmission_translation/transmission_translation.py
  6. 34
      smart_service/masters/report/variant_translation/variant_translation.py
  7. 58
      smart_service/masters/report/vehicle_segment_translation/vehicle_segment_translation.py
  8. 52
      smart_service/masters/report/vehicle_translation/vehicle_translation.py

50
smart_service/masters/report/drive_translation/drive_translation.py

@ -5,62 +5,68 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=1)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabDrive`.modified as "Modified On",
`tabDrive`.active_status as "Status",
`tabDrive`.drive as 'Drive'
%s
From %s.`tabDrive`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabDrive`.drive = tabTrans.source_text
From `tabDrive`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabDrive`.drive = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
,tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabDrive`.drive = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabDrive`.drive = tabTranslation.sourceText
ORDER BY `tabDrive`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Drive</b>") + ":Data/:220",
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Drive</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns,lang
return columns, lang

32
smart_service/masters/report/fuel_translation/fuel_translation.py

@ -5,29 +5,32 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name""",as_list=True)
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name""", as_list=1)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" %(d[0],d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabFuel`.modified as "Modified On",
@ -46,10 +49,9 @@ def get_data():
, tanLang.language_code as languageCode
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabFuel`.fuel = tabTranslation.sourceText;""" % (sel ,queryAppendLang)
ON `tabFuel`.fuel = tabTranslation.sourceText ORDER BY `tabFuel`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
@ -59,11 +61,13 @@ def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Fuel</b>") + ":Data/:220",
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Fuel</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM {}.`tabCustom Languages` where lang_code <> "en" order by lang_name """.format(current_db_name),as_dict=1)
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name; """, as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns,lang
return columns, lang

60
smart_service/masters/report/sub_systems_translation/sub_systems_translation.py

@ -5,53 +5,54 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM {}.`tabCustom Languages` where lang_code <> "en" order by lang_name""".format(current_db_name),as_list=True)
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=1)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
{0}.`tabSub Systems`.modified as "Modified On",
{0}.`tabSub Systems`.active_status as "Status",
{0}.`tabSub Systems`.sub_system_name as 'Vehicle Segment'
{1}
From {0}.`tabSub Systems`
LEFT JOIN {0}.`tabTranslation` as tabTrans
ON {0}.`tabSub Systems`.sub_system_name = tabTrans.source_text
`tabSub Systems`.modified as "Modified On",
`tabSub Systems`.active_status as "Status",
`tabSub Systems`.sub_system_name as 'Vehicle Segment'
{0}
From `tabSub Systems`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabSub Systems`.sub_system_name = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,{0}.tabTranslation.source_text as sourceText
, {0}.tabTranslation.translated_text as translated_text
{2}
From {0}.tabTranslation
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
{1}
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM {0}.tabLanguage as tanLang) as tabLang
ON {0}.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON {0}.`tabSub Systems`.sub_system_name = tabTranslation.sourceText;""" .format(current_db_name,sel ,queryAppendLang)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabSub Systems`.sub_system_name = tabTranslation.sourceText
ORDER BY `tabSub Systems`.modified DESC;""" .format(sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
@ -60,11 +61,14 @@ def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Sub Systems</b>") + ":Data/:300",
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Sub Systems</b>") + ":Data/:300",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM {0}.`tabCustom Languages` where lang_code <> "en" order by lang_name""".format(current_db_name),as_dict=1)
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages`
where lang_code <> "en" order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::300")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::300")
columns += lang
return columns,lang
return columns, lang

51
smart_service/masters/report/systems_translation/systems_translation.py

@ -5,63 +5,70 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
# = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
custom_lang = frappe.db.sql("""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_list=1)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabSystems`.modified as "Modified On",
`tabSystems`.active_status as "Status",
`tabSystems`.system_name as 'Vehicle Segment'
%s
From %s.`tabSystems`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabSystems`.system_name = tabTrans.source_text
From `tabSystems`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabSystems`.system_name = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
,tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabSystems`.system_name = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabSystems`.system_name = tabTranslation.sourceText;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Systems</b>") + ":Data/:300",
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Systems</b>") + ":Data/:300",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::300")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::300")
columns += lang
return columns,lang
return columns, lang

52
smart_service/masters/report/transmission_translation/transmission_translation.py

@ -5,61 +5,67 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabTransmission`.modified as "Modified On",
`tabTransmission`.active_status as "Status",
`tabTransmission`.transmission as 'Transmission'
%s
From %s.`tabTransmission`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabTransmission`.transmission = tabTrans.source_text
From `tabTransmission`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabTransmission`.transmission = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabTransmission`.transmission = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabTransmission`.transmission = tabTranslation.sourceText
ORDER BY `tabTransmission`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Transmission</b>") + ":Data/:220",
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Transmission</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns,lang
return columns, lang

34
smart_service/masters/report/variant_translation/variant_translation.py

@ -5,35 +5,37 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name""",as_list=True)
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" %(d[0],d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabVariant`.modified as "Modified On",
`tabVariant`.active_status as "Status",
`tabVariant`.vehicle as "Vehicle",
`tabVariant`.variant as 'Variant'
%s
From `tabVariant`
LEFT JOIN `tabTranslation` as tabTrans
@ -47,9 +49,9 @@ def get_data():
, tanLang.language_code as languageCode
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabVariant`.variant = tabTranslation.sourceText;""" % (sel ,queryAppendLang)
ON `tabVariant`.variant = tabTranslation.sourceText ORDER BY `tabVariant`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
@ -57,11 +59,15 @@ def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Data/:240", _("<b>Status</b>") + ":Data/:100", _("<b>Vehicle</b>") + ":Data/:200",_("<b>Variant</b>") + ":Data/:220",
_("<b>Modified On</b>") + ":Datetime/:240", _("<b>Status</b>") +
":Data/:100", _("<b>Vehicle</b>") +
":Data/:200", _("<b>Variant</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns,lang
return columns, lang

58
smart_service/masters/report/vehicle_segment_translation/vehicle_segment_translation.py

@ -5,67 +5,71 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
def get_data():
try:
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=True)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabVehicle Segment`.modified as "Modified On",
`tabVehicle Segment`.active_status as "Status",
`tabVehicle Segment`.vehicle_segment as 'Vehicle Segment'
%s
From %s.`tabVehicle Segment`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabVehicle Segment`.vehicle_segment = tabTrans.source_text
From `tabVehicle Segment`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabVehicle Segment`.vehicle_segment = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabVehicle Segment`.vehicle_segment = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabVehicle Segment`.vehicle_segment = tabTranslation.sourceText
ORDER BY `tabVehicle Segment`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
except Exception as e:
frappe.throw(str(frappe.get_traceback()))
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Vehicle Segment</b>") + ":Data/:220",
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Vehicle Segment</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns,lang
return columns, lang

52
smart_service/masters/report/vehicle_translation/vehicle_translation.py

@ -5,61 +5,67 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, getdate
from frappe.utils import cstr
from frappe import msgprint, _
current_db_name = frappe.conf.get("db_name")
def execute(filters=None):
columns, data = [], []
columns,lang = get_columns()
columns, lang = get_columns()
data = get_data()
return columns, data
def get_data():
custom_lang = frappe.db.sql("""SELECT lang_code FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_list=True)
custom_lang = frappe.db.sql(
"""SELECT lang_code FROM `tabCustom Languages` where lang_code <> "en" order by lang_name;""", as_list=1)
queryAppendLang = ""
for d in custom_lang:
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN %s.tabTranslation.translated_text ELSE null END) as %s" %(d[0],current_db_name,d[0])
q = ", (CASE WHEN tabLang.languageCode = '%s' THEN tabTranslation.translated_text ELSE null END) as %s" % (
d[0], d[0])
queryAppendLang += q
sel = ""
for d in custom_lang:
r = ",tabTranslation.%s as %s"%(d[0],d[0])
sel+= r
r = ",tabTranslation.%s as %s" % (d[0], d[0])
sel += r
actualQuery = """Select
`tabVehicle`.modified as "Modified On",
`tabVehicle`.active_status as "Status",
`tabVehicle`.vehicle as 'Vehicle'
%s
From %s.`tabVehicle`
LEFT JOIN %s.`tabTranslation` as tabTrans
ON %s.`tabVehicle`.vehicle = tabTrans.source_text
From `tabVehicle`
LEFT JOIN `tabTranslation` as tabTrans
ON `tabVehicle`.vehicle = tabTrans.source_text
LEFT JOIN (Select tabLang.languageCode as languageCode
,%s.tabTranslation.source_text as sourceText
, %s.tabTranslation.translated_text as translated_text
,tabTranslation.source_text as sourceText
, tabTranslation.translated_text as translated_text
%s
From %s.tabTranslation
From tabTranslation
INNER JOIN (SELECT tanLang.language_name as language_name
, tanLang.language_code as languageCode
FROM %s.tabLanguage as tanLang) as tabLang
ON %s.tabTranslation.language = tabLang.languageCode) as tabTranslation
ON %s.`tabVehicle`.vehicle = tabTranslation.sourceText;""" % (sel,current_db_name,current_db_name,current_db_name,current_db_name,current_db_name ,queryAppendLang,current_db_name,current_db_name,current_db_name,current_db_name)
FROM tabLanguage as tanLang) as tabLang
ON tabTranslation.language = tabLang.languageCode) as tabTranslation
ON `tabVehicle`.vehicle = tabTranslation.sourceText ORDER BY `tabVehicle`.modified DESC;""" % (sel, queryAppendLang)
data = frappe.db.sql(actualQuery,as_list=True)
data = frappe.db.sql(actualQuery, as_list=True)
return data
def get_columns():
columns = []
columns += [
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") + ":Data/:100",_("<b>Vehicle</b>") + ":Data/:220",
_("<b>Modified On</b>") + ":Datetime/:200", _("<b>Status</b>") +
":Data/:100", _("<b>Vehicle</b>") + ":Data/:220",
]
lang = []
custom_lang = frappe.db.sql("""SELECT lang_code,lang_name,active_status FROM %s.`tabCustom Languages` where lang_code <> "en" order by lang_name"""%(current_db_name),as_dict=1)
custom_lang = frappe.db.sql(
"""SELECT lang_code,lang_name,active_status FROM `tabCustom Languages` where lang_code <> "en"
order by lang_name;""", as_dict=1)
for d in custom_lang:
lang.append("<b>"+cstr(d["lang_name"])+"</b>"+ "::220")
lang.append("<b>"+cstr(d["lang_name"])+"</b>" + "::220")
columns += lang
return columns,lang
return columns, lang

Loading…
Cancel
Save