lims_report_html: allow to sort by function fields in notebook
This commit is contained in:
parent
d36d95ba05
commit
9a5d250a8c
|
@ -18,6 +18,7 @@ def register():
|
|||
html_template.ReportTemplateTranslation,
|
||||
html_template.ReportTemplateSection,
|
||||
html_template.ReportTemplateTrendChart,
|
||||
sample.Fraction,
|
||||
sample.Sample,
|
||||
sample.CreateSampleStart,
|
||||
analysis.Analysis,
|
||||
|
|
|
@ -14,6 +14,10 @@ msgctxt "field:lims.create_sample.start,resultrange_origin:"
|
|||
msgid "Comparison range"
|
||||
msgstr "Rango de comparación"
|
||||
|
||||
msgctxt "field:lims.fraction,result_template:"
|
||||
msgid "Report Template"
|
||||
msgstr "Plantilla de Informe"
|
||||
|
||||
msgctxt "field:lims.notebook,result_template:"
|
||||
msgid "Report Template"
|
||||
msgstr "Plantilla de Informe"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# the full copyright notices and license terms.
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
|
||||
class Notebook(metaclass=PoolMeta):
|
||||
|
@ -13,3 +13,21 @@ class Notebook(metaclass=PoolMeta):
|
|||
'lims.result_report.template', 'Report Template'), 'get_sample_field')
|
||||
resultrange_origin = fields.Function(fields.Many2One('lims.range.type',
|
||||
'Comparison range'), 'get_sample_field')
|
||||
|
||||
def _order_sample_field(name):
|
||||
def order_field(tables):
|
||||
pool = Pool()
|
||||
Sample = pool.get('lims.sample')
|
||||
Fraction = pool.get('lims.fraction')
|
||||
field = Sample._fields[name]
|
||||
table, _ = tables[None]
|
||||
fraction_tables = tables.get('fraction')
|
||||
if fraction_tables is None:
|
||||
fraction = Fraction.__table__()
|
||||
fraction_tables = {
|
||||
None: (fraction, fraction.id == table.fraction),
|
||||
}
|
||||
tables['fraction'] = fraction_tables
|
||||
return field.convert_order(name, fraction_tables, Fraction)
|
||||
return staticmethod(order_field)
|
||||
order_result_template = _order_sample_field('result_template')
|
||||
|
|
|
@ -3,7 +3,30 @@
|
|||
# the full copyright notices and license terms.
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
|
||||
class Fraction(metaclass=PoolMeta):
|
||||
__name__ = 'lims.fraction'
|
||||
|
||||
result_template = fields.Function(fields.Many2One(
|
||||
'lims.report.template', 'Report Template'), 'get_sample_field')
|
||||
|
||||
def _order_sample_field(name):
|
||||
def order_field(tables):
|
||||
Sample = Pool().get('lims.sample')
|
||||
field = Sample._fields[name]
|
||||
table, _ = tables[None]
|
||||
sample_tables = tables.get('sample')
|
||||
if sample_tables is None:
|
||||
sample = Sample.__table__()
|
||||
sample_tables = {
|
||||
None: (sample, sample.id == table.sample),
|
||||
}
|
||||
tables['sample'] = sample_tables
|
||||
return field.convert_order(name, sample_tables, Sample)
|
||||
return staticmethod(order_field)
|
||||
order_result_template = _order_sample_field('result_template')
|
||||
|
||||
|
||||
class Sample(metaclass=PoolMeta):
|
||||
|
|
Loading…
Reference in New Issue