lims_report_html/lims_diagnosis: comments in html format and plain text

This commit is contained in:
Adrián Bernardi 2020-11-17 18:45:42 -03:00
parent 10e31ab53b
commit 64703dd9e0
5 changed files with 95 additions and 22 deletions

View file

@ -131,6 +131,10 @@ msgctxt "field:lims.results_report.version.detail.sample,diagnosis_warning:"
msgid "Diagnosis Warning"
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:"
msgid "Diagnostician"
msgstr "Diagnosticador"
@ -320,6 +324,18 @@ msgctxt "selection:lims.results_report.version.detail,state:"
msgid "Diagnosed"
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:"
msgid "Options"
msgstr "Opciones"

View file

@ -106,33 +106,30 @@ class ResultsReportVersionDetailSample(metaclass=PoolMeta):
('base', 'HTML'),
('header', 'HTML - Header'),
('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):
return self.diagnosis
@classmethod
def set_diagnosis_plain(cls, records, name, value):
if not value:
return
cls.write(records, {'diagnosis': value})
def get_template_type(self, name):
return (self.version_detail.template and
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
def create(cls, vlist):
samples = super().create(vlist)

View file

@ -126,6 +126,10 @@ msgctxt "field:lims.results_report.version.detail,charts_x_row:"
msgid "Charts per Row"
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:"
msgid "Following Sections"
msgstr "Secciones siguientes"
@ -142,10 +146,18 @@ msgctxt "field:lims.results_report.version.detail,template:"
msgid "Report Template"
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:"
msgid "Trend Charts"
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:"
msgid "Trend Charts"
msgstr "Gráficos de tendencia"
@ -282,6 +294,18 @@ msgctxt "selection:lims.results_report.version.detail,charts_x_row:"
msgid "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:"
msgid "Following"
msgstr "Siguiente"
@ -297,3 +321,7 @@ msgstr "Informe"
msgctxt "view:lims.result_report.template:"
msgid "Header and Footer"
msgstr "Encabezado y Pie de página"
msgctxt "view:lims.results_report.version.detail:"
msgid "Comments"
msgstr "Observaciones"

View file

@ -19,7 +19,7 @@ from PyPDF2.utils import PdfReadError
from trytond.model import ModelView, ModelSQL, fields
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.exceptions import UserError
from trytond.i18n import gettext
@ -33,6 +33,12 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
template = fields.Many2One('lims.result_report.template',
'Report Template', domain=[('type', 'in', [None, 'base'])],
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',
'version_detail', 'Sections')
previous_sections = fields.Function(fields.One2Many(
@ -50,6 +56,8 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
('1', '1'),
('2', '2'),
], 'Charts per Row')
comments_plain = fields.Function(fields.Text('Comments'),
'get_comments_plain', setter='set_comments_plain')
@classmethod
def __setup__(cls):
@ -59,10 +67,24 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
if 'required' in cls.resultrange_origin.states:
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
def default_charts_x_row():
return '1'
def get_template_type(self, name):
return self.template and self.template.type or None
@fields.depends('template', '_parent_template.trend_charts',
'_parent_template.sections', 'sections')
def on_change_template(self):
@ -170,6 +192,13 @@ class ResultsReportVersionDetail(metaclass=PoolMeta):
} for s in detail.sections])]
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):
'Results Report Version Detail Section'

View file

@ -14,12 +14,15 @@
<label name="template"/>
<field name="template"/>
</xpath>
<xpath
expr="/form/notebook/page[@name='comments']/field[@name='comments']"
position="replace">
<field name="comments" colspan="4" widget="html"/>
</xpath>
<xpath expr="/form/notebook/page[@name='comments']" position="after">
<xpath expr="/form/notebook/page[@name='comments']" position="replace">
<page id="comments_plain" string="Comments">
<field name="comments_plain" colspan="4" widget="text"/>
<field name="template_type" colspan="4" invisible="1"/>
</page>
<page id="comments" string="Comments">
<field name="comments" colspan="4" widget="html"/>
<field name="template_type" colspan="4" invisible="1"/>
</page>
<page name="sections">
<field name="previous_sections" colspan="4"/>
<field name="following_sections" colspan="4"/>