mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims_industry: Results Report: show precedent results
This commit is contained in:
parent
edb89986a1
commit
3431e8b759
10 changed files with 225 additions and 17 deletions
|
@ -875,7 +875,7 @@ class ResultsReportVersionDetailSample(ModelSQL, ModelView):
|
||||||
result = {}
|
result = {}
|
||||||
for name in names:
|
for name in names:
|
||||||
result[name] = {}
|
result[name] = {}
|
||||||
if name in ('product_type', 'matrix'):
|
if cls._fields[name]._type == 'many2one':
|
||||||
for s in samples:
|
for s in samples:
|
||||||
field = getattr(s.notebook, name, None)
|
field = getattr(s.notebook, name, None)
|
||||||
result[name][s.id] = field.id if field else None
|
result[name][s.id] = field.id if field else None
|
||||||
|
@ -994,9 +994,7 @@ class ResultsReportVersionDetailLine(ModelSQL, ModelView):
|
||||||
result = {}
|
result = {}
|
||||||
for name in names:
|
for name in names:
|
||||||
result[name] = {}
|
result[name] = {}
|
||||||
if name in ('notebook', 'party', 'analysis', 'laboratory',
|
if cls._fields[name]._type == 'many2one':
|
||||||
'method', 'device', 'initial_unit', 'final_unit',
|
|
||||||
'product_type', 'matrix'):
|
|
||||||
for d in details:
|
for d in details:
|
||||||
field = getattr(d.notebook_line, name, None)
|
field = getattr(d.notebook_line, name, None)
|
||||||
result[name][d.id] = field.id if field else None
|
result[name][d.id] = field.id if field else None
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<form>
|
<form col="6">
|
||||||
<group id="notebook" colspan="4" col="6">
|
<label name="notebook"/>
|
||||||
<label name="notebook"/>
|
<field name="notebook"/>
|
||||||
<field name="notebook"/>
|
<label name="product_type"/>
|
||||||
<label name="product_type"/>
|
<field name="product_type"/>
|
||||||
<field name="product_type"/>
|
<label name="matrix"/>
|
||||||
<label name="matrix"/>
|
<field name="matrix"/>
|
||||||
<field name="matrix"/>
|
<notebook colspan="6">
|
||||||
</group>
|
|
||||||
<notebook>
|
|
||||||
<page id="lines" string="Lines">
|
<page id="lines" string="Lines">
|
||||||
<field name="notebook_lines"/>
|
<field name="notebook_lines"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
|
@ -7,6 +7,7 @@ from . import industry
|
||||||
from . import analysis
|
from . import analysis
|
||||||
from . import sample
|
from . import sample
|
||||||
from . import notebook
|
from . import notebook
|
||||||
|
from . import results_report
|
||||||
from . import party
|
from . import party
|
||||||
from . import task
|
from . import task
|
||||||
|
|
||||||
|
@ -34,6 +35,8 @@ def register():
|
||||||
sample.CreateSampleStart,
|
sample.CreateSampleStart,
|
||||||
sample.EditSampleStart,
|
sample.EditSampleStart,
|
||||||
notebook.Notebook,
|
notebook.Notebook,
|
||||||
|
results_report.ResultsReportVersionDetailSample,
|
||||||
|
results_report.ResultsReportVersionDetailLine,
|
||||||
party.Party,
|
party.Party,
|
||||||
party.Address,
|
party.Address,
|
||||||
task.AdministrativeTaskTemplate,
|
task.AdministrativeTaskTemplate,
|
||||||
|
|
|
@ -334,6 +334,42 @@ msgctxt "field:lims.product.type,attribute_set:"
|
||||||
msgid "Attribute Set"
|
msgid "Attribute Set"
|
||||||
msgstr "Conjunto de atributos"
|
msgstr "Conjunto de atributos"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.line,precedent1_result:"
|
||||||
|
msgid "Precedent 1"
|
||||||
|
msgstr "Antecedente 1"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.line,precedent2_result:"
|
||||||
|
msgid "Precedent 2"
|
||||||
|
msgstr "Antecedente 2"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.line,precedent3_result:"
|
||||||
|
msgid "Precedent 3"
|
||||||
|
msgstr "Antecedente 3"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,component:"
|
||||||
|
msgid "Component"
|
||||||
|
msgstr "Componente"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,equipment:"
|
||||||
|
msgid "Equipment"
|
||||||
|
msgstr "Equipo"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,plant:"
|
||||||
|
msgid "Plant"
|
||||||
|
msgstr "Planta"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,precedent1:"
|
||||||
|
msgid "Precedent 1"
|
||||||
|
msgstr "Antecedente 1"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,precedent2:"
|
||||||
|
msgid "Precedent 2"
|
||||||
|
msgstr "Antecedente 2"
|
||||||
|
|
||||||
|
msgctxt "field:lims.results_report.version.detail.sample,precedent3:"
|
||||||
|
msgid "Precedent 3"
|
||||||
|
msgstr "Antecedente 3"
|
||||||
|
|
||||||
msgctxt "field:lims.sample,attributes_domain:"
|
msgctxt "field:lims.sample,attributes_domain:"
|
||||||
msgid "Attributes domain"
|
msgid "Attributes domain"
|
||||||
msgstr "Dominio para Atributos"
|
msgstr "Dominio para Atributos"
|
||||||
|
@ -826,6 +862,10 @@ msgctxt "view:lims.plant:"
|
||||||
msgid "General"
|
msgid "General"
|
||||||
msgstr "General"
|
msgstr "General"
|
||||||
|
|
||||||
|
msgctxt "view:lims.results_report.version.detail.sample:"
|
||||||
|
msgid "Precedents"
|
||||||
|
msgstr "Antecedentes"
|
||||||
|
|
||||||
msgctxt "view:lims.sample:"
|
msgctxt "view:lims.sample:"
|
||||||
msgid "Industry"
|
msgid "Industry"
|
||||||
msgstr "Industria"
|
msgstr "Industria"
|
||||||
|
|
|
@ -12,8 +12,8 @@ class Notebook(metaclass=PoolMeta):
|
||||||
__name__ = 'lims.notebook'
|
__name__ = 'lims.notebook'
|
||||||
|
|
||||||
plant = fields.Function(fields.Many2One('lims.plant', 'Plant'),
|
plant = fields.Function(fields.Many2One('lims.plant', 'Plant'),
|
||||||
'get_sample_field')
|
'get_sample_field', searcher='search_sample_field')
|
||||||
equipment = fields.Function(fields.Many2One('lims.equipment', 'Equipment'),
|
equipment = fields.Function(fields.Many2One('lims.equipment', 'Equipment'),
|
||||||
'get_sample_field')
|
'get_sample_field', searcher='search_sample_field')
|
||||||
component = fields.Function(fields.Many2One('lims.component', 'Component'),
|
component = fields.Function(fields.Many2One('lims.component', 'Component'),
|
||||||
'get_sample_field')
|
'get_sample_field', searcher='search_sample_field')
|
||||||
|
|
117
lims_industry/results_report.py
Normal file
117
lims_industry/results_report.py
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
# This file is part of lims_industry module for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains
|
||||||
|
# the full copyright notices and license terms.
|
||||||
|
|
||||||
|
from trytond.model import fields
|
||||||
|
from trytond.pool import Pool, PoolMeta
|
||||||
|
from trytond.pyson import Eval
|
||||||
|
from trytond.i18n import gettext
|
||||||
|
|
||||||
|
__all__ = ['ResultsReportVersionDetailSample',
|
||||||
|
'ResultsReportVersionDetailLine']
|
||||||
|
|
||||||
|
|
||||||
|
class ResultsReportVersionDetailSample(metaclass=PoolMeta):
|
||||||
|
__name__ = 'lims.results_report.version.detail.sample'
|
||||||
|
|
||||||
|
plant = fields.Function(fields.Many2One('lims.plant', 'Plant'),
|
||||||
|
'get_notebook_field')
|
||||||
|
equipment = fields.Function(fields.Many2One('lims.equipment', 'Equipment'),
|
||||||
|
'get_notebook_field')
|
||||||
|
component = fields.Function(fields.Many2One('lims.component', 'Component'),
|
||||||
|
'get_notebook_field')
|
||||||
|
precedent1 = fields.Many2One('lims.notebook', 'Precedent 1',
|
||||||
|
domain=[('component', '=', Eval('component'))],
|
||||||
|
depends=['component'])
|
||||||
|
precedent2 = fields.Many2One('lims.notebook', 'Precedent 2',
|
||||||
|
domain=[('component', '=', Eval('component'))],
|
||||||
|
depends=['component'])
|
||||||
|
precedent3 = fields.Many2One('lims.notebook', 'Precedent 3',
|
||||||
|
domain=[('component', '=', Eval('component'))],
|
||||||
|
depends=['component'])
|
||||||
|
|
||||||
|
|
||||||
|
class ResultsReportVersionDetailLine(metaclass=PoolMeta):
|
||||||
|
__name__ = 'lims.results_report.version.detail.line'
|
||||||
|
|
||||||
|
precedent1_result = fields.Function(fields.Char('Precedent 1'),
|
||||||
|
'get_precedent_result')
|
||||||
|
precedent2_result = fields.Function(fields.Char('Precedent 2'),
|
||||||
|
'get_precedent_result')
|
||||||
|
precedent3_result = fields.Function(fields.Char('Precedent 3'),
|
||||||
|
'get_precedent_result')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_precedent_result(cls, details, names):
|
||||||
|
result = {}
|
||||||
|
for name in names:
|
||||||
|
result[name] = {}
|
||||||
|
if name == 'precedent1_result':
|
||||||
|
for d in details:
|
||||||
|
result[name][d.id] = cls._get_precedent_result(
|
||||||
|
d.detail_sample.precedent1, d)
|
||||||
|
elif name == 'precedent2_result':
|
||||||
|
for d in details:
|
||||||
|
result[name][d.id] = cls._get_precedent_result(
|
||||||
|
d.detail_sample.precedent2, d)
|
||||||
|
else: # name == 'precedent3_result':
|
||||||
|
for d in details:
|
||||||
|
result[name][d.id] = cls._get_precedent_result(
|
||||||
|
d.detail_sample.precedent3, d)
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_precedent_result(cls, precedent, line):
|
||||||
|
pool = Pool()
|
||||||
|
NotebookLine = pool.get('lims.notebook.line')
|
||||||
|
|
||||||
|
if not precedent:
|
||||||
|
return None
|
||||||
|
precedent_line = NotebookLine.search([
|
||||||
|
('notebook', '=', precedent),
|
||||||
|
('analysis', '=', line.notebook_line.analysis),
|
||||||
|
('accepted', '=', True),
|
||||||
|
])
|
||||||
|
if not precedent_line:
|
||||||
|
return None
|
||||||
|
return cls._get_result(precedent_line[0])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_result(cls, notebook_line):
|
||||||
|
literal_result = notebook_line.literal_result
|
||||||
|
result = notebook_line.result
|
||||||
|
decimals = notebook_line.decimals
|
||||||
|
result_modifier = notebook_line.result_modifier
|
||||||
|
|
||||||
|
res = ''
|
||||||
|
if literal_result:
|
||||||
|
res = literal_result
|
||||||
|
else:
|
||||||
|
if result:
|
||||||
|
res = round(float(result), decimals)
|
||||||
|
if decimals == 0:
|
||||||
|
res = int(res)
|
||||||
|
else:
|
||||||
|
res = ''
|
||||||
|
|
||||||
|
if result_modifier == 'eq':
|
||||||
|
res = res
|
||||||
|
elif result_modifier == 'low':
|
||||||
|
res = gettext('lims.msg_quantification_limit', loq=res)
|
||||||
|
elif result_modifier == 'd':
|
||||||
|
res = gettext('lims.msg_d')
|
||||||
|
elif result_modifier == 'nd':
|
||||||
|
res = gettext('lims.msg_nd')
|
||||||
|
elif result_modifier == 'ni':
|
||||||
|
res = ''
|
||||||
|
elif result_modifier == 'pos':
|
||||||
|
res = gettext('lims.msg_pos')
|
||||||
|
elif result_modifier == 'neg':
|
||||||
|
res = gettext('lims.msg_neg')
|
||||||
|
elif result_modifier == 'pre':
|
||||||
|
res = gettext('lims.msg_pre')
|
||||||
|
elif result_modifier == 'abs':
|
||||||
|
res = gettext('lims.msg_abs')
|
||||||
|
else:
|
||||||
|
res = result_modifier
|
||||||
|
return res
|
22
lims_industry/results_report.xml
Normal file
22
lims_industry/results_report.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Results Report Version Detail Sample -->
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="results_report_version_detail_sample_view_form">
|
||||||
|
<field name="model">lims.results_report.version.detail.sample</field>
|
||||||
|
<field name="inherit" ref="lims.lims_results_report_version_detail_sample_view_form"/>
|
||||||
|
<field name="name">results_report_version_detail_sample_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Results Report Version Detail Line -->
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="results_report_version_detail_line_view_list">
|
||||||
|
<field name="model">lims.results_report.version.detail.line</field>
|
||||||
|
<field name="inherit" ref="lims.lims_results_report_version_detail_line_view_list"/>
|
||||||
|
<field name="name">results_report_version_detail_line_list</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -7,5 +7,6 @@ xml:
|
||||||
industry.xml
|
industry.xml
|
||||||
analysis.xml
|
analysis.xml
|
||||||
sample.xml
|
sample.xml
|
||||||
|
results_report.xml
|
||||||
party.xml
|
party.xml
|
||||||
message.xml
|
message.xml
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<data>
|
||||||
|
<xpath expr="/tree/field[@name='comments']" position="after">
|
||||||
|
<field name="precedent1_result"/>
|
||||||
|
<field name="precedent2_result"/>
|
||||||
|
<field name="precedent3_result"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<data>
|
||||||
|
<xpath expr="/form/field[@name='matrix']" position="after">
|
||||||
|
<label name="plant"/>
|
||||||
|
<field name="plant"/>
|
||||||
|
<label name="equipment"/>
|
||||||
|
<field name="equipment"/>
|
||||||
|
<label name="component"/>
|
||||||
|
<field name="component"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="/form/notebook/page[@id='lines']" position="after">
|
||||||
|
<page id="precedents" col="6" string="Precedents">
|
||||||
|
<label name="precedent1"/>
|
||||||
|
<field name="precedent1"/>
|
||||||
|
<label name="precedent2"/>
|
||||||
|
<field name="precedent2"/>
|
||||||
|
<label name="precedent3"/>
|
||||||
|
<field name="precedent3"/>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
Loading…
Reference in a new issue