Accept Merge Request #1440: (feature/设备维保优化 -> develop)
Merge Request: 设备维保计划优化 Created By: @禹翔辉 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @禹翔辉 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1440
This commit is contained in:
@@ -2,3 +2,4 @@
|
|||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import wizard
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
'views/equipment_maintenance_standards_views.xml',
|
'views/equipment_maintenance_standards_views.xml',
|
||||||
'views/maintenance_request_views.xml',
|
'views/maintenance_request_views.xml',
|
||||||
'views/maintenance_equipment_category_views.xml',
|
'views/maintenance_equipment_category_views.xml',
|
||||||
|
'wizard/maintenance_request_wizard.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'application': False,
|
'application': False,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import requests
|
import requests
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
|
|
||||||
|
|
||||||
class SfMaintenanceEquipmentCategory(models.Model):
|
class SfMaintenanceEquipmentCategory(models.Model):
|
||||||
@@ -122,6 +123,13 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
'sf_maintenance_equipment_ids', string='设备维保标准')
|
'sf_maintenance_equipment_ids', string='设备维保标准')
|
||||||
eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准',
|
eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准',
|
||||||
domain="[('maintenance_type','=','保养')]")
|
domain="[('maintenance_type','=','保养')]")
|
||||||
|
|
||||||
|
initial_action_date = fields.Date(string='重置保养日期')
|
||||||
|
initial_action_date_old = fields.Date(string='重置保养日期(旧)')
|
||||||
|
next_action_date = fields.Date(string='下次预防保养')
|
||||||
|
|
||||||
|
initial_overhaul_date = fields.Date(string='重置维修日期')
|
||||||
|
initial_overhaul_date_old = fields.Date(string='重置维修日期(旧)')
|
||||||
overhaul_date = fields.Date(string='下次预防检修')
|
overhaul_date = fields.Date(string='下次预防检修')
|
||||||
overhaul_period = fields.Integer(string='预防检修频次')
|
overhaul_period = fields.Integer(string='预防检修频次')
|
||||||
overhaul_duration = fields.Float(string='检修时长')
|
overhaul_duration = fields.Float(string='检修时长')
|
||||||
@@ -129,6 +137,61 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准',
|
overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准',
|
||||||
domain="[('maintenance_type','=','检修')]")
|
domain="[('maintenance_type','=','检修')]")
|
||||||
|
|
||||||
|
def confirm_maintenance(self):
|
||||||
|
"""
|
||||||
|
确认保养/检修
|
||||||
|
"""
|
||||||
|
context = self.env.context
|
||||||
|
if context['type'] == '保养':
|
||||||
|
if not self.initial_action_date:
|
||||||
|
raise ValidationError('重置保养日期不能为空!!')
|
||||||
|
elif self.initial_action_date < fields.Date.today():
|
||||||
|
raise ValidationError('重置保养日期不能小于当前日期!!')
|
||||||
|
elif context['type'] == '检修':
|
||||||
|
if not self.initial_overhaul_date:
|
||||||
|
raise ValidationError('重置检修日期不能为空!!')
|
||||||
|
elif self.initial_overhaul_date < fields.Date.today():
|
||||||
|
raise ValidationError('重置检修日期不能小于当前日期!!')
|
||||||
|
|
||||||
|
request_ids = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||||
|
('equipment_id', '=', self.id),
|
||||||
|
('maintenance_type', '=', 'preventive'),
|
||||||
|
('sf_maintenance_type', '=', context['type'])])
|
||||||
|
|
||||||
|
if not request_ids:
|
||||||
|
return self.create_maintenance_request(context['type'])
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
"type": "ir.actions.act_window",
|
||||||
|
"res_model": "maintenance.request.wizard",
|
||||||
|
"views": [[False, "form"]],
|
||||||
|
"target": "new",
|
||||||
|
'context': {
|
||||||
|
'equipment_id': self.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def create_maintenance_request(self, maintenance_request_type):
|
||||||
|
"""
|
||||||
|
根据条件创建维保计划
|
||||||
|
"""
|
||||||
|
if maintenance_request_type == '保养':
|
||||||
|
self._create_new_request(self.initial_action_date + timedelta(days=self.period))
|
||||||
|
self.initial_action_date_old = self.initial_action_date
|
||||||
|
elif maintenance_request_type == '检修':
|
||||||
|
self._create_new_request1(self.initial_overhaul_date + timedelta(days=self.overhaul_period))
|
||||||
|
self.initial_overhaul_date_old = self.initial_overhaul_date
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.client',
|
||||||
|
'tag': 'display_notification',
|
||||||
|
'params': {
|
||||||
|
'title': f'创建{maintenance_request_type}计划',
|
||||||
|
'message': f'新{maintenance_request_type}维保计划创建成功',
|
||||||
|
'type': 'success',
|
||||||
|
'next': {'type': 'ir.actions.act_window_close'},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@api.onchange('eq_maintenance_id', 'overhaul_id')
|
@api.onchange('eq_maintenance_id', 'overhaul_id')
|
||||||
def _compute_equipment_maintenance_standards_ids(self):
|
def _compute_equipment_maintenance_standards_ids(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
@@ -591,11 +654,13 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
('equipment_id', '=', equipment.id),
|
('equipment_id', '=', equipment.id),
|
||||||
('sf_maintenance_type', '=', '保养'),
|
('sf_maintenance_type', '=', '保养'),
|
||||||
('stage_id.done', '!=', True),
|
('stage_id.done', '!=', True),
|
||||||
|
('active', '!=', False),
|
||||||
('close_date', '=', False)], order="request_date asc", limit=1)
|
('close_date', '=', False)], order="request_date asc", limit=1)
|
||||||
last_maintenance_done = self.env['maintenance.request'].search([
|
last_maintenance_done = self.env['maintenance.request'].search([
|
||||||
('equipment_id', '=', equipment.id),
|
('equipment_id', '=', equipment.id),
|
||||||
('sf_maintenance_type', '=', '保养'),
|
('sf_maintenance_type', '=', '保养'),
|
||||||
('stage_id.done', '=', True),
|
('stage_id.done', '=', True),
|
||||||
|
('active', '!=', False),
|
||||||
('close_date', '!=', False)], order="close_date desc", limit=1)
|
('close_date', '!=', False)], order="close_date desc", limit=1)
|
||||||
if next_maintenance_todo and last_maintenance_done:
|
if next_maintenance_todo and last_maintenance_done:
|
||||||
next_date = next_maintenance_todo.request_date
|
next_date = next_maintenance_todo.request_date
|
||||||
@@ -624,7 +689,7 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
if next_date < date_now:
|
if next_date < date_now:
|
||||||
next_date = date_now
|
next_date = date_now
|
||||||
else:
|
else:
|
||||||
next_date = equipment.effective_date + timedelta(days=equipment.period)
|
next_date = equipment.initial_action_date + timedelta(days=equipment.period)
|
||||||
equipment.next_action_date = next_date
|
equipment.next_action_date = next_date
|
||||||
else:
|
else:
|
||||||
self.next_action_date = False
|
self.next_action_date = False
|
||||||
@@ -635,11 +700,13 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
('equipment_id', '=', equipment.id),
|
('equipment_id', '=', equipment.id),
|
||||||
('sf_maintenance_type', '=', '检修'),
|
('sf_maintenance_type', '=', '检修'),
|
||||||
('stage_id.done', '!=', True),
|
('stage_id.done', '!=', True),
|
||||||
|
('active', '!=', False),
|
||||||
('close_date', '=', False)], order="request_date asc", limit=1)
|
('close_date', '=', False)], order="request_date asc", limit=1)
|
||||||
last_maintenance_done = self.env['maintenance.request'].search([
|
last_maintenance_done = self.env['maintenance.request'].search([
|
||||||
('equipment_id', '=', equipment.id),
|
('equipment_id', '=', equipment.id),
|
||||||
('sf_maintenance_type', '=', '检修'),
|
('sf_maintenance_type', '=', '检修'),
|
||||||
('stage_id.done', '=', True),
|
('stage_id.done', '=', True),
|
||||||
|
('active', '!=', False),
|
||||||
('close_date', '!=', False)], order="close_date desc", limit=1)
|
('close_date', '!=', False)], order="close_date desc", limit=1)
|
||||||
if next_maintenance_todo and last_maintenance_done:
|
if next_maintenance_todo and last_maintenance_done:
|
||||||
next_date = next_maintenance_todo.request_date
|
next_date = next_maintenance_todo.request_date
|
||||||
@@ -668,7 +735,7 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
if next_date < date_now:
|
if next_date < date_now:
|
||||||
next_date = date_now
|
next_date = date_now
|
||||||
else:
|
else:
|
||||||
next_date = equipment.effective_date + timedelta(days=equipment.overhaul_period)
|
next_date = equipment.initial_overhaul_date + timedelta(days=equipment.overhaul_period)
|
||||||
equipment.overhaul_date = next_date
|
equipment.overhaul_date = next_date
|
||||||
else:
|
else:
|
||||||
self.overhaul_date = False
|
self.overhaul_date = False
|
||||||
@@ -735,6 +802,7 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
next_requests = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
next_requests = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||||
('equipment_id', '=', equipment.id),
|
('equipment_id', '=', equipment.id),
|
||||||
('maintenance_type', '=', 'preventive'),
|
('maintenance_type', '=', 'preventive'),
|
||||||
|
('active', '=', True),
|
||||||
('request_date', '=', equipment.next_action_date),
|
('request_date', '=', equipment.next_action_date),
|
||||||
('sf_maintenance_type', '=', '保养')])
|
('sf_maintenance_type', '=', '保养')])
|
||||||
if not next_requests:
|
if not next_requests:
|
||||||
@@ -743,6 +811,7 @@ class SfMaintenanceEquipment(models.Model):
|
|||||||
next_requests = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
next_requests = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||||
('equipment_id', '=', equipment.id),
|
('equipment_id', '=', equipment.id),
|
||||||
('maintenance_type', '=', 'preventive'),
|
('maintenance_type', '=', 'preventive'),
|
||||||
|
('active', '=', True),
|
||||||
('request_date', '=', equipment.overhaul_date),
|
('request_date', '=', equipment.overhaul_date),
|
||||||
('sf_maintenance_type', '=', '检修')])
|
('sf_maintenance_type', '=', '检修')])
|
||||||
if not next_requests:
|
if not next_requests:
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
|||||||
equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准',
|
equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准',
|
||||||
domain="[('maintenance_type','=',sf_maintenance_type)]")
|
domain="[('maintenance_type','=',sf_maintenance_type)]")
|
||||||
|
|
||||||
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
@api.onchange('sf_maintenance_type')
|
@api.onchange('sf_maintenance_type')
|
||||||
def _compute_equipment_maintenance_request_id(self):
|
def _compute_equipment_maintenance_request_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ access_maintenance_equipment_agv_log,maintenance_equipment_agv_log,model_mainten
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
access_maintenance_system_user,equipment.request system user,maintenance.model_maintenance_request,base.group_user,1,0,0,0
|
access_maintenance_system_user,equipment.request system user,maintenance.model_maintenance_request,base.group_user,1,1,1,0
|
||||||
|
access_maintenance_wizard_system_user,maintenance.request.wizard system user,model_maintenance_request_wizard,base.group_user,1,1,1,0
|
||||||
|
|
||||||
access_maintenance_equipment_group_plan_dispatch,maintenance.equipment,maintenance.model_maintenance_equipment,sf_base.group_plan_dispatch,1,0,0,0
|
access_maintenance_equipment_group_plan_dispatch,maintenance.equipment,maintenance.model_maintenance_equipment,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
access_maintenance_equipment_oee_group_plan_dispatch,maintenance_equipment_oee,model_maintenance_equipment_oee,sf_base.group_plan_dispatch,1,0,0,0
|
access_maintenance_equipment_oee_group_plan_dispatch,maintenance_equipment_oee,model_maintenance_equipment_oee,sf_base.group_plan_dispatch,1,0,0,0
|
||||||
|
|||||||
|
@@ -60,9 +60,9 @@
|
|||||||
<field name="function_type"/>
|
<field name="function_type"/>
|
||||||
<field name="code" readonly="1"/>
|
<field name="code" readonly="1"/>
|
||||||
<field name="equipment_type" invisible="1"/>
|
<field name="equipment_type" invisible="1"/>
|
||||||
<field name="brand_id" force_save="1" />
|
<field name="brand_id" force_save="1"/>
|
||||||
<field name="type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
<field name="type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||||
domain="[('brand_id', '=', brand_id)]" />
|
domain="[('brand_id', '=', brand_id)]"/>
|
||||||
<field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}"
|
<field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}"
|
||||||
force_save="1"/>
|
force_save="1"/>
|
||||||
<field name="run_time" force_save="1"/>
|
<field name="run_time" force_save="1"/>
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
<group>
|
<group>
|
||||||
<group string="基础参数">
|
<group string="基础参数">
|
||||||
<field name="control_system_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
<field name="control_system_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||||
options="{'no_create': True}" />
|
options="{'no_create': True}"/>
|
||||||
<label for="workbench_L" string="工作台尺寸(mm)"/>
|
<label for="workbench_L" string="工作台尺寸(mm)"/>
|
||||||
<div class="test_model">
|
<div class="test_model">
|
||||||
<label for="workbench_L" string="长"/>
|
<label for="workbench_L" string="长"/>
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
<field name="workbench_W" class="o_address_zip"
|
<field name="workbench_W" class="o_address_zip"
|
||||||
attrs="{'required': [('equipment_type', '=', '机床')]}"
|
attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||||
options="{'format': false}"/>
|
options="{'format': false}"/>
|
||||||
<span>&nbsp;</span>
|
<span>&nbsp;</span>
|
||||||
<label for="workbench_H" string="高"/>
|
<label for="workbench_H" string="高"/>
|
||||||
<field name="workbench_H" class="o_address_zip"
|
<field name="workbench_H" class="o_address_zip"
|
||||||
attrs="{'required': [('equipment_type', '=', '机床')]}"
|
attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
<!-- <field name="guide_rail" required="1"/>-->
|
<!-- <field name="guide_rail" required="1"/>-->
|
||||||
<field name="number_of_axles" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
<field name="number_of_axles" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||||
widget="radio"
|
widget="radio"
|
||||||
options="{'horizontal': true}" />
|
options="{'horizontal': true}"/>
|
||||||
<label for="x_axis" string="加工行程(mm)"
|
<label for="x_axis" string="加工行程(mm)"
|
||||||
attrs="{'invisible': [('number_of_axles', '=', False)]}"/>
|
attrs="{'invisible': [('number_of_axles', '=', False)]}"/>
|
||||||
<div class="test_model"
|
<div class="test_model"
|
||||||
@@ -196,8 +196,8 @@
|
|||||||
<field name="T_tool_time"/>
|
<field name="T_tool_time"/>
|
||||||
<field name="C_tool_time"/>
|
<field name="C_tool_time"/>
|
||||||
</group>
|
</group>
|
||||||
<group string="主轴">
|
<group string="主轴">
|
||||||
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}" />
|
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"/>
|
||||||
<label for="distance_min" string="主轴端面-工作台距离(mm)"/>
|
<label for="distance_min" string="主轴端面-工作台距离(mm)"/>
|
||||||
<div class="test_model">
|
<div class="test_model">
|
||||||
<label for="distance_min" string="最小(min)"/>
|
<label for="distance_min" string="最小(min)"/>
|
||||||
@@ -237,7 +237,7 @@
|
|||||||
<field name="c_precision"/>
|
<field name="c_precision"/>
|
||||||
<field name="c_precision_repeat"/>
|
<field name="c_precision_repeat"/>
|
||||||
</group>
|
</group>
|
||||||
<group string="进给参数">
|
<group string="进给参数">
|
||||||
<field name="X_axis_rapid_traverse_speed"/>
|
<field name="X_axis_rapid_traverse_speed"/>
|
||||||
<field name="Y_axis_rapid_traverse_speed"/>
|
<field name="Y_axis_rapid_traverse_speed"/>
|
||||||
<field name="Z_axis_rapid_traverse_speed"/>
|
<field name="Z_axis_rapid_traverse_speed"/>
|
||||||
@@ -252,21 +252,21 @@
|
|||||||
|
|
||||||
|
|
||||||
</page>
|
</page>
|
||||||
<page string="AGV运行日志" name="sf_equipment"
|
<page string="AGV运行日志" name="sf_equipment"
|
||||||
attrs="{'invisible': [('equipment_type', '!=', 'AGV小车')]}">
|
attrs="{'invisible': [('equipment_type', '!=', 'AGV小车')]}">
|
||||||
<field name="agv_logs">
|
<field name="agv_logs">
|
||||||
<tree create="1" edit="1" delete="1" editable="bottom">
|
<tree create="1" edit="1" delete="1" editable="bottom">
|
||||||
<field name = 'run_type'/>
|
<field name='run_type'/>
|
||||||
<field name = 'run_code'/>
|
<field name='run_code'/>
|
||||||
<field name = 'run_first'/>
|
<field name='run_first'/>
|
||||||
<field name = 'run_last'/>
|
<field name='run_last'/>
|
||||||
<field name = 'production_line'/>
|
<field name='production_line'/>
|
||||||
<field name = 'workorder'/>
|
<field name='workorder'/>
|
||||||
<field name = 'time'/>
|
<field name='time'/>
|
||||||
<field name = 'state'/>
|
<field name='state'/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
<page string="设备参数" name="sf_equipment"
|
<page string="设备参数" name="sf_equipment"
|
||||||
attrs="{'invisible': [('equipment_type', '!=', 'AGV小车')]}">
|
attrs="{'invisible': [('equipment_type', '!=', 'AGV小车')]}">
|
||||||
@@ -979,31 +979,58 @@
|
|||||||
</group>
|
</group>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//field[@name='next_action_date']" position="before">
|
|
||||||
|
|
||||||
<field name='eq_maintenance_id' force_save="1" widget="many2one"/>
|
<xpath expr="//page[@name='maintenance']" position="replace">
|
||||||
|
<page string="维保" name="maintenance">
|
||||||
|
<group>
|
||||||
|
<group string="保养">
|
||||||
|
<field name='eq_maintenance_id' force_save="1" widget="many2one"/>
|
||||||
|
<field name="initial_action_date"/>
|
||||||
|
<field name="next_action_date" string="下次预防保养"/>
|
||||||
|
<label for="period" string="预防保养频次"/>
|
||||||
|
<div class="o_row">
|
||||||
|
<field name="period"/>
|
||||||
|
days
|
||||||
|
</div>
|
||||||
|
<label for="maintenance_duration" string="保养时长"/>
|
||||||
|
<div class="o_row">
|
||||||
|
<field name="maintenance_duration"/>
|
||||||
|
hours
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
|
||||||
|
<button name="confirm_maintenance" string="确认保养" type="object"
|
||||||
|
class="oe_highlight" context="{'type': '保养'}"/>
|
||||||
|
</div>
|
||||||
|
</group>
|
||||||
|
<group string="检修">
|
||||||
|
<field name='overhaul_id'/>
|
||||||
|
<field name="initial_overhaul_date"/>
|
||||||
|
<field name="overhaul_date" string="下次预防检修"/>
|
||||||
|
<label for="overhaul_period" string="预防检修频次"/>
|
||||||
|
<div class="o_row">
|
||||||
|
<field name="overhaul_period"/>
|
||||||
|
days
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label for="overhaul_duration" string="检修时长"/>
|
||||||
|
<div class="o_row">
|
||||||
|
<field name="overhaul_duration"/>
|
||||||
|
hours
|
||||||
|
</div>
|
||||||
|
<field name='equipment_maintenance_standards_ids' widget="many2many_tags"
|
||||||
|
invisible="1"/>
|
||||||
|
|
||||||
|
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
|
||||||
|
<button name="confirm_maintenance" string="确认检修" type="object"
|
||||||
|
class="oe_highlight" context="{'type': '检修'}"/>
|
||||||
|
</div>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
|
||||||
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
<xpath expr="//div[hasclass('o_row')][field[@name='maintenance_duration']]" position="after">
|
|
||||||
|
|
||||||
|
|
||||||
<field name='overhaul_id' options="{'no_create':True}"/>
|
|
||||||
<field name="overhaul_date" string="下次预防检修"/>
|
|
||||||
<label for="overhaul_period" string="预防检修频次"/>
|
|
||||||
<div class="o_row">
|
|
||||||
<field name="overhaul_period"/>
|
|
||||||
days
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label for="overhaul_duration" string="检修时长"/>
|
|
||||||
<div class="o_row">
|
|
||||||
<field name="overhaul_duration"/>
|
|
||||||
hours
|
|
||||||
</div>
|
|
||||||
<field name='equipment_maintenance_standards_ids' widget="many2many_tags" invisible="1"/>
|
|
||||||
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//page[@name='description']" position="attributes">
|
<xpath expr="//page[@name='description']" position="attributes">
|
||||||
<attribute name="invisible">1</attribute>
|
<attribute name="invisible">1</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
@@ -1189,7 +1216,7 @@
|
|||||||
<field name="name" readonly="1"/>
|
<field name="name" readonly="1"/>
|
||||||
<field name="type" readonly="1"/>
|
<field name="type" readonly="1"/>
|
||||||
<field name="image" widget="image" readonly="1"/>
|
<field name="image" widget="image" readonly="1"/>
|
||||||
<!-- <field name="equipment_id"/>-->
|
<!-- <field name="equipment_id"/>-->
|
||||||
<field name="active" invisible="1"/>
|
<field name="active" invisible="1"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
1
sf_maintenance/wizard/__init__.py
Normal file
1
sf_maintenance/wizard/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import maintenance_request_wizard
|
||||||
26
sf_maintenance/wizard/maintenance_request_wizard.py
Normal file
26
sf_maintenance/wizard/maintenance_request_wizard.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class MaintenanceRequestWizard(models.TransientModel):
|
||||||
|
_name = 'maintenance.request.wizard'
|
||||||
|
_description = '维保二次确认弹窗'
|
||||||
|
|
||||||
|
name = fields.Char('')
|
||||||
|
|
||||||
|
def submit(self):
|
||||||
|
context = self.env.context
|
||||||
|
equipment_id = self.env['maintenance.equipment'].sudo().search([('id', '=', context['equipment_id'])])
|
||||||
|
request_ids = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||||
|
('equipment_id', '=', equipment_id.id),
|
||||||
|
('maintenance_type', '=', 'preventive'),
|
||||||
|
('sf_maintenance_type', '=', context['type'])])
|
||||||
|
request_ids.write({'active': False})
|
||||||
|
return equipment_id.create_maintenance_request(context['type'])
|
||||||
|
|
||||||
|
def cancel(self):
|
||||||
|
context = self.env.context
|
||||||
|
equipment_id = self.env['maintenance.equipment'].sudo().search([('id', '=', context['equipment_id'])])
|
||||||
|
if context['type'] == '保养':
|
||||||
|
equipment_id.initial_action_date = equipment_id.initial_action_date_old
|
||||||
|
elif context['type'] == '检修':
|
||||||
|
equipment_id.initial_overhaul_date = equipment_id.initial_overhaul_date_old
|
||||||
29
sf_maintenance/wizard/maintenance_request_wizard.xml
Normal file
29
sf_maintenance/wizard/maintenance_request_wizard.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<record id="action_maintenance_request_wizard" model="ir.actions.act_window">
|
||||||
|
<field name="name">维保计划</field>
|
||||||
|
<field name="res_model">maintenance.request.wizard</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="maintenance_request_wizard_form_view">
|
||||||
|
<field name="name">maintenance.request.wizard.form.view</field>
|
||||||
|
<field name="model">maintenance.request.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<div>
|
||||||
|
<field name="name" invisible="1"/>
|
||||||
|
有未执行的历史维保计划,是否创建新维保计划!!
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<button string="确认" name="submit" type="object" class="oe_highlight"/>
|
||||||
|
<button string="取消" name="cancel" type="object" class="oe_highlight"/>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
@@ -51,6 +51,8 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
string='位置', compute='_compute_current_location_id', store=True)
|
string='位置', compute='_compute_current_location_id', store=True)
|
||||||
image = fields.Binary('图片', readonly=True)
|
image = fields.Binary('图片', readonly=True)
|
||||||
|
|
||||||
|
stock_num = fields.Integer('库存变更次数', default=0)
|
||||||
|
|
||||||
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
|
safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools',
|
||||||
string='功能刀具安全库存', readonly=True)
|
string='功能刀具安全库存', readonly=True)
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
})
|
})
|
||||||
|
|
||||||
@api.depends('barcode_id.quant_ids', 'barcode_id.quant_ids.location_id', 'functional_tool_status',
|
@api.depends('barcode_id.quant_ids', 'barcode_id.quant_ids.location_id', 'functional_tool_status',
|
||||||
'current_shelf_location_id')
|
'current_shelf_location_id', 'stock_num')
|
||||||
def _compute_current_location_id(self):
|
def _compute_current_location_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.functional_tool_status == '已拆除':
|
if record.functional_tool_status == '已拆除':
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ class StockMoveLine(models.Model):
|
|||||||
[('barcode_id', '=', line_id.lot_id.id),
|
[('barcode_id', '=', line_id.lot_id.id),
|
||||||
('functional_tool_status', '=', '正常')]).cnc_function_tool_use_verify()
|
('functional_tool_status', '=', '正常')]).cnc_function_tool_use_verify()
|
||||||
|
|
||||||
|
for move_line in move_lines:
|
||||||
|
if move_line.lot_id:
|
||||||
|
tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||||
|
[('barcode_id', '=', move_line.lot_id.id),
|
||||||
|
('functional_tool_status', '=', '正常')])
|
||||||
|
tool_id.stock_num += tool_id.stock_num
|
||||||
|
|
||||||
|
|
||||||
class StockPicking(models.Model):
|
class StockPicking(models.Model):
|
||||||
_inherit = 'stock.picking'
|
_inherit = 'stock.picking'
|
||||||
|
|||||||
Reference in New Issue
Block a user