mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'mig/17.0/maintenance_usage' into '17.0'
WIP: mig/17.0/maintenance_usage into 17.0 See merge request hibou-io/hibou-odoo/suite!1758
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):
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<field string="Usage" name="usage_count" widget="statinfo"/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//form/sheet/group/group[1]" position="inside">
|
||||
<xpath expr="//field[@name='equipment_assign_to']/.." position="inside">
|
||||
<label for="usage_qty"/>
|
||||
<div class="o_row" name="usage">
|
||||
<field name="usage_qty" nolabel="1"/>
|
||||
@@ -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