更改排程结构前备份
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
@@ -34,10 +35,28 @@ class MrpProduction(models.Model):
|
||||
" * 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()
|
||||
self.state = '已排程'
|
||||
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:
|
||||
@@ -54,9 +73,8 @@ class MrpProduction(models.Model):
|
||||
|
||||
def cancel_plan(self):
|
||||
self.ensure_one()
|
||||
self.date_planned_finished = None
|
||||
self.state = 'confirmed'
|
||||
# self.plan_start_time = None
|
||||
# self.plan_end_time = None
|
||||
|
||||
@api.depends('request_ids')
|
||||
def _compute_maintenance_count(self):
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
</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"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='date_planned_start']" position="after">
|
||||
<field name="date_deadline" widget="remaining_days" attrs="{'invisible': [('state', 'in', ['done', 'cancel'])]}" optional="show"/>
|
||||
<xpath expr="//field[@name='date_planned_start']" position="replace">
|
||||
<field name="date_planned_start" optional="show"/>
|
||||
<field name="date_planned_finished" string="计划结束时间"/>
|
||||
<!-- <field name="date_deadline" widget="remaining_days" attrs="{'invisible': [('state', 'in', ['done', 'cancel'])]}" optional="show"/> -->
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='production_real_duration']" position="after">
|
||||
<field name="reservation_state" optional="hide" decoration-danger="reservation_state == 'confirmed'" decoration-success="reservation_state == 'assigned'"/>
|
||||
@@ -61,7 +64,12 @@
|
||||
</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> -->
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ from odoo import models, fields, api, _
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
# sf坯料预制排程
|
||||
class sf_pl_plan(models.Model):
|
||||
_name = 'sf.pl.plan'
|
||||
_description = 'sf_pl_plan'
|
||||
# sf排程
|
||||
class sf_production_plan(models.Model):
|
||||
_name = 'sf.production.plan'
|
||||
_description = 'sf_production_plan'
|
||||
|
||||
name = fields.Char(string='名称', size=64)
|
||||
# 序号、坯料编号、坯料名称、材质、数量、长度、宽度、厚度、直径、计划开始时间、计划结束时间、状态(已产出与待产出)、操作、创建人、创建时间、客户名称、订单号、行号、长度、宽度、厚度、直径、交货数量、交货日期
|
||||
|
||||
@@ -149,6 +149,57 @@
|
||||
<!-- <field name="res_model">sf.pl.plan</field> -->
|
||||
<!-- <field name="view_mode">tree,form,gantt</field> -->
|
||||
<!-- </record> -->
|
||||
<record id="sf_production_gantt_view" model="ir.ui.view">
|
||||
<field name="name">sf.production.plan.gantt</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="arch" type="xml">
|
||||
<gantt class="o_mrp_workorder_gantt" date_stop="date_planned_finished" date_start="date_planned_start"
|
||||
string="制造订单生产计划" default_group_by="production_line_id" create="0"
|
||||
delete="0" sample="1" plan="0"
|
||||
display_unavailability="1"
|
||||
decoration-success="state == 'done'"
|
||||
decoration-secondary="state == 'cancel'"
|
||||
color="production_line_id"
|
||||
progress_bar="state"
|
||||
form_view_id="mrp.mrp_production_form_view">
|
||||
<field name="name"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="date_planned_start"/>
|
||||
<field name="date_planned_finished" string="计划结束时间"/>
|
||||
<field name="state"/>
|
||||
<templates>
|
||||
<div t-name="gantt-popover" class="container-fluid">
|
||||
<div class="row g-0">
|
||||
<div class="col">
|
||||
<ul class="ps-1 mb-0 list-unstyled">
|
||||
<li>
|
||||
<strong>开始时间:</strong>
|
||||
<t t-out="userTimezoneStartDate.format('L LTS')"/>
|
||||
</li>
|
||||
<li>
|
||||
<strong>结束时间:</strong>
|
||||
<t t-out="userTimezoneStopDate.format('L LTS')"/>
|
||||
</li>
|
||||
<li>
|
||||
<strong>数量:</strong>
|
||||
<t t-out="product_qty"/>
|
||||
</li>
|
||||
<li>
|
||||
<strong>状态:</strong>
|
||||
<t t-if="state === 'cancel'">已取消</t>
|
||||
<t t-elif="state === 'done'">已完成</t>
|
||||
<t t-elif="state === '已排程'">已排程</t>
|
||||
<t t-else="">其他状态</t>
|
||||
<!-- <t t-out="state"/> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</templates>
|
||||
</gantt>
|
||||
</field>
|
||||
</record>
|
||||
<record id="sf_pl_plan_action" model="ir.actions.act_window">
|
||||
<field name="name">制造订单生产计划</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
|
||||
Reference in New Issue
Block a user