change of state agended

This commit is contained in:
raskolnikov 2023-01-11 15:52:08 -05:00
parent 25f2b90809
commit 739032bd8e
3 changed files with 19 additions and 4 deletions

View File

@ -4,7 +4,8 @@ from trytond.model import (
class Diary(ModelSQL, ModelView):
'Diary'
__name__ = 'optical_equipment_maintenance.diary'
_rec_name = 'code'
code = fields.Char("Code", select=True,states={'readonly': True })
date_expected = fields.DateTime("Expected Date", required=True)
date_estimated = fields.DateTime("Estimated Date")

View File

@ -53,6 +53,8 @@ class MaintenanceService(Workflow, ModelSQL, ModelView):
lines = fields.One2Many('optical_equipment.maintenance', 'service_maintenance', "Lines",
states={'readonly': If(Eval('state') != 'in_progress', True)})
estimated_agended = fields.DateTime("Date Maintenance", states=_states)
current_agended = fields.Many2One('optical_equipment_maintenance.diary', "Current Agended",
states=_states)
history_agended = fields.Many2Many('optical_equipment_maintenance.service-maintenance.diary', 'maintenance_service', 'agended', "History Agended", readonly=True)
state_agended = fields.Selection([('no_agenda', "No agenda"),
('agended', "Agended"),
@ -240,13 +242,19 @@ class MaintenanceService(Workflow, ModelSQL, ModelView):
@ModelView.button
@Workflow.transition('in_progress')
def in_progress(cls, maintenances):
pass
for maintenance in maintenances:
maintenance.current_agended.state = 'in_progress'
maintenance.current_agended.save()
@classmethod
@ModelView.button
@Workflow.transition('finished')
def finished(cls, maintenances):
pass
for maintenance in maintenances:
maintenance.current_agended.state = 'finished'
maintenance.current_agended.save()
class Maintenance(Workflow, ModelSQL, ModelView):
@ -574,7 +582,7 @@ class Maintenance(Workflow, ModelSQL, ModelView):
@Workflow.transition('in_progress')
def in_progress(cls, maintenances):
pass
@classmethod
@ModelView.button
@Workflow.transition('finished')
@ -820,6 +828,7 @@ class AssingAgended(Wizard):
maintenanceService.technical = self.start.technical
maintenanceService.state_agended = 'agended'
maintenanceService.state = 'agended'
maintenanceService.current_agended = diary.id
maintenanceService.history_agended += (diary.id,)
maintenanceService.set_code(maintenanceService)
maintenanceService.save()

View File

@ -46,6 +46,11 @@
<field name="lines"/>
</page>
<page string="Agendes" id="agendes">
<group col="-1" id="current_agended">
<label name="current_agended"/>
<field name="current_agended"/>
</group>
<newline/>
<field name="history_agended"/>
</page>
<page string="Other Info" id="other_info">