Accept Merge Request #361: (feature/生产排程 -> develop)

Merge Request: 基本排程功能合并

Created By: @马广威
Accepted By: @马广威
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/361?initial=true
This commit is contained in:
马广威
2023-09-05 09:33:01 +08:00
committed by Coding
13 changed files with 528 additions and 176 deletions

View File

@@ -20,8 +20,10 @@
<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'"/>
@@ -40,7 +42,64 @@
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_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>
<field name="inherit_id" ref="mrp.view_mrp_production_filter"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<searchpanel class="account_root">
<field name="state" icon="fa-filter"/>
</searchpanel>
</xpath>
<filter name='todo' position="replace"/>
</field>
</record>
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已完成" name="filter_done" domain="[('state', '=', 'done')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已取消" name="filter_cancel" domain="[('state', '=', 'cancel')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="进行中" name="filter_progress" domain="[('state', '=', 'progress')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已确认" name="filter_confirmed" domain="[('state', '=', 'confirmed')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="草稿" name="filter_draft" domain="[('state', '=', 'draft')]"/> -->
<!-- </xpath> -->
</data>
</odoo>

View File

@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import controllers

View File

@@ -13,7 +13,7 @@
'author': 'jikimo',
'website': 'https://sf.cs.jikimo.com',
# 此处依赖sf_manufacturing是因为我要重写其中的一个字段operation_id的string故需要sf_manufacturing先安装
'depends': ['mrp', 'mrp_workorder'],
'depends': ['mrp', 'mrp_workorder', 'sf_manufacturing'],
'data': [
'security/ir.model.access.csv',
'views/view.xml'
@@ -24,7 +24,8 @@
'web.assets_qweb': [
],
'web.assets_backend': [
'sf_plan/static/src/scss/gannt_change.scss'
'sf_plan/static/src/scss/gannt_change.scss',
'sf_plan/static/src/css/button_color.css'
],
},

View File

@@ -0,0 +1,2 @@
from .import controllers

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
import json
import logging
from odoo import http
from odoo.http import request
class ProductionPlan(http.Controller):
@http.route('/api/production/plan', type='http', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def schedule_orders(self, **kw):
"""
排程订单
"""
logging.info('schedule_orders', kw)

View File

@@ -1,25 +1,89 @@
# -*- coding: utf-8 -*-
import base64
from odoo import models, fields, api, _
from datetime import datetime, timedelta
from odoo.exceptions import UserError, ValidationError
import json, requests, logging
# 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'
# _inherit = 'mrp.production'
_description = 'sf_production_plan'
name = fields.Char(string='名称')
production_id = fields.Many2one('mrp.production', '关联制造订单')
product_qty = fields.Float(string='数量', digits='Product Unit of Measure', required=True, default=0.0)
date_planned_start = fields.Datetime(string='计划开始时间', required=True, index=True, copy=False,
default=fields.Datetime.now)
date_planned_finished = fields.Datetime(string='计划结束时间')
state = fields.Selection([
('draft', '未排程'), ('done', '已排程')], string='状态', copy=False, index=True, readonly=True,
store=True, tracking=True)
product_id = fields.Many2one('product.product', '关联产品')
origin = fields.Char(string='来源')
name = fields.Char(string='名称', size=64)
# 序号、坯料编号、坯料名称、材质、数量、长度、宽度、厚度、直径、计划开始时间、计划结束时间、状态(已产出与待产出)、操作、创建人、创建时间、客户名称、订单号、行号、长度、宽度、厚度、直径、交货数量、交货日期
# sequence = fields.Integer(string='序号', required=True, copy=False, readonly=True, index=True,
# default=lambda self: self.env['ir.sequence'].sudo().next_by_code('sf.pl.plan'))
sequence = fields.Integer(string='序号', required=True, copy=False, readonly=True, index=True)
current_operation_name = fields.Char(string='当前工序名称', size=64, default='坯料预制')
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
production_line_id = fields.Many2one('sf.production.line', string='生产线')
# state = fields.Selection([
# ('未排程', '未排程'), ('已排程', '已排程')], string='State', copy=False, index=True, readonly=True,
# store=True, tracking=True)
# orderpoint_id = fields.Many2one('stock.warehouse.orderpoint', compute='_compute_orderpoint_id')
# location_src_id = fields.Many2one('stock.location', 'Components Location', compute='_compute_orderpoint_id', active=False)
# location_dest_id = fields.Many2one('stock.location', 'Finished Products Location', compute='_compute_orderpoint_id')
# picking_type_id = fields.Many2one('stock.picking.type', 'Operation Type', compute='_compute_orderpoint_id')
# move_dest_ids = fields.One2many('stock.move', 'created_production_id', compute='_compute_orderpoint_id')
@api.model
def create(self, vals):
if 'sequence' not in vals:
vals['sequence'] = self.env['sf.pl.plan'].search_count([]) + 1
return super().create(vals)
def _compute_orderpoint_id(self):
pass
def test_sale_order(self):
company_id = self.env.ref('base.main_company').sudo()
date = datetime.today()
aaa = self.env['sale.order'].with_user(self.env.ref("base.user_admin")).sale_order_create(
company_id, 'delivery_name', 'delivery_telephone', 'delivery_address',
date)
print('aaa', aaa)
# 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了
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
def cancel_plan(self):
self.ensure_one()
self.date_planned_finished = None
self.state = 'draft'
# @api.model
# def create(self, vals):
# if 'sequence' not in vals:
# vals['sequence'] = self.env['sf.production.plan'].search_count([]) + 1
# return super().create(vals)
def unlink(self):
sequence_to_reorder = self.mapped('sequence')
@@ -31,7 +95,7 @@ class sf_pl_plan(models.Model):
# 生成编码
def _get_pl_no(self):
sf_pl_no = self.env['sf.pl.plan'].sudo().search(
sf_pl_no = self.env['sf.production.plan'].sudo().search(
[('pl_no', '!=', '')],
limit=1,
order="id desc")
@@ -55,57 +119,126 @@ class sf_pl_plan(models.Model):
return num
pl_no = fields.Char(string='坯料编号', required=True, default=_get_pl_no, readonly=True)
pl_name = fields.Char(string='坯料名称', size=64, required=True)
material = fields.Many2one('sf.production.materials', string='材质', required=True)
quantity = fields.Float(string='数量', required=True)
length = fields.Float(string='长度', required=True)
width = fields.Float(string='宽度', required=True)
thickness = fields.Float(string='厚度', required=True)
diameter = fields.Float(string='直径', required=True)
plan_start_time = fields.Datetime(string='计划开始时间')
plan_end_time = fields.Datetime(string='计划结束时间')
state = fields.Selection([
('draft', '待产出'),
('produce', '已产出'),
], string='状态', copy=False, index=True, default='draft')
customer_name = fields.Char(string='客户名称', size=64)
order_no = fields.Char(string='订单号', size=64)
line_no = fields.Char(string='行号', size=64)
delivery_length = fields.Float(string='交货长度')
delivery_width = fields.Float(string='交货宽度')
delivery_thickness = fields.Float(string='交货厚度')
delivery_diameter = fields.Float(string='交货直径')
delivery_quantity = fields.Float(string='交货数量')
delivery_date = fields.Datetime(string='交货日期', related='plan_end_time', readonly=False, store=True)
# pl_no = fields.Char(string='坯料编号', required=True, default=_get_pl_no, readonly=True)
# pl_name = fields.Char(string='坯料名称', size=64, required=True)
# material = fields.Many2one('sf.production.materials', string='材质', required=True)
# quantity = fields.Float(string='数量', required=True)
# length = fields.Float(string='长度', required=True)
# width = fields.Float(string='宽度', required=True)
# thickness = fields.Float(string='厚度', required=True)
# diameter = fields.Float(string='直径', required=True)
# plan_start_time = fields.Datetime(string='计划开始时间')
# plan_end_time = fields.Datetime(string='计划结束时间')
# state = fields.Selection([
# ('draft', '待排程'),
# ('produce', '已排程'),
# ('done', '已产出'),
# ], string='状态', copy=False, index=True, default='draft')
# customer_name = fields.Char(string='客户名称', size=64)
# order_no = fields.Char(string='订单号', size=64)
# line_no = fields.Char(string='行号', size=64)
# delivery_length = fields.Float(string='交货长度')
# delivery_width = fields.Float(string='交货宽度')
# delivery_thickness = fields.Float(string='交货厚度')
# delivery_diameter = fields.Float(string='交货直径')
# delivery_quantity = fields.Float(string='交货数量')
# delivery_date = fields.Datetime(string='交货日期', related='plan_end_time', readonly=False, store=True)
# 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了
def get_plan_end_time(self):
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
def do_production_schedule(self):
aa = self.env['mrp.production'].sudo().search([('name', '=', self.name)])
workorder_time = 0
print(aa.workorder_ids)
print(type(aa.workorder_ids))
if aa.workorder_ids:
for item in aa.workorder_ids:
current_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', item.id)])
workorder_time += current_workorder.duration_expected
print(workorder_time)
self.date_planned_finished = self.date_planned_start + timedelta(minutes=workorder_time)
self.state = 'done'
else:
return None
# 后面要补充计划开始时间的计算方法
# # 坯料预制时间
# # pl_time = 0.5
self.date_planned_finished = self.date_planned_start + timedelta(days=3)
self.state = 'done'
return {
'name': '排程甘特图',
'type': 'ir.actions.act_window',
'res_model': 'sf.production.plan', # 要跳转的模型名称
'view_mode': 'gantt,tree,form', # 要显示的视图类型,可以是'form', 'tree', 'kanban', 'graph', 'calendar', 'pivot'等
'target': 'current', # 跳转的目标窗口,可以是'current'或'new'
}
# if self.production_line_id:
# 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
# # 计划结束时间 = 计划开始时间 + 坯料预制时间 + 采购周期 + 缓冲期
# # plan_end_time = plan_start_time + pl_time + purchase_cycle + buffer_period
# # 计划结束时间 = 计划开始时间(是一个datatime) + 采购周期(Float) + 缓冲期(Float)
# self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period)
# # 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期
# self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(
# days=buffer_period)
# self.state = 'produce'
# return self.plan_end_time
# else:
# return None
# # 后面要补充计划开始时间的计算方法
# # # 坯料预制时间
# # # pl_time = 0.5
# # # 采购周期
# # purchase_cycle = 3
# # # 缓冲期
# # buffer_period = 1
# # # 计划结束时间 = 计划开始时间 + 坯料预制时间 + 采购周期 + 缓冲期
# # # plan_end_time = plan_start_time + pl_time + purchase_cycle + buffer_period
# # # 计划结束时间 = 计划开始时间(是一个datatime) + 采购周期(Float) + 缓冲期(Float)
# # self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period)
# # return self.plan_end_time
# else:
# raise ValidationError('生产线为空!')
def cancel_production_schedule(self):
self.date_planned_finished = False
self.state = 'draft'
return self.date_planned_finished
def liucheng_cs(self):
res = {'order_number': '123', 'delivery_end_date': str(datetime.now()),
'delivery_name': '机企猫', 'delivery_telephone': '18943919239',
'delivery_address': '新时空大厦',
'bfm_process_order_list': []}
aa = self.env['ir.attachment'].search([('id', '=', 631)])
temp = self.env['product.template'].search([('id', '=', 47)])
item = aa.datas.decode('utf-8')
val = {
'model_long': 3,
'model_width': 1,
'model_height': 1,
'model_volume': 3,
'model_machining_precision': '0.10',
'model_name': aa.name,
'model_data': base64.b64encode(aa.datas).decode('utf-8'),
'model_file': base64.b64encode(temp.model_file).decode('utf-8'),
'texture_code': '001',
'texture_type_code': '001001',
# 'surface_process_code': self.env['jikimo.surface.process']._json_surface_process_code(item),
'process_parameters_code': 'R',
'price': 20,
'number': 2,
'total_amount': 100,
'remark': '这只是测试',
'barcode': 123456789,
}
res['bfm_process_order_list'].append(val)
url = '/api/bfm_process_order/list'
res['bfm_process_order_list'] = json.dumps(res['bfm_process_order_list'])
try:
ret = requests.post(('http://localhost:1069' + url), json={}, data=res)
# aa = json.loads(ret.text)
print(ret)
except Exception as e:
raise UserError(e)
# # sf生产排程
# class sf_produce_plan(models.Model):

View File

@@ -1,5 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sf_pl_plan,sf.pl.plan,model_sf_pl_plan,base.group_user,1,1,1,1
access_sf_production_plan,sf.production.plan,model_sf_production_plan,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_sf_pl_plan access_sf_production_plan sf.pl.plan sf.production.plan model_sf_pl_plan model_sf_production_plan base.group_user 1 1 1 1
3
4
5

View File

@@ -0,0 +1,8 @@
.schedule_done {
background-color: #69c17d;
color: white;
}
.schedule_cancel {
background-color: #ffc54d;
color: black;
}

View File

@@ -1,103 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="sf_pl_plan_tree" model="ir.ui.view">
<field name="name">sf.pl.plan.tree</field>
<field name="model">sf.pl.plan</field>
<record id="sf_production_plan_tree" model="ir.ui.view">
<field name="name">sf.production.plan.tree</field>
<field name="model">sf.production.plan</field>
<field name="arch" type="xml">
<tree string="坯料预制计划">
<tree string="订单计划">
<!-- sequence、pl_no、pl_name、quantity、plan_start_time、plan_end_time、actual_start_time、actual_end_time、state、create_uid、create_date -->
<field name="sequence"/>
<field name="pl_no"/>
<field name="pl_name"/>
<field name="quantity"/>
<field name="plan_start_time"/>
<field name="plan_end_time"/>
<field name="state"/>
<field name="create_uid" string="创建人"/>
<field name="create_date" string="创建时间"/>
<!-- <field name="sequence"/> -->
<field name="name"/>
<field name="product_qty"/>
<field name="date_planned_start"/>
<field name="date_planned_finished"/>
<field name="state" widget="badge" decoration-warning="state == 'draft'" decoration-success="state == 'done'"/>
<button name="do_production_schedule" class="btn schedule_done" string="生产排程" type="object" attrs="{'invisible': [('state', 'not in', ['draft'])]}"/>
<button name="cancel_production_schedule" class="btn schedule_cancel" string="取消排程" type="object" attrs="{'invisible': [('state', 'not in', ['done'])]}"/>
</tree>
</field>
</record>
<record id="sf_pl_plan_form" model="ir.ui.view">
<field name="name">sf.pl.plan.form</field>
<field name="model">sf.pl.plan</field>
<record id="sf_production_plan_form" model="ir.ui.view">
<field name="name">sf.production.plan.form</field>
<field name="model">sf.production.plan</field>
<field name="arch" type="xml">
<form string="坯料预制计划">
<form string="订单计划">
<header>
<button string="执行排程" name="get_plan_end_time" type="object" class="oe_highlight"/>
<field name="state" widget="statusbar" statusbar_visible="draft,produce"/>
<button string="执行排程" name="do_production_schedule" type="object" class="oe_highlight" icon="fa-step-forward"/>
<button string="销售单" name="test_sale_order" type="object" class="oe_highlight"/>
<button string="测试流程" name="liucheng_cs" type="object" class="oe_highlight"/>
<!-- <field name="state" widget="statusbar" statusbar_visible="draft,produce"/> -->
</header>
<sheet>
<div class="oe_title">
<h1>
<field name="pl_no" readonly="1"/>
<field name="name" readonly="1"/>
</h1>
</div>
<group>
<group string="基本信息">
<field name="pl_no"/>
<field name="pl_name"/>
<field name="quantity"/>
<field name="plan_start_time"/>
<field name="plan_end_time"/>
<field name="production_id"/>
<field name="product_id"/>
<field name="origin"/>
<field name="product_qty"/>
<field name="date_planned_start"/>
<field name="date_planned_finished"/>
<field name="state"/>
<field name="production_line_id"/>
</group>
<group string="规格信息" col="1">
<group col="3">
<group>
<field name="length"/>
</group>
<group>
<field name="width"/>
</group>
<group>
<field name="thickness"/>
</group>
</group>
<!-- <group string="规格信息" col="1"> -->
<!-- <group col="3"> -->
<!-- <group> -->
<!-- <field name="length"/> -->
<!-- </group> -->
<!-- <group> -->
<!-- <field name="width"/> -->
<!-- </group> -->
<!-- <group> -->
<!-- <field name="thickness"/> -->
<!-- </group> -->
<!-- </group> -->
<!-- <field name="length"/> -->
<!-- <field name="width"/> -->
<!-- <field name="thickness"/> -->
<group>
<field name="diameter"/>
<field name="material"/>
</group>
</group>
<group string="绑定订单">
<field name="customer_name"/>
<field name="order_no"/>
<field name="line_no"/>
<field name="delivery_length"/>
<field name="delivery_width"/>
<field name="delivery_thickness"/>
<field name="delivery_diameter"/>
<field name="delivery_quantity"/>
<field name="delivery_date"/>
</group>
<!-- <group> -->
<!-- <field name="diameter"/> -->
<!-- <field name="material"/> -->
<!-- </group> -->
<!-- </group> -->
<!-- <group string="绑定订单"> -->
<!-- <field name="customer_name"/> -->
<!-- <field name="order_no"/> -->
<!-- <field name="line_no"/> -->
<!-- <field name="delivery_length"/> -->
<!-- <field name="delivery_width"/> -->
<!-- <field name="delivery_thickness"/> -->
<!-- <field name="delivery_diameter"/> -->
<!-- <field name="delivery_quantity"/> -->
<!-- <field name="delivery_date"/> -->
<!-- </group> -->
</group>
</sheet>
</form>
</field>
</record>
<record id="sf_pl_plan_gantt" model="ir.ui.view">
<field name="name">sf.pl.plan.gantt</field>
<field name="model">sf.pl.plan</field>
<!-- 搜索视图 -->
<record id="sf_production_plan_search" model="ir.ui.view">
<field name="name">sf.production.plan.search</field>
<field name="model">sf.production.plan</field>
<field name="arch" type="xml">
<gantt class="o_mrp_workorder_gantt" date_stop="plan_end_time" date_start="plan_start_time"
string="坯料预制计划" default_group_by="current_operation_name" create="0"
<search string="订单计划">
<field name="name"/>
<field name="product_qty"/>
<field name="date_planned_start"/>
<field name="date_planned_finished"/>
<field name="state"/>
<searchpanel class="account_root">
<field name="state" icon="fa-filter"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_production_plan_gantt" model="ir.ui.view">
<field name="name">sf.production.plan.gantt</field>
<field name="model">sf.production.plan</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"
display_unavailability="1"
color="state"
progress_bar="pl_name"
form_view_id="sf_pl_plan_form">
color="production_line_id"
decoration-success="state == 'done'"
progress_bar="name"
form_view_id="sf_production_plan_form">
<field name="pl_no"/>
<field name="pl_name"/>
<field name="quantity"/>
<field name="plan_start_time"/>
<field name="plan_end_time"/>
<field name="name"/>
<field name="product_qty"/>
<field name="date_planned_start"/>
<field name="date_planned_finished"/>
<field name="state"/>
<templates>
<div t-name="gantt-popover" class="container-fluid">
@@ -113,20 +134,12 @@
<t t-out="userTimezoneStopDate.format('L LTS')"/>
</li>
<li>
<strong>坯料编号:</strong>
<t t-out="pl_no"/>
</li>
<li>
<strong>坯料名称:</strong>
<t t-out="pl_name"/>
<strong>名称:</strong>
<t t-out="name"/>
</li>
<li>
<strong>数量:</strong>
<t t-out="quantity"/>
</li>
<li>
<strong>材质:</strong>
<t t-out="material"/>
<t t-out="product_qty"/>
</li>
<li>
<strong>状态:</strong>
@@ -142,19 +155,135 @@
</record>
<record id="sf_pl_plan_action" model="ir.actions.act_window">
<field name="name">坯料预制计划</field>
<!-- <record id="sf_pl_plan_action" model="ir.actions.act_window"> -->
<!-- <field name="name">制造订单生产计划</field> -->
<!-- <field name="type">ir.actions.act_window</field> -->
<!-- <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_production_plan_action" model="ir.actions.act_window">
<field name="name">制造订单生产计划</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.pl.plan</field>
<field name="view_mode">tree,form,gantt</field>
<field name="res_model">sf.production.plan</field>
<field name="view_mode">gantt,tree,form</field>
</record>
<!-- 这个也是制造订单生产计划只是把tree视图放在了默认位置 -->
<record id="sf_production_plan_action1" model="ir.actions.act_window">
<field name="name">制造订单生产计划</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sf.production.plan</field>
<field name="view_mode">tree,gantt,form</field>
</record>
<menuitem
id="sf_pl_plan_menu"
name="坯料预制计划"
parent="mrp_workorder.mrp_workorder_menu_planning"
sequence="10"
action="sf_pl_plan_action"
id="sf_production_plan_menu"
name="计划"
sequence="150"
action="sf_production_plan_action"
/>
<!-- <record model="ir.ui.menu" id="mrp_custom_menu" inherit_id="mrp.menu_mrp_manufacturing"> -->
<!-- <field name="name">Custom Manufacturing Orders</field> -->
<!-- <field name="action" ref="mrp.mrp_manufacturing_action"/> -->
<!-- --><!-- 扩展现有的动作 --><!-- -->
<!-- </record> -->
<record model="ir.actions.act_window" id="mrp_custom_action">
<!-- 自定义额外的动作 -->
<field name="name">制造订单</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.production</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.actions.act_window" id="sale_custom_action">
<!-- 自定义额外的动作 -->
<field name="name">报价单</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
id="mrp_custom_menu"
name="制造订单"
sequence="150"
action="mrp_custom_action"
parent="sf_production_plan_menu"
/>
<menuitem
id="sale_custom_menu"
name="报价单"
sequence="50"
action="sale_custom_action"
parent="sf_production_plan_menu"
/>
<menuitem
id="schedule_custom_menu"
name="排程单"
sequence="180"
action="sf_production_plan_action1"
parent="sf_production_plan_menu"
/>
<!-- --><!-- 在现有菜单结构后面加入自定义的动作 -->
<!-- <menuitem -->
<!-- id="mrp_custom_menuitem" -->
<!-- name="My Custom Menuitem" -->
<!-- sequence="20" -->
<!-- action="mrp_custom_action"/> -->
<!-- --><!-- 自定义额外的菜单项 --><!-- -->
<!-- </field> -->
</data>
</odoo>

View File

@@ -637,8 +637,10 @@ export default AbstractRenderer.extend(WidgetAdapterMixin, {
case 'day':
return focusDate.format('dddd, MMMM DD, YYYY');
case 'week':
const dateStart = focusDate.clone().startOf('week').format('DD MMMM YYYY');
const dateEnd = focusDate.clone().endOf('week').format('DD MMMM YYYY');
// const dateStart = focusDate.clone().startOf('week').format('DD MMMM YYYY');
const dateStart = focusDate.clone().startOf('week').format('YYYY MMMM DD ');
// const dateEnd = focusDate.clone().endOf('week').format('DD MMMM YYYY');
const dateEnd = focusDate.clone().endOf('week').format('YYYY MMMM DD ');
return _.str.sprintf('%s - %s', dateStart, dateEnd);
case 'month':
return focusDate.format('MMMM YYYY');

View File

@@ -112,7 +112,7 @@ const GanttView = AbstractView.extend({
allowedScales = Object.keys(this.SCALES);
}
const scale = params.context.default_scale || arch.attrs.default_scale || 'month';
const scale = params.context.default_scale || arch.attrs.default_scale || 'week';
const initialDate = moment(params.context.initialDate || params.initialDate || arch.attrs.initial_date || new Date());
const offset = arch.attrs.offset;
if (offset && scale) {

View File

@@ -69,7 +69,7 @@
</div>
</div>
<div class="row g-0 o_gantt_header_scale">
<t t-set="formats" t-value="{'week': 'dddd, Do', 'month': 'DD', 'year': isMobile ? 'MMM' : 'MMMM'}"/>
<t t-set="formats" t-value="{'week': 'Do(dddd)', 'month': 'DD', 'year': isMobile ? 'MMM' : 'MMMM'}"/>
<t t-foreach="widget.viewInfo.slots" t-as="slot">
<t t-set="isToday" t-value="slot.isSame(new Date(), 'day') &amp;&amp; widget.state.scale !== 'day'"/>