mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims_report_html/lims_diagnosis: comments in html format and plain text
This commit is contained in:
parent
10e31ab53b
commit
64703dd9e0
5 changed files with 95 additions and 22 deletions
|
@ -131,6 +131,10 @@ msgctxt "field:lims.results_report.version.detail.sample,diagnosis_warning:"
|
||||||
msgid "Diagnosis Warning"
|
msgid "Diagnosis Warning"
|
||||||
msgstr "Advertencia de diagnóstico"
|
msgstr "Advertencia de diagnóstico"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,template_type:"
|
||||||
|
msgid "Report Template Type"
|
||||||
|
msgstr "Tipo de Plantilla de Informe"
|
||||||
|
|
||||||
msgctxt "field:lims.sample,diagnostician:"
|
msgctxt "field:lims.sample,diagnostician:"
|
||||||
msgid "Diagnostician"
|
msgid "Diagnostician"
|
||||||
msgstr "Diagnosticador"
|
msgstr "Diagnosticador"
|
||||||
|
@ -320,6 +324,18 @@ msgctxt "selection:lims.results_report.version.detail,state:"
|
||||||
msgid "Diagnosed"
|
msgid "Diagnosed"
|
||||||
msgstr "Diagnosticado"
|
msgstr "Diagnosticado"
|
||||||
|
|
||||||
|
msgctxt "selection:lims.results_report.version.detail.sample,template_type:"
|
||||||
|
msgid "HTML"
|
||||||
|
msgstr "HTML"
|
||||||
|
|
||||||
|
msgctxt "selection:lims.results_report.version.detail.sample,template_type:"
|
||||||
|
msgid "HTML - Footer"
|
||||||
|
msgstr "HTML - Pie de página"
|
||||||
|
|
||||||
|
msgctxt "selection:lims.results_report.version.detail.sample,template_type:"
|
||||||
|
msgid "HTML - Header"
|
||||||
|
msgstr "HTML - Encabezado"
|
||||||
|
|
||||||
msgctxt "view:lims.diagnosis.state:"
|
msgctxt "view:lims.diagnosis.state:"
|
||||||
msgid "Options"
|
msgid "Options"
|
||||||
msgstr "Opciones"
|
msgstr "Opciones"
|
||||||
|
|
|
@ -106,33 +106,30 @@ class ResultsReportVersionDetailSample(metaclass=PoolMeta):
|
||||||
('base', 'HTML'),
|
('base', 'HTML'),
|
||||||
('header', 'HTML - Header'),
|
('header', 'HTML - Header'),
|
||||||
('footer', 'HTML - Footer'),
|
('footer', 'HTML - Footer'),
|
||||||
], 'Type'), 'get_template_type')
|
], 'Report Template Type'), 'get_template_type')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def view_attributes(cls):
|
||||||
|
return super().view_attributes() + [
|
||||||
|
('//page[@id="diagnosis"]', 'states', {
|
||||||
|
'invisible': Not(Bool(Eval('template_type'))),
|
||||||
|
}),
|
||||||
|
('//page[@id="diagnosis_plain"]', 'states', {
|
||||||
|
'invisible': Eval('template_type') == 'base',
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
|
||||||
def get_diagnosis_plain(self, name):
|
def get_diagnosis_plain(self, name):
|
||||||
return self.diagnosis
|
return self.diagnosis
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_diagnosis_plain(cls, records, name, value):
|
def set_diagnosis_plain(cls, records, name, value):
|
||||||
if not value:
|
|
||||||
return
|
|
||||||
cls.write(records, {'diagnosis': value})
|
cls.write(records, {'diagnosis': value})
|
||||||
|
|
||||||
def get_template_type(self, name):
|
def get_template_type(self, name):
|
||||||
return (self.version_detail.template and
|
return (self.version_detail.template and
|
||||||
self.version_detail.template.type or None)
|
self.version_detail.template.type or None)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def view_attributes(cls):
|
|
||||||
return super(
|
|
||||||
ResultsReportVersionDetailSample, cls).view_attributes() + [
|
|
||||||
('/form/notebook/page[@id="diagnosis"]', 'states', {
|
|
||||||
'invisible': Not(Bool(Eval('template_type'))),
|
|
||||||
}),
|
|
||||||
('/form/notebook/page[@id="diagnosis_plain"]', 'states', {
|
|
||||||
'invisible': Eval('template_type') == 'base',
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
samples = super().create(vlist)
|
samples = super().create(vlist)
|
||||||
|
|
|
@ -126,6 +126,10 @@ msgctxt "field:lims.results_report.version.detail,charts_x_row:"
|
||||||
msgid "Charts per Row"
|
msgid "Charts per Row"
|
||||||
msgstr "Gráficos por fila"
|
msgstr "Gráficos por fila"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail,comments_plain:"
|
||||||
|
msgid "Comments"
|
||||||
|
msgstr "Observaciones"
|
||||||
|
|
||||||
msgctxt "field:lims.results_report.version.detail,following_sections:"
|
msgctxt "field:lims.results_report.version.detail,following_sections:"
|
||||||
msgid "Following Sections"
|
msgid "Following Sections"
|
||||||
msgstr "Secciones siguientes"
|
msgstr "Secciones siguientes"
|
||||||
|
@ -142,10 +146,18 @@ msgctxt "field:lims.results_report.version.detail,template:"
|
||||||
msgid "Report Template"
|
msgid "Report Template"
|
||||||
msgstr "Plantilla de Informe"
|
msgstr "Plantilla de Informe"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail,template_type:"
|
||||||
|
msgid "Report Template Type"
|
||||||
|
msgstr "Tipo de Plantilla de Informe"
|
||||||
|
|
||||||
msgctxt "field:lims.results_report.version.detail,trend_charts:"
|
msgctxt "field:lims.results_report.version.detail,trend_charts:"
|
||||||
msgid "Trend Charts"
|
msgid "Trend Charts"
|
||||||
msgstr "Gráficos de tendencia"
|
msgstr "Gráficos de tendencia"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,attachments:"
|
||||||
|
msgid "Attachments"
|
||||||
|
msgstr "Adjuntos"
|
||||||
|
|
||||||
msgctxt "field:lims.results_report.version.detail.sample,trend_charts:"
|
msgctxt "field:lims.results_report.version.detail.sample,trend_charts:"
|
||||||
msgid "Trend Charts"
|
msgid "Trend Charts"
|
||||||
msgstr "Gráficos de tendencia"
|
msgstr "Gráficos de tendencia"
|
||||||
|
@ -282,6 +294,18 @@ msgctxt "selection:lims.results_report.version.detail,charts_x_row:"
|
||||||
msgid "2"
|
msgid "2"
|
||||||
msgstr "2"
|
msgstr "2"
|
||||||
|
|
||||||
|
msgctxt "selection:lims.results_report.version.detail,template_type:"
|
||||||
|
msgid "HTML"
|
||||||
|
msgstr "HTML"
|
||||||
|
|
||||||
|
msgctxt "selection:lims.results_report.version.detail,template_type:"
|
||||||
|
msgid "HTML - Footer"
|
||||||
|
msgstr "HTML - Pie de página"
|
||||||
|
|
||||||
|
msgctxt "selection:lims.results_report.version.detail,template_type:"
|
||||||
|
msgid "HTML - Header"
|
||||||
|
msgstr "HTML - Encabezado"
|
||||||
|
|
||||||
msgctxt "selection:lims.results_report.version.detail.section,position:"
|
msgctxt "selection:lims.results_report.version.detail.section,position:"
|
||||||
msgid "Following"
|
msgid "Following"
|
||||||
msgstr "Siguiente"
|
msgstr "Siguiente"
|
||||||
|
@ -297,3 +321,7 @@ msgstr "Informe"
|
||||||
msgctxt "view:lims.result_report.template:"
|
msgctxt "view:lims.result_report.template:"
|
||||||
msgid "Header and Footer"
|
msgid "Header and Footer"
|
||||||
msgstr "Encabezado y Pie de página"
|
msgstr "Encabezado y Pie de página"
|
||||||
|
|
||||||
|
msgctxt "view:lims.results_report.version.detail:"
|
||||||
|
msgid "Comments"
|
||||||
|
msgstr "Observaciones"
|
||||||
|
|
|
@ -19,7 +19,7 @@ from PyPDF2.utils import PdfReadError
|
||||||
|
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import ModelView, ModelSQL, fields
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.pyson import Eval
|
from trytond.pyson import Eval, Not, Bool
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
|
@ -33,6 +33,12 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
|
||||||
template = fields.Many2One('lims.result_report.template',
|
template = fields.Many2One('lims.result_report.template',
|
||||||
'Report Template', domain=[('type', 'in', [None, 'base'])],
|
'Report Template', domain=[('type', 'in', [None, 'base'])],
|
||||||
states={'readonly': Eval('state') != 'draft'}, depends=['state'])
|
states={'readonly': Eval('state') != 'draft'}, depends=['state'])
|
||||||
|
template_type = fields.Function(fields.Selection([
|
||||||
|
(None, ''),
|
||||||
|
('base', 'HTML'),
|
||||||
|
('header', 'HTML - Header'),
|
||||||
|
('footer', 'HTML - Footer'),
|
||||||
|
], 'Report Template Type'), 'get_template_type')
|
||||||
sections = fields.One2Many('lims.results_report.version.detail.section',
|
sections = fields.One2Many('lims.results_report.version.detail.section',
|
||||||
'version_detail', 'Sections')
|
'version_detail', 'Sections')
|
||||||
previous_sections = fields.Function(fields.One2Many(
|
previous_sections = fields.Function(fields.One2Many(
|
||||||
|
@ -50,6 +56,8 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
|
||||||
('1', '1'),
|
('1', '1'),
|
||||||
('2', '2'),
|
('2', '2'),
|
||||||
], 'Charts per Row')
|
], 'Charts per Row')
|
||||||
|
comments_plain = fields.Function(fields.Text('Comments'),
|
||||||
|
'get_comments_plain', setter='set_comments_plain')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
@ -59,10 +67,24 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
|
||||||
if 'required' in cls.resultrange_origin.states:
|
if 'required' in cls.resultrange_origin.states:
|
||||||
del cls.resultrange_origin.states['required']
|
del cls.resultrange_origin.states['required']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def view_attributes(cls):
|
||||||
|
return super().view_attributes() + [
|
||||||
|
('//page[@id="comments"]', 'states', {
|
||||||
|
'invisible': Not(Bool(Eval('template_type'))),
|
||||||
|
}),
|
||||||
|
('//page[@id="comments_plain"]', 'states', {
|
||||||
|
'invisible': Eval('template_type') == 'base',
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_charts_x_row():
|
def default_charts_x_row():
|
||||||
return '1'
|
return '1'
|
||||||
|
|
||||||
|
def get_template_type(self, name):
|
||||||
|
return self.template and self.template.type or None
|
||||||
|
|
||||||
@fields.depends('template', '_parent_template.trend_charts',
|
@fields.depends('template', '_parent_template.trend_charts',
|
||||||
'_parent_template.sections', 'sections')
|
'_parent_template.sections', 'sections')
|
||||||
def on_change_template(self):
|
def on_change_template(self):
|
||||||
|
@ -170,6 +192,13 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
|
||||||
} for s in detail.sections])]
|
} for s in detail.sections])]
|
||||||
return detail_default
|
return detail_default
|
||||||
|
|
||||||
|
def get_comments_plain(self, name):
|
||||||
|
return self.comments
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_comments_plain(cls, records, name, value):
|
||||||
|
cls.write(records, {'comments': value})
|
||||||
|
|
||||||
|
|
||||||
class ResultsReportVersionDetailSection(ModelSQL, ModelView):
|
class ResultsReportVersionDetailSection(ModelSQL, ModelView):
|
||||||
'Results Report Version Detail Section'
|
'Results Report Version Detail Section'
|
||||||
|
|
|
@ -14,12 +14,15 @@
|
||||||
<label name="template"/>
|
<label name="template"/>
|
||||||
<field name="template"/>
|
<field name="template"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath
|
<xpath expr="/form/notebook/page[@name='comments']" position="replace">
|
||||||
expr="/form/notebook/page[@name='comments']/field[@name='comments']"
|
<page id="comments_plain" string="Comments">
|
||||||
position="replace">
|
<field name="comments_plain" colspan="4" widget="text"/>
|
||||||
<field name="comments" colspan="4" widget="html"/>
|
<field name="template_type" colspan="4" invisible="1"/>
|
||||||
</xpath>
|
</page>
|
||||||
<xpath expr="/form/notebook/page[@name='comments']" position="after">
|
<page id="comments" string="Comments">
|
||||||
|
<field name="comments" colspan="4" widget="html"/>
|
||||||
|
<field name="template_type" colspan="4" invisible="1"/>
|
||||||
|
</page>
|
||||||
<page name="sections">
|
<page name="sections">
|
||||||
<field name="previous_sections" colspan="4"/>
|
<field name="previous_sections" colspan="4"/>
|
||||||
<field name="following_sections" colspan="4"/>
|
<field name="following_sections" colspan="4"/>
|
||||||
|
|
Loading…
Reference in a new issue