更改排程结构前备份
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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user