Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
],
|
],
|
||||||
'web.assets_backend': [
|
'web.assets_backend': [
|
||||||
'jikimo_frontend/static/src/fields/custom_many2many_checkboxes/*',
|
'jikimo_frontend/static/src/fields/custom_many2many_checkboxes/*',
|
||||||
|
'jikimo_frontend/static/src/fields/Many2OneRadioField/*',
|
||||||
'jikimo_frontend/static/src/scss/custom_style.scss',
|
'jikimo_frontend/static/src/scss/custom_style.scss',
|
||||||
# 'jikimo_frontend/static/src/views/list_nums/list_nbCols.js',
|
# 'jikimo_frontend/static/src/views/list_nums/list_nbCols.js',
|
||||||
'jikimo_frontend/static/src/views/list_nums/list_nums.xml',
|
'jikimo_frontend/static/src/views/list_nums/list_nums.xml',
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.many2one_radio_field {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import { RadioField } from "@web/views/fields/radio/radio_field"; // 导入单选按钮组件
|
||||||
|
import { registry } from "@web/core/registry";
|
||||||
|
|
||||||
|
export class Many2OneRadioField extends RadioField {
|
||||||
|
// 你可以重写或者添加一些方法和属性
|
||||||
|
// 例如,你可以重写setup方法来添加一些事件监听器或者初始化一些变量
|
||||||
|
setup() {
|
||||||
|
super.setup(); // 调用父类的setup方法
|
||||||
|
// 你自己的代码
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onImageClick(event) {
|
||||||
|
// 放大图片逻辑
|
||||||
|
// 获取图片元素
|
||||||
|
const img = event.target;
|
||||||
|
const close = img.nextSibling
|
||||||
|
|
||||||
|
// 实现放大图片逻辑
|
||||||
|
// 比如使用 CSS 放大
|
||||||
|
img.parentElement.classList.add('zoomed');
|
||||||
|
close.classList.add('img_close')
|
||||||
|
}
|
||||||
|
|
||||||
|
onCloseClick(event) {
|
||||||
|
const close = event.target;
|
||||||
|
const img = close.previousSibling
|
||||||
|
img.parentElement.classList.remove('zoomed')
|
||||||
|
close.classList.remove('img_close')
|
||||||
|
}
|
||||||
|
|
||||||
|
get items() {
|
||||||
|
return Many2OneRadioField.getItems(this.props.name, this.props.record);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getItems(fieldName, record) {
|
||||||
|
switch (record.fields[fieldName].type) {
|
||||||
|
case "selection":
|
||||||
|
return record.fields[fieldName].selection;
|
||||||
|
case "many2one": {
|
||||||
|
const value = record.preloadedData[fieldName] || [];
|
||||||
|
return value.map((item) => [item.id, item.display_name, item.image]);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Many2OneRadioField.template = "jikimo_frontend.Many2OneRadioField"
|
||||||
|
// MyCustomWidget.supportedTypes = ['many2many'];
|
||||||
|
|
||||||
|
registry.category("fields").add("many2one_radio", Many2OneRadioField);
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<templates xml:space="preserve">
|
||||||
|
|
||||||
|
<t t-name="jikimo_frontend.Many2OneRadioField" owl="1">
|
||||||
|
<div
|
||||||
|
role="radiogroup"
|
||||||
|
t-attf-class="o_{{ props.orientation }}"
|
||||||
|
t-att-aria-label="string"
|
||||||
|
>
|
||||||
|
<t t-foreach="items" t-as="item" t-key="item[0]">
|
||||||
|
<div class="form-check o_radio_item many2one_radio_field" aria-atomic="true">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
class="form-check-input o_radio_input"
|
||||||
|
t-att-checked="item[0] === value"
|
||||||
|
t-att-disabled="props.readonly"
|
||||||
|
t-att-name="id"
|
||||||
|
t-att-data-value="item[0]"
|
||||||
|
t-att-data-index="item_index"
|
||||||
|
t-att-id="`${id}_${item[0]}`"
|
||||||
|
t-on-change="() => this.onChange(item)"
|
||||||
|
/>
|
||||||
|
<label class="form-check-label o_form_label" t-att-for="`${id}_${item[0]}`" t-esc="item[1]" />
|
||||||
|
<div t-on-dblclick="onImageClick">
|
||||||
|
<t>
|
||||||
|
<img t-att-src="item[2]" width="50" height="50"/>
|
||||||
|
<div class="close" t-on-click="onCloseClick">×</div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
|
||||||
|
</templates>
|
||||||
@@ -44,11 +44,11 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setDefaultColumnWidths(column_num) {
|
setDefaultColumnWidths(column_num) {
|
||||||
const bbb = this.state.columns[0].name
|
// const bbb = this.state.columns[0].name
|
||||||
const widths = this.state.columns.map((col) => this.calculateColumnWidth(col));
|
const widths = this.state.columns.map((col) => this.calculateColumnWidth(col));
|
||||||
const sumOfRelativeWidths = (widths
|
// const sumOfRelativeWidths = (widths
|
||||||
.filter(({ type }) => type === "relative")
|
// .filter(({ type }) => type === "relative")
|
||||||
.reduce((sum, { value }) => sum + value, 0));
|
// .reduce((sum, { value }) => sum + value, 0));
|
||||||
|
|
||||||
// 获取数组的最后一项
|
// 获取数组的最后一项
|
||||||
const lastItem = widths[widths.length - 1];
|
const lastItem = widths[widths.length - 1];
|
||||||
@@ -60,10 +60,16 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
|
|||||||
widths.push(newItem);
|
widths.push(newItem);
|
||||||
|
|
||||||
// 判断销售的sequence
|
// 判断销售的sequence
|
||||||
if (this.state.columns[0].name === "sequence") {
|
// if (this.state.columns[0].name === "sequence") {
|
||||||
widths[1] = { type: "relative", value: 0.1 };
|
// widths[1] = { type: "relative", value: 0.1 };
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 判断 this.state.columns 是否存在且长度大于零
|
||||||
|
if (this.state.columns && this.state.columns.length > 0 && this.state.columns[0].name === "sequence") {
|
||||||
|
widths[1] = { type: "relative", value: 0.1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 1 because nth-child selectors are 1-indexed, 2 when the first column contains
|
// 1 because nth-child selectors are 1-indexed, 2 when the first column contains
|
||||||
// the checkboxes to select records.
|
// the checkboxes to select records.
|
||||||
const columnOffset = this.hasSelectors ? 2 : 1;
|
const columnOffset = this.hasSelectors ? 2 : 1;
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class StatusChange(models.Model):
|
|||||||
'process_start_time': process_start_time,
|
'process_start_time': process_start_time,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
# url1 = config['bfm_url'] + '/api/get/state/get_order'
|
url1 = config['bfm_url'] + '/api/get/state/get_order'
|
||||||
# requests.post(url1, json=json1, data=None)
|
requests.post(url1, json=json1, data=None)
|
||||||
logging.info('接口已经执行=============')
|
logging.info('接口已经执行=============')
|
||||||
|
|
||||||
return res
|
return res
|
||||||
@@ -57,8 +57,8 @@ class StatusChange(models.Model):
|
|||||||
'state': '待派单',
|
'state': '待派单',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
# url1 = config['bfm_url'] + '/api/get/state/cancel_order'
|
url1 = config['bfm_url'] + '/api/get/state/cancel_order'
|
||||||
# requests.post(url1, json=json1, data=None)
|
requests.post(url1, json=json1, data=None)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
<field name="company_id" ref="base.main_company"/>
|
<field name="company_id" ref="base.main_company"/>
|
||||||
<field name="single_manufacturing">true</field>
|
<field name="single_manufacturing">true</field>
|
||||||
<field name="tracking">serial</field>
|
<field name="tracking">serial</field>
|
||||||
<field name="is_bfm">false</field>
|
<field name="is_bfm">true</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="product_embryo_sf_self_machining" model="product.product">
|
<record id="product_embryo_sf_self_machining" model="product.product">
|
||||||
<field name="name">坯料自加工模板</field>
|
<field name="name">坯料自加工模板</field>
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
<field name="company_id" ref="base.main_company"/>
|
<field name="company_id" ref="base.main_company"/>
|
||||||
<field name="single_manufacturing">true</field>
|
<field name="single_manufacturing">true</field>
|
||||||
<field name="tracking">serial</field>
|
<field name="tracking">serial</field>
|
||||||
<field name="is_bfm">false</field>
|
<field name="is_bfm">true</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="product_embryo_sf_outsource" model="product.product">
|
<record id="product_embryo_sf_outsource" model="product.product">
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||||
<field name="company_id" ref="base.main_company"/>
|
<field name="company_id" ref="base.main_company"/>
|
||||||
<field name="tracking">serial</field>
|
<field name="tracking">serial</field>
|
||||||
<field name="is_bfm">false</field>
|
<field name="is_bfm">true</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="product_embryo_sf_purchase" model="product.product">
|
<record id="product_embryo_sf_purchase" model="product.product">
|
||||||
<field name="name">坯料采购模板</field>
|
<field name="name">坯料采购模板</field>
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
<field name="uom_po_id" ref="uom.product_uom_unit"/>
|
||||||
<field name="company_id" ref="base.main_company"/>
|
<field name="company_id" ref="base.main_company"/>
|
||||||
<field name="tracking">serial</field>
|
<field name="tracking">serial</field>
|
||||||
<field name="is_bfm">false</field>
|
<field name="is_bfm">true</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -21,7 +21,7 @@ class ResProductProduct(models.Model):
|
|||||||
class ResProducTemplate(models.Model):
|
class ResProducTemplate(models.Model):
|
||||||
_inherit = 'product.template'
|
_inherit = 'product.template'
|
||||||
|
|
||||||
single_manufacturing = fields.Binary('模型文件')
|
single_manufacturing = fields.Boolean(string="单个制造")
|
||||||
|
|
||||||
|
|
||||||
class ResMrpBomMo(models.Model):
|
class ResMrpBomMo(models.Model):
|
||||||
@@ -95,7 +95,7 @@ class ResMrpBomMo(models.Model):
|
|||||||
limit=1,
|
limit=1,
|
||||||
order='volume desc'
|
order='volume desc'
|
||||||
)
|
)
|
||||||
logging.info('get_bom-vals:%s' % embryo_has)
|
# logging.info('get_bom-vals:%s' % embryo_has)
|
||||||
if embryo_has:
|
if embryo_has:
|
||||||
rate_of_waste = ((embryo_has.volume - product.model_volume) % embryo_has.volume) * 100
|
rate_of_waste = ((embryo_has.volume - product.model_volume) % embryo_has.volume) * 100
|
||||||
if rate_of_waste <= 20:
|
if rate_of_waste <= 20:
|
||||||
|
|||||||
@@ -8,10 +8,11 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="invoice_policy" position="after">
|
<field name="invoice_policy" position="after">
|
||||||
<field name='categ_id'/>
|
<field name='categ_id'/>
|
||||||
|
<field name='is_bfm' invisible="1"/>
|
||||||
<field name='categ_type' invisible="1"/>
|
<field name='categ_type' invisible="1"/>
|
||||||
<field name="upload_model_file"
|
<field name="upload_model_file"
|
||||||
widget="many2many_binary"
|
widget="many2many_binary"
|
||||||
attrs="{'invisible': ['|', ('categ_type', '!=', '成品'),('categ_type', '=', False)]}"/>
|
attrs="{'invisible': ['|', '|',('categ_type', '!=', '成品'),('categ_type', '=', False),('is_bfm','=', True)]}"/>
|
||||||
<field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
|
<field name="model_file" widget="Viewer3D" string="模型" readonly="1" force_save="1"
|
||||||
attrs="{'invisible': ['|','|', ('categ_type', '!=', '成品'),('categ_type', '=', False),('model_file', '=', False)]}"/>
|
attrs="{'invisible': ['|','|', ('categ_type', '!=', '成品'),('categ_type', '=', False),('model_file', '=', False)]}"/>
|
||||||
<field name='cutting_tool_type' invisible="1"/>
|
<field name='cutting_tool_type' invisible="1"/>
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
from . import controllers
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'views/view.xml',
|
'views/view.xml',
|
||||||
# 'views/duration_view.xml'
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'assets': {
|
'assets': {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
from .import controllers
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# -*- 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)
|
|
||||||
|
|
||||||
@@ -2,4 +2,3 @@
|
|||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
from . import custom_plan
|
from . import custom_plan
|
||||||
# from . import duration
|
|
||||||
|
|||||||
@@ -102,12 +102,6 @@ class sf_production_plan(models.Model):
|
|||||||
self.date_planned_finished = None
|
self.date_planned_finished = None
|
||||||
self.state = 'draft'
|
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):
|
def unlink(self):
|
||||||
sequence_to_reorder = self.mapped('sequence')
|
sequence_to_reorder = self.mapped('sequence')
|
||||||
res = super().unlink()
|
res = super().unlink()
|
||||||
@@ -168,64 +162,107 @@ class sf_production_plan(models.Model):
|
|||||||
# delivery_date = fields.Datetime(string='交货日期', related='plan_end_time', readonly=False, store=True)
|
# delivery_date = fields.Datetime(string='交货日期', related='plan_end_time', readonly=False, store=True)
|
||||||
|
|
||||||
# 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了
|
# 当不设置计划结束时间时,增加计算计划结束时间的方法,根据采购周期加缓冲期两个值来算就可以了
|
||||||
|
# def do_production_schedule(self):
|
||||||
|
# """
|
||||||
|
# 排程方法
|
||||||
|
# """
|
||||||
|
# if not self.production_line_id:
|
||||||
|
# raise ValidationError("未选择生产线")
|
||||||
|
# else:
|
||||||
|
# aa = self.env['mrp.production'].sudo().search([('name', '=', self.name)])
|
||||||
|
# workorder_time = 0
|
||||||
|
# workorder_id_list = self.production_id.workorder_ids.ids
|
||||||
|
# print(workorder_id_list)
|
||||||
|
# print(type(self.production_id.workorder_ids))
|
||||||
|
# if self.production_id.workorder_ids:
|
||||||
|
# for item in self.production_id.workorder_ids:
|
||||||
|
# if item.name == 'CNC加工':
|
||||||
|
# item.date_planned_start = self.date_planned_start
|
||||||
|
# item.date_planned_finished = item.date_planned_start + timedelta(
|
||||||
|
# minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
# [('name', '=', 'CNC加工')]).time_cycle)
|
||||||
|
# item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
# [('name', '=', 'CNC加工')]).time_cycle
|
||||||
|
# # print(item.id)
|
||||||
|
# sequence = workorder_id_list.index(item.id) - 1
|
||||||
|
# # print('sequence', sequence)
|
||||||
|
# # print('total', len(workorder_id_list))
|
||||||
|
# # 计算CNC加工之前工单的开始结束时间
|
||||||
|
# for i in range(sequence):
|
||||||
|
# current_workorder_id = (item.id - (i + 1))
|
||||||
|
# current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
|
# [('id', '=', current_workorder_id)])
|
||||||
|
# old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
|
# [('id', '=', (current_workorder_id + 1))])
|
||||||
|
# work_order = self.env['mrp.workorder'].sudo().search(
|
||||||
|
# [('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
||||||
|
# work_order.date_planned_finished = old_workorder_obj.date_planned_start
|
||||||
|
# work_order.date_planned_start = old_workorder_obj.date_planned_start - timedelta(
|
||||||
|
# minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
# [('name', '=', current_workorder_obj.name)]).time_cycle)
|
||||||
|
# work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
# [('name', '=', current_workorder_obj.name)]).time_cycle
|
||||||
|
# # 计算CNC加工之后工单的开始结束时间
|
||||||
|
# for j in range(len(workorder_id_list) - sequence - 2):
|
||||||
|
# current_workorder_id = (item.id + (j + 1))
|
||||||
|
# current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
|
# [('id', '=', current_workorder_id)])
|
||||||
|
# old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
|
# [('id', '=', (current_workorder_id - 1))])
|
||||||
|
# work_order = self.env['mrp.workorder'].sudo().search(
|
||||||
|
# [('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
||||||
|
# try:
|
||||||
|
# work_order.date_planned_start = old_workorder_obj.date_planned_finished
|
||||||
|
# print('work_order.data_start', work_order.date_planned_start)
|
||||||
|
# work_order.date_planned_finished = old_workorder_obj.date_planned_finished + timedelta(
|
||||||
|
# minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
# [('name', '=', current_workorder_obj.name)]).time_cycle)
|
||||||
|
# work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
# [('name', '=', current_workorder_obj.name)]).time_cycle
|
||||||
|
# except ValueError as e:
|
||||||
|
# print('时间设置失败,请检查是否为工序分配工作中心,%s' % e)
|
||||||
|
#
|
||||||
|
# current_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', item.id)])
|
||||||
|
# workorder_time += current_workorder.duration_expected
|
||||||
|
# print('workorder_time', workorder_time)
|
||||||
|
# self.date_planned_finished = self.date_planned_start + timedelta(minutes=workorder_time)
|
||||||
|
# self.state = 'done'
|
||||||
|
# self.production_id.schedule_state = '已排'
|
||||||
|
# # self.production_id.date_planned_start = self.date_planned_start
|
||||||
|
# # self.production_id.date_planned_finished = self.date_planned_finished
|
||||||
|
# else:
|
||||||
|
# raise ValidationError("未找到工单")
|
||||||
|
# # 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'
|
||||||
|
# }
|
||||||
|
|
||||||
def do_production_schedule(self):
|
def do_production_schedule(self):
|
||||||
|
"""
|
||||||
|
排程方法
|
||||||
|
"""
|
||||||
if not self.production_line_id:
|
if not self.production_line_id:
|
||||||
raise ValidationError("未选择生产线")
|
raise ValidationError("未选择生产线")
|
||||||
else:
|
else:
|
||||||
aa = self.env['mrp.production'].sudo().search([('name', '=', self.name)])
|
|
||||||
workorder_time = 0
|
|
||||||
workorder_id_list = self.production_id.workorder_ids.ids
|
workorder_id_list = self.production_id.workorder_ids.ids
|
||||||
print(workorder_id_list)
|
|
||||||
print(type(self.production_id.workorder_ids))
|
|
||||||
if self.production_id.workorder_ids:
|
if self.production_id.workorder_ids:
|
||||||
for item in self.production_id.workorder_ids:
|
for item in self.production_id.workorder_ids:
|
||||||
if item.name == 'CNC加工':
|
if item.name == 'CNC加工':
|
||||||
|
item.date_planned_finished = datetime.now() + timedelta(days=100)
|
||||||
item.date_planned_start = self.date_planned_start
|
item.date_planned_start = self.date_planned_start
|
||||||
item.date_planned_finished = item.date_planned_start + timedelta(
|
item.date_planned_finished = item.date_planned_start + timedelta(
|
||||||
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
[('name', '=', 'CNC加工')]).time_cycle)
|
[('name', '=', 'CNC加工')]).time_cycle)
|
||||||
item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
[('name', '=', 'CNC加工')]).time_cycle
|
[('name', '=', 'CNC加工')]).time_cycle
|
||||||
# print(item.id)
|
self.calculate_plan_time_before(item, workorder_id_list)
|
||||||
sequence = workorder_id_list.index(item.id) - 1
|
self.calculate_plan_time_after(item, workorder_id_list)
|
||||||
# print('sequence', sequence)
|
self.date_planned_start, self.date_planned_finished = item.date_planned_start, item.date_planned_finished
|
||||||
# print('total', len(workorder_id_list))
|
|
||||||
# 计算CNC加工之前工单的开始结束时间
|
|
||||||
for i in range(sequence):
|
|
||||||
current_workorder_id = (item.id - (i + 1))
|
|
||||||
current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
[('id', '=', current_workorder_id)])
|
|
||||||
old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
[('id', '=', (current_workorder_id + 1))])
|
|
||||||
work_order = self.env['mrp.workorder'].sudo().search(
|
|
||||||
[('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
|
||||||
work_order.date_planned_finished = old_workorder_obj.date_planned_start
|
|
||||||
work_order.date_planned_start = old_workorder_obj.date_planned_start - timedelta(
|
|
||||||
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
[('name', '=', current_workorder_obj.name)]).time_cycle)
|
|
||||||
# work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search([('name', '=', current_workorder_obj.name)]).time_cycle
|
|
||||||
# 计算CNC加工之后工单的开始结束时间
|
|
||||||
for j in range(len(workorder_id_list) - sequence - 2):
|
|
||||||
current_workorder_id = (item.id + (j + 1))
|
|
||||||
current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
[('id', '=', current_workorder_id)])
|
|
||||||
old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
|
||||||
[('id', '=', (current_workorder_id - 1))])
|
|
||||||
work_order = self.env['mrp.workorder'].sudo().search(
|
|
||||||
[('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
|
||||||
try:
|
|
||||||
work_order.date_planned_start = old_workorder_obj.date_planned_finished
|
|
||||||
print('work_order.data_start', work_order.date_planned_start)
|
|
||||||
work_order.date_planned_finished = old_workorder_obj.date_planned_finished + timedelta(
|
|
||||||
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
|
||||||
[('name', '=', current_workorder_obj.name)]).time_cycle)
|
|
||||||
except ValueError as e:
|
|
||||||
print('时间设置失败,请检查是否为工序分配工作中心,%s' % e)
|
|
||||||
|
|
||||||
current_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', item.id)])
|
|
||||||
workorder_time += current_workorder.duration_expected
|
|
||||||
print('workorder_time', workorder_time)
|
|
||||||
self.date_planned_finished = self.date_planned_start + timedelta(minutes=workorder_time)
|
|
||||||
self.state = 'done'
|
self.state = 'done'
|
||||||
self.production_id.schedule_state = '已排'
|
self.production_id.schedule_state = '已排'
|
||||||
# self.production_id.date_planned_start = self.date_planned_start
|
# self.production_id.date_planned_start = self.date_planned_start
|
||||||
@@ -241,36 +278,62 @@ class sf_production_plan(models.Model):
|
|||||||
'view_mode': 'gantt,tree,form', # 要显示的视图类型,可以是'form', 'tree', 'kanban', 'graph', 'calendar', 'pivot'等
|
'view_mode': 'gantt,tree,form', # 要显示的视图类型,可以是'form', 'tree', 'kanban', 'graph', 'calendar', 'pivot'等
|
||||||
'target': 'current', # 跳转的目标窗口,可以是'current'或'new'
|
'target': 'current', # 跳转的目标窗口,可以是'current'或'new'
|
||||||
}
|
}
|
||||||
# if self.production_line_id:
|
|
||||||
# if self.plan_start_time and self.plan_end_time:
|
def calculate_plan_time_before(self, item, workorder_id_list):
|
||||||
# return None
|
"""
|
||||||
# elif self.plan_start_time and not self.plan_end_time:
|
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
||||||
# # 如果没有给出计划结束时间,则计划结束时间为计划开始时间+采购周期+缓冲期
|
"""
|
||||||
# # 采购周期
|
sequence = workorder_id_list.index(item.id) - 1
|
||||||
# purchase_cycle = 3
|
# 计算CNC加工之前工单的开始结束时间
|
||||||
# # 缓冲期
|
for i in range(sequence):
|
||||||
# buffer_period = 1
|
current_workorder_id = (item.id - (i + 1))
|
||||||
# # 计划结束时间 = 计划开始时间 + 采购周期 + 缓冲期
|
current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
# self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(
|
[('id', '=', current_workorder_id)])
|
||||||
# days=buffer_period)
|
old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
# self.state = 'produce'
|
[('id', '=', (current_workorder_id + 1))])
|
||||||
# return self.plan_end_time
|
work_order = self.env['mrp.workorder'].sudo().search(
|
||||||
# else:
|
[('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
||||||
# return None
|
work_order.date_planned_finished = datetime.now() + timedelta(days=100)
|
||||||
# # 后面要补充计划开始时间的计算方法
|
work_order.date_planned_start = old_workorder_obj.date_planned_start - timedelta(
|
||||||
# # # 坯料预制时间
|
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
# # # pl_time = 0.5
|
[('name', '=', current_workorder_obj.name)]).time_cycle)
|
||||||
# # # 采购周期
|
work_order.date_planned_finished = old_workorder_obj.date_planned_start
|
||||||
# # purchase_cycle = 3
|
work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
# # # 缓冲期
|
[('name', '=', current_workorder_obj.name)]).time_cycle
|
||||||
# # buffer_period = 1
|
first_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id_list[0])])
|
||||||
# # # 计划结束时间 = 计划开始时间 + 坯料预制时间 + 采购周期 + 缓冲期
|
second_workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id_list[1])])
|
||||||
# # # plan_end_time = plan_start_time + pl_time + purchase_cycle + buffer_period
|
if second_workorder.date_planned_start < first_workorder.date_planned_finished:
|
||||||
# # # 计划结束时间 = 计划开始时间(是一个datatime) + 采购周期(Float) + 缓冲期(Float)
|
item.date_planned_start += timedelta(minutes=60)
|
||||||
# # self.plan_end_time = self.plan_start_time + timedelta(days=purchase_cycle) + timedelta(days=buffer_period)
|
item.date_planned_finished += timedelta(minutes=60)
|
||||||
# # return self.plan_end_time
|
item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
# else:
|
[('name', '=', 'CNC加工')]).time_cycle
|
||||||
# raise ValidationError('生产线为空!')
|
self.calculate_plan_time_before(item, workorder_id_list)
|
||||||
|
|
||||||
|
def calculate_plan_time_after(self, item, workorder_id_list):
|
||||||
|
"""
|
||||||
|
计算CNC加工之后工单的开始结束时间
|
||||||
|
"""
|
||||||
|
sequence = workorder_id_list.index(item.id) - 1
|
||||||
|
# 计算CNC加工之后工单的开始结束时间
|
||||||
|
for j in range(len(workorder_id_list) - sequence - 2):
|
||||||
|
current_workorder_id = (item.id + (j + 1))
|
||||||
|
current_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
|
[('id', '=', current_workorder_id)])
|
||||||
|
old_workorder_obj = self.env['mrp.workorder'].sudo().search(
|
||||||
|
[('id', '=', (current_workorder_id - 1))])
|
||||||
|
work_order = self.env['mrp.workorder'].sudo().search(
|
||||||
|
[('production_id', '=', self.production_id.id), ('id', '=', current_workorder_id)])
|
||||||
|
try:
|
||||||
|
work_order.date_planned_finished = datetime.now() + timedelta(days=100)
|
||||||
|
work_order.date_planned_start = old_workorder_obj.date_planned_finished
|
||||||
|
print('work_order.data_start', work_order.date_planned_start)
|
||||||
|
work_order.date_planned_finished = old_workorder_obj.date_planned_finished + timedelta(
|
||||||
|
minutes=self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
[('name', '=', current_workorder_obj.name)]).time_cycle)
|
||||||
|
work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
|
[('name', '=', current_workorder_obj.name)]).time_cycle
|
||||||
|
except ValueError as e:
|
||||||
|
print('时间设置失败,请检查是否为工序分配工作中心,%s' % e)
|
||||||
|
|
||||||
def cancel_production_schedule(self):
|
def cancel_production_schedule(self):
|
||||||
self.date_planned_finished = False
|
self.date_planned_finished = False
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import base64
|
|
||||||
import json, requests
|
|
||||||
from odoo import models, fields, api, _
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from odoo.exceptions import UserError, ValidationError
|
|
||||||
|
|
||||||
|
|
||||||
class HoleDuration(models.Model):
|
|
||||||
_name = 'hole.duration'
|
|
||||||
_description = 'Hole Duration'
|
|
||||||
|
|
||||||
hole_diameter = fields.Selection([('3', '≤¢3'), ('6', '≤¢6'), ('10', '≤¢10'), ('12', '≤¢12'), ('16', '≤¢16'), ('25', '≤¢25')], string='孔径', required=True)
|
|
||||||
name = fields.Char(string='名称', required=True, default='钻孔')
|
|
||||||
hole_depth = fields.Selection([
|
|
||||||
('10', '≤10'),
|
|
||||||
('30', '≤30'),
|
|
||||||
('50', '≤50'),
|
|
||||||
('70', '≤70'),
|
|
||||||
('90', '≤90'),
|
|
||||||
('100', '≤100'),
|
|
||||||
('120', '≤120'),
|
|
||||||
('150', '≤150')], string='深度', required=True)
|
|
||||||
working_hours = fields.Float(string='工时', required=True)
|
|
||||||
hole_expansion = fields.Float(string='扩孔', required=True, default=0.6)
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<record id="hole_duration_tree" model="ir.ui.view">
|
|
||||||
<field name="name">hole.duration.tree</field>
|
|
||||||
<field name="model">hole.duration</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<tree string="孔加工">
|
|
||||||
<field name="name"/>
|
|
||||||
<field name="hole_diameter"/>
|
|
||||||
<field name="hole_depth"/>
|
|
||||||
<field name="working_hours"/>
|
|
||||||
<field name="hole_expansion"/>
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="hole_duration_form" model="ir.ui.view">
|
|
||||||
<field name="name">hole.duration.form</field>
|
|
||||||
<field name="model">hole.duration</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form string="孔加工">
|
|
||||||
<sheet>
|
|
||||||
<group>
|
|
||||||
<field name="name"/>
|
|
||||||
<field name="hole_diameter"/>
|
|
||||||
<field name="hole_depth"/>
|
|
||||||
<field name="working_hours"/>
|
|
||||||
<field name="hole_expansion"/>
|
|
||||||
</group>
|
|
||||||
</sheet>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="hole_duration_action" model="ir.actions.act_window">
|
|
||||||
<field name="name">孔加工</field>
|
|
||||||
<field name="type">ir.actions.act_window</field>
|
|
||||||
<field name="res_model">hole.duration</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<menuitem
|
|
||||||
id="hole_duration_menu"
|
|
||||||
name="孔加工"
|
|
||||||
sequence="900"
|
|
||||||
action="hole_duration_action"
|
|
||||||
parent="sf_production_plan_menu"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
@@ -10,8 +10,9 @@
|
|||||||
|
|
||||||
<record id="mrp_workorder.menu_mrp_workorder_workcenter" model="ir.ui.menu">
|
<record id="mrp_workorder.menu_mrp_workorder_workcenter" model="ir.ui.menu">
|
||||||
<!-- <field name="name">工单计划</field> -->
|
<!-- <field name="name">工单计划</field> -->
|
||||||
<field name="sequence" eval="300"/>
|
<!-- <field name="sequence" eval="300"/> -->
|
||||||
<field name="parent_id" ref="sf_plan.sf_production_plan_menu"/>
|
<!-- <field name="parent_id" ref="sf_plan.sf_production_plan_menu"/> -->
|
||||||
|
<field name="active" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -688,45 +688,46 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
|
|
||||||
# 整体式刀具型号
|
# 整体式刀具型号
|
||||||
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', readonly=True)
|
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号', readonly=True)
|
||||||
cutting_tool_integral_model_id = fields.Many2one('sf.cutting.tool.material', string='整体式刀具型号', readonly=True)
|
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', readonly=True)
|
||||||
integral_name = fields.Char('整体式刀具名称', readonly=True)
|
integral_name = fields.Char('整体式刀具名称', readonly=True, compute='_compute_auto_fill')
|
||||||
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True)
|
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True)
|
||||||
|
|
||||||
# 刀片型号
|
# 刀片型号
|
||||||
blade_code_id = fields.Many2one('stock.lot', '刀片序列号', readonly=True)
|
blade_code_id = fields.Many2one('stock.lot', '刀片序列号', readonly=True)
|
||||||
cutting_tool_blade_model_id = fields.Many2one('sf.cutting.tool.material', string='刀片型号', readonly=True)
|
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True)
|
||||||
blade_name = fields.Char('刀片名称', readonly=True)
|
blade_name = fields.Char('刀片名称', readonly=True, compute='_compute_auto_fill')
|
||||||
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True)
|
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True)
|
||||||
|
|
||||||
# 刀杆型号
|
# 刀杆型号
|
||||||
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', readonly=True)
|
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号', readonly=True)
|
||||||
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting.tool.material', string='刀杆型号', readonly=True)
|
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', readonly=True)
|
||||||
bar_name = fields.Char('刀杆名称', readonly=True)
|
bar_name = fields.Char('刀杆名称', readonly=True, compute='_compute_auto_fill')
|
||||||
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True)
|
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True)
|
||||||
|
|
||||||
# 刀盘型号
|
# 刀盘型号
|
||||||
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', readonly=True)
|
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号', readonly=True)
|
||||||
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting.tool.material', string='刀盘型号', readonly=True)
|
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', readonly=True)
|
||||||
pad_name = fields.Char('刀盘名称', readonly=True)
|
pad_name = fields.Char('刀盘名称', readonly=True, compute='_compute_auto_fill')
|
||||||
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True)
|
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True)
|
||||||
|
|
||||||
# 刀柄型号
|
# 刀柄型号
|
||||||
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', readonly=True)
|
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号', readonly=True)
|
||||||
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting.tool.material', string='刀柄型号', readonly=True)
|
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', readonly=True)
|
||||||
handle_name = fields.Char('刀柄名称', readonly=True)
|
handle_name = fields.Char('刀柄名称', readonly=True, compute='_compute_auto_fill')
|
||||||
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True)
|
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True)
|
||||||
|
|
||||||
# 夹头型号
|
# 夹头型号
|
||||||
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', readonly=True)
|
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号', readonly=True)
|
||||||
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting.tool.material', string='夹头型号', readonly=True)
|
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', readonly=True)
|
||||||
chuck_name = fields.Char('夹头名称', readonly=True)
|
chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill')
|
||||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
|
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
|
||||||
|
|
||||||
@api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id')
|
@api.depends('integral_code_id', 'blade_code_id', 'bar_code_id', 'pad_code_id', 'handle_code_id', 'chuck_code_id')
|
||||||
def _compute_auto_fill(self):
|
def _compute_auto_fill(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.integral_code_id:
|
if record.integral_code_id:
|
||||||
record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_material_id.id
|
print(record.integral_code_id.product_id)
|
||||||
|
record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.integral_name = record.integral_code_id.product_id.name
|
record.integral_name = record.integral_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -734,7 +735,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
record.integral_name = None
|
record.integral_name = None
|
||||||
record.sf_tool_brand_id_1 = None
|
record.sf_tool_brand_id_1 = None
|
||||||
if record.blade_code_id:
|
if record.blade_code_id:
|
||||||
record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.blade_name = record.blade_code_id.product_id.name
|
record.blade_name = record.blade_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -742,7 +743,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
record.blade_name = None
|
record.blade_name = None
|
||||||
record.sf_tool_brand_id_2 = None
|
record.sf_tool_brand_id_2 = None
|
||||||
if record.bar_code_id:
|
if record.bar_code_id:
|
||||||
record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.bar_name = record.bar_code_id.product_id.name
|
record.bar_name = record.bar_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -750,7 +751,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
record.bar_name = None
|
record.bar_name = None
|
||||||
record.sf_tool_brand_id_3 = None
|
record.sf_tool_brand_id_3 = None
|
||||||
if record.pad_code_id:
|
if record.pad_code_id:
|
||||||
record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.pad_name = record.pad_code_id.product_id.name
|
record.pad_name = record.pad_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -758,7 +759,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
record.pad_name = None
|
record.pad_name = None
|
||||||
record.sf_tool_brand_id_4 = None
|
record.sf_tool_brand_id_4 = None
|
||||||
if record.handle_code_id:
|
if record.handle_code_id:
|
||||||
record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.handle_name = record.handle_code_id.product_id.name
|
record.handle_name = record.handle_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -766,7 +767,7 @@ class FunctionalToolAssembly(models.Model):
|
|||||||
record.handle_name = None
|
record.handle_name = None
|
||||||
record.sf_tool_brand_id_5 = None
|
record.sf_tool_brand_id_5 = None
|
||||||
if record.chuck_code_id:
|
if record.chuck_code_id:
|
||||||
record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.chuck_name = record.chuck_code_id.product_id.name
|
record.chuck_name = record.chuck_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -796,7 +796,7 @@
|
|||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="待换功能刀具信息">
|
<page string="待换功能刀具信息">
|
||||||
<group>
|
<group attrs="{'invisible': [('sf_functional_tool_assembly_id', '=', False)]}">
|
||||||
<group>
|
<group>
|
||||||
<field name="replacement_tool_name_id"/>
|
<field name="replacement_tool_name_id"/>
|
||||||
<field name="replacement_tool_type_id"/>
|
<field name="replacement_tool_type_id"/>
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ class ToolChangeRequirementInformation(models.TransientModel):
|
|||||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True)
|
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True)
|
||||||
|
|
||||||
# replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True)
|
# replacement_tool_code = fields.Char(string='待换功能刀具编码', readonly=True)
|
||||||
replacement_tool_name_id = fields.Many2one('product.product', string='待换功能刀具名称', )
|
replacement_tool_name_id = fields.Many2one('product.product', string='待换功能刀具名称',
|
||||||
|
domain=[('name', '=', '功能刀具')])
|
||||||
replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型')
|
replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型')
|
||||||
replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
|
replacement_tool_coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')],
|
||||||
string='粗/中/精')
|
string='粗/中/精')
|
||||||
@@ -139,42 +140,42 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
# 整体式刀具型号
|
# 整体式刀具型号
|
||||||
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
|
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具')])
|
domain=[('product_id.cutting_tool_material_id.name', '=', '整体式刀具')])
|
||||||
cutting_tool_integral_model_id = fields.Many2one('sf.cutting.tool.material', string='整体式刀具型号', readonly=True)
|
cutting_tool_integral_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', readonly=True)
|
||||||
integral_name = fields.Char('整体式刀具名称', readonly=True)
|
integral_name = fields.Char('整体式刀具名称', readonly=True)
|
||||||
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True)
|
sf_tool_brand_id_1 = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', readonly=True)
|
||||||
|
|
||||||
# 刀片型号
|
# 刀片型号
|
||||||
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
|
blade_code_id = fields.Many2one('stock.lot', '刀片序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片')])
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀片')])
|
||||||
cutting_tool_blade_model_id = fields.Many2one('sf.cutting.tool.material', string='刀片型号', readonly=True)
|
cutting_tool_blade_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', readonly=True)
|
||||||
blade_name = fields.Char('刀片名称', readonly=True)
|
blade_name = fields.Char('刀片名称', readonly=True)
|
||||||
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True)
|
sf_tool_brand_id_2 = fields.Many2one('sf.machine.brand', '刀片品牌', readonly=True)
|
||||||
|
|
||||||
# 刀杆型号
|
# 刀杆型号
|
||||||
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
|
bar_code_id = fields.Many2one('stock.lot', '刀杆序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆')])
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀杆')])
|
||||||
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting.tool.material', string='刀杆型号', readonly=True)
|
cutting_tool_cutterbar_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', readonly=True)
|
||||||
bar_name = fields.Char('刀杆名称', readonly=True)
|
bar_name = fields.Char('刀杆名称', readonly=True)
|
||||||
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True)
|
sf_tool_brand_id_3 = fields.Many2one('sf.machine.brand', '刀杆品牌', readonly=True)
|
||||||
|
|
||||||
# 刀盘型号
|
# 刀盘型号
|
||||||
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
|
pad_code_id = fields.Many2one('stock.lot', '刀盘序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘')])
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀盘')])
|
||||||
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting.tool.material', string='刀盘型号', readonly=True)
|
cutting_tool_cutterpad_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', readonly=True)
|
||||||
pad_name = fields.Char('刀盘名称', readonly=True)
|
pad_name = fields.Char('刀盘名称', readonly=True)
|
||||||
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True)
|
sf_tool_brand_id_4 = fields.Many2one('sf.machine.brand', '刀盘品牌', readonly=True)
|
||||||
|
|
||||||
# 刀柄型号
|
# 刀柄型号
|
||||||
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号',
|
handle_code_id = fields.Many2one('stock.lot', '刀柄序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄')])
|
domain=[('product_id.cutting_tool_material_id.name', '=', '刀柄')])
|
||||||
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting.tool.material', string='刀柄型号', readonly=True)
|
cutting_tool_cutterhandle_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', readonly=True)
|
||||||
handle_name = fields.Char('刀柄名称', readonly=True)
|
handle_name = fields.Char('刀柄名称', readonly=True)
|
||||||
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True)
|
sf_tool_brand_id_5 = fields.Many2one('sf.machine.brand', '刀柄品牌', readonly=True)
|
||||||
|
|
||||||
# 夹头型号
|
# 夹头型号
|
||||||
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号',
|
chuck_code_id = fields.Many2one('stock.lot', '夹头序列号',
|
||||||
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')])
|
domain=[('product_id.cutting_tool_material_id.name', '=', '夹头')])
|
||||||
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting.tool.material', string='夹头型号', readonly=True)
|
cutting_tool_cutterhead_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', readonly=True)
|
||||||
chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill')
|
chuck_name = fields.Char('夹头名称', readonly=True, compute='_compute_auto_fill')
|
||||||
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
|
sf_tool_brand_id_6 = fields.Many2one('sf.machine.brand', '夹头品牌', readonly=True)
|
||||||
|
|
||||||
@@ -207,7 +208,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
def _compute_auto_fill(self):
|
def _compute_auto_fill(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.integral_code_id:
|
if record.integral_code_id:
|
||||||
record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_integral_model_id = record.integral_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.integral_name = record.integral_code_id.product_id.name
|
record.integral_name = record.integral_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_1 = record.integral_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -215,7 +216,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
record.integral_name = None
|
record.integral_name = None
|
||||||
record.sf_tool_brand_id_1 = None
|
record.sf_tool_brand_id_1 = None
|
||||||
if record.blade_code_id:
|
if record.blade_code_id:
|
||||||
record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_blade_model_id = record.blade_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.blade_name = record.blade_code_id.product_id.name
|
record.blade_name = record.blade_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_2 = record.blade_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -223,7 +224,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
record.blade_name = None
|
record.blade_name = None
|
||||||
record.sf_tool_brand_id_2 = None
|
record.sf_tool_brand_id_2 = None
|
||||||
if record.bar_code_id:
|
if record.bar_code_id:
|
||||||
record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterbar_model_id = record.bar_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.bar_name = record.bar_code_id.product_id.name
|
record.bar_name = record.bar_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_3 = record.bar_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -231,7 +232,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
record.bar_name = None
|
record.bar_name = None
|
||||||
record.sf_tool_brand_id_3 = None
|
record.sf_tool_brand_id_3 = None
|
||||||
if record.pad_code_id:
|
if record.pad_code_id:
|
||||||
record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterpad_model_id = record.pad_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.pad_name = record.pad_code_id.product_id.name
|
record.pad_name = record.pad_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_4 = record.pad_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -239,7 +240,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
record.pad_name = None
|
record.pad_name = None
|
||||||
record.sf_tool_brand_id_4 = None
|
record.sf_tool_brand_id_4 = None
|
||||||
if record.handle_code_id:
|
if record.handle_code_id:
|
||||||
record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterhandle_model_id = record.handle_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.handle_name = record.handle_code_id.product_id.name
|
record.handle_name = record.handle_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_5 = record.handle_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -247,7 +248,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
record.handle_name = None
|
record.handle_name = None
|
||||||
record.sf_tool_brand_id_5 = None
|
record.sf_tool_brand_id_5 = None
|
||||||
if record.chuck_code_id:
|
if record.chuck_code_id:
|
||||||
record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_material_id.id
|
record.cutting_tool_cutterhead_model_id = record.chuck_code_id.product_id.cutting_tool_model_id.id
|
||||||
record.chuck_name = record.chuck_code_id.product_id.name
|
record.chuck_name = record.chuck_code_id.product_id.name
|
||||||
record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
|
record.sf_tool_brand_id_6 = record.chuck_code_id.product_id.brand_id.id
|
||||||
else:
|
else:
|
||||||
@@ -302,12 +303,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
|
|||||||
'barcode_id': stock_lot.id,
|
'barcode_id': stock_lot.id,
|
||||||
'functional_tool_name_id': self.functional_tool_name_id.id,
|
'functional_tool_name_id': self.functional_tool_name_id.id,
|
||||||
'mrs_cutting_tool_type_id': self.functional_tool_type_id.id,
|
'mrs_cutting_tool_type_id': self.functional_tool_type_id.id,
|
||||||
'cutting_tool_integral_model_id': self.cutting_tool_integral_model_id.id,
|
'cutting_tool_integral_model_id': self.integral_code_id.product_id.id,
|
||||||
'cutting_tool_blade_model_id': self.cutting_tool_blade_model_id.id,
|
'cutting_tool_blade_model_id': self.blade_code_id.product_id.id,
|
||||||
'cutting_tool_cutterbar_model_id': self.cutting_tool_cutterbar_model_id.id,
|
'cutting_tool_cutterbar_model_id': self.bar_code_id.product_id.id,
|
||||||
'cutting_tool_cutterpad_model_id': self.cutting_tool_cutterpad_model_id.id,
|
'cutting_tool_cutterpad_model_id': self.pad_code_id.product_id.id,
|
||||||
'cutting_tool_cutterhandle_model_id': self.cutting_tool_cutterhandle_model_id.id,
|
'cutting_tool_cutterhandle_model_id': self.handle_code_id.product_id.id,
|
||||||
'cutting_tool_cutterhead_model_id': self.cutting_tool_cutterhead_model_id.id,
|
'cutting_tool_cutterhead_model_id': self.chuck_code_id.product_id.id,
|
||||||
'diameter': self.functional_tool_diameter,
|
'diameter': self.functional_tool_diameter,
|
||||||
'tool_grade': None,
|
'tool_grade': None,
|
||||||
'machining_accuracy': None,
|
'machining_accuracy': None,
|
||||||
|
|||||||
@@ -774,7 +774,14 @@ var GanttRow = Widget.extend({
|
|||||||
let index = 0;
|
let index = 0;
|
||||||
for (const date of this.viewInfo.slots) {
|
for (const date of this.viewInfo.slots) {
|
||||||
const slotStart = date;
|
const slotStart = date;
|
||||||
const slotStop = date.clone().add(8, interval);
|
// const slotStop = date.clone().add(8, interval);
|
||||||
|
let slotStop;
|
||||||
|
|
||||||
|
if (interval === "hour") {
|
||||||
|
slotStop = date.clone().add(8, "hour");
|
||||||
|
} else {
|
||||||
|
slotStop = date.clone().add(1, interval);
|
||||||
|
}
|
||||||
const isToday = date.isSame(new Date(), 'day') && this.state.scale !== 'day';
|
const isToday = date.isSame(new Date(), 'day') && this.state.scale !== 'day';
|
||||||
|
|
||||||
let slotStyle = '';
|
let slotStyle = '';
|
||||||
|
|||||||
@@ -77,13 +77,13 @@
|
|||||||
<t t-if="widget.state.scale in formats" t-esc="slot.format(formats[widget.state.scale])"/>
|
<t t-if="widget.state.scale in formats" t-esc="slot.format(formats[widget.state.scale])"/>
|
||||||
<small t-else="">
|
<small t-else="">
|
||||||
<t t-if="slot.format('k') == 24">
|
<t t-if="slot.format('k') == 24">
|
||||||
<div>夜班</div>
|
<div>夜班(00:00-08:00)</div>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="slot.format('k') == 8">
|
<t t-if="slot.format('k') == 8">
|
||||||
<div>早班</div>
|
<div>早班(08:00-16:00)</div>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="slot.format('k') == 16">
|
<t t-if="slot.format('k') == 16">
|
||||||
<div>晚班</div>
|
<div>晚班(16:00-00:00)</div>
|
||||||
</t>
|
</t>
|
||||||
<!-- <b t-esc="slot.format('k')"/> -->
|
<!-- <b t-esc="slot.format('k')"/> -->
|
||||||
<!-- <span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/> -->
|
<!-- <span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/> -->
|
||||||
|
|||||||
Reference in New Issue
Block a user