lims_device_maintenance: allow maintenance of products
This commit is contained in:
parent
c40814aa00
commit
a7f0a22ed3
|
@ -10,6 +10,14 @@ msgctxt "field:lims.lab.device.maintenance,activity:"
|
|||
msgid "Activity"
|
||||
msgstr "Actividad"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance,asset:"
|
||||
msgid "Asset"
|
||||
msgstr "Activo"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance,asset_name:"
|
||||
msgid "Asset"
|
||||
msgstr "Activo"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance,color:"
|
||||
msgid "Color"
|
||||
msgstr "Color"
|
||||
|
@ -26,10 +34,18 @@ msgctxt "field:lims.lab.device.maintenance,device:"
|
|||
msgid "Device"
|
||||
msgstr "Equipo"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance,lot:"
|
||||
msgid "Lot"
|
||||
msgstr "Lote"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance,notice_date:"
|
||||
msgid "Notice Date"
|
||||
msgstr "Fecha de aviso"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance,product:"
|
||||
msgid "Product"
|
||||
msgstr "Producto"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance,responsible:"
|
||||
msgid "Responsible User"
|
||||
msgstr "Usuario responsable"
|
||||
|
@ -50,6 +66,10 @@ msgctxt "field:lims.lab.device.maintenance.program,activity:"
|
|||
msgid "Activity"
|
||||
msgstr "Actividad"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance.program,asset:"
|
||||
msgid "Asset"
|
||||
msgstr "Activo"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance.program,detail_frequence:"
|
||||
msgid "Frequence"
|
||||
msgstr "Frecuencia"
|
||||
|
@ -83,6 +103,10 @@ msgctxt "field:lims.lab.device.maintenance.program,latest_date:"
|
|||
msgid "Latest scheduled date"
|
||||
msgstr "Última fecha programada"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance.program,lot:"
|
||||
msgid "Lot"
|
||||
msgstr "Lote"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance.program,notice_days:"
|
||||
msgid "Days to notify"
|
||||
msgstr "Días para el aviso"
|
||||
|
@ -91,6 +115,10 @@ msgctxt "field:lims.lab.device.maintenance.program,only_workdays:"
|
|||
msgid "Allow working days only"
|
||||
msgstr "Permitir solamente días laborables"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance.program,product:"
|
||||
msgid "Product"
|
||||
msgstr "Producto"
|
||||
|
||||
msgctxt "field:lims.lab.device.maintenance.program,responsible:"
|
||||
msgid "Responsible User"
|
||||
msgstr "Usuario responsable"
|
||||
|
@ -214,6 +242,14 @@ msgctxt "selection:ir.cron,method:"
|
|||
msgid "Device Maintenance Calendar Notice"
|
||||
msgstr "Aviso de Calendario de mantenimiento de Equipo"
|
||||
|
||||
msgctxt "selection:lims.lab.device.maintenance,asset:"
|
||||
msgid "Device"
|
||||
msgstr "Equipo"
|
||||
|
||||
msgctxt "selection:lims.lab.device.maintenance,asset:"
|
||||
msgid "Product"
|
||||
msgstr "Producto"
|
||||
|
||||
msgctxt "selection:lims.lab.device.maintenance,state:"
|
||||
msgid "Discarded"
|
||||
msgstr "Descartado"
|
||||
|
@ -230,6 +266,14 @@ msgctxt "selection:lims.lab.device.maintenance,state:"
|
|||
msgid "Pending"
|
||||
msgstr "Pendiente"
|
||||
|
||||
msgctxt "selection:lims.lab.device.maintenance.program,asset:"
|
||||
msgid "Device"
|
||||
msgstr "Equipo"
|
||||
|
||||
msgctxt "selection:lims.lab.device.maintenance.program,asset:"
|
||||
msgid "Product"
|
||||
msgstr "Producto"
|
||||
|
||||
msgctxt ""
|
||||
"selection:lims.lab.device.maintenance.program,detail_frequence_selection:"
|
||||
msgid "Days"
|
||||
|
|
|
@ -40,8 +40,30 @@ class LabDeviceMaintenanceProgram(EventCreator, ModelSQL, ModelView):
|
|||
'Device Maintenance Program'
|
||||
__name__ = 'lims.lab.device.maintenance.program'
|
||||
|
||||
device = fields.Many2One('lims.lab.device', 'Device', required=True,
|
||||
ondelete='CASCADE', select=True)
|
||||
asset = fields.Selection([
|
||||
('device', 'Device'),
|
||||
('product', 'Product'),
|
||||
], 'Asset', select=True, required=True)
|
||||
device = fields.Many2One('lims.lab.device', 'Device',
|
||||
select=True, depends=['asset'],
|
||||
states={
|
||||
'required': Eval('asset') == 'device',
|
||||
'invisible': Eval('asset') != 'device',
|
||||
})
|
||||
product = fields.Many2One('product.product', 'Product',
|
||||
domain=[('type', 'in', ['goods', 'assets'])],
|
||||
depends=['asset'],
|
||||
states={
|
||||
'required': Eval('asset') == 'product',
|
||||
'invisible': Eval('asset') != 'product',
|
||||
})
|
||||
lot = fields.Many2One('stock.lot', 'Lot',
|
||||
domain=[('product', '=', Eval('product'))],
|
||||
depends=['asset', 'product'],
|
||||
states={
|
||||
'required': Eval('asset') == 'product',
|
||||
'invisible': Eval('asset') != 'product',
|
||||
})
|
||||
activity = fields.Many2One('lims.lab.device.maintenance.activity',
|
||||
'Activity', required=True)
|
||||
responsible = fields.Many2One('res.user', 'Responsible User')
|
||||
|
@ -78,19 +100,38 @@ class LabDeviceMaintenanceProgram(EventCreator, ModelSQL, ModelView):
|
|||
'WHERE frequency = \'yearly\'')
|
||||
table_h.drop_column('frequency')
|
||||
|
||||
@staticmethod
|
||||
def default_asset():
|
||||
return 'device'
|
||||
|
||||
def get_rec_name(self, name):
|
||||
return '%s - %s' % (self.activity.rec_name, self.device.description)
|
||||
asset_name = (self.product.rec_name
|
||||
if self.asset == 'product'
|
||||
else self.device.description)
|
||||
return '%s - %s' % (self.activity.rec_name, asset_name)
|
||||
|
||||
@classmethod
|
||||
def get_latest_date(cls, programs, name):
|
||||
Maintenance = Pool().get('lims.lab.device.maintenance')
|
||||
pool = Pool()
|
||||
Maintenance = pool.get('lims.lab.device.maintenance')
|
||||
|
||||
result = {}
|
||||
for p in programs:
|
||||
latest_maintenance = Maintenance.search([
|
||||
('device', '=', p.device),
|
||||
clause = [
|
||||
('activity', '=', p.activity),
|
||||
('state', '=', 'pending'),
|
||||
], order=[('date', 'DESC')], limit=1)
|
||||
]
|
||||
if p.asset == 'product':
|
||||
clause.extend([
|
||||
('product', '=', p.product),
|
||||
('lot', '=', p.lot),
|
||||
])
|
||||
else:
|
||||
clause.extend([
|
||||
('device', '=', p.device),
|
||||
])
|
||||
latest_maintenance = Maintenance.search(clause,
|
||||
order=[('date', 'DESC')], limit=1)
|
||||
result[p.id] = (latest_maintenance and
|
||||
latest_maintenance[0].date or None)
|
||||
return result
|
||||
|
@ -115,7 +156,10 @@ class LabDeviceMaintenanceProgram(EventCreator, ModelSQL, ModelView):
|
|||
Maintenance = pool.get('lims.lab.device.maintenance')
|
||||
|
||||
maintenance = Maintenance()
|
||||
maintenance.asset = program.asset
|
||||
maintenance.device = program.device
|
||||
maintenance.product = program.product
|
||||
maintenance.lot = program.lot
|
||||
maintenance.activity = program.activity
|
||||
maintenance.responsible = program.responsible
|
||||
maintenance.date = schedule_info['scheduled_date'].date()
|
||||
|
@ -133,8 +177,35 @@ class LabDeviceMaintenance(Workflow, ModelSQL, ModelView):
|
|||
_states = {'readonly': Eval('state') != 'draft'}
|
||||
_depends = ['state']
|
||||
|
||||
device = fields.Many2One('lims.lab.device', 'Device', required=True,
|
||||
asset = fields.Selection([
|
||||
('device', 'Device'),
|
||||
('product', 'Product'),
|
||||
], 'Asset', select=True, required=True,
|
||||
states=_states, depends=_depends)
|
||||
device = fields.Many2One('lims.lab.device', 'Device',
|
||||
select=True, depends=['asset', 'state'],
|
||||
states={
|
||||
'required': Eval('asset') == 'device',
|
||||
'invisible': Eval('asset') != 'device',
|
||||
'readonly': Eval('state') != 'draft',
|
||||
})
|
||||
product = fields.Many2One('product.product', 'Product',
|
||||
domain=[('type', 'in', ['goods', 'assets'])],
|
||||
depends=['asset', 'state'],
|
||||
states={
|
||||
'required': Eval('asset') == 'product',
|
||||
'invisible': Eval('asset') != 'product',
|
||||
'readonly': Eval('state') != 'draft',
|
||||
})
|
||||
lot = fields.Many2One('stock.lot', 'Lot',
|
||||
domain=[('product', '=', Eval('product'))],
|
||||
depends=['asset', 'product', 'state'],
|
||||
states={
|
||||
'required': Eval('asset') == 'product',
|
||||
'invisible': Eval('asset') != 'product',
|
||||
'readonly': Eval('state') != 'draft',
|
||||
})
|
||||
asset_name = fields.Function(fields.Char('Asset'), 'get_asset_name')
|
||||
activity = fields.Many2One('lims.lab.device.maintenance.activity',
|
||||
'Activity', required=True, states=_states, depends=_depends)
|
||||
date = fields.Date('Date', required=True, states=_states, depends=_depends)
|
||||
|
@ -173,12 +244,23 @@ class LabDeviceMaintenance(Workflow, ModelSQL, ModelView):
|
|||
},
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def default_asset():
|
||||
return 'device'
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
return 'draft'
|
||||
|
||||
def get_asset_name(self, name=None):
|
||||
asset_name = (self.product.rec_name
|
||||
if self.asset == 'product'
|
||||
else self.device.description)
|
||||
return asset_name
|
||||
|
||||
def get_rec_name(self, name):
|
||||
return '%s - %s' % (self.activity.rec_name, self.device.description)
|
||||
asset_name = self.get_asset_name()
|
||||
return '%s - %s' % (self.activity.rec_name, asset_name)
|
||||
|
||||
def get_color(self, name):
|
||||
if self.state in ('done', 'discarded'):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<calendar dtstart="date" dtend="date" mode="month" background_color="color">
|
||||
<field name="device"/>
|
||||
<field name="asset_name"/>
|
||||
<field name="activity"/>
|
||||
<field name="responsible"/>
|
||||
</calendar>
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<form>
|
||||
<label name="asset"/>
|
||||
<field name="asset"/>
|
||||
<label name="device"/>
|
||||
<field name="device"/>
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
<label name="lot"/>
|
||||
<field name="lot"/>
|
||||
<label name="activity"/>
|
||||
<field name="activity"/>
|
||||
<label name="date"/>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<tree>
|
||||
<field name="date"/>
|
||||
<field name="asset"/>
|
||||
<field name="device"/>
|
||||
<field name="product"/>
|
||||
<field name="lot"/>
|
||||
<field name="activity"/>
|
||||
<field name="responsible"/>
|
||||
<field name="state"/>
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<form>
|
||||
<label name="asset"/>
|
||||
<field name="asset"/>
|
||||
<label name="device"/>
|
||||
<field name="device"/>
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
<label name="lot"/>
|
||||
<field name="lot"/>
|
||||
<label name="activity"/>
|
||||
<field name="activity"/>
|
||||
<label name="responsible"/>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<tree>
|
||||
<field name="asset"/>
|
||||
<field name="device"/>
|
||||
<field name="product"/>
|
||||
<field name="lot"/>
|
||||
<field name="activity"/>
|
||||
<field name="responsible"/>
|
||||
<field name="latest_date"/>
|
||||
|
|
Loading…
Reference in New Issue