lims_planning_automatic: automatically plan repetitions
This commit is contained in:
parent
7d8d0779bf
commit
6d886501d3
|
@ -9,6 +9,7 @@ from . import entry
|
|||
from . import sheet
|
||||
from . import quality
|
||||
from . import sample
|
||||
from . import notebook
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -30,4 +31,6 @@ def register():
|
|||
entry.ManageServices,
|
||||
entry.AddSampleService,
|
||||
entry.EditSampleService,
|
||||
notebook.NotebookRepeatAnalysis,
|
||||
notebook.NotebookLineRepeatAnalysis,
|
||||
module='lims_planning_automatic', type_='wizard')
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
# This file is part of lims_planning_automatic module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class NotebookRepeatAnalysis(metaclass=PoolMeta):
|
||||
__name__ = 'lims.notebook.repeat_analysis'
|
||||
|
||||
def transition_repeat(self):
|
||||
pool = Pool()
|
||||
Notebook = pool.get('lims.notebook')
|
||||
Planification = pool.get('lims.planification')
|
||||
|
||||
res = super().transition_repeat()
|
||||
|
||||
entries = set()
|
||||
for notebook in Notebook.browse(Transaction().context['active_ids']):
|
||||
entries.add(notebook.fraction.entry)
|
||||
Planification.automatic_plan(entries=list(entries))
|
||||
return res
|
||||
|
||||
|
||||
class NotebookLineRepeatAnalysis(metaclass=PoolMeta):
|
||||
__name__ = 'lims.notebook.line.repeat_analysis'
|
||||
|
||||
def transition_repeat(self):
|
||||
pool = Pool()
|
||||
NotebookLine = pool.get('lims.notebook.line')
|
||||
Planification = pool.get('lims.planification')
|
||||
|
||||
res = super().transition_repeat()
|
||||
|
||||
line_id = self._get_notebook_line_id()
|
||||
notebook_line = NotebookLine(line_id)
|
||||
entries = [notebook_line.notebook.fraction.entry]
|
||||
Planification.automatic_plan(entries=entries)
|
||||
return res
|
Loading…
Reference in New Issue