删除制造订单处排程相关的部分,排程模块架构改造完成

This commit is contained in:
mgw
2023-08-25 10:43:22 +08:00
parent eda57036bd
commit 7e071151a8
5 changed files with 236 additions and 251 deletions

View File

@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import re
from datetime import datetime, timedelta
from odoo import api, fields, models, _
@@ -15,66 +14,6 @@ class MrpProduction(models.Model):
model_file = fields.Binary('模型文件', related='product_id.model_file')
schedule_state = fields.Selection([('未排', '未排'), ('已排', '已排')],
string='排程状态', default='未排')
# state = fields.Selection(selection_add=[('未排程', '未排程'), ('已排程', '已排程')])
# 生产线
production_line_id = fields.Many2one('sf.production.line', string='生产线')
state = fields.Selection([
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('未排程', '未排程'), ('已排程', '已排程'),
('progress', 'In Progress'),
('to_close', 'To Close'),
('done', 'Done'),
('cancel', 'Cancelled')], string='State',
compute='_compute_state', copy=False, index=True, readonly=True,
store=True, tracking=True,
help=" * Draft: The MO is not confirmed yet.\n"
" * Confirmed: The MO is confirmed, the stock rules and the reordering of the components are trigerred.\n"
" * In Progress: The production has started (on the MO or on the WO).\n"
" * To Close: The production is done, the MO has to be closed.\n"
" * Done: The MO is closed, the stock moves are posted. \n"
" * Cancelled: The MO has been cancelled, can't be confirmed anymore.")
@api.depends('company_id', 'date_planned_start', 'is_planned', 'product_id')
def _compute_date_planned_finished(self):
pass
# 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了
def action_view_production_schedule(self):
self.ensure_one()
if self.date_planned_start and self.date_planned_finished:
return None
elif self.date_planned_start and not self.date_planned_finished:
# 如果没有给出计划结束时间,则计划结束时间为计划开始时间+采购周期+缓冲期
# 采购周期
purchase_cycle = 3
# 缓冲期
buffer_period = 1
# 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期
self.date_planned_finished = self.date_planned_start + timedelta(days=purchase_cycle) + timedelta(
days=buffer_period)
self.state = '已排程'
return self.date_planned_finished
else:
return None
# if self.plan_start_time and self.plan_end_time:
# return None
# elif self.plan_start_time and not self.plan_end_time:
# # 如果没有给出计划结束时间,则计划结束时间为计划开始时间+采购周期+缓冲期
# # 采购周期
# purchase_cycle = 3
# # 缓冲期
# buffer_period = 1
# # 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期
# self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period)
# return self.plan_end_time
# else:
# return None
def cancel_plan(self):
self.ensure_one()
self.date_planned_finished = None
self.state = 'confirmed'
@api.depends('request_ids')
def _compute_maintenance_count(self):
@@ -400,7 +339,7 @@ class MrpProduction(models.Model):
current_sequence += 1
if work.name == '获取CNC加工程序':
work.button_start()
#work.fetchCNC()
# work.fetchCNC()
# 创建工单并进行排序
def _create_workorder(self):

View File

@@ -16,7 +16,6 @@
</xpath>
<xpath expr="//field[@name='product_id']" position="after">
<field name="product_qty" sum="Total Qty" string="数量" readonly="1" optional="show"/>
<field name="production_line_id"/>
</xpath>
<xpath expr="//field[@name='product_qty']" position="after">
<field name="product_uom_id" string="计量单位" options="{'no_open':True,'no_create':True}" groups="uom.group_uom" optional="show"/>
@@ -43,36 +42,35 @@
decoration-warning="reservation_state != 'assigned' and components_availability_state in ('expected', 'available')"
decoration-danger="reservation_state != 'assigned' and components_availability_state == 'late'"/>
</xpath>
<xpath expr="//field[@name='state']" position="after">
<button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/>
<button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/>
</xpath>
</field>
</record>
<record id="custom_mrp_production_form_view" model="ir.ui.view">
<field name="name">custom.mrp.production.form</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<xpath expr="//header//field[@name='state']" position="replace">
<field name="state" widget="statusbar" statusbar_visible="draft,confirmed,已排程,progress,done"/>
</xpath>
<xpath expr="//header" position="inside">
<button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/>
<button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/>
</xpath>
<xpath expr="//sheet//group//group//field[@name='product_id']" position="after">
<field name="production_line_id"/>
<!-- <field name="date_deadline"/> -->
<field name="date_planned_finished" string="计划结束时间"/>
</xpath>
<!-- <xpath expr="//sheet//group//group//field[@name='date_planned_start']" position="after"> -->
<!-- <field name="date_planned_finished"/> -->
<!-- <xpath expr="//field[@name='state']" position="after"> -->
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
<!-- </xpath> -->
</field>
</record>
<!-- <record id="custom_mrp_production_form_view" model="ir.ui.view"> -->
<!-- <field name="name">custom.mrp.production.form</field> -->
<!-- <field name="model">mrp.production</field> -->
<!-- <field name="inherit_id" ref="mrp.mrp_production_form_view"/> -->
<!-- <field name="arch" type="xml"> -->
<!-- <xpath expr="//header//field[@name='state']" position="replace"> -->
<!-- <field name="state" widget="statusbar" statusbar_visible="draft,confirmed,已排程,progress,done"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//header" position="inside"> -->
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//sheet//group//group//field[@name='product_id']" position="after"> -->
<!-- <field name="production_line_id"/> -->
<!-- <field name="date_planned_finished" string="计划结束时间"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//sheet//group//group//field[@name='date_planned_start']" position="after"> -->
<!-- <field name="date_planned_finished"/> -->
<!-- </xpath> -->
<!-- </field> -->
<!-- </record> -->
<record id="custom_view_mrp_production_filter" model="ir.ui.view">
<field name="name">custom.mrp.production.select</field>
<field name="model">mrp.production</field>