lims/lims_analysis_sheet: Planification: improve "search fractions" wizard

This commit is contained in:
Adri?n Bernardi 2020-02-19 21:28:35 -03:00
parent 78f929d99d
commit 27ef14687b
9 changed files with 52 additions and 305 deletions

View File

@ -235,7 +235,6 @@ def register():
planification.SearchFractionsDetail,
planification.SearchPlannedFractionsStart,
planification.SearchPlannedFractionsNext,
planification.SearchPlannedFractionsDetail,
planification.CreateFractionControlStart,
planification.ReleaseFractionStart,
planification.ReleaseFractionEmpty,

View File

@ -14428,6 +14428,10 @@ msgctxt "field:lims.planification.search_fractions.detail,create_date:"
msgid "Create Date"
msgstr "Fecha creación"
msgctxt "field:lims.planification.search_fractions.detail,create_date2:"
msgid "Create Date"
msgstr "Fecha de creación"
msgctxt "field:lims.planification.search_fractions.detail,create_uid:"
msgid "Create User"
msgstr "Usuario creación"
@ -14436,10 +14440,6 @@ msgctxt "field:lims.planification.search_fractions.detail,fraction:"
msgid "Fraction"
msgstr "Fracción"
msgctxt "field:lims.planification.search_fractions.detail,fraction_type:"
msgid "Fraction type"
msgstr "Tipo de fracción"
msgctxt "field:lims.planification.search_fractions.detail,id:"
msgid "ID"
msgstr "ID"
@ -14480,6 +14480,10 @@ msgctxt "field:lims.planification.search_fractions.detail,session_id:"
msgid "Session ID"
msgstr "ID Sesión"
msgctxt "field:lims.planification.search_fractions.detail,type:"
msgid "Fraction type"
msgstr "Tipo de fracción"
msgctxt "field:lims.planification.search_fractions.detail,urgent:"
msgid "Urgent"
msgstr "Urgente"
@ -14504,79 +14508,6 @@ msgctxt "field:lims.planification.search_fractions.next,id:"
msgid "ID"
msgstr "ID"
msgctxt ""
"field:lims.planification.search_planned_fractions.detail,create_date:"
msgid "Create Date"
msgstr "Fecha creación"
msgctxt "field:lims.planification.search_planned_fractions.detail,create_uid:"
msgid "Create User"
msgstr "Usuario creación"
msgctxt "field:lims.planification.search_planned_fractions.detail,fraction:"
msgid "Fraction"
msgstr "Fracción"
msgctxt ""
"field:lims.planification.search_planned_fractions.detail,fraction_type:"
msgid "Fraction type"
msgstr "Tipo de fracción"
msgctxt "field:lims.planification.search_planned_fractions.detail,id:"
msgid "ID"
msgstr "ID"
msgctxt "field:lims.planification.search_planned_fractions.detail,label:"
msgid "Label"
msgstr "Rótulo"
msgctxt "field:lims.planification.search_planned_fractions.detail,matrix:"
msgid "Matrix"
msgstr "Matriz"
msgctxt "field:lims.planification.search_planned_fractions.detail,priority:"
msgid "Priority"
msgstr "Prioridad"
msgctxt ""
"field:lims.planification.search_planned_fractions.detail,product_type:"
msgid "Product type"
msgstr "Tipo de producto"
msgctxt "field:lims.planification.search_planned_fractions.detail,rec_name:"
msgid "Name"
msgstr "Nombre"
msgctxt "field:lims.planification.search_planned_fractions.detail,repetition:"
msgid "Repetition"
msgstr "Repetición"
msgctxt ""
"field:lims.planification.search_planned_fractions.detail,report_date:"
msgid "Date agreed for result"
msgstr "Fecha pactada de resultado"
msgctxt ""
"field:lims.planification.search_planned_fractions.detail,service_analysis:"
msgid "Service"
msgstr "Servicio"
msgctxt "field:lims.planification.search_planned_fractions.detail,session_id:"
msgid "Session ID"
msgstr "ID Sesión"
msgctxt "field:lims.planification.search_planned_fractions.detail,urgent:"
msgid "Urgent"
msgstr "Urgente"
msgctxt "field:lims.planification.search_planned_fractions.detail,write_date:"
msgid "Write Date"
msgstr "Fecha modificación"
msgctxt "field:lims.planification.search_planned_fractions.detail,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:lims.planification.search_planned_fractions.next,details:"
msgid "Fractions to replan"
msgstr "Fracciones a replanificar"
@ -15162,10 +15093,6 @@ msgctxt "model:lims.planification.search_fractions.next,name:"
msgid "Search Fractions"
msgstr "Buscar fracciones"
msgctxt "model:lims.planification.search_planned_fractions.detail,name:"
msgid "Fraction to Replan"
msgstr "Fracción a replanificar"
msgctxt "model:lims.planification.search_planned_fractions.next,name:"
msgid "Search Planned Fractions"
msgstr "Buscar fracciones planificadas"
@ -16215,14 +16142,6 @@ msgctxt "view:lims.planification.search_fractions.next:"
msgid "Search Fractions"
msgstr "Buscar fracciones"
msgctxt "view:lims.planification.search_planned_fractions.detail:"
msgid "Fraction to Replan"
msgstr "Fracción a replanificar"
msgctxt "view:lims.planification.search_planned_fractions.detail:"
msgid "Fractions to Replan"
msgstr "Fracciones a replanificar"
msgctxt "view:lims.planification.search_planned_fractions.next:"
msgid "Search Planned Fractions"
msgstr "Buscar fracciones planificadas"

