mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[FIX] maintenance_usage: migration cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from math import floor
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.tools import get_timedelta
|
||||
|
||||
|
||||
class MaintenanceEquipmentCategory(models.Model):
|
||||
@@ -27,8 +28,8 @@ class MaintenanceEquipment(models.Model):
|
||||
|
||||
def _compute_period(self):
|
||||
for equipment in self:
|
||||
recurring = equipment.maintenance_ids.filtered('recurring_maintenance')
|
||||
equipment.period = min(recurring.mapped('period'), default=0)
|
||||
recurring = equipment.maintenance_ids.filtered('repeat_unit')
|
||||
equipment.period = min([get_timedelta(r.repeat_interval, r.repeat_unit).days for r in recurring], default=0)
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
|
||||
@@ -38,8 +38,11 @@
|
||||
<xpath expr="//group[@name='statistics']" position="inside">
|
||||
<field name="maintenance_usage"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='mttr']" position="after">
|
||||
<field name="period"/>
|
||||
<xpath expr="//field[@name='mttr']/.." position="after">
|
||||
<label for="period"/>
|
||||
<div class="o_row">
|
||||
<field name="period" /> days
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='maintenance_team_id']" position="attributes">
|
||||
<attribute name="required">period != 0 or maintenance_usage != 0</attribute>
|
||||
|
||||
Reference in New Issue
Block a user