计划排程考虑CNC生产线日产能的优化需求,新增可用机台数量,单台小时产能,日有效工作时长计算规则
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from odoo import fields, models
|
from odoo import fields, models, api
|
||||||
from odoo.addons.resource.models.resource import Intervals
|
from odoo.addons.resource.models.resource import Intervals
|
||||||
|
|
||||||
|
|
||||||
@@ -41,14 +41,16 @@ class ResWorkcenter(models.Model):
|
|||||||
|
|
||||||
oee_target = fields.Float(
|
oee_target = fields.Float(
|
||||||
string='OEE Target', help="Overall Effective Efficiency Target in percentage", default=90, tracking=True)
|
string='OEE Target', help="Overall Effective Efficiency Target in percentage", default=90, tracking=True)
|
||||||
oee = fields.Float(compute='_compute_oee', help='Overall Equipment Effectiveness, based on the last month', store=True)
|
oee = fields.Float(compute='_compute_oee', help='Overall Equipment Effectiveness, based on the last month',
|
||||||
|
store=True)
|
||||||
|
|
||||||
time_start = fields.Float('Setup Time', tracking=True)
|
time_start = fields.Float('Setup Time', tracking=True)
|
||||||
time_stop = fields.Float('Cleanup Time', tracking=True)
|
time_stop = fields.Float('Cleanup Time', tracking=True)
|
||||||
costs_hour = fields.Float(string='Cost per hour', help='Hourly processing cost.', default=0.0, tracking=True)
|
costs_hour = fields.Float(string='Cost per hour', help='Hourly processing cost.', default=0.0, tracking=True)
|
||||||
|
|
||||||
equipment_status = fields.Selection(
|
equipment_status = fields.Selection(
|
||||||
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), ("封存(报废)", "封存(报废)")],
|
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"),
|
||||||
|
("封存(报废)", "封存(报废)")],
|
||||||
string="设备状态", related='equipment_id.state')
|
string="设备状态", related='equipment_id.state')
|
||||||
|
|
||||||
# @api.depends('equipment_id')
|
# @api.depends('equipment_id')
|
||||||
@@ -127,6 +129,43 @@ class ResWorkcenter(models.Model):
|
|||||||
|
|
||||||
# AGV是否可配送
|
# AGV是否可配送
|
||||||
is_agv_scheduling = fields.Boolean(string="AGV所属区域", tracking=True)
|
is_agv_scheduling = fields.Boolean(string="AGV所属区域", tracking=True)
|
||||||
|
# 生产线优化
|
||||||
|
available_machine_number = fields.Integer(string="可用机台数量")
|
||||||
|
single_machine_capacity = fields.Float(string="单台小时产能")
|
||||||
|
production_line_hour_capacity = fields.Float(string="生产线小时产能", readonly=True,
|
||||||
|
_compute='_compute_production_line_hour_capacity')
|
||||||
|
effective_working_hours_day = fields.Float(string="日有效工作时长", default=0, readonly=True,
|
||||||
|
_compute='_compute_effective_working_hours_day')
|
||||||
|
default_capacity = fields.Float(
|
||||||
|
'生产线日产能', default=2.0, _compute='_compute_production_line_day_capacity', readonly=True)
|
||||||
|
|
||||||
|
# 计算生产线日产能
|
||||||
|
@api.depends('production_line_hour_capacity', 'effective_working_hours_day')
|
||||||
|
def _compute_production_line_day_capacity(self):
|
||||||
|
for record in self:
|
||||||
|
record.default_capacity = round(
|
||||||
|
record.production_line_hour_capacity * record.effective_working_hours_day, 2)
|
||||||
|
|
||||||
|
# 计算日有效工作时长
|
||||||
|
@api.depends('attendance_ids', 'attendance_ids.hour_to', 'attendance_ids.hour_from')
|
||||||
|
def _compute_effective_working_hours_day(self):
|
||||||
|
for record in self:
|
||||||
|
attendance_ids = record.resource_calendar_id.attendance_ids.filter(
|
||||||
|
lambda r: r.dayofweek == datetime.now().weekday())
|
||||||
|
if attendance_ids:
|
||||||
|
for attendance_id in attendance_ids:
|
||||||
|
if attendance_id.hour_from and attendance_id.hour_to:
|
||||||
|
record.effective_working_hours_day += attendance_id.hour_to - attendance_id.hour_from
|
||||||
|
else:
|
||||||
|
record.effective_working_hours_day = 0
|
||||||
|
|
||||||
|
# 计算生产线小时产能
|
||||||
|
@api.depends('single_machine_capacity', 'available_machine_number')
|
||||||
|
def _compute_production_line_hour_capacity(self):
|
||||||
|
for record in self:
|
||||||
|
record.production_line_hour_capacity = round(
|
||||||
|
record.single_machine_capacity * record.available_machine_number, 2)
|
||||||
|
|
||||||
|
|
||||||
class ResWorkcenterProductivity(models.Model):
|
class ResWorkcenterProductivity(models.Model):
|
||||||
_inherit = 'mrp.workcenter.productivity'
|
_inherit = 'mrp.workcenter.productivity'
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
<field name="model">mrp.production</field>
|
<field name="model">mrp.production</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<!-- <button name="action_cancel" position="before"> -->
|
<!-- <button name="action_cancel" position="before"> -->
|
||||||
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
|
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
|
||||||
<!-- </button> -->
|
<!-- </button> -->
|
||||||
<div name="button_box" position="inside">
|
<div name="button_box" position="inside">
|
||||||
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
|
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
|
||||||
attrs="{'invisible': [('maintenance_count', '=', 0)]}"
|
attrs="{'invisible': [('maintenance_count', '=', 0)]}"
|
||||||
@@ -25,38 +25,59 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="custom_model_form_view_inherit" model="ir.ui.view">
|
<record id="custom_model_form_view_inherit" model="ir.ui.view">
|
||||||
<field name="name">custom.model.form.view.inherit</field>
|
<field name="name">custom.model.form.view.inherit</field>
|
||||||
<field name="model">mrp.workcenter</field>
|
<field name="model">mrp.workcenter</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_workcenter_view"/>
|
<field name="inherit_id" ref="mrp.mrp_workcenter_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr='//form//sheet' position="after">
|
<xpath expr='//form//sheet' position="after">
|
||||||
<div class="oe_chatter">
|
<div class="oe_chatter">
|
||||||
<field name="message_follower_ids"/>
|
<field name="message_follower_ids"/>
|
||||||
<field name="message_ids"/>
|
<field name="message_ids"/>
|
||||||
</div>
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
<xpath expr="//field[@name='default_capacity'][last()]" position="attributes">
|
||||||
</record>
|
<attribute name="string">产线日产能</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='default_capacity'][last()]" position="before">
|
||||||
|
|
||||||
<record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
|
<field name="available_machine_number"/>
|
||||||
<field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
|
<field name="single_machine_capacity"/>
|
||||||
<field name="model">mrp.workcenter</field>
|
<field name="production_line_hour_capacity"/>
|
||||||
<field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
|
<field name="effective_working_hours_day"/>
|
||||||
<field name="arch" type="xml">
|
|
||||||
<!-- Desktop view -->
|
</xpath>
|
||||||
<xpath expr='(//field[@name="name"])[1]' position="after">
|
<!-- <xpath expr='//group[@name="capacity"]//field[@name="default_capacity"])' position="after">-->
|
||||||
<field name="equipment_status" />
|
<!-- <group>-->
|
||||||
<field name="equipment_image" />
|
<!-- <field name="available_machine_number"/>-->
|
||||||
</xpath>
|
<!-- <field name="single_machine_capacity"/>-->
|
||||||
<xpath expr='(//field[@name="name"])[2]' position="after">
|
<!-- <field name="production_line_hour_capacity"/>-->
|
||||||
<field name="equipment_status" />
|
<!-- <field name="effective_working_hours_day"/>-->
|
||||||
<field name="equipment_image" widget="image" />
|
|
||||||
</xpath>
|
<!-- </group>-->
|
||||||
<xpath expr='(//a[@name="unblock"])' position="after">
|
<!-- </xpath>-->
|
||||||
<div class="czyg">绿色:正常,红色:故障,黄色:下线/暂停</div>
|
|
||||||
</xpath>
|
</field>
|
||||||
</field>
|
</record>
|
||||||
</record>
|
|
||||||
|
<record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
|
||||||
|
<field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
|
||||||
|
<field name="model">mrp.workcenter</field>
|
||||||
|
<field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<!-- Desktop view -->
|
||||||
|
<xpath expr='(//field[@name="name"])[1]' position="after">
|
||||||
|
<field name="equipment_status"/>
|
||||||
|
<field name="equipment_image"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr='(//field[@name="name"])[2]' position="after">
|
||||||
|
<field name="equipment_status"/>
|
||||||
|
<field name="equipment_image" widget="image"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr='(//a[@name="unblock"])' position="after">
|
||||||
|
<div class="czyg">绿色:正常,红色:故障,黄色:下线/暂停</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
|
<record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
|
||||||
<field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
|
<field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
|
||||||
@@ -73,11 +94,11 @@
|
|||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr='(//a[@name="unblock"])' position="after">
|
<xpath expr='(//a[@name="unblock"])' position="after">
|
||||||
<!-- <div class="czyg">绿色:正常,红色:故障,黄色:下线/暂停</div>-->
|
<!-- <div class="czyg">绿色:正常,红色:故障,黄色:下线/暂停</div>-->
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<!-------------------->
|
<!-------------------->
|
||||||
<record id="mrp_workcenter_kanban_inherit1" model="ir.ui.view">
|
<record id="mrp_workcenter_kanban_inherit1" model="ir.ui.view">
|
||||||
<field name="name">mrp.workcenter.kanban.inherit</field>
|
<field name="name">mrp.workcenter.kanban.inherit</field>
|
||||||
<field name="model">mrp.workcenter</field>
|
<field name="model">mrp.workcenter</field>
|
||||||
@@ -99,7 +120,7 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- 继承原有的看板视图 -->
|
<!-- 继承原有的看板视图 -->
|
||||||
<record id="mrp_workcenter_kanban_inherit1" model="ir.ui.view">
|
<record id="mrp_workcenter_kanban_inherit1" model="ir.ui.view">
|
||||||
<field name="name">mrp.workcenter.kanban.inherit</field>
|
<field name="name">mrp.workcenter.kanban.inherit</field>
|
||||||
<field name="model">mrp.workcenter</field>
|
<field name="model">mrp.workcenter</field>
|
||||||
@@ -391,9 +412,9 @@
|
|||||||
<field name="model">mrp.production</field>
|
<field name="model">mrp.production</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<!-- <button name="action_cancel" position="before"> -->
|
<!-- <button name="action_cancel" position="before"> -->
|
||||||
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
|
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
|
||||||
<!-- </button> -->
|
<!-- </button> -->
|
||||||
<div name="button_box" position="inside">
|
<div name="button_box" position="inside">
|
||||||
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
|
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
|
||||||
attrs="{'invisible': [('maintenance_count', '=', 0)]}"
|
attrs="{'invisible': [('maintenance_count', '=', 0)]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user