View File

@ -34,11 +34,11 @@ __all__ = ['Planification', 'PlanificationTechnician',
'AddFractionMRT', 'RemoveControlStart', 'RemoveControl',
'AddAnalysisStart', 'AddAnalysis', 'SearchFractionsNext',
'SearchFractionsDetail', 'SearchFractions', 'SearchPlannedFractionsStart',
'SearchPlannedFractionsNext', 'SearchPlannedFractionsDetail',
'SearchPlannedFractions', 'CreateFractionControlStart',
'CreateFractionControl', 'ReleaseFractionStart', 'ReleaseFractionEmpty',
'ReleaseFractionResult', 'ReleaseFraction', 'QualificationSituations',
'QualificationSituation', 'QualificationAction', 'QualificationSituation2',
'SearchPlannedFractionsNext', 'SearchPlannedFractions',
'CreateFractionControlStart', 'CreateFractionControl',
'ReleaseFractionStart', 'ReleaseFractionEmpty', 'ReleaseFractionResult',
'ReleaseFraction', 'QualificationSituations', 'QualificationSituation',
'QualificationAction', 'QualificationSituation2',
'QualificationSituation3', 'QualificationSituation4',
'TechniciansQualification', 'ReplaceTechnicianStart', 'ReplaceTechnician',
'LoadServices', 'PlanificationSequenceReport',
@ -3649,11 +3649,18 @@ class SearchFractionsDetail(ModelSQL, ModelView):
fraction = fields.Many2One('lims.fraction', 'Fraction', readonly=True)
service_analysis = fields.Many2One('lims.analysis', 'Service',
readonly=True)
fraction_type = fields.Function(fields.Many2One('lims.fraction.type',
'Fraction type'), 'get_fraction_field')
label = fields.Function(fields.Char('Label'), 'get_fraction_field')
product_type = fields.Many2One('lims.product.type', 'Product type')
matrix = fields.Many2One('lims.matrix', 'Matrix')
type = fields.Function(fields.Many2One('lims.fraction.type',
'Fraction type'), 'get_fraction_field',
searcher='search_fraction_field')
label = fields.Function(fields.Char('Label'), 'get_fraction_field',
searcher='search_fraction_field')
product_type = fields.Function(fields.Many2One('lims.product.type',
'Product type'), 'get_fraction_field',
searcher='search_fraction_field')
matrix = fields.Function(fields.Many2One('lims.matrix', 'Matrix'),
'get_fraction_field', searcher='search_fraction_field')
create_date2 = fields.Function(fields.DateTime('Create Date'),
'get_fraction_field', searcher='search_fraction_field')
urgent = fields.Function(fields.Boolean('Urgent'), 'get_service_field')
priority = fields.Function(fields.Integer('Priority'), 'get_service_field')
repetition = fields.Boolean('Repetition', readonly=True)
@ -3681,13 +3688,9 @@ class SearchFractionsDetail(ModelSQL, ModelView):
result = {}
for name in names:
result[name] = {}
if name == 'label':
if name in ('label', 'create_date2'):
for d in details:
result[name][d.id] = getattr(d.fraction, name, None)
elif name == 'fraction_type':
for d in details:
field = getattr(d.fraction, 'type', None)
result[name][d.id] = field.id if field else None
else:
for d in details:
field = getattr(d.fraction, name, None)
@ -3780,8 +3783,6 @@ class SearchFractions(Wizard):
'session_id': self._session_id,
'fraction': k[0],
'service_analysis': k[1],
'product_type': v['product_type'],
'matrix': v['matrix'],
'repetition': v['repetition'],
})
fractions_added = SearchFractionsDetail.create(to_create)
@ -3844,7 +3845,6 @@ class SearchFractions(Wizard):
NotebookLine = pool.get('lims.notebook.line')
Notebook = pool.get('lims.notebook')
Fraction = pool.get('lims.fraction')
Sample = pool.get('lims.sample')
EntryDetailAnalysis = pool.get('lims.entry.detail.analysis')
Service = pool.get('lims.service')
Analysis = pool.get('lims.analysis')
@ -3869,19 +3869,8 @@ class SearchFractions(Wizard):
service_where = ('AND ad.analysis IN (' +
all_included_analysis_ids + ') ')
if extra_where:
sample_select = ''
sample_from = ''
repetition_select = ''
else:
sample_select = ', smp.product_type, smp.matrix'
sample_from = (
'INNER JOIN "' + Sample._table + '" smp '
'ON smp.id = frc.sample ')
repetition_select = ', nl.repetition != 0'
sql_select = ('SELECT nl.id, nb.fraction, srv.analysis' +
sample_select + repetition_select + ' ')
sql_select = (
'SELECT nl.id, nb.fraction, srv.analysis, nl.repetition != 0 ')
sql_from = (
'FROM "' + NotebookLine._table + '" nl '
@ -3894,8 +3883,7 @@ class SearchFractions(Wizard):
'INNER JOIN "' + EntryDetailAnalysis._table + '" ad '
'ON ad.id = nl.analysis_detail '
'INNER JOIN "' + Service._table + '" srv '
'ON srv.id = nl.service ' +
sample_from)
'ON srv.id = nl.service ')
sql_where = (
'WHERE ad.plannable = TRUE '
@ -3935,9 +3923,7 @@ class SearchFractions(Wizard):
f_ = nl[1]
s_ = nl[2]
result[(f_, s_)] = {
'product_type': nl[3],
'matrix': nl[4],
'repetition': nl[5],
'repetition': nl[3],
}
return result
@ -3963,92 +3949,14 @@ class SearchPlannedFractionsNext(ModelView):
__name__ = 'lims.planification.search_planned_fractions.next'
details = fields.Many2Many(
'lims.planification.search_planned_fractions.detail',
'lims.planification.search_fractions.detail',
None, None, 'Fractions to replan', depends=['details_domain'],
domain=[('id', 'in', Eval('details_domain'))], required=True)
details_domain = fields.One2Many(
'lims.planification.search_planned_fractions.detail',
'lims.planification.search_fractions.detail',
None, 'Fractions domain')
class SearchPlannedFractionsDetail(ModelSQL, ModelView):
'Fraction to Replan'
__name__ = 'lims.planification.search_planned_fractions.detail'
_table = 'lims_plan_search_planned_fractions_detail'
fraction = fields.Many2One('lims.fraction', 'Fraction', readonly=True)
service_analysis = fields.Many2One('lims.analysis', 'Service',
readonly=True)
fraction_type = fields.Function(fields.Many2One('lims.fraction.type',
'Fraction type'), 'get_fraction_field')
label = fields.Function(fields.Char('Label'), 'get_fraction_field')
product_type = fields.Many2One('lims.product.type', 'Product type')
matrix = fields.Many2One('lims.matrix', 'Matrix')
urgent = fields.Function(fields.Boolean('Urgent'), 'get_service_field')
priority = fields.Function(fields.Integer('Priority'), 'get_service_field')
repetition = fields.Boolean('Repetition', readonly=True)
report_date = fields.Function(fields.Date('Date agreed for result'),
'get_service_field')
session_id = fields.Integer('Session ID')
@classmethod
def __register__(cls, module_name):
super(SearchPlannedFractionsDetail,
cls).__register__(module_name)
cursor = Transaction().connection.cursor()
cursor.execute('DELETE FROM "' + cls._table + '"')
@classmethod
def __setup__(cls):
super(SearchPlannedFractionsDetail, cls).__setup__()
cls._order.insert(0, ('fraction', 'ASC'))
cls._order.insert(1, ('service_analysis', 'ASC'))
@classmethod
def get_fraction_field(cls, details, names):
result = {}
for name in names:
result[name] = {}
if name == 'label':
for d in details:
result[name][d.id] = getattr(d.fraction, name, None)
elif name == 'fraction_type':
for d in details:
field = getattr(d.fraction, 'type', None)
result[name][d.id] = field.id if field else None
else:
for d in details:
field = getattr(d.fraction, name, None)
result[name][d.id] = field.id if field else None
return result
@classmethod
def search_fraction_field(cls, name, clause):
return [('fraction.' + name,) + tuple(clause[1:])]
@classmethod
def get_service_field(cls, details, names):
result = {}
for name in names:
result[name] = {}
if name == 'urgent':
for d in details:
result[name][d.id] = False
elif name == 'priority':
for d in details:
result[name][d.id] = 0
else:
for d in details:
result[name][d.id] = None
for d in details:
if d.fraction and d.service_analysis:
for service in d.fraction.services:
if service.analysis == d.service_analysis:
for name in names:
result[name][d.id] = getattr(service, name)
return result
class SearchPlannedFractions(Wizard):
'Search Planned Fractions'
__name__ = 'lims.planification.search_planned_fractions'
@ -4080,8 +3988,8 @@ class SearchPlannedFractions(Wizard):
def transition_search(self):
pool = Pool()
SearchPlannedFractionsDetail = pool.get(
'lims.planification.search_planned_fractions.detail')
SearchFractionsDetail = pool.get(
'lims.planification.search_fractions.detail')
data = self._get_service_details()
@ -4091,11 +3999,9 @@ class SearchPlannedFractions(Wizard):
'session_id': self._session_id,
'fraction': k[0],
'service_analysis': k[1],
'product_type': v['product_type'],
'matrix': v['matrix'],
'repetition': v['repetition'],
})
fractions_added = SearchPlannedFractionsDetail.create(to_create)
fractions_added = SearchFractionsDetail.create(to_create)
self.next.details = fractions_added
return 'next'
@ -4153,7 +4059,6 @@ class SearchPlannedFractions(Wizard):
NotebookLine = pool.get('lims.notebook.line')
Notebook = pool.get('lims.notebook')
Fraction = pool.get('lims.fraction')
Sample = pool.get('lims.sample')
EntryDetailAnalysis = pool.get('lims.entry.detail.analysis')
Service = pool.get('lims.service')
Analysis = pool.get('lims.analysis')
@ -4176,19 +4081,8 @@ class SearchPlannedFractions(Wizard):
excluded_fractions_ids = ', '.join(str(x)
for x in [0] + excluded_fractions)
if extra_where:
sample_select = ''
sample_from = ''
repetition_select = ''
else:
sample_select = ', smp.product_type, smp.matrix'
sample_from = (
'INNER JOIN "' + Sample._table + '" smp '
'ON smp.id = frc.sample ')
repetition_select = ', nl.repetition != 0'
sql_select = ('SELECT nl.id, nb.fraction, srv.analysis' +
sample_select + repetition_select + ' ')
sql_select = (
'SELECT nl.id, nb.fraction, srv.analysis, nl.repetition != 0 ')
sql_from = (
'FROM "' + NotebookLine._table + '" nl '
@ -4201,8 +4095,7 @@ class SearchPlannedFractions(Wizard):
'INNER JOIN "' + EntryDetailAnalysis._table + '" ad '
'ON ad.id = nl.analysis_detail '
'INNER JOIN "' + Service._table + '" srv '
'ON srv.id = nl.service ' +
sample_from)
'ON srv.id = nl.service ')
sql_where = (
'WHERE ad.plannable = TRUE '
@ -4242,9 +4135,7 @@ class SearchPlannedFractions(Wizard):
f_ = nl[1]
s_ = nl[2]
result[(f_, s_)] = {
'product_type': nl[3],
'matrix': nl[4],
'repetition': nl[5],
'repetition': nl[3],
}
return result
@ -4268,7 +4159,7 @@ class SearchPlannedFractions(Wizard):
special_types.append(config.bre_fraction_type.id)
if config.mrt_fraction_type:
special_types.append(config.mrt_fraction_type.id)
special_types_ids = ', '.join(str(x) for x in special_types)
special_types_ids = ', '.join(str(x) for x in [0] + special_types)
cursor.execute('SELECT nl.analysis, nl.notebook '
'FROM "' + NotebookLine._table + '" nl '

View File

@ -667,17 +667,6 @@
<field name="name">planification_search_planned_fractions_next_form</field>
</record>
<record model="ir.ui.view" id="lims_search_planned_fractions_detail_view_form">
<field name="model">lims.planification.search_planned_fractions.detail</field>
<field name="type">form</field>
<field name="name">planification_search_planned_fractions_detail_form</field>
</record>
<record model="ir.ui.view" id="lims_search_planned_fractions_detail_view_list">
<field name="model">lims.planification.search_planned_fractions.detail</field>
<field name="type">tree</field>
<field name="name">planification_search_planned_fractions_detail_list</field>
</record>
<record model="ir.action.wizard" id="wiz_lims_search_planned_fractions">
<field name="name">Search Planned Fractions</field>
<field name="wiz_name">lims.planification.search_planned_fractions</field>

View File

@ -4,22 +4,26 @@
<field name="fraction"/>
<label name="service_analysis"/>
<field name="service_analysis"/>
<label name="fraction_type"/>
<field name="fraction_type"/>
<label name="type"/>
<field name="type"/>
<label name="label"/>
<field name="label"/>
<label name="product_type"/>
<field name="product_type"/>
<label name="matrix"/>
<field name="matrix"/>
<group col="8" colspan="4" id="priority">
<group col="6" colspan="2" id="priority">
<label name="urgent"/>
<field name="urgent"/>
<label name="priority"/>
<field name="priority"/>
<label name="repetition"/>
<field name="repetition"/>
</group>
<group col="4" colspan="2" id="dates">
<label name="report_date"/>
<field name="report_date"/>
<label name="create_date2"/>
<field name="create_date2" widget="date"/>
</group>
</form>

View File

@ -2,7 +2,7 @@
<tree>
<field name="fraction"/>
<field name="service_analysis"/>
<field name="fraction_type"/>
<field name="type"/>
<field name="label"/>
<field name="product_type"/>
<field name="matrix"/>
@ -10,6 +10,7 @@
<field name="priority"/>
<field name="repetition"/>
<field name="report_date"/>
<field name="create_date2" widget="date"/>
<field name="completion_percentage" factor="100">
<suffix name="completion_percentage" string="%"/>
</field>

View File

@ -1,25 +0,0 @@
<?xml version="1.0"?>
<form>
<label name="fraction"/>
<field name="fraction"/>
<label name="service_analysis"/>
<field name="service_analysis"/>
<label name="fraction_type"/>
<field name="fraction_type"/>
<label name="label"/>
<field name="label"/>
<label name="product_type"/>
<field name="product_type"/>
<label name="matrix"/>
<field name="matrix"/>
<group col="8" colspan="4" id="priority">
<label name="urgent"/>
<field name="urgent"/>
<label name="priority"/>
<field name="priority"/>
<label name="repetition"/>
<field name="repetition"/>
<label name="report_date"/>
<field name="report_date"/>
</group>
</form>

View File

@ -1,13 +0,0 @@
<?xml version="1.0"?>
<tree>
<field name="fraction"/>
<field name="service_analysis"/>
<field name="fraction_type"/>
<field name="label"/>
<field name="product_type"/>
<field name="matrix"/>
<field name="urgent"/>
<field name="priority"/>
<field name="repetition"/>
<field name="report_date"/>
</tree>

View File

@ -213,8 +213,6 @@ class SearchAnalysisSheet(Wizard):
'session_id': self._session_id,
'fraction': k[0],
'service_analysis': k[1],
'product_type': v['product_type'],
'matrix': v['matrix'],
'repetition': v['repetition'],
})
fractions_added = SearchFractionsDetail.create(to_create)
@ -291,7 +289,6 @@ class SearchAnalysisSheet(Wizard):
NotebookLine = pool.get('lims.notebook.line')
Notebook = pool.get('lims.notebook')
Fraction = pool.get('lims.fraction')
Sample = pool.get('lims.sample')
EntryDetailAnalysis = pool.get('lims.entry.detail.analysis')
Service = pool.get('lims.service')
Analysis = pool.get('lims.analysis')
@ -321,20 +318,8 @@ class SearchAnalysisSheet(Wizard):
service_where = ('AND ad.analysis IN (' +
all_included_analysis_ids + ') ')
if extra_where:
sample_select = ''
sample_from = ''
repetition_select = ''
else:
sample_select = ', smp.product_type, smp.matrix'
sample_from = (
'INNER JOIN "' + Sample._table + '" smp '
'ON smp.id = frc.sample ')
repetition_select = ', nl.repetition != 0'
sql_select = ('SELECT nl.id, nb.fraction, srv.analysis' +
', nl.analysis, nl.method' +
sample_select + repetition_select + ' ')
', nl.analysis, nl.method, nl.repetition != 0 ')
sql_from = (
'FROM "' + NotebookLine._table + '" nl '
@ -347,8 +332,7 @@ class SearchAnalysisSheet(Wizard):
'INNER JOIN "' + EntryDetailAnalysis._table + '" ad '
'ON ad.id = nl.analysis_detail '
'INNER JOIN "' + Service._table + '" srv '
'ON srv.id = nl.service ' +
sample_from)
'ON srv.id = nl.service ')
sql_where = (
'WHERE ad.plannable = TRUE '
@ -397,9 +381,7 @@ class SearchAnalysisSheet(Wizard):
f_ = nl[1]
s_ = nl[2]
result[(f_, s_)] = {
'product_type': nl[5],
'matrix': nl[6],
'repetition': nl[7],
'repetition': nl[5],
}
return result