Compare commits
1 Commits
feature/ma
...
release/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71eefe7bc6 |
@@ -3,8 +3,8 @@
|
||||
'name': "jikimo_account_process",
|
||||
|
||||
'summary': """
|
||||
处理会计凭证生成重复名称报错问题
|
||||
""",
|
||||
Short (1 phrase/line) summary of the module's purpose, used as
|
||||
subtitle on modules listing or apps.openerp.com""",
|
||||
|
||||
'description': """
|
||||
Long description of module's purpose
|
||||
|
||||
@@ -1,99 +1,41 @@
|
||||
|
||||
.processing-capabilities-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
.zoomed {
|
||||
position: fixed !important;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%) scale(10);
|
||||
}
|
||||
|
||||
.grid-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.many2many_flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.item-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
/*控制图片大小*/
|
||||
.item-icon {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
margin-bottom: 5px;
|
||||
.many2many_flex>div {
|
||||
margin-right: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-label {
|
||||
font-size: 12px;
|
||||
word-break: break-word;
|
||||
.many2many_flex>div>:nth-child(2) {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.processing-capabilities-grid {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
.close {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
top: -8.8px;
|
||||
right: -8.8px;
|
||||
color: #fff;
|
||||
background-color: #000;
|
||||
opacity: 0;
|
||||
text-align: center;
|
||||
line-height: 20px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.processing-capabilities-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.processing-capabilities-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
.image-preview-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.image-preview-container.show {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.image-preview {
|
||||
max-width: 90%;
|
||||
max-height: 90%;
|
||||
object-fit: contain;
|
||||
box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
|
||||
border-radius: 5px;
|
||||
transform: scale(0.9);
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.image-preview-container.show .image-preview {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.image-preview-close {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 30px;
|
||||
color: #fff;
|
||||
font-size: 40px;
|
||||
font-weight: bold;
|
||||
transition: 0.3s;
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.image-preview-close:hover,
|
||||
.image-preview-close:focus {
|
||||
opacity: 1;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
.img_close {
|
||||
opacity: 1;
|
||||
transform: scale(0.1);
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -4,57 +4,35 @@ import {Many2ManyCheckboxesField} from "@web/views/fields/many2many_checkboxes/m
|
||||
import {registry} from "@web/core/registry";
|
||||
|
||||
export class MyCustomWidget extends Many2ManyCheckboxesField {
|
||||
// 你可以重写或者添加一些方法和属性
|
||||
// 例如,你可以重写setup方法来添加一些事件监听器或者初始化一些变量
|
||||
setup() {
|
||||
super.setup();
|
||||
super.setup(); // 调用父类的setup方法
|
||||
// 你自己的代码
|
||||
}
|
||||
|
||||
onImageClick(event, src) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onImageClick(event) {
|
||||
// 放大图片逻辑
|
||||
// 获取图片元素
|
||||
const img = event.target;
|
||||
const close = img.nextSibling;
|
||||
|
||||
// 创建预览框
|
||||
const previewContainer = document.createElement('div');
|
||||
previewContainer.className = 'image-preview-container';
|
||||
// 实现放大图片逻辑
|
||||
// 比如使用 CSS 放大
|
||||
img.parentElement.classList.add('zoomed');
|
||||
close.classList.add('img_close');
|
||||
}
|
||||
|
||||
const previewImg = document.createElement('img');
|
||||
previewImg.src = src;
|
||||
previewImg.className = 'image-preview';
|
||||
// 设置放大的预览图片大小
|
||||
previewImg.style.width = '600px';
|
||||
previewImg.style.height = 'auto'; // 保持宽高比
|
||||
|
||||
const closeButton = document.createElement('span');
|
||||
closeButton.innerHTML = '×';
|
||||
closeButton.className = 'image-preview-close';
|
||||
|
||||
previewContainer.appendChild(previewImg);
|
||||
previewContainer.appendChild(closeButton);
|
||||
document.body.appendChild(previewContainer);
|
||||
|
||||
// 添加关闭预览的事件监听器
|
||||
const closePreview = () => {
|
||||
previewContainer.classList.remove('show');
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(previewContainer);
|
||||
}, 300);
|
||||
};
|
||||
|
||||
closeButton.addEventListener('click', closePreview);
|
||||
|
||||
// 点击预览框外部也可以关闭
|
||||
previewContainer.addEventListener('click', (e) => {
|
||||
if (e.target === previewContainer) {
|
||||
closePreview();
|
||||
}
|
||||
});
|
||||
|
||||
// 使用 setTimeout 来触发过渡效果
|
||||
setTimeout(() => {
|
||||
previewContainer.classList.add('show');
|
||||
}, 10);
|
||||
onCloseClick(event) {
|
||||
const close = event.target;
|
||||
const img = close.previousSibling;
|
||||
img.parentElement.classList.remove('zoomed');
|
||||
close.classList.remove('img_close');
|
||||
}
|
||||
}
|
||||
|
||||
MyCustomWidget.template = "jikimo_frontend.MyCustomWidget";
|
||||
// MyCustomWidget.supportedTypes = ['many2many'];
|
||||
|
||||
registry.category("fields").add("custom_many2many_checkboxes", MyCustomWidget);
|
||||
|
||||
|
||||
@@ -2,20 +2,25 @@
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="jikimo_frontend.MyCustomWidget" owl="1">
|
||||
<div aria-atomic="true" class="many2many_flex processing-capabilities-grid">
|
||||
<div aria-atomic="true" class="many2many_flex">
|
||||
<t t-foreach="items" t-as="item" t-key="item[0]">
|
||||
<div class="grid-item">
|
||||
<div>
|
||||
<CheckBox
|
||||
value="isSelected(item)"
|
||||
disabled="props.readonly"
|
||||
onChange="(ev) => this.onChange(item[0], ev)"
|
||||
>
|
||||
<div class="item-content">
|
||||
<img t-att-src="item[2]" class="item-icon" t-on-click="(ev) => this.onImageClick(ev, item[2])"/>
|
||||
<span class="item-label"><t t-esc="item[1]"/></span>
|
||||
</div>
|
||||
<t t-esc="item[1]"/>
|
||||
|
||||
</CheckBox>
|
||||
<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>
|
||||
|
||||
@@ -108,10 +108,6 @@ td.o_required_modifier {
|
||||
}
|
||||
|
||||
.color_3 {
|
||||
background-color: #808080;
|
||||
}
|
||||
|
||||
.color_4 {
|
||||
background-color: rgb(255, 150, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
from . import controllers
|
||||
@@ -1,21 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': '机企猫 工单异常记录',
|
||||
'version': '1.0',
|
||||
'summary': '记录工单的异常日志',
|
||||
'sequence': 1,
|
||||
'category': 'sf',
|
||||
'website': 'https://www.sf.jikimo.com',
|
||||
'depends': ['sf_manufacturing', 'sf_mrs_connect'],
|
||||
'data': [
|
||||
'views/mrp_workorder_views.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
'license': 'LGPL-3',
|
||||
'installable': True,
|
||||
'application': False,
|
||||
'auto_install': False,
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
from . import main
|
||||
@@ -1,89 +0,0 @@
|
||||
from odoo import http, fields
|
||||
from odoo.http import request
|
||||
import json
|
||||
import logging
|
||||
from odoo.addons.sf_mrs_connect.controllers.controllers import Sf_Mrs_Connect
|
||||
from odoo.addons.sf_manufacturing.controllers.controllers import Manufacturing_Connect
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class WorkorderExceptionConroller(http.Controller):
|
||||
|
||||
@http.route('/AutoDeviceApi/BillError', type='json', auth='public', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def workder_exception(self, **kw):
|
||||
"""
|
||||
记录工单异常
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
_logger.info('workder_exception:%s' % kw)
|
||||
try:
|
||||
res = {'Succeed': True, 'ErrorCode': 0, 'Error': ''}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
if not ret.get('RfidCode') or not ret.get('coding'):
|
||||
res = {'Succeed': False, 'ErrorCode': 400, 'Error': '参数错误'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
# 通过RfidCode获取就绪的CNC工单
|
||||
workorder = request.env['mrp.workorder'].sudo().search([
|
||||
('rfid_code', '=', ret['RfidCode']),
|
||||
('routing_type', '=', 'CNC加工'),
|
||||
])
|
||||
if not workorder:
|
||||
res = {'Succeed': False, 'ErrorCode': 401, 'Error': '无效的工单'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
# 创建工单异常记录,关联工单
|
||||
request.env['jikimo.workorder.exception'].sudo().create({
|
||||
'workorder_id': workorder.id,
|
||||
'exception_code': ret.get('coding'),
|
||||
'exception_content': ret.get('Error', '')
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
_logger.info('workder_exception error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
|
||||
class SfMrsConnectController(Sf_Mrs_Connect):
|
||||
|
||||
@http.route('/api/cnc_processing/create', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def get_cnc_processing_create(self, **kw):
|
||||
"""
|
||||
更新工单异常记录【'YC001', 'YC004'】
|
||||
"""
|
||||
res = super(SfMrsConnectController, self).get_cnc_processing_create(**kw)
|
||||
# 如果有未完成的YC0001、YC0004异常记录,则标记为完成
|
||||
res = json.loads(res)
|
||||
_logger.info('已进入工单异常:%s' % res)
|
||||
if res.get('production_ids'):
|
||||
try:
|
||||
productions = request.env['mrp.production'].sudo().search([('id', 'in', res.get('production_ids'))])
|
||||
if productions.workorder_ids:
|
||||
productions.workorder_ids.handle_exception(['YC0001', 'YC0004'])
|
||||
except Exception as e:
|
||||
_logger.info('更新工单异常记录失败:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
class ManufactruingController(Manufacturing_Connect):
|
||||
|
||||
@http.route('/AutoDeviceApi/FeedBackStart', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def button_Work_START(self, **kw):
|
||||
"""
|
||||
更新工单异常记录【'YC0002', 'YC0003'】
|
||||
"""
|
||||
res = super(ManufactruingController, self).button_Work_START(**kw)
|
||||
res = json.loads(res)
|
||||
_logger.info('已进入工单异常:%s' % res)
|
||||
if res.get('workorder_id'):
|
||||
try:
|
||||
workorder = request.env['mrp.workorder'].sudo().browse(int(res.get('workorder_id')))
|
||||
workorder.handle_exception(['YC0002', 'YC0003'])
|
||||
except Exception as e:
|
||||
_logger.info('更新工单异常记录失败:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import jikimo_workorder_exception
|
||||
from . import mrp_workorder
|
||||
@@ -1,14 +0,0 @@
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class JikimoWorkorderException(models.Model):
|
||||
_name = 'jikimo.workorder.exception'
|
||||
_description = '工单异常记录'
|
||||
_order = 'id desc'
|
||||
|
||||
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||
exception_code = fields.Char('异常编码')
|
||||
exception_content = fields.Char('反馈的异常/问题信息')
|
||||
completion_time = fields.Datetime('处理完成时间')
|
||||
state = fields.Selection([('pending', '进行中'), ('done', '已处理')], string='状态', default='pending')
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
from odoo import models, fields
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class MrpWorkorder(models.Model):
|
||||
_inherit = 'mrp.workorder'
|
||||
|
||||
exception_ids = fields.One2many('jikimo.workorder.exception', 'workorder_id', string='工单异常记录')
|
||||
|
||||
def write(self, values):
|
||||
if values.get('test_results') and self.exception_ids:
|
||||
pending_exception = self.exception_ids.filtered(
|
||||
lambda exc: exc.state == 'pending' and exc.exception_code == 'YC0005'
|
||||
)
|
||||
if pending_exception:
|
||||
pending_exception.write({
|
||||
'completion_time': fields.Datetime.now(),
|
||||
'state': 'done'
|
||||
})
|
||||
return super(MrpWorkorder, self).write(values)
|
||||
|
||||
def handle_exception(self, exception_codes):
|
||||
"""
|
||||
处理异常
|
||||
:param exception_codes: 需要处理的异常编码列表
|
||||
"""
|
||||
if not isinstance(exception_codes, list):
|
||||
exception_codes = [exception_codes]
|
||||
if self.exception_ids:
|
||||
_logger.info('workorder.exception_ids:%s' % self.exception_ids)
|
||||
pending_exception = self.exception_ids.filtered(
|
||||
lambda exc: exc.state == 'pending' and exc.exception_code in exception_codes
|
||||
)
|
||||
_logger.info('pending_exception:%s' % pending_exception)
|
||||
if pending_exception:
|
||||
pending_exception.write({
|
||||
'completion_time': fields.Datetime.now(),
|
||||
'state': 'done'
|
||||
})
|
||||
@@ -1,2 +0,0 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_jikimo_workorder_exception","access.jikimo.workorder.exception","model_jikimo_workorder_exception","mrp.group_mrp_user",1,1,1,0
|
||||
|
@@ -1,2 +0,0 @@
|
||||
from . import common
|
||||
from . import test_jikimo_workorder_exception
|
||||
@@ -1,48 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import fields, Command
|
||||
from odoo.tests.common import TransactionCase, HttpCase, tagged, Form
|
||||
|
||||
import json
|
||||
import time
|
||||
import base64
|
||||
from lxml import etree
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestJikimoWorkorderExceptionCommon(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestJikimoWorkorderExceptionCommon, self).setUp()
|
||||
# 获取名字为“1#自动生产线”的制造中心
|
||||
workcenter = self.env['mrp.workcenter'].search([('name', '=', '1#自动生产线')], limit=1)
|
||||
# 创建一个产品
|
||||
product_product = self.env['product.product'].create({
|
||||
'name': '测试产品',
|
||||
'type': 'product',
|
||||
})
|
||||
uom_unit = self.env.ref('uom.product_uom_unit')
|
||||
# 创建一个bom
|
||||
self.bom = self.env['mrp.bom'].create({
|
||||
'product_id': product_product.id,
|
||||
'product_tmpl_id': product_product.product_tmpl_id.id,
|
||||
'product_uom_id': uom_unit.id,
|
||||
'product_qty': 1.0,
|
||||
'type': 'normal',
|
||||
})
|
||||
# 创建一个制造订单
|
||||
self.production = self.env['mrp.production'].create({
|
||||
'name': 'Test Production',
|
||||
'product_id': product_product.id,
|
||||
'bom_id': self.bom.id,
|
||||
'company_id': self.env.ref('base.main_company').id,
|
||||
})
|
||||
# 创建一个测试工单
|
||||
self.workorder = self.env['mrp.workorder'].create({
|
||||
'name': 'Test order',
|
||||
'workcenter_id': workcenter.id,
|
||||
'product_uom_id': self.bom.product_uom_id.id,
|
||||
'production_id': self.production.id,
|
||||
'duration_expected': 1.0,
|
||||
'rfid_code': 'test-123456',
|
||||
'routing_type': 'CNC加工'
|
||||
})
|
||||
@@ -1,53 +0,0 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from odoo.addons.jikimo_workorder_exception.tests.common import TestJikimoWorkorderExceptionCommon
|
||||
|
||||
class TestJikimoWorkorderException(TestJikimoWorkorderExceptionCommon):
|
||||
|
||||
def test_create_exception_record(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0001',
|
||||
'exception_content': '无CNC编程'
|
||||
})
|
||||
|
||||
self.assertTrue(exception_record)
|
||||
self.assertEqual(exception_record.exception_content, '无CNC编程')
|
||||
self.assertEqual(exception_record.workorder_id.id, self.workorder.id)
|
||||
self.assertEqual(exception_record.exception_code, 'YC0001')
|
||||
|
||||
def test_handle_exception(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0001',
|
||||
'exception_content': '无CNC编程'
|
||||
})
|
||||
self.workorder.handle_exception('YC0001')
|
||||
self.assertEqual(exception_record.state, 'done')
|
||||
# 判断完成时间是否为当前分钟
|
||||
self.assertEqual(exception_record.completion_time.minute, datetime.now().minute)
|
||||
|
||||
def test_handle_exception_with_invalid_code(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0001',
|
||||
'exception_content': '无CNC编程'
|
||||
})
|
||||
self.workorder.handle_exception(['YC0002', 'YC0004'])
|
||||
self.assertEqual(exception_record.state, 'pending')
|
||||
self.assertEqual(exception_record.completion_time, False)
|
||||
|
||||
|
||||
def test_handle_exception_with_test_results(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0005',
|
||||
'exception_content': '工单加工失败'
|
||||
})
|
||||
self.workorder.write({
|
||||
'test_results': '返工',
|
||||
'reason': 'cutter',
|
||||
'detailed_reason': '刀坏了',
|
||||
})
|
||||
self.assertEqual(exception_record.state, 'done')
|
||||
self.assertEqual(exception_record.completion_time.minute, datetime.now().minute)
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="jikimo_workorder_exception_form_view_inherit" model="ir.ui.view">
|
||||
<field name="name">mrp.workorder.form</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//notebook/page[last()]" position="after">
|
||||
<page string="异常记录" name="workorder_exception" attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}">
|
||||
<field name="exception_ids" nolabel="1" readonly="1">
|
||||
<tree create="false" delete="false" edit="false">
|
||||
<field name="exception_content" string="反馈的异常/问题信息"/>
|
||||
<field name="create_date" string="时间"/>
|
||||
<field name="completion_time"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': '机企猫 工单异常消息通知',
|
||||
'version': '1.0',
|
||||
'summary': '当产生工单异常时,发送消息通知',
|
||||
'sequence': 1,
|
||||
'category': 'sf',
|
||||
'website': 'https://www.sf.jikimo.com',
|
||||
'depends': ['jikimo_workorder_exception', 'jikimo_message_notify'],
|
||||
'data': [
|
||||
'data/bussiness_node.xml',
|
||||
'data/template_data.xml',
|
||||
# 'security/ir.model.access.csv',
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
'license': 'LGPL-3',
|
||||
'installable': True,
|
||||
'application': False,
|
||||
'auto_install': False,
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="bussiness_no_functional_tool" model="jikimo.message.bussiness.node">
|
||||
<field name="name">无功能刀具</field>
|
||||
<field name="model">jikimo.workorder.exception</field>
|
||||
</record>
|
||||
<record id="bussiness_no_position_data" model="jikimo.message.bussiness.node">
|
||||
<field name="name">无定位数据</field>
|
||||
<field name="model">jikimo.workorder.exception</field>
|
||||
</record>
|
||||
<record id="bussiness_processing_failure" model="jikimo.message.bussiness.node">
|
||||
<field name="name">加工失败</field>
|
||||
<field name="model">jikimo.workorder.exception</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="template_no_function_tool" model="jikimo.message.template">
|
||||
<field name="name">生产线无功能刀具提醒</field>
|
||||
<field name="model_id" ref="jikimo_workorder_exception_notify.model_jikimo_workorder_exception"/>
|
||||
<field name="model">jikimo.workorder.exception</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_no_functional_tool"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">urgent</field>
|
||||
<field name="content">### 生产线无功能刀具提醒
|
||||
单号:工单[{{workorder_id.production_id.name}}]({{url}})
|
||||
原因:生产线无加工程序要用的功能刀具</field>
|
||||
</record>
|
||||
<record id="template_no_position_data" model="jikimo.message.template">
|
||||
<field name="name">工单无定位数据提醒</field>
|
||||
<field name="model_id" ref="jikimo_workorder_exception_notify.model_jikimo_workorder_exception"/>
|
||||
<field name="model">jikimo.workorder.exception</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_no_position_data"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">urgent</field>
|
||||
<field name="content">### 工单无定位数据提醒
|
||||
单号:工单[{{workorder_id.production_id.name}}]({{url}})
|
||||
原因:无装夹定位测量数据</field>
|
||||
</record>
|
||||
<record id="template_processing_failure" model="jikimo.message.template">
|
||||
<field name="name">工单加工失败提醒</field>
|
||||
<field name="model_id" ref="jikimo_workorder_exception_notify.model_jikimo_workorder_exception"/>
|
||||
<field name="model">jikimo.workorder.exception</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_processing_failure"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">urgent</field>
|
||||
<field name="content">### 工单加工失败提醒
|
||||
单号:工单[{{workorder_id.production_id.name}}]({{url}})
|
||||
原因:加工失败,工件下产线处理</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import jikimo_message_template
|
||||
from . import jikimo_workorder_exception
|
||||
@@ -1,10 +0,0 @@
|
||||
from odoo import models
|
||||
|
||||
|
||||
class JikimoMessageTemplate(models.Model):
|
||||
_inherit = "jikimo.message.template"
|
||||
|
||||
def _get_message_model(self):
|
||||
res = super(JikimoMessageTemplate, self)._get_message_model()
|
||||
res.append('jikimo.workorder.exception')
|
||||
return res
|
||||
@@ -1,61 +0,0 @@
|
||||
from odoo import models, api
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
import requests, logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class JikimoWorkorderException(models.Model):
|
||||
_name = 'jikimo.workorder.exception'
|
||||
_inherit = ['jikimo.workorder.exception', 'jikimo.message.dispatch']
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
res = super(JikimoWorkorderException, self).create(vals_list)
|
||||
# 根据异常编码发送消息提醒
|
||||
try:
|
||||
for rec in res:
|
||||
if rec.exception_code == 'YC0001':
|
||||
# 无CNC程序,调用cloud接口
|
||||
data = {'name': rec.workorder_id.production_id.programming_no, 'exception_code': 'YC0001'}
|
||||
configsettings = self.env['res.config.settings'].sudo().get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/message/workorder_exception'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
data['token'] = configsettings['token']
|
||||
ret = requests.post(config_url, json=data, headers=config_header)
|
||||
ret = ret.json()
|
||||
_logger.info('无CNC程序异常消息推送接口:%s' % ret)
|
||||
elif rec.exception_code == 'YC0002':
|
||||
# 无功能刀具
|
||||
rec.add_queue('无功能刀具')
|
||||
elif rec.exception_code == 'YC0003':
|
||||
# 无定位数据
|
||||
rec.add_queue('无定位数据')
|
||||
elif rec.exception_code == 'YC0004':
|
||||
# 无FTP文件,调用cloud接口
|
||||
data = {'name': rec.workorder_id.production_id.programming_no, 'exception_code': 'YC0004'}
|
||||
configsettings = self.env['res.config.settings'].sudo().get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/message/workorder_exception'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
data['token'] = configsettings['token']
|
||||
ret = requests.post(config_url, json=data, headers=config_header)
|
||||
ret = ret.json()
|
||||
_logger.info('无FTP文件异常消息推送接口:%s' % ret)
|
||||
elif rec.exception_code == 'YC0005':
|
||||
# 加工失败
|
||||
rec.add_queue('加工失败')
|
||||
except Exception as e:
|
||||
_logger.error('异常编码发送消息提醒失败:%s' % e)
|
||||
return res
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = super(JikimoWorkorderException, self)._get_message(message_queue_ids)
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
action_id = self.env.ref('mrp.mrp_production_action').id
|
||||
for index, content in enumerate(contents):
|
||||
exception_id = self.env['jikimo.workorder.exception'].browse(message_queue_ids[index].res_id)
|
||||
url = url + '/web#id=%s&view_type=form&action=%s' % (exception_id.workorder_id.production_id.id, action_id)
|
||||
contents[index] = content.replace('{{url}}', url)
|
||||
return contents
|
||||
@@ -1,2 +0,0 @@
|
||||
from . import common
|
||||
from . import test_jikimo_workorder_exception_notify
|
||||
@@ -1,18 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import fields, Command
|
||||
from odoo.tests.common import TransactionCase, HttpCase, tagged, Form
|
||||
|
||||
import json
|
||||
import time
|
||||
import base64
|
||||
from lxml import etree
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestJikimoWorkorderExceptionNotifyCommonNotify(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestJikimoWorkorderExceptionNotifyCommonNotify, self).setUp()
|
||||
# 获取最后一个工单
|
||||
self.workorder = self.env['mrp.workorder'].search([], order='id desc', limit=1)
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from odoo.addons.jikimo_workorder_exception_notify.tests.common import TestJikimoWorkorderExceptionNotifyCommonNotify
|
||||
|
||||
class TestJikimoWorkorderExceptionNotify(TestJikimoWorkorderExceptionNotifyCommonNotify):
|
||||
|
||||
def test_create_message_template(self):
|
||||
self.assertTrue(self.env['jikimo.message.template'].search([
|
||||
('name', '=', '生产线无功能刀具提醒'),
|
||||
('model', '=', 'jikimo.workorder.exception')
|
||||
]))
|
||||
self.assertTrue(self.env['jikimo.message.template'].search([
|
||||
('name', '=', '工单无定位数据提醒'),
|
||||
('model', '=', 'jikimo.workorder.exception')
|
||||
]))
|
||||
self.assertTrue(self.env['jikimo.message.template'].search([
|
||||
('name', '=', '工单加工失败提醒'),
|
||||
('model', '=', 'jikimo.workorder.exception')
|
||||
]))
|
||||
|
||||
def test_create_message_queue_yc0001(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0001',
|
||||
'exception_content': '无CNC程序'
|
||||
})
|
||||
|
||||
message_record = self.env['jikimo.message.queue'].search([
|
||||
('res_id', '=', exception_record.id),
|
||||
('model', '=', 'jikimo.workorder.exception'),
|
||||
('message_status', '=', 'pending')
|
||||
])
|
||||
self.assertFalse(message_record)
|
||||
|
||||
def test_create_message_queue_yc0002(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0002',
|
||||
'exception_content': '无功能刀具'
|
||||
})
|
||||
|
||||
bussiness_node = self.env['jikimo.message.bussiness.node'].search([
|
||||
('name', '=', '无功能刀具'),
|
||||
('model', '=', 'jikimo.workorder.exception')
|
||||
])
|
||||
|
||||
message_template = self.env['jikimo.message.template'].search([
|
||||
('bussiness_node_id', '=', bussiness_node.id),
|
||||
('model', '=', 'jikimo.workorder.exception')
|
||||
])
|
||||
|
||||
message_record = self.env['jikimo.message.queue'].search([
|
||||
('res_id', '=', exception_record.id),
|
||||
('model', '=', 'jikimo.workorder.exception'),
|
||||
('message_status', '=', 'pending'),
|
||||
('message_template_id', '=', message_template.id)
|
||||
])
|
||||
self.assertTrue(message_record)
|
||||
|
||||
def test_create_message_queue_yc0003(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0003',
|
||||
'exception_content': '无定位数据'
|
||||
})
|
||||
|
||||
bussiness_node = self.env['jikimo.message.bussiness.node'].search([
|
||||
('name', '=', '无定位数据'),
|
||||
('model', '=', 'jikimo.workorder.exception')
|
||||
])
|
||||
|
||||
message_template = self.env['jikimo.message.template'].search([
|
||||
('bussiness_node_id', '=', bussiness_node.id),
|
||||
('model', '=', 'jikimo.workorder.exception')
|
||||
])
|
||||
|
||||
message_record = self.env['jikimo.message.queue'].search([
|
||||
('res_id', '=', exception_record.id),
|
||||
('model', '=', 'jikimo.workorder.exception'),
|
||||
('message_status', '=', 'pending'),
|
||||
('message_template_id', '=', message_template.id)
|
||||
])
|
||||
self.assertTrue(message_record)
|
||||
|
||||
def test_create_message_queue_yc0004(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0004',
|
||||
'exception_content': '无CNC程序'
|
||||
})
|
||||
|
||||
message_record = self.env['jikimo.message.queue'].search([
|
||||
('res_id', '=', exception_record.id),
|
||||
('model', '=', 'jikimo.workorder.exception'),
|
||||
('message_status', '=', 'pending')
|
||||
])
|
||||
self.assertFalse(message_record)
|
||||
|
||||
def test_get_message(self):
|
||||
exception_record = self.env['jikimo.workorder.exception'].create({
|
||||
'workorder_id': self.workorder.id,
|
||||
'exception_code': 'YC0002',
|
||||
'exception_content': '无功能刀具'
|
||||
})
|
||||
message_queue_ids = self.env['jikimo.message.queue'].search([
|
||||
('res_id', '=', exception_record.id),
|
||||
('model', '=', 'jikimo.workorder.exception'),
|
||||
('message_status', '=', 'pending')
|
||||
])
|
||||
message = self.env['jikimo.workorder.exception']._get_message(message_queue_ids)
|
||||
self.assertTrue(message)
|
||||
|
||||
|
||||
@@ -1273,18 +1273,3 @@ msgstr ""
|
||||
#: model:product.template,description_sale:mrp_workorder.product_template_stool_top
|
||||
msgid "wooden stool top"
|
||||
msgstr ""
|
||||
|
||||
#. module: mrp_workorder
|
||||
#: model:quality.point.test_type,name:mrp_workorder.test_type_register_consumed_materials
|
||||
msgid "Register Consumed Materials"
|
||||
msgstr "登记消耗材料"
|
||||
|
||||
#. module: mrp_workorder
|
||||
#: model:quality.point.test_type,name:mrp_workorder.test_type_register_byproducts
|
||||
msgid "Register By-products"
|
||||
msgstr "按产品注册"
|
||||
|
||||
#. module: mrp_workorder
|
||||
#: model:quality.point.test_type,name:mrp_workorder.test_type_print_label
|
||||
msgid "Print label"
|
||||
msgstr "打印标签"
|
||||
@@ -1050,13 +1050,3 @@ msgstr "工作中心故障"
|
||||
#: model:ir.model.fields,field_description:quality.field_quality_point_test_type__active
|
||||
msgid "active"
|
||||
msgstr "有效"
|
||||
|
||||
#. module: quality
|
||||
#: model:quality.point.test_type,name:quality.test_type_instructions
|
||||
msgid "Instructions"
|
||||
msgstr "使用说明"
|
||||
|
||||
#. module: quality
|
||||
#: model:quality.point.test_type,name:quality.test_type_picture
|
||||
msgid "Take a Picture"
|
||||
msgstr "照片"
|
||||
@@ -15,7 +15,7 @@ class TestType(models.Model):
|
||||
_description = "Quality Control Test Type"
|
||||
|
||||
# Used instead of selection field in order to hide a choice depending on the view.
|
||||
name = fields.Char('Name', required=True,translate=True)
|
||||
name = fields.Char('Name', required=True)
|
||||
technical_name = fields.Char('Technical name', required=True)
|
||||
active = fields.Boolean('active', default=True)
|
||||
|
||||
|
||||
@@ -1185,14 +1185,3 @@ msgstr "请先进行质量检查!"
|
||||
#: model_terms:ir.ui.view,arch_db:quality_control.quality_alert_team_view_form
|
||||
msgid "e.g. The QA Masters"
|
||||
msgstr "例如:QA大师"
|
||||
|
||||
|
||||
#. module: quality_control
|
||||
#: model:quality.point.test_type,name:quality_control.test_type_passfail
|
||||
msgid "Pass - Fail"
|
||||
msgstr "通过-失败"
|
||||
|
||||
#. module: quality_control
|
||||
#: model:quality.point.test_type,name:quality_control.test_type_measure
|
||||
msgid "Measure"
|
||||
msgstr "测量"
|
||||
@@ -6,4 +6,3 @@ from . import stock_move
|
||||
from . import stock_move_line
|
||||
from . import stock_picking
|
||||
from . import stock_lot
|
||||
from . import product_category
|
||||
@@ -1,32 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from math import sqrt
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from datetime import datetime
|
||||
|
||||
import random
|
||||
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, float_round
|
||||
from odoo.osv.expression import OR
|
||||
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = 'product.category'
|
||||
@api.model
|
||||
def name_search(self, name='', args=None, operator='ilike', limit=100):
|
||||
if args is None:
|
||||
args = []
|
||||
# 添加过滤条件,确保只返回名称为 'abc' 的记录
|
||||
args += [('name', 'not in', ['Saleable', 'Expenses', 'Deliveries'])]
|
||||
|
||||
# 调用父类的 name_search 方法
|
||||
return super(ProductCategory, self).name_search(name, args=args, operator=operator, limit=limit)
|
||||
|
||||
@api.model
|
||||
def search(self, args, limit=100, offset=0, order=None, count=False):
|
||||
# 添加过滤条件,确保只返回名称不在指定列表中的记录
|
||||
args += [('name', 'not in', ['Saleable', 'Expenses', 'Deliveries'])]
|
||||
|
||||
# 调用父类的 search 方法
|
||||
return super(ProductCategory, self).search(args, limit=limit, offset=offset, order=order, count=count)
|
||||
@@ -1033,7 +1033,7 @@
|
||||
name="Overview"
|
||||
action="quality_alert_team_action"
|
||||
parent="menu_quality_root"
|
||||
sequence="5" active="False"/>
|
||||
sequence="5"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_quality_control"
|
||||
|
||||
@@ -38,17 +38,3 @@ class Manufacturing_Connect(http.Controller):
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('get_maintenance_tool_groups_Info error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
|
||||
class MultiInheritController():
|
||||
_sub_classes = []
|
||||
|
||||
def __init_subclass__(cls):
|
||||
"""
|
||||
多继承,解决多个字类时方法调用super的问题
|
||||
"""
|
||||
super().__init_subclass__()
|
||||
if len(cls._sub_classes) > 0 and cls not in cls._sub_classes:
|
||||
cls.__bases__ = (cls._sub_classes[-1],)
|
||||
if cls not in cls._sub_classes:
|
||||
cls._sub_classes.append(cls)
|
||||
|
||||
@@ -394,11 +394,3 @@ class MachineToolCategory(models.Model):
|
||||
active = fields.Boolean('有效', default=True)
|
||||
category = fields.Selection([('shukong', u'数控'), ('putong', u'普通')], string=u'机床类别',
|
||||
default='shukong')
|
||||
|
||||
|
||||
class MachiningAccuracy(models.Model):
|
||||
_name = 'sf.machining.accuracy'
|
||||
_description = '加工精度'
|
||||
name = fields.Char('一般公差', index=True)
|
||||
standard_tolerance = fields.Char(string="标准公差")
|
||||
sync_id = fields.Char('同步ID')
|
||||
|
||||
@@ -247,7 +247,3 @@ access_sf_cutting_tool_type_group_sf_stock_manager,sf_cutting_tool_type_group_sf
|
||||
access_sf_cutting_tool_material_group_plan_dispatch,sf_cutting_tool_material_group_plan_dispatch,model_sf_cutting_tool_material,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_functional_cutting_tool_model_group_plan_dispatch,sf_functional_cutting_tool_model_group_plan_dispatch,model_sf_functional_cutting_tool_model,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_cutting_tool_type_group_plan_dispatch,sf_cutting_tool_type_group_plan_dispatch,model_sf_cutting_tool_type,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
|
||||
access_sf_machining_accuracy,sf_machining_accuracy,model_sf_machining_accuracy,base.group_user,1,0,0,0
|
||||
access_sf_machining_accuracy_admin,sf_machining_accuracy_admin,model_sf_machining_accuracy,base.group_system,1,0,0,0
|
||||
|
||||
|
@@ -1,125 +0,0 @@
|
||||
// 获取表格数据
|
||||
function getDomData() {
|
||||
const dom = $('div[name=cutting_speed_ids]')
|
||||
if (!dom.length) return
|
||||
const table = dom.find('.o_list_table')
|
||||
const thead = table.children('thead')
|
||||
const tbody = table.children('tbody')
|
||||
const tbody_child = tbody.children()
|
||||
const hideTheadDom = thead.find('[data-name=process_capability]')
|
||||
hideTheadDom.hide().next().hide()
|
||||
hideTheadDom.before('<th customTh>精加工</th><th customTh>粗加工</th>')
|
||||
tbody_child.each(function () {
|
||||
const dom = $(this).children('[name=process_capability]')
|
||||
if(!dom.length) return
|
||||
dom.css('cssText', 'display: none!important').next().css('cssText', 'display: none!important')
|
||||
const isCu = dom.text() == '粗加工' // 是否粗加工
|
||||
const v = dom.next().text() // 切削速度
|
||||
dom.after(`<td customSpeed="1" name="process_capability" is="精加工" val="${ v }">${!isCu ? v : ''}</td><td customSpeed="1" name="process_capability" is="粗加工" val="${ v }">${isCu ? v : ''}</td>`)
|
||||
setListenClick()
|
||||
})
|
||||
return;
|
||||
handleTbody(tbody, newTableData, ΦList, table)
|
||||
}
|
||||
|
||||
// 监听点击
|
||||
function setListenClick() {
|
||||
$(document).click(function (e) {
|
||||
if ($(e.target).attr('customSpeed')) {
|
||||
const orginV = $('[customInput=1]').children('input').val()
|
||||
$('[customInput=1]').parent().html(orginV)
|
||||
const v = $(e.target).attr('val')
|
||||
const is = $(e.target).attr('is')
|
||||
$(e.target).html('')
|
||||
const input = $('<div customInput="1" is="' + is + '" class="o_field_widget o_field_char"><input class="o_input" type="text" autocomplete="off" maxlength="20"></div>')
|
||||
input.children('input').val(v)
|
||||
$(e.target).append(input)
|
||||
input.children('input').focus()
|
||||
input.children('input').select()
|
||||
} else if ($(e.target).attr('customInput')) {
|
||||
|
||||
} else {
|
||||
const orginV = $('[customInput=1]').children('input').val()
|
||||
$('[customInput=1]').parent().html(orginV)
|
||||
const v = $(e.target).attr('val')
|
||||
}
|
||||
})
|
||||
$(document).off('change') // 防止重复绑定
|
||||
$(document).on('change', '[customInput] input', async function () {
|
||||
$(this).parents('td').attr('val', $(this).val())
|
||||
$(this).parents('td').siblings('[customspeed]').attr('val', $(this).val())
|
||||
var eve1 = new Event('change')
|
||||
var eve2 = new Event('input')
|
||||
var eve3 = new Event('click')
|
||||
let patchSpeedDom = $(this).parents('td').siblings('[name=cutting_speed]')
|
||||
let patchProcessDom = $(this).parents('td').siblings('[name=process_capability]')
|
||||
$(this).parents('td').siblings('[customspeed]').text('') // 清空其他加工类型的数据
|
||||
await timeOut(500)
|
||||
patchProcessDom[0].dispatchEvent(eve3)
|
||||
await timeOut(200)
|
||||
const processVal = $(this).parent().attr('is')
|
||||
patchProcessDom.find('select').val(`"${processVal}"`) // 设置源select的val为“加工类型 is”、
|
||||
patchProcessDom.attr("data-tooltip", `${processVal}`)
|
||||
patchProcessDom.find('select')[0].dispatchEvent(eve1)
|
||||
|
||||
patchSpeedDom[0].dispatchEvent(eve3)
|
||||
await timeOut(200)
|
||||
patchSpeedDom.find('input').val($(this).val())
|
||||
await timeOut(50)
|
||||
patchSpeedDom.find('input')[0].dispatchEvent(eve2)
|
||||
patchSpeedDom.find('input')[0].dispatchEvent(eve1)
|
||||
})
|
||||
$(document).off('blur') // 防止重复绑定
|
||||
$(document).on('blur', '[customInput] input', async function () {
|
||||
if(!$(this).length) return
|
||||
|
||||
$(this).parents('td').siblings('[customspeed]').text('') // 清空其他加工类型的数据
|
||||
let patchProcessDom = $(this).parents('td').siblings('[name=process_capability]')
|
||||
try {
|
||||
patchProcessDom[0].dispatchEvent(new Event('click'))
|
||||
const processVal = $(this).parent().attr('is')
|
||||
patchProcessDom.find('select').val(`"${processVal}"`) // 设置源select的val为“加工类型 is”、
|
||||
patchProcessDom.attr("data-tooltip", `${processVal}`)
|
||||
patchProcessDom.find('select')[0].dispatchEvent(new Event('change'))
|
||||
} catch {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
function timeOut(time) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, time)
|
||||
})
|
||||
}
|
||||
|
||||
function listenAdd() {
|
||||
$('td.o_field_x2many_list_row_add a').click(async function () {
|
||||
await timeOut(500)
|
||||
const tr = $('.o_list_table').children('tbody').children('tr').eq(-2)
|
||||
if(tr.children('td').eq(2).text() == '') {
|
||||
const dom = tr.children('[name=process_capability]')
|
||||
if(!dom.length) return
|
||||
dom.css('cssText', 'display: none!important').next().css('cssText', 'display: none!important')
|
||||
const isCu = dom.text() == '粗加工' // 是否粗加工
|
||||
const v = dom.next().text() // 切削速度
|
||||
dom.after(`<td customSpeed="1" name="process_capability" is="精加工" val="${ v }">${!isCu ? v : ''}</td><td customSpeed="1" name="process_capability" is="粗加工" val="${ v }">${isCu ? v : ''}</td>`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function listenSave() {
|
||||
$('.o_form_button_save').click( async function () {
|
||||
await timeOut(1000)
|
||||
if($(this).parent().next().length) return
|
||||
$('th[customTh],td[cusomSpeed]').remove()
|
||||
getDomData()
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
listenAdd()
|
||||
listenSave()
|
||||
getDomData()
|
||||
@@ -1,47 +0,0 @@
|
||||
// 因为表格可以拖动设置宽度,所以需要用js设置初始宽度
|
||||
function setBasicParamTableWidth() {
|
||||
// const _100px = 'th[data-name="cutting_blade_length"],th[data-name="cutting_blade_length"],th[data-name="name"],th[data-name="tip_handling_size"],th[data-name="cutting_depth_max"],th[data-name="diameter_inner_circle"],th[data-name="diameter_mounting_hole" ],th[data-name="radius_tip_re" ],th[data-name="is_chip_breaker"],th[data-name="chip_breaker_type_code"],th[data-name="blade_profile"]'
|
||||
// const _65px = 'th[data-name="edge_angle"],th[data-name="relief_angle"],[data-name="total_length"],th[data-name="length"],th[data-name="thickness"],th[data-name="blade_number"]'
|
||||
// const _80px = 'th[data-name="arbor_diameter"],th[data-name="head_height"],th[data-name="head_width"],th[data-name="head_length"],th[data-name="blade_diameter"],th[data-name="blade_length"] ,th[data-name="neck_length"] ,th[data-name="neck_diameter"] ,th[data-name="shank_diameter"],th[data-name="shank_length"],th[data-name="tip_diameter"],th[data-name="knife_tip_taper"],th[data-name="blade_helix_angle"] ,th[data-name="blade_width"],th[data-name="blade_depth"]'
|
||||
// const _50px = 'th[data-name="pitch"],th[data-name="width"],th[data-name="height"]'
|
||||
|
||||
const basicParamDom = $('.fixTableCss')
|
||||
// const basicParamDom_100px = basicParamDom.find(_100px) // 四字以上
|
||||
// const basicParamDom_65px = basicParamDom.find(_65px) // 大概三个字加单位
|
||||
// const basicParamDom_80px = basicParamDom.find(_80px) // 大概四个字加单位
|
||||
// const basicParamDom_50px= basicParamDom.find(_50px) // 大概两个字加单位
|
||||
//
|
||||
// basicParamDom_100px.css({'width': '100px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||
// basicParamDom_65px.css({'width': '65px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||
// basicParamDom_80px.css({'width': '80px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||
// basicParamDom_50px.css({'width': '50px', 'max-width': 'auto', ',min-width': 'auto'})
|
||||
let dom = []
|
||||
try {
|
||||
dom = basicParamDom.find('table').find('thead').children().children()
|
||||
|
||||
} catch {
|
||||
dom = []
|
||||
}
|
||||
if (!dom) return
|
||||
dom.each(function () {
|
||||
if ($(this).hasClass('row_no') >= 0) { // 序号列
|
||||
// 不设置 通过css设置
|
||||
}
|
||||
const text = $(this).text().split('(')
|
||||
if ($(this).attr('data-name') == 'name' || text[0].length > 4) {
|
||||
$(this).width('100px')
|
||||
} else if(text[0].length == 4){
|
||||
$(this).width('80px')
|
||||
} else if(text[0].length == 3){
|
||||
$(this).width('65px')
|
||||
} else if(text[0].length == 2){
|
||||
$(this).width('50px')
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
setBasicParamTableWidth()
|
||||
$('.o_field_many2one_selection').on('click', $('#cutting_tool_material_id + ul'), function () {
|
||||
setTimeout(setBasicParamTableWidth, 500)
|
||||
})
|
||||
@@ -1,159 +0,0 @@
|
||||
// 获取表格数据
|
||||
function getDomData() {
|
||||
const dom = $('#updateTable').prev()
|
||||
if (!dom.length) return
|
||||
const table = $('#updateTable').prev().find('.o_list_table')
|
||||
const customTable = table.clone()
|
||||
customTable.addClass('customTable')
|
||||
table.parent().append(customTable)
|
||||
table.hide()
|
||||
const thead = customTable.children('thead')
|
||||
const tbody = customTable.children('tbody')
|
||||
const tableData = []
|
||||
const tbody_child = tbody.children()
|
||||
|
||||
const tbody_child_len = tbody_child.length
|
||||
|
||||
for (let v = 0; v < tbody_child_len; v++) { // 将数据取出来到tableData里面
|
||||
const data = tbody_child[v].innerText.split('\t')
|
||||
// console.log('dom data',data)
|
||||
const [index, deep, name, Φ, value] = data
|
||||
tableData.push({index, deep, name, Φ, value})
|
||||
}
|
||||
const ΦList = [...new Set(tableData.map(_ => _.name))] // ΦList去重
|
||||
const newTableData = {}
|
||||
tableData.forEach(_ => {
|
||||
const key = _.deep + '|' + _.Φ
|
||||
!newTableData[key] ? newTableData[key] = {i: _.index} : '';
|
||||
if (_.Φ) { // 去除没有Φ的脏数据
|
||||
newTableData[key]['Φ' + _.Φ] = _.value
|
||||
newTableData[key]['Φ' + _.Φ + 'i'] = _.index
|
||||
}
|
||||
})
|
||||
// console.log('qwdh',tableData, ΦList, newTableData);
|
||||
|
||||
if (ΦList.filter(_ => _).length == 0) return;
|
||||
handleThead(thead, ΦList)
|
||||
|
||||
handleTbody(tbody, newTableData, ΦList, table)
|
||||
}
|
||||
|
||||
// 重新设置表头、
|
||||
function handleThead(thead, ΦList) {
|
||||
const dom = thead.children().eq(0).children()
|
||||
const len = dom.length
|
||||
dom.eq(0).attr('rowspan', 2)
|
||||
dom.eq(1).attr('rowspan', 2)
|
||||
len == 5 ? dom.eq(2).attr('rowspan', 2) : ''
|
||||
dom.eq(-2).attr('colspan', ΦList.length)
|
||||
dom.eq(-1).remove()
|
||||
|
||||
const tr = document.createElement('tr')
|
||||
for (let v = 0; v < ΦList.length; v++) {
|
||||
const th = document.createElement('th')
|
||||
th.innerText = 'Φ' + ΦList[v]
|
||||
tr.append(th)
|
||||
}
|
||||
thead.append(tr)
|
||||
}
|
||||
|
||||
// 重新设置表格
|
||||
function handleTbody(tbody, newTableData, ΦList, table) {
|
||||
console.log(newTableData)
|
||||
tbody.html('')
|
||||
let i = 0
|
||||
const data = Object.keys(newTableData)
|
||||
// data.sort((a, b) => {
|
||||
// a = a.split('=')[1].split('%')[0]
|
||||
// b = b.split('=')[1].split('%')[0]
|
||||
// return a - b
|
||||
// })
|
||||
// console.log('wqoqw ',ΦList)
|
||||
data.forEach(_ => {
|
||||
i++
|
||||
const tr = $('<tr class="o_data_row"></tr>')
|
||||
const td0 = $('<td></td>')
|
||||
td0.text(i)
|
||||
tr.append(td0)
|
||||
const lit = _.split('|')
|
||||
//
|
||||
const td1 = $('<td></td>')
|
||||
const td2 = $('<td></td>')
|
||||
td1.text(lit[0])
|
||||
td2.text(lit[1] || '')
|
||||
tr.append(td1)
|
||||
tr.append(td2)
|
||||
ΦList.forEach(Φ => {
|
||||
const td = $('<td class="o_data_cell cursor-pointer o_field_cell o_list_char"></td>')
|
||||
td.text(newTableData[_]['Φ' + Φ])
|
||||
td.attr('col', newTableData[_]['Φ' + Φ + 'i'])
|
||||
td.attr('val', newTableData[_]['Φ' + Φ])
|
||||
td.attr('coustomTd', 1)
|
||||
tr.append(td)
|
||||
})
|
||||
// // for (let j = 0; j < ΦList.length; j++) {
|
||||
// // const td = document.createElement('td')
|
||||
// // td.innerText = newTableData[data[v]][_]
|
||||
// // th.append(td)
|
||||
// // }
|
||||
tbody.append(tr)
|
||||
})
|
||||
// $(document).click(function (e) {
|
||||
// if ($(e.target).attr('coustomTd')) {
|
||||
// const orginV = $('[coustomInput=1]').children('input').val()
|
||||
// $('[coustomInput=1]').parent().html(orginV)
|
||||
// const v = $(e.target).attr('val')
|
||||
// console.log($(e.target));
|
||||
// $(e.target).html('')
|
||||
// const input = $('<div coustomInput="1" name="feed_per_tooth" class="o_field_widget o_field_char"><input class="o_input" type="text" autocomplete="off" maxlength="20"></div>')
|
||||
// input.children('input').val(v)
|
||||
// $(e.target).append(input)
|
||||
// input.children('input').focus()
|
||||
// input.children('input').select()
|
||||
// } else if ($(e.target).attr('coustomInput')) {
|
||||
//
|
||||
// } else {
|
||||
// const orginV = $('[coustomInput=1]').children('input').val()
|
||||
// $('[coustomInput=1]').parent().html(orginV)
|
||||
// const v = $(e.target).attr('val')
|
||||
// }
|
||||
// })
|
||||
// $(document).off('change') // 防止重复绑定
|
||||
// $(document).on('change', '[coustomInput] input', function () {
|
||||
// $(this).parents('td').attr('val', $(this).val());
|
||||
// var eve1 = new Event('change');
|
||||
// var eve2 = new Event('input');
|
||||
// var eve3 = new Event('click');
|
||||
// const i = $(this).parents('td').attr('col');
|
||||
// let patchDom = table.find('tbody').children('tr').eq(i - 1);
|
||||
//
|
||||
// if (patchDom.length === 0) {
|
||||
// console.error('No such row found');
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// patchDom = patchDom.children().eq(-1);
|
||||
//
|
||||
// setTimeout(() => {
|
||||
// if (patchDom.length === 0) {
|
||||
// console.error('No such cell found');
|
||||
// return;
|
||||
// }
|
||||
// patchDom[0].dispatchEvent(eve3); // Simulate click event
|
||||
//
|
||||
// setTimeout(() => {
|
||||
// patchDom = patchDom.find('input');
|
||||
// if (patchDom.length === 0) {
|
||||
// console.error('No input found in the target cell');
|
||||
// return;
|
||||
// }
|
||||
// patchDom.val($(this).val());
|
||||
// patchDom[0].dispatchEvent(eve2);
|
||||
// patchDom[0].dispatchEvent(eve1);
|
||||
// }, 200);
|
||||
// }, 500);
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
getDomData()
|
||||
@@ -1,52 +0,0 @@
|
||||
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) {
|
||||
white-space: nowrap !important;
|
||||
}
|
||||
|
||||
.text-truncate {
|
||||
overflow: unset !important;
|
||||
text-overflow: unset !important;
|
||||
white-space: unset !important;
|
||||
}
|
||||
|
||||
|
||||
// 设置表格不超出页面宽度
|
||||
.o_form_view .o_field_widget .o_list_renderer {
|
||||
width: calc(100% - 64px) !important;
|
||||
margin:0 auto;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
// 表格针对处理
|
||||
.fixTableCss {
|
||||
text-align: center;
|
||||
.o_list_number_th,.o_list_number {
|
||||
text-align: center!important;
|
||||
}
|
||||
.ui-sortable {
|
||||
tr > td:first-child {
|
||||
padding: 0!important;
|
||||
}
|
||||
}
|
||||
.row_no {
|
||||
padding: 0!important;;
|
||||
width: 35px!important;
|
||||
}
|
||||
|
||||
th[data-name="total_length"],th[data-name="length"],th[data-name="thickness"] {
|
||||
.flex-row-reverse {
|
||||
span {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 其他不能用js处理的表格
|
||||
.otherTableFix {
|
||||
th[data-name="cutting_tool_material_id"] {
|
||||
width: 100px!important;
|
||||
}
|
||||
th[data-name="ramping_angle_max"],th[data-name="ramping_angle_min"] {
|
||||
width: 200px!important;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@
|
||||
<field name="name">form.sf.machine_tool.type</field>
|
||||
<field name="model">sf.machine_tool.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="机床型号" delete="0">
|
||||
<form string="机床型号" delete="0">
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
@@ -129,28 +129,31 @@
|
||||
<field name="machine_tool_picture" widget="image" nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="加工能力">
|
||||
<group string="加工能力">
|
||||
<div>
|
||||
<field name='jg_image_id' widget="custom_many2many_checkboxes">
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="image" widget="image"/>
|
||||
<field name='jg_image_id' widget="custom_many2many_checkboxes">
|
||||
|
||||
</tree>
|
||||
</field>
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="image" widget="image"
|
||||
options="{'size': [100, 100], 'click enlarge': True}"/>
|
||||
|
||||
</tree>
|
||||
</field>
|
||||
</div>
|
||||
|
||||
</group>
|
||||
<group string="冷却方式">
|
||||
<div>
|
||||
<field name='lq_image_id' widget="custom_many2many_checkboxes">
|
||||
<field name='lq_image_id' widget="custom_many2many_checkboxes">
|
||||
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="image" widget="image"/>
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
<field name="image" widget="image"
|
||||
options="{'size': [100, 100], 'click enlarge': True}"/>
|
||||
|
||||
</tree>
|
||||
</field>
|
||||
</tree>
|
||||
</field>
|
||||
</div>
|
||||
|
||||
</group>
|
||||
@@ -175,7 +178,7 @@
|
||||
<field name="workbench_H" class="o_address_zip" required="1"
|
||||
options="{'format': false}"/>
|
||||
</div>
|
||||
<field name="workpiece_load"/>
|
||||
<field name="workpiece_load"/>
|
||||
<label for="machine_tool_L" string="机床尺寸(mm)"/>
|
||||
<div class="test_model">
|
||||
<label for="machine_tool_L" string="长"/>
|
||||
@@ -189,7 +192,7 @@
|
||||
<field name="machine_tool_H" class="o_address_zip"
|
||||
options="{'format': false}"/>
|
||||
</div>
|
||||
<label for="T_trough_num" string="T型槽尺寸:"/>
|
||||
<label for="T_trough_num" string="T型槽尺寸:"/>
|
||||
<div class="test_model">
|
||||
<label for="T_trough_num" string="槽数"/>
|
||||
<field name="T_trough_num" class="o_address_zip"
|
||||
@@ -202,20 +205,20 @@
|
||||
<field name="T_trough_distance" class="o_address_zip"
|
||||
options="{'format': false}"/>
|
||||
</div>
|
||||
<!-- <field name="feed_speed" required="1"/>-->
|
||||
<!-- <label for="precision_min" string="X轴定位精度(mm)"/>-->
|
||||
<!-- <div class="test_model">-->
|
||||
<!-- <label for="precision_min" string="最小(min)"/>-->
|
||||
<!-- <field name="precision_min" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<!-- <label for="precision_max" string="最大(max)"/>-->
|
||||
<!-- <field name="precision_max" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <field name="feed_speed" required="1"/>-->
|
||||
<!-- <label for="precision_min" string="X轴定位精度(mm)"/>-->
|
||||
<!-- <div class="test_model">-->
|
||||
<!-- <label for="precision_min" string="最小(min)"/>-->
|
||||
<!-- <field name="precision_min" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<!-- <label for="precision_max" string="最大(max)"/>-->
|
||||
<!-- <field name="precision_max" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- <field name="lead_screw" required="1"/>-->
|
||||
<!-- <field name="guide_rail" required="1"/>-->
|
||||
<!-- <field name="lead_screw" required="1"/>-->
|
||||
<!-- <field name="guide_rail" required="1"/>-->
|
||||
<field name="number_of_axles" required="1" widget="radio"
|
||||
options="{'horizontal': true}"/>
|
||||
<label for="x_axis" string="加工行程(mm)"
|
||||
@@ -255,7 +258,7 @@
|
||||
</group>
|
||||
<group string="主轴">
|
||||
<field name="taper_type_id" required="1"/>
|
||||
<label for="distance_min" string="主轴端面-工作台距离(mm)"/>
|
||||
<label for="distance_min" string="主轴端面-工作台距离(mm)"/>
|
||||
<div class="test_model">
|
||||
<label for="distance_min" string="最小(min)"/>
|
||||
<field name="distance_min" class="o_address_zip"
|
||||
@@ -265,7 +268,7 @@
|
||||
<field name="distance_max" class="o_address_zip"
|
||||
options="{'format': false}"/>
|
||||
</div>
|
||||
<field name="rotate_speed" string="主轴最高转速(r/min)"
|
||||
<field name="rotate_speed" string="主轴最高转速(r/min)"
|
||||
options="{'format': false}"/>
|
||||
<field name="spindle_center_distance"/>
|
||||
<field name="spindle_continuous_power"/>
|
||||
@@ -283,50 +286,50 @@
|
||||
<page string="进给/精度参数">
|
||||
<group>
|
||||
<group string="进给参数">
|
||||
<field name="X_axis_rapid_traverse_speed"/>
|
||||
<field name="Y_axis_rapid_traverse_speed"/>
|
||||
<field name="Z_axis_rapid_traverse_speed"/>
|
||||
<field name="a_axis_rapid_traverse_speed"/>
|
||||
<field name="b_axis_rapid_traverse_speed"/>
|
||||
<field name="c_axis_rapid_traverse_speed"/>
|
||||
<field name="straight_cutting_feed_rate"/>
|
||||
<field name="rotary_cutting_feed_rate"/>
|
||||
<field name="X_axis_rapid_traverse_speed"/>
|
||||
<field name="Y_axis_rapid_traverse_speed"/>
|
||||
<field name="Z_axis_rapid_traverse_speed"/>
|
||||
<field name="a_axis_rapid_traverse_speed"/>
|
||||
<field name="b_axis_rapid_traverse_speed"/>
|
||||
<field name="c_axis_rapid_traverse_speed"/>
|
||||
<field name="straight_cutting_feed_rate"/>
|
||||
<field name="rotary_cutting_feed_rate"/>
|
||||
</group>
|
||||
<group string="精度参数">
|
||||
<field name="X_precision"/>
|
||||
<field name="X_precision_repeat"/>
|
||||
<field name="Y_precision"/>
|
||||
<field name="Y_precision_repeat"/>
|
||||
<field name="Z_precision"/>
|
||||
<field name="Z_precision_repeat"/>
|
||||
<field name="a_precision"/>
|
||||
<field name="a_precision_repeat"/>
|
||||
<field name="b_precision"/>
|
||||
<field name="b_precision_repeat"/>
|
||||
<field name="c_precision"/>
|
||||
<field name="c_precision_repeat"/>
|
||||
<field name="X_precision"/>
|
||||
<field name="X_precision_repeat"/>
|
||||
<field name="Y_precision"/>
|
||||
<field name="Y_precision_repeat"/>
|
||||
<field name="Z_precision"/>
|
||||
<field name="Z_precision_repeat"/>
|
||||
<field name="a_precision"/>
|
||||
<field name="a_precision_repeat"/>
|
||||
<field name="b_precision"/>
|
||||
<field name="b_precision_repeat"/>
|
||||
<field name="c_precision"/>
|
||||
<field name="c_precision_repeat"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="刀库参数">
|
||||
<group>
|
||||
<page string="刀库参数">
|
||||
<group>
|
||||
<group string="刀具">
|
||||
<!-- <field name="knife_type" required="1"/>-->
|
||||
<!-- <field name="knife_type" required="1"/>-->
|
||||
<field name="number_of_knife_library" required="1" options="{'format': false}"/>
|
||||
<!-- <field name="tool_speed" required="1"/>-->
|
||||
<!-- <field name="tool_speed" required="1"/>-->
|
||||
<field name="tool_full_diameter_max"/>
|
||||
<field name="tool_perimeter_diameter_max"/>
|
||||
<field name="tool_long_max"/>
|
||||
<!-- <label for="tool_diameter_min" string="刀具刀径(mm)"/>-->
|
||||
<!-- <div class="test_model">-->
|
||||
<!-- <label for="tool_diameter_min" string="最小(min)"/>-->
|
||||
<!-- <field name="tool_diameter_min" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<!-- <label for="tool_diameter_max" string="最大(max)"/>-->
|
||||
<!-- <field name="tool_diameter_max" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <label for="tool_diameter_min" string="刀具刀径(mm)"/>-->
|
||||
<!-- <div class="test_model">-->
|
||||
<!-- <label for="tool_diameter_min" string="最小(min)"/>-->
|
||||
<!-- <field name="tool_diameter_min" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- <span>&nbsp;</span>-->
|
||||
<!-- <label for="tool_diameter_max" string="最大(max)"/>-->
|
||||
<!-- <field name="tool_diameter_max" class="o_address_zip" required="1"-->
|
||||
<!-- options="{'format': false}"/>-->
|
||||
<!-- </div>-->
|
||||
<field name="tool_quality_max"/>
|
||||
<field name="T_tool_time"/>
|
||||
<field name="C_tool_time"/>
|
||||
@@ -614,23 +617,4 @@
|
||||
<field name="res_model">sf.machine.control_system</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
|
||||
#------------------加工精度------------------
|
||||
<record model="ir.ui.view" id="tree_sf_machining_accuracy_view">
|
||||
<field name="name">tree.sf.machining.accuracy</field>
|
||||
<field name="model">sf.machining.accuracy</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="加工精度" create="0" edit="0" delete="0">
|
||||
<field name="name"/>
|
||||
<field name="standard_tolerance"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_sf_machining_accuracy" model="ir.actions.act_window">
|
||||
<field name="name">加工精度</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.machining.accuracy</field>
|
||||
<field name="view_mode">tree</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -141,18 +141,12 @@
|
||||
sequence="1"
|
||||
action="action_sf_machine_brand"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_machining_accuracy"
|
||||
parent="menu_sf_base"
|
||||
name="加工精度"
|
||||
sequence="1"
|
||||
action="action_sf_machining_accuracy"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_sf_machine_control_system"
|
||||
parent="menu_sf_base"
|
||||
name="数控系统"
|
||||
sequence="2"
|
||||
sequence="1"
|
||||
action="action_sf_machine_control_system"/>
|
||||
|
||||
|
||||
|
||||
@@ -360,7 +360,6 @@
|
||||
<field name="cooling_jacket"/>
|
||||
</tree>
|
||||
</field>
|
||||
<script src="/sf_base/static/js/setTableWidth.js?time=3"></script>
|
||||
</page>
|
||||
<page string="切削速度Vc"
|
||||
attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))]}">
|
||||
@@ -381,9 +380,6 @@
|
||||
<field name="cutting_speed"/>
|
||||
</tree>
|
||||
</field>
|
||||
<script src="/sf_base/static/js/customTable.js?time=3"></script>
|
||||
<script src="/sf_base/static/js/setTableWidth.js?time=3"></script>
|
||||
|
||||
</page>
|
||||
<page string="每齿走刀量fz"
|
||||
attrs="{'invisible': [('cutting_tool_type', 'not in', ('整体式刀具','刀片'))]}">
|
||||
@@ -396,8 +392,6 @@
|
||||
<field name="feed_per_tooth"/>
|
||||
</tree>
|
||||
</field>
|
||||
<div id="updateTable"></div>
|
||||
<script src="/sf_base/static/js/updateTable.js?time=3"></script>
|
||||
<field name="feed_per_tooth_ids_3"
|
||||
attrs="{'invisible': [('cutting_tool_type', 'not in', ('刀片'))]}">
|
||||
<tree editable="bottom" class="center" create="0" delete="0">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
""",
|
||||
'category': 'sf',
|
||||
'website': 'https://www.sf.jikimo.com',
|
||||
'depends': ['sf_base', 'mrp_subcontracting', 'purchase_stock', 'uom'],
|
||||
'depends': ['sf_base', 'web_widget_model_viewer', 'mrp_subcontracting', 'purchase_stock', 'uom', ],
|
||||
'data': [
|
||||
'data/product_data.xml',
|
||||
'data/uom_data.xml',
|
||||
|
||||
@@ -109,19 +109,6 @@
|
||||
'刀具')], 'required': True}
|
||||
</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//notebook" position="inside">
|
||||
<page string="2D加工图纸">
|
||||
<field name='machining_drawings' attrs="{'invisible': [('categ_type', '!=', '成品')]}"
|
||||
widget="adaptive_viewer"/>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//notebook" position="inside">
|
||||
<page string="质检标准">
|
||||
<field name='quality_standard' attrs="{'invisible': [('categ_type', '!=', '成品')]}"
|
||||
widget="adaptive_viewer"/>
|
||||
|
||||
</page>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//field[@name='default_code']" position="attributes">-->
|
||||
<!-- <attribute name="attrs">{'readonly': [('categ_type', '=', '刀具')], 'invisible':-->
|
||||
<!-- [('product_variant_count', '>' , 1)]}-->
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
'category': 'sf',
|
||||
'author': 'jikimo',
|
||||
'website': 'https://sf.cs.jikimo.com',
|
||||
'depends': ['web', 'sf_manufacturing', 'barcodes'],
|
||||
'depends': ['web', 'mail', 'sf_base', 'sf_manufacturing', 'barcodes', ],
|
||||
'data': [
|
||||
# 定义权限组放在最上面
|
||||
# 权限组
|
||||
|
||||
@@ -15,7 +15,7 @@ db_config = {
|
||||
"user": "postgres",
|
||||
"password": "postgres",
|
||||
"port": "5432",
|
||||
"host": "172.16.10.131"
|
||||
"host": "172.16.10.113"
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@ def convert_to_seconds(time_str):
|
||||
|
||||
if time_str is None:
|
||||
return 0
|
||||
if time_str == 0:
|
||||
return 0
|
||||
|
||||
pattern = r"(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?"
|
||||
|
||||
@@ -402,45 +400,20 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
try:
|
||||
plan_obj = request.env['sf.production.plan'].sudo()
|
||||
production_obj = request.env['mrp.production'].sudo()
|
||||
work_order_obj = request.env['mrp.workorder'].sudo()
|
||||
line_list = ast.literal_eval(kw['line_list'])
|
||||
# print('line_list: %s' % line_list)
|
||||
for line in line_list:
|
||||
|
||||
# 工单计划量
|
||||
plan_data_total_counts = production_obj.search_count(
|
||||
[('production_line_id.name', '=', line), ('state', 'not in', ['cancel']),
|
||||
('active', '=', True)])
|
||||
# 工单完成量
|
||||
plan_data_finish_counts = plan_obj.search_count(
|
||||
[('production_line_id.name', '=', line), ('state', 'in', ['finished'])])
|
||||
# # 工单计划量
|
||||
# plan_data_total_counts = production_obj.search_count(
|
||||
# [('production_line_id.name', '=', line), ('state', 'not in', ['cancel']),
|
||||
# ('active', '=', True)])
|
||||
|
||||
# 工单计划量切换为CNC工单
|
||||
plan_data_total_counts = work_order_obj.search_count(
|
||||
[('production_id.production_line_id.name', '=', line),
|
||||
('state', 'in', ['ready', 'progress', 'done']), ('routing_type', '=', 'CNC加工')])
|
||||
|
||||
# # 工单完成量
|
||||
# plan_data_finish_counts = plan_obj.search_count(
|
||||
# [('production_line_id.name', '=', line), ('state', 'in', ['finished'])])
|
||||
|
||||
# 工单完成量切换为CNC工单
|
||||
plan_data_finish_counts = work_order_obj.search_count(
|
||||
[('production_id.production_line_id.name', '=', line),
|
||||
('state', 'in', ['done']), ('routing_type', '=', 'CNC加工')])
|
||||
|
||||
# 超期完成量
|
||||
# 搜索所有已经完成的工单
|
||||
plan_data_overtime = work_order_obj.search([
|
||||
('production_id.production_line_id.name', '=', line),
|
||||
('state', 'in', ['done']),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
])
|
||||
|
||||
# 使用 filtered 进行字段比较
|
||||
plan_data_overtime_counts = plan_data_overtime.filtered(
|
||||
lambda order: order.date_finished > order.date_planned_finished
|
||||
)
|
||||
|
||||
# 获取数量
|
||||
plan_data_overtime_counts = len(plan_data_overtime_counts)
|
||||
# plan_data_plan_counts = plan_obj.search_count(
|
||||
# [('production_line_id.name', '=', line), ('state', 'not in', ['finished'])])
|
||||
|
||||
# 查找符合条件的生产计划记录
|
||||
plan_data = plan_obj.search([
|
||||
@@ -542,10 +515,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
'on_time_rate': on_time_rate,
|
||||
# 'detection_data': detection_data,
|
||||
'detection_data': plan_data_finish_counts,
|
||||
'pass_rate': (plan_data_finish_counts - plan_data_fault_counts) / plan_data_finish_counts,
|
||||
'plan_data_overtime_counts': plan_data_overtime_counts,
|
||||
'overtime_rate': plan_data_overtime_counts / plan_data_finish_counts
|
||||
if plan_data_finish_counts > 0 else 0,
|
||||
'pass_rate': (plan_data_finish_counts - plan_data_fault_counts) / plan_data_finish_counts
|
||||
}
|
||||
res['data'][line] = data
|
||||
|
||||
@@ -1272,7 +1242,6 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
time_threshold = datetime.now() - timedelta(days=1)
|
||||
|
||||
alarm_last_24_time = 0.0
|
||||
alarm_all_time = 0.0
|
||||
|
||||
def fetch_result_as_dict(cursor):
|
||||
"""辅助函数:将查询结果转为字典"""
|
||||
@@ -1333,49 +1302,17 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
alarm_last_24_time += float(result[0])
|
||||
else:
|
||||
alarm_last_24_time += 0.0
|
||||
|
||||
alarm_all_nums = []
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
SELECT DISTINCT ON (alarm_start_time) alarm_time, alarm_start_time
|
||||
FROM device_data
|
||||
WHERE device_name = %s
|
||||
AND alarm_start_time IS NOT NULL;
|
||||
""", (item,))
|
||||
results = cur.fetchall()
|
||||
for result in results:
|
||||
alarm_all_nums.append(result[1])
|
||||
if result[0]:
|
||||
if float(result[0]) >= 1000:
|
||||
continue
|
||||
alarm_all_time += float(result[0])
|
||||
else:
|
||||
alarm_all_time += 0.0
|
||||
|
||||
# with conn.cursor() as cur:
|
||||
# cur.execute("""
|
||||
# SELECT * FROM device_data
|
||||
# WHERE device_name = %s
|
||||
# AND total_count IS NOT NULL
|
||||
# ORDER BY time ASC
|
||||
# LIMIT 1;
|
||||
# """, (item, ))
|
||||
# total_count = fetch_result_as_dict(cur)
|
||||
|
||||
# 返回数据
|
||||
res['data'][item] = {
|
||||
'wait_time': last_all_time['run_time'] if last_all_time['run_time'] is not None else 0,
|
||||
'cut_time': last_all_time['process_time'] if last_all_time['process_time'] is not None else 0,
|
||||
'cut_24_time': last_24_time['process_time'] if last_24_time else 0,
|
||||
'cut_24_time': last_24_time['process_time'] if last_24_time['process_time'] is not None else 0,
|
||||
'power_on_time': last_all_time['power_on_time'] if last_all_time['power_on_time'] is not None else 0,
|
||||
'power_on_24_time': last_24_time['power_on_time'] if last_24_time else 0,
|
||||
'power_on_24_time': last_24_time['power_on_time'] if last_24_time['power_on_time'] is not None else 0,
|
||||
'alarm_last_24_time': alarm_last_24_time,
|
||||
'alarm_last_24_nums': len(list(set(alarm_last_24_nums))),
|
||||
'idle_count': idle_count,
|
||||
'first_online_time': first_online_duration,
|
||||
'alarm_all_time': alarm_all_time,
|
||||
'alarm_all_nums': len(list(set(alarm_all_nums)))
|
||||
# 'total_count': total_count['total_count'] if total_count else 0
|
||||
}
|
||||
|
||||
conn.close()
|
||||
|
||||
@@ -217,7 +217,7 @@ class Machine_ftp(models.Model):
|
||||
status = fields.Boolean('机床在线状态', readonly=True)
|
||||
# run_status = fields.Selection([('0', '空闲中'), ('1', '加工中'), ('2', '加工中'), ('3', '加工中')], string='机床运行状态',
|
||||
# readonly=True, default='0')
|
||||
# run_status = fields.Char('机床运行状态', readonly=True)
|
||||
run_status = fields.Char('机床运行状态', readonly=True)
|
||||
run_time = fields.Char('机床累计运行时长', readonly=True)
|
||||
# 机床系统日期
|
||||
system_date = fields.Char('机床系统日期', readonly=True)
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
@@ -11,14 +11,12 @@
|
||||
'security/group_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/ir_rule_data.xml',
|
||||
'data/scheduled_actions.xml',
|
||||
'views/maintenance_logs_views.xml',
|
||||
'views/maintenance_equipment_oee_views.xml',
|
||||
'views/maintenance_views.xml',
|
||||
'views/equipment_maintenance_standards_views.xml',
|
||||
'views/maintenance_request_views.xml',
|
||||
'views/maintenance_equipment_category_views.xml',
|
||||
'wizard/maintenance_request_wizard.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="ir_cron_oee_get_running_datas" model="ir.cron">
|
||||
<field name="name">设备运行数据</field>
|
||||
<field name="model_id" ref="model_maintenance_equipment_oee"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.get_running_datas()</field>
|
||||
<field name="interval_number">15</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import json
|
||||
import base64
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import requests
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class SfMaintenanceEquipmentCategory(models.Model):
|
||||
@@ -39,8 +38,6 @@ class SfMaintenanceEquipment(models.Model):
|
||||
|
||||
crea_url = "/api/machine_tool/create"
|
||||
|
||||
run_status = fields.Char('机床运行状态', readonly=True)
|
||||
|
||||
# AGV运行日志
|
||||
agv_logs = fields.One2many('maintenance.equipment.agv.log', 'equipment_id', string='AGV运行日志')
|
||||
# 1212修改后的字段
|
||||
@@ -123,13 +120,6 @@ class SfMaintenanceEquipment(models.Model):
|
||||
'sf_maintenance_equipment_ids', string='设备维保标准')
|
||||
eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准',
|
||||
domain="[('maintenance_type','=','保养')]")
|
||||
|
||||
initial_action_date = fields.Date(string='重置保养日期')
|
||||
initial_action_date_old = fields.Date(string='重置保养日期(旧)')
|
||||
next_action_date = fields.Date(string='下次预防保养')
|
||||
|
||||
initial_overhaul_date = fields.Date(string='重置维修日期')
|
||||
initial_overhaul_date_old = fields.Date(string='重置维修日期(旧)')
|
||||
overhaul_date = fields.Date(string='下次预防检修')
|
||||
overhaul_period = fields.Integer(string='预防检修频次')
|
||||
overhaul_duration = fields.Float(string='检修时长')
|
||||
@@ -137,61 +127,6 @@ class SfMaintenanceEquipment(models.Model):
|
||||
overhaul_id = fields.Many2one('equipment.maintenance.standards', string='设备检修标准',
|
||||
domain="[('maintenance_type','=','检修')]")
|
||||
|
||||
def confirm_maintenance(self):
|
||||
"""
|
||||
确认保养/检修
|
||||
"""
|
||||
context = self.env.context
|
||||
if context['type'] == '保养':
|
||||
if not self.initial_action_date:
|
||||
raise ValidationError('重置保养日期不能为空!!')
|
||||
elif self.initial_action_date < fields.Date.today():
|
||||
raise ValidationError('重置保养日期不能小于当前日期!!')
|
||||
elif context['type'] == '检修':
|
||||
if not self.initial_overhaul_date:
|
||||
raise ValidationError('重置检修日期不能为空!!')
|
||||
elif self.initial_overhaul_date < fields.Date.today():
|
||||
raise ValidationError('重置检修日期不能小于当前日期!!')
|
||||
|
||||
request_ids = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||
('equipment_id', '=', self.id),
|
||||
('maintenance_type', '=', 'preventive'),
|
||||
('sf_maintenance_type', '=', context['type'])])
|
||||
|
||||
if not request_ids:
|
||||
return self.create_maintenance_request(context['type'])
|
||||
else:
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "maintenance.request.wizard",
|
||||
"views": [[False, "form"]],
|
||||
"target": "new",
|
||||
'context': {
|
||||
'equipment_id': self.id
|
||||
}
|
||||
}
|
||||
|
||||
def create_maintenance_request(self, maintenance_request_type):
|
||||
"""
|
||||
根据条件创建维保计划
|
||||
"""
|
||||
if maintenance_request_type == '保养':
|
||||
self._create_new_request(self.initial_action_date + timedelta(days=self.period))
|
||||
self.initial_action_date_old = self.initial_action_date
|
||||
elif maintenance_request_type == '检修':
|
||||
self._create_new_request1(self.initial_overhaul_date + timedelta(days=self.overhaul_period))
|
||||
self.initial_overhaul_date_old = self.initial_overhaul_date
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'title': f'创建{maintenance_request_type}计划',
|
||||
'message': f'新{maintenance_request_type}维保计划创建成功',
|
||||
'type': 'success',
|
||||
'next': {'type': 'ir.actions.act_window_close'},
|
||||
}
|
||||
}
|
||||
|
||||
@api.onchange('eq_maintenance_id', 'overhaul_id')
|
||||
def _compute_equipment_maintenance_standards_ids(self):
|
||||
for record in self:
|
||||
@@ -654,13 +589,11 @@ class SfMaintenanceEquipment(models.Model):
|
||||
('equipment_id', '=', equipment.id),
|
||||
('sf_maintenance_type', '=', '保养'),
|
||||
('stage_id.done', '!=', True),
|
||||
('active', '!=', False),
|
||||
('close_date', '=', False)], order="request_date asc", limit=1)
|
||||
last_maintenance_done = self.env['maintenance.request'].search([
|
||||
('equipment_id', '=', equipment.id),
|
||||
('sf_maintenance_type', '=', '保养'),
|
||||
('stage_id.done', '=', True),
|
||||
('active', '!=', False),
|
||||
('close_date', '!=', False)], order="close_date desc", limit=1)
|
||||
if next_maintenance_todo and last_maintenance_done:
|
||||
next_date = next_maintenance_todo.request_date
|
||||
@@ -689,7 +622,7 @@ class SfMaintenanceEquipment(models.Model):
|
||||
if next_date < date_now:
|
||||
next_date = date_now
|
||||
else:
|
||||
next_date = equipment.initial_action_date + timedelta(days=equipment.period)
|
||||
next_date = equipment.effective_date + timedelta(days=equipment.period)
|
||||
equipment.next_action_date = next_date
|
||||
else:
|
||||
self.next_action_date = False
|
||||
@@ -700,13 +633,11 @@ class SfMaintenanceEquipment(models.Model):
|
||||
('equipment_id', '=', equipment.id),
|
||||
('sf_maintenance_type', '=', '检修'),
|
||||
('stage_id.done', '!=', True),
|
||||
('active', '!=', False),
|
||||
('close_date', '=', False)], order="request_date asc", limit=1)
|
||||
last_maintenance_done = self.env['maintenance.request'].search([
|
||||
('equipment_id', '=', equipment.id),
|
||||
('sf_maintenance_type', '=', '检修'),
|
||||
('stage_id.done', '=', True),
|
||||
('active', '!=', False),
|
||||
('close_date', '!=', False)], order="close_date desc", limit=1)
|
||||
if next_maintenance_todo and last_maintenance_done:
|
||||
next_date = next_maintenance_todo.request_date
|
||||
@@ -735,7 +666,7 @@ class SfMaintenanceEquipment(models.Model):
|
||||
if next_date < date_now:
|
||||
next_date = date_now
|
||||
else:
|
||||
next_date = equipment.initial_overhaul_date + timedelta(days=equipment.overhaul_period)
|
||||
next_date = equipment.effective_date + timedelta(days=equipment.overhaul_period)
|
||||
equipment.overhaul_date = next_date
|
||||
else:
|
||||
self.overhaul_date = False
|
||||
@@ -802,7 +733,6 @@ class SfMaintenanceEquipment(models.Model):
|
||||
next_requests = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||
('equipment_id', '=', equipment.id),
|
||||
('maintenance_type', '=', 'preventive'),
|
||||
('active', '=', True),
|
||||
('request_date', '=', equipment.next_action_date),
|
||||
('sf_maintenance_type', '=', '保养')])
|
||||
if not next_requests:
|
||||
@@ -811,7 +741,6 @@ class SfMaintenanceEquipment(models.Model):
|
||||
next_requests = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||
('equipment_id', '=', equipment.id),
|
||||
('maintenance_type', '=', 'preventive'),
|
||||
('active', '=', True),
|
||||
('request_date', '=', equipment.overhaul_date),
|
||||
('sf_maintenance_type', '=', '检修')])
|
||||
if not next_requests:
|
||||
|
||||
@@ -12,8 +12,6 @@ def convert_to_seconds(time_str):
|
||||
|
||||
if time_str is None:
|
||||
return 0
|
||||
if time_str == 0:
|
||||
return 0
|
||||
|
||||
pattern = r"(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?"
|
||||
|
||||
@@ -88,69 +86,6 @@ class SfMaintenanceEquipmentOEE(models.Model):
|
||||
begin_time = fields.Date('开始时间')
|
||||
end_time = fields.Date('结束时间')
|
||||
|
||||
def get_running_datas(self):
|
||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
url_time = base_url + '/api/RunningTimeDetail'
|
||||
cnc_list_obj = self.env['maintenance.equipment'].sudo().search(
|
||||
[('function_type', '!=', False), ('active', '=', True)])
|
||||
machine_list = list(map(lambda x: x.code, cnc_list_obj))
|
||||
# print('machine_list: %s' % machine_list)
|
||||
|
||||
data_time = {
|
||||
"machine_list": str(machine_list)
|
||||
}
|
||||
# 发送POST请求
|
||||
response_time = requests.post(url_time, json={}, data=data_time)
|
||||
# print(response_time.json())
|
||||
if response_time.status_code == 200:
|
||||
result_time = response_time.json()
|
||||
if result_time['status'] == 1:
|
||||
real_dict = result_time['data']
|
||||
for key in real_dict:
|
||||
# print(key)
|
||||
equipment_obj = self.env['maintenance.equipment.oee'].sudo().search([('equipment_code', '=', key)])
|
||||
if real_dict[key]['power_on_time'] == 0:
|
||||
equipment_obj.online_time = 0
|
||||
equipment_obj.idle_time = 0
|
||||
equipment_obj.idle_rate = 0
|
||||
equipment_obj.work_rate = 0
|
||||
equipment_obj.fault_time = 0
|
||||
equipment_obj.fault_rate = 0
|
||||
equipment_obj.fault_nums = 0
|
||||
equipment_obj.idle_nums = 0
|
||||
equipment_obj.work_time = 0
|
||||
else:
|
||||
equipment_obj.online_time = round(convert_to_seconds(real_dict[key]['power_on_time']) / 3600, 2)
|
||||
equipment_obj.work_time = round(convert_to_seconds(real_dict[key]['cut_time']) / 3600, 2)
|
||||
equipment_obj.fault_nums = real_dict[key]['alarm_all_nums']
|
||||
equipment_obj.idle_nums = real_dict[key]['idle_count']
|
||||
equipment_obj.fault_time = round((float(real_dict[key]['alarm_all_time']) if real_dict[key][
|
||||
'alarm_all_time'] else 0) / 3600, 2)
|
||||
equipment_obj.idle_time = float(equipment_obj.online_time) - float(
|
||||
equipment_obj.work_time) if equipment_obj.online_time and equipment_obj.work_time else 0
|
||||
equipment_obj.idle_rate = round(
|
||||
float(equipment_obj.idle_time) / (
|
||||
float(equipment_obj.online_time) if equipment_obj.online_time else 1) * 100, 2)
|
||||
equipment_obj.work_rate = round(
|
||||
float(equipment_obj.work_time) / (
|
||||
float(equipment_obj.online_time) if equipment_obj.online_time else 1) * 100, 2)
|
||||
|
||||
equipment_obj.fault_rate = round(
|
||||
float(equipment_obj.fault_time) / (
|
||||
float(equipment_obj.online_time) if equipment_obj.online_time else 1) * 100, 2)
|
||||
|
||||
# 获取当前时间的时间戳
|
||||
current_timestamp = datetime.datetime.now().timestamp()
|
||||
# 机床上线时间段
|
||||
first_online_duration = current_timestamp - int(equipment_obj.equipment_id.first_online_time.timestamp())
|
||||
|
||||
if equipment_obj.online_time:
|
||||
equipment_obj.offline_time = round((first_online_duration - float(equipment_obj.online_time)) / 3600, 2)
|
||||
else:
|
||||
equipment_obj.offline_time = False
|
||||
# equipment_obj.offline_time = equipment_obj.equipment_id.first_online_time - (
|
||||
# float(equipment_obj.online_time) if equipment_obj.online_time else 0)
|
||||
|
||||
# 获取日志详情
|
||||
def get_day_logs(self):
|
||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
@@ -187,36 +122,24 @@ class SfMaintenanceEquipmentOEE(models.Model):
|
||||
real_dict = result_time['data'][self.equipment_code]
|
||||
print('=', result_time)
|
||||
if result_time['status'] == 1:
|
||||
if real_dict['power_on_24_time'] == 0:
|
||||
self.online_time = 0
|
||||
self.idle_time = 0
|
||||
self.idle_rate = 0
|
||||
self.work_rate = 0
|
||||
self.fault_time = 0
|
||||
self.fault_rate = 0
|
||||
self.fault_nums = 0
|
||||
self.idle_nums = 0
|
||||
self.work_time = 0
|
||||
else:
|
||||
self.online_time = round((convert_to_seconds(real_dict['power_on_time']) - convert_to_seconds(
|
||||
real_dict['power_on_24_time'])) / 3600, 2)
|
||||
self.idle_time = float(self.online_time) - float(
|
||||
self.work_time) if self.online_time and self.work_time else 0
|
||||
self.idle_rate = round(
|
||||
float(self.idle_time) / (float(self.online_time) if self.online_time else 1) * 100, 2)
|
||||
self.work_rate = round(
|
||||
float(self.work_time) / (float(self.online_time) if self.online_time else 1) * 100, 2)
|
||||
self.fault_time = (float(real_dict['alarm_last_24_time']) if real_dict[
|
||||
'alarm_last_24_time'] else 0) / 3600
|
||||
self.fault_rate = round(
|
||||
float(self.fault_time) / (float(self.online_time) if self.online_time else 1) * 100, 2)
|
||||
self.fault_nums = real_dict['alarm_last_24_nums']
|
||||
self.idle_nums = real_dict['idle_count']
|
||||
self.work_time = round(
|
||||
(convert_to_seconds(real_dict['cut_time']) - convert_to_seconds(
|
||||
real_dict['cut_24_time'])) / 3600,
|
||||
2)
|
||||
self.online_time = round((convert_to_seconds(real_dict['power_on_time']) - convert_to_seconds(
|
||||
real_dict['power_on_24_time'])) / 3600, 2)
|
||||
self.work_time = round(
|
||||
(convert_to_seconds(real_dict['cut_time']) - convert_to_seconds(real_dict['cut_24_time'])) / 3600,
|
||||
2)
|
||||
self.offline_time = 24 - (float(self.online_time) if self.online_time else 0)
|
||||
self.idle_time = float(self.online_time) - float(
|
||||
self.work_time) if self.online_time and self.work_time else 0
|
||||
self.idle_rate = round(
|
||||
float(self.idle_time) / (float(self.online_time) if self.online_time else 1) * 100, 2)
|
||||
self.work_rate = round(
|
||||
float(self.work_time) / (float(self.online_time) if self.online_time else 1) * 100, 2)
|
||||
self.fault_time = (float(real_dict['alarm_last_24_time']) if real_dict[
|
||||
'alarm_last_24_time'] else 0) / 3600
|
||||
self.fault_rate = round(
|
||||
float(self.fault_time) / (float(self.online_time) if self.online_time else 1) * 100, 2)
|
||||
self.fault_nums = real_dict['alarm_last_24_nums']
|
||||
self.idle_nums = real_dict['idle_count']
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
|
||||
@@ -14,8 +14,6 @@ class SfMaintenanceEquipmentCategory(models.Model):
|
||||
equipment_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备维保标准',
|
||||
domain="[('maintenance_type','=',sf_maintenance_type)]")
|
||||
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
@api.onchange('sf_maintenance_type')
|
||||
def _compute_equipment_maintenance_request_id(self):
|
||||
for record in self:
|
||||
|
||||
@@ -20,8 +20,7 @@ access_maintenance_equipment_agv_log,maintenance_equipment_agv_log,model_mainten
|
||||
|
||||
|
||||
|
||||
access_maintenance_system_user,equipment.request system user,maintenance.model_maintenance_request,base.group_user,1,1,1,0
|
||||
access_maintenance_wizard_system_user,maintenance.request.wizard system user,model_maintenance_request_wizard,base.group_user,1,1,1,0
|
||||
access_maintenance_system_user,equipment.request system user,maintenance.model_maintenance_request,base.group_user,1,0,0,0
|
||||
|
||||
access_maintenance_equipment_group_plan_dispatch,maintenance.equipment,maintenance.model_maintenance_equipment,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_maintenance_equipment_oee_group_plan_dispatch,maintenance_equipment_oee,model_maintenance_equipment_oee,sf_base.group_plan_dispatch,1,0,0,0
|
||||
|
||||
|
@@ -79,12 +79,12 @@
|
||||
</group>
|
||||
|
||||
</group>
|
||||
<!-- <notebook> -->
|
||||
<!-- <page string="24H日志详情"> -->
|
||||
<!-- <group> -->
|
||||
<!-- <button name="get_day_logs" type="object" string="查看24H日志" t-attf-style="white-space:nowrap;"/> -->
|
||||
<!-- </group> -->
|
||||
<!-- <field name="day_logs_detail" readonly="1" widget="html"/> -->
|
||||
<notebook>
|
||||
<page string="24H日志详情">
|
||||
<group>
|
||||
<button name="get_day_logs" type="object" string="查看24H日志" t-attf-style="white-space:nowrap;"/>
|
||||
</group>
|
||||
<field name="day_logs_detail" readonly="1" widget="html"/>
|
||||
<!-- <field name="page_num"/> -->
|
||||
<!-- <group> -->
|
||||
<!-- <group> -->
|
||||
@@ -109,7 +109,7 @@
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </group> -->
|
||||
<!-- </page> -->
|
||||
</page>
|
||||
<!-- <page string="历史日志详情"> -->
|
||||
<!-- <group> -->
|
||||
<!-- <group> -->
|
||||
@@ -132,7 +132,7 @@
|
||||
<!-- </group> -->
|
||||
<!-- <field name="history_logs_detail"/> -->
|
||||
<!-- </page> -->
|
||||
<!-- </notebook> -->
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
@@ -60,9 +60,9 @@
|
||||
<field name="function_type"/>
|
||||
<field name="code" readonly="1"/>
|
||||
<field name="equipment_type" invisible="1"/>
|
||||
<field name="brand_id" force_save="1"/>
|
||||
<field name="brand_id" force_save="1" />
|
||||
<field name="type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||
domain="[('brand_id', '=', brand_id)]"/>
|
||||
domain="[('brand_id', '=', brand_id)]" />
|
||||
<field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}"
|
||||
force_save="1"/>
|
||||
<field name="run_time" force_save="1"/>
|
||||
@@ -73,7 +73,7 @@
|
||||
<group>
|
||||
<group string="基础参数">
|
||||
<field name="control_system_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||
options="{'no_create': True}"/>
|
||||
options="{'no_create': True}" />
|
||||
<label for="workbench_L" string="工作台尺寸(mm)"/>
|
||||
<div class="test_model">
|
||||
<label for="workbench_L" string="长"/>
|
||||
@@ -85,7 +85,7 @@
|
||||
<field name="workbench_W" class="o_address_zip"
|
||||
attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||
options="{'format': false}"/>
|
||||
<span>&nbsp;</span>
|
||||
<span>&nbsp;</span>
|
||||
<label for="workbench_H" string="高"/>
|
||||
<field name="workbench_H" class="o_address_zip"
|
||||
attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||
@@ -134,7 +134,7 @@
|
||||
<!-- <field name="guide_rail" required="1"/>-->
|
||||
<field name="number_of_axles" attrs="{'required': [('equipment_type', '=', '机床')]}"
|
||||
widget="radio"
|
||||
options="{'horizontal': true}"/>
|
||||
options="{'horizontal': true}" />
|
||||
<label for="x_axis" string="加工行程(mm)"
|
||||
attrs="{'invisible': [('number_of_axles', '=', False)]}"/>
|
||||
<div class="test_model"
|
||||
@@ -196,8 +196,8 @@
|
||||
<field name="T_tool_time"/>
|
||||
<field name="C_tool_time"/>
|
||||
</group>
|
||||
<group string="主轴">
|
||||
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"/>
|
||||
<group string="主轴">
|
||||
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}" />
|
||||
<label for="distance_min" string="主轴端面-工作台距离(mm)"/>
|
||||
<div class="test_model">
|
||||
<label for="distance_min" string="最小(min)"/>
|
||||
@@ -237,7 +237,7 @@
|
||||
<field name="c_precision"/>
|
||||
<field name="c_precision_repeat"/>
|
||||
</group>
|
||||
<group string="进给参数">
|
||||
<group string="进给参数">
|
||||
<field name="X_axis_rapid_traverse_speed"/>
|
||||
<field name="Y_axis_rapid_traverse_speed"/>
|
||||
<field name="Z_axis_rapid_traverse_speed"/>
|
||||
@@ -252,21 +252,21 @@
|
||||
|
||||
|
||||
</page>
|
||||
<page string="AGV运行日志" name="sf_equipment"
|
||||
<page string="AGV运行日志" name="sf_equipment"
|
||||
attrs="{'invisible': [('equipment_type', '!=', 'AGV小车')]}">
|
||||
<field name="agv_logs">
|
||||
<tree create="1" edit="1" delete="1" editable="bottom">
|
||||
<field name='run_type'/>
|
||||
<field name='run_code'/>
|
||||
<field name='run_first'/>
|
||||
<field name='run_last'/>
|
||||
<field name='production_line'/>
|
||||
<field name='workorder'/>
|
||||
<field name='time'/>
|
||||
<field name='state'/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<field name="agv_logs">
|
||||
<tree create="1" edit="1" delete="1" editable="bottom">
|
||||
<field name = 'run_type'/>
|
||||
<field name = 'run_code'/>
|
||||
<field name = 'run_first'/>
|
||||
<field name = 'run_last'/>
|
||||
<field name = 'production_line'/>
|
||||
<field name = 'workorder'/>
|
||||
<field name = 'time'/>
|
||||
<field name = 'state'/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
<page string="设备参数" name="sf_equipment"
|
||||
attrs="{'invisible': [('equipment_type', '!=', 'AGV小车')]}">
|
||||
@@ -979,58 +979,31 @@
|
||||
</group>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//field[@name='next_action_date']" position="before">
|
||||
|
||||
<xpath expr="//page[@name='maintenance']" position="replace">
|
||||
<page string="维保" name="maintenance">
|
||||
<group>
|
||||
<group string="保养">
|
||||
<field name='eq_maintenance_id' force_save="1" widget="many2one"/>
|
||||
<field name="initial_action_date"/>
|
||||
<field name="next_action_date" string="下次预防保养"/>
|
||||
<label for="period" string="预防保养频次"/>
|
||||
<div class="o_row">
|
||||
<field name="period"/>
|
||||
days
|
||||
</div>
|
||||
<label for="maintenance_duration" string="保养时长"/>
|
||||
<div class="o_row">
|
||||
<field name="maintenance_duration"/>
|
||||
hours
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
|
||||
<button name="confirm_maintenance" string="确认保养" type="object"
|
||||
class="oe_highlight" context="{'type': '保养'}"/>
|
||||
</div>
|
||||
</group>
|
||||
<group string="检修">
|
||||
<field name='overhaul_id'/>
|
||||
<field name="initial_overhaul_date"/>
|
||||
<field name="overhaul_date" string="下次预防检修"/>
|
||||
<label for="overhaul_period" string="预防检修频次"/>
|
||||
<div class="o_row">
|
||||
<field name="overhaul_period"/>
|
||||
days
|
||||
</div>
|
||||
<field name='eq_maintenance_id' force_save="1" widget="many2one"/>
|
||||
|
||||
<label for="overhaul_duration" string="检修时长"/>
|
||||
<div class="o_row">
|
||||
<field name="overhaul_duration"/>
|
||||
hours
|
||||
</div>
|
||||
<field name='equipment_maintenance_standards_ids' widget="many2many_tags"
|
||||
invisible="1"/>
|
||||
|
||||
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
|
||||
<button name="confirm_maintenance" string="确认检修" type="object"
|
||||
class="oe_highlight" context="{'type': '检修'}"/>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
|
||||
</page>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//div[hasclass('o_row')][field[@name='maintenance_duration']]" position="after">
|
||||
|
||||
|
||||
<field name='overhaul_id' options="{'no_create':True}"/>
|
||||
<field name="overhaul_date" string="下次预防检修"/>
|
||||
<label for="overhaul_period" string="预防检修频次"/>
|
||||
<div class="o_row">
|
||||
<field name="overhaul_period"/>
|
||||
days
|
||||
</div>
|
||||
|
||||
<label for="overhaul_duration" string="检修时长"/>
|
||||
<div class="o_row">
|
||||
<field name="overhaul_duration"/>
|
||||
hours
|
||||
</div>
|
||||
<field name='equipment_maintenance_standards_ids' widget="many2many_tags" invisible="1"/>
|
||||
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='description']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
</xpath>
|
||||
@@ -1169,16 +1142,14 @@
|
||||
</div>
|
||||
<div class="show_state" t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click
|
||||
">
|
||||
<div t-attf-class="#{record.run_status.raw_value == '运行中' ? 'color_1' : ''}"></div>
|
||||
<div t-attf-class="#{record.run_status.raw_value == '待机' ? 'color_4' : ''}"></div>
|
||||
<div t-attf-class="#{record.run_status.raw_value == '故障' ? 'color_2' : ''}"></div>
|
||||
<div t-attf-class="#{record.run_status.raw_value == '离线' ? 'color_3' : ''}"></div>
|
||||
<div t-attf-class="#{record.state.raw_value == '正常' ? 'color_1' : ''}"></div>
|
||||
<div t-attf-class="#{record.state.raw_value == '故障' ? 'color_2' : ''}"></div>
|
||||
<div t-attf-class="#{record.state.raw_value == '不可用' ? 'color_3' : ''}"></div>
|
||||
<p class="o_kanban_record_bottom state_zc"
|
||||
t-attf-class="#{record.run_status.raw_value == '运行中' ? 'font_color_1' : ''}
|
||||
#{record.run_status.raw_value == '待机' ? 'font_color_4' : ''}
|
||||
#{record.run_status.raw_value == '故障' ? 'font_color_2' : ''}
|
||||
#{record.run_status.raw_value == '离线' ? 'font_color_3' : ''}">
|
||||
<field name="run_status"/>
|
||||
t-attf-class="#{record.state.raw_value == '正常' ? 'font_color_1' : ''}
|
||||
#{record.state.raw_value == '故障' ? 'font_color_2' : ''}
|
||||
#{record.state.raw_value == '不可用' ? 'font_color_3' : ''}">
|
||||
<field name="state"/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1216,7 +1187,7 @@
|
||||
<field name="name" readonly="1"/>
|
||||
<field name="type" readonly="1"/>
|
||||
<field name="image" widget="image" readonly="1"/>
|
||||
<!-- <field name="equipment_id"/>-->
|
||||
<!-- <field name="equipment_id"/>-->
|
||||
<field name="active" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
from . import maintenance_request_wizard
|
||||
@@ -1,26 +0,0 @@
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MaintenanceRequestWizard(models.TransientModel):
|
||||
_name = 'maintenance.request.wizard'
|
||||
_description = '维保二次确认弹窗'
|
||||
|
||||
name = fields.Char('')
|
||||
|
||||
def submit(self):
|
||||
context = self.env.context
|
||||
equipment_id = self.env['maintenance.equipment'].sudo().search([('id', '=', context['equipment_id'])])
|
||||
request_ids = self.env['maintenance.request'].search([('stage_id.done', '=', False),
|
||||
('equipment_id', '=', equipment_id.id),
|
||||
('maintenance_type', '=', 'preventive'),
|
||||
('sf_maintenance_type', '=', context['type'])])
|
||||
request_ids.write({'active': False})
|
||||
return equipment_id.create_maintenance_request(context['type'])
|
||||
|
||||
def cancel(self):
|
||||
context = self.env.context
|
||||
equipment_id = self.env['maintenance.equipment'].sudo().search([('id', '=', context['equipment_id'])])
|
||||
if context['type'] == '保养':
|
||||
equipment_id.initial_action_date = equipment_id.initial_action_date_old
|
||||
elif context['type'] == '检修':
|
||||
equipment_id.initial_overhaul_date = equipment_id.initial_overhaul_date_old
|
||||
@@ -1,29 +0,0 @@
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="action_maintenance_request_wizard" model="ir.actions.act_window">
|
||||
<field name="name">维保计划</field>
|
||||
<field name="res_model">maintenance.request.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="maintenance_request_wizard_form_view">
|
||||
<field name="name">maintenance.request.wizard.form.view</field>
|
||||
<field name="model">maintenance.request.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<div>
|
||||
<field name="name" invisible="1"/>
|
||||
有未执行的历史维保计划,是否创建新维保计划!!
|
||||
</div>
|
||||
<footer>
|
||||
<button string="确认" name="submit" type="object" class="oe_highlight"/>
|
||||
<button string="取消" name="cancel" type="object" class="oe_highlight"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -189,7 +189,6 @@ class Manufacturing_Connect(http.Controller):
|
||||
request.env['sf.production.plan'].sudo().search([('production_id', '=', production_id)]).write(
|
||||
{'actual_start_time': workorder.date_start,
|
||||
'state': 'processing'})
|
||||
res.update({'workorder_id': workorder.id})
|
||||
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
@@ -596,6 +595,14 @@ class Manufacturing_Connect(http.Controller):
|
||||
if panel_workorder:
|
||||
panel_workorder.write({'production_line_state': '已下产线'})
|
||||
workorder.write({'state': 'to be detected'})
|
||||
# workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
# [
|
||||
# ('rfid_code', '=', rfid_code), ('type', '=', '下产线'),
|
||||
# ('production_id', '=', order.production_id.id),
|
||||
# ('workorder_id', '=', order.id),
|
||||
# ('workorder_state', '=', 'done')])
|
||||
# if workpiece_delivery:
|
||||
# delivery_Arr.append(workpiece_delivery.id)
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 204,
|
||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||
|
||||
@@ -18,7 +18,7 @@ class MrpProduction(models.Model):
|
||||
_inherit = 'mrp.production'
|
||||
_description = "制造订单"
|
||||
_order = 'create_date desc'
|
||||
deadline_of_delivery = fields.Date('订单交期', tracking=True, compute='_compute_deadline_of_delivery')
|
||||
|
||||
# tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
||||
maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests")
|
||||
request_ids = fields.One2many('maintenance.request', 'production_id')
|
||||
@@ -34,29 +34,6 @@ class MrpProduction(models.Model):
|
||||
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True)
|
||||
tool_state_remark2 = fields.Text(string='功能刀具状态备注(无效刀)', readonly=True)
|
||||
|
||||
@api.depends('procurement_group_id.mrp_production_ids.move_dest_ids.group_id.sale_id')
|
||||
def _compute_deadline_of_delivery(self):
|
||||
for production in self:
|
||||
# 确保 procurement_group_id 和相关字段存在
|
||||
if production.procurement_group_id:
|
||||
# 获取相关的 sale_id
|
||||
sale_order_id = production.procurement_group_id.mrp_production_ids.mapped(
|
||||
'move_dest_ids.group_id.sale_id')
|
||||
|
||||
# 确保 sale_order_id 是有效的 ID 列表
|
||||
if sale_order_id:
|
||||
# 获取 sale.order 记录
|
||||
sale_id = self.env['sale.order'].sudo().browse(sale_order_id.ids) # 使用 mapped 返回的 ID 列表
|
||||
|
||||
# 处理 sale_id
|
||||
if sale_id:
|
||||
# 假设我们只需要第一个 sale_id
|
||||
production.deadline_of_delivery = sale_id[0].deadline_of_delivery if sale_id else False
|
||||
else:
|
||||
production.deadline_of_delivery = False
|
||||
else:
|
||||
production.deadline_of_delivery = False
|
||||
|
||||
@api.depends('workorder_ids.tool_state_remark')
|
||||
def _compute_tool_state_remark(self):
|
||||
for item in self:
|
||||
@@ -141,12 +118,10 @@ class MrpProduction(models.Model):
|
||||
], string='工序状态', default='待装夹')
|
||||
|
||||
# 零件图号
|
||||
part_number = fields.Char('零件图号', readonly=True)
|
||||
part_number = fields.Char('零件图号')
|
||||
|
||||
# 上传零件图纸
|
||||
part_drawing = fields.Binary('零件图纸', readonly=True)
|
||||
|
||||
quality_standard = fields.Binary('质检标准', readonly=True)
|
||||
part_drawing = fields.Binary('零件图纸')
|
||||
|
||||
@api.depends('product_id.manual_quotation')
|
||||
def _compute_manual_quotation(self):
|
||||
@@ -321,13 +296,8 @@ class MrpProduction(models.Model):
|
||||
# 编程单更新
|
||||
def update_programming_state(self):
|
||||
try:
|
||||
manufacturing_type = 'rework'
|
||||
if self.is_scrap:
|
||||
manufacturing_type = 'scrap'
|
||||
elif self.tool_state == '2':
|
||||
manufacturing_type = 'invalid_tool_rework'
|
||||
res = {'programming_no': self.programming_no,
|
||||
'manufacturing_type': manufacturing_type}
|
||||
'manufacturing_type': 'rework' if self.is_scrap is False else 'scrap'}
|
||||
logging.info('res=%s:' % res)
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
@@ -973,8 +943,6 @@ class MrpProduction(models.Model):
|
||||
if production.programming_no in program_to_production_names:
|
||||
productions_not_delivered = self.env['mrp.production'].search(
|
||||
[('programming_no', '=', production.programming_no), ('programming_state', '=', '已编程未下发')])
|
||||
productions = self.env['mrp.production'].search(
|
||||
[('programming_no', '=', production.programming_no), ('state', 'not in', ('cancel', 'done'))])
|
||||
rework_workorder = production.workorder_ids.filtered(lambda m: m.state == 'rework')
|
||||
if rework_workorder:
|
||||
for rework_item in rework_workorder:
|
||||
@@ -987,13 +955,6 @@ class MrpProduction(models.Model):
|
||||
productions_not_delivered.write(
|
||||
{'state': 'progress', 'programming_state': '已编程', 'is_rework': False})
|
||||
|
||||
# 对制造订单所以面的cnc工单的程序用刀进行校验
|
||||
try:
|
||||
logging.info(f'已更新制造订单:{productions_not_delivered}')
|
||||
productions.production_cnc_tool_checkout()
|
||||
except Exception as e:
|
||||
logging.info(f'对cnc工单的程序用刀进行校验报错:{e}')
|
||||
|
||||
# 从cloud获取重新编程过的最新程序
|
||||
def get_new_program(self, processing_panel):
|
||||
try:
|
||||
|
||||
@@ -40,7 +40,7 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
def get_company_id(self):
|
||||
self.company_id = self.env.user.company_id.id
|
||||
|
||||
company_id = fields.Many2one('res.company', compute="get_company_id", related=False, store=True)
|
||||
company_id = fields.Many2one('res.company', compute="get_company_id", related=False)
|
||||
|
||||
# 排产的时候, 根据坯料的长宽高比对一下机床的最大加工尺寸.不符合就不要分配给这个加工中心(机床).
|
||||
# 工单对应的工作中心,根据工序中的工作中心去匹配,
|
||||
|
||||
@@ -231,13 +231,13 @@ class ResWorkcenter(models.Model):
|
||||
default_capacity = round(
|
||||
self.production_line_hour_capacity * date_planned_working_hours, 2)
|
||||
_logger.info('排程日期:%s,计划数量:%s,日产能:%s,日工时:%s' % (
|
||||
date_planned, sum_qty, default_capacity, date_planned_working_hours))
|
||||
date_planned, sum_qty, default_capacity, date_planned_working_hours))
|
||||
if sum_qty >= default_capacity:
|
||||
return False
|
||||
return True
|
||||
|
||||
# 处理排程是否超过小时产能
|
||||
def deal_available_single_machine_capacity(self, date_planned, count):
|
||||
def deal_available_single_machine_capacity(self, date_planned):
|
||||
|
||||
date_planned_start = date_planned.strftime('%Y-%m-%d %H:00:00')
|
||||
date_planned_end = date_planned + timedelta(hours=1)
|
||||
@@ -249,11 +249,7 @@ class ResWorkcenter(models.Model):
|
||||
|
||||
if plan_ids:
|
||||
sum_qty = sum([p.product_qty for p in plan_ids])
|
||||
production_line_hour_capacity = self.production_line_hour_capacity
|
||||
if sum_qty >= production_line_hour_capacity:
|
||||
message = '当前计划开始时间不能预约排程,超过生产线小时产能(%d件)%d件' % (
|
||||
production_line_hour_capacity, count)
|
||||
raise UserError(message)
|
||||
if sum_qty >= self.production_line_hour_capacity:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
compute='_compute_state', store=True,
|
||||
default='pending', copy=False, readonly=True, recursive=True, index=True, tracking=True)
|
||||
|
||||
delivery_warning = fields.Selection([('normal', '正常'), ('warning', '告警'), ('overdue', '逾期')], string='时效')
|
||||
# state = fields.Selection(selection_add=[('to be detected', "待检测"), ('rework', '返工')], tracking=True)
|
||||
|
||||
@api.depends('production_id.manual_quotation')
|
||||
def _compute_manual_quotation(self):
|
||||
@@ -225,9 +225,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
material_height = fields.Float(string='高')
|
||||
# 零件图号
|
||||
part_number = fields.Char(related='production_id.part_number', string='零件图号')
|
||||
machining_drawings = fields.Binary('2D加工图纸', related='production_id.part_drawing', readonly=True)
|
||||
quality_standard = fields.Binary('质检标准', related='production_id.quality_standard', readonly=True)
|
||||
|
||||
# 工序状态
|
||||
process_state = fields.Selection([
|
||||
('待装夹', '待装夹'),
|
||||
@@ -1051,17 +1048,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
if (workorder.production_id.tool_state in ['1', '2']
|
||||
and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
||||
and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
|
||||
if workorder.state == 'pending' and workorder == self.search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('routing_type', '=', '装夹预调'),
|
||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
limit=1,
|
||||
order="sequence"):
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
|
||||
# elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress',
|
||||
# 'rework']:
|
||||
@@ -1211,8 +1197,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
if record.is_rework is False:
|
||||
if not record.material_center_point:
|
||||
raise UserError("坯料中心点为空,请检查")
|
||||
# if record.X_deviation_angle <= 0:
|
||||
# raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle)
|
||||
if record.X_deviation_angle <= 0:
|
||||
raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle)
|
||||
record.process_state = '待加工'
|
||||
# record.write({'process_state': '待加工'})
|
||||
record.production_id.process_state = '待加工'
|
||||
|
||||
@@ -16,12 +16,6 @@ from OCC.Extend.DataExchange import write_stl_file
|
||||
class ResProductMo(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
def _get_machining_precision(self):
|
||||
machinings = self.env['sf.machining.accuracy'].sudo().search([])
|
||||
|
||||
list = [(m.sync_id, m.name) for m in machinings]
|
||||
return list
|
||||
|
||||
model_file = fields.Binary('模型文件')
|
||||
categ_type = fields.Selection(string='产品的类别', related='categ_id.type', store=True)
|
||||
model_name = fields.Char('模型名称')
|
||||
@@ -29,7 +23,12 @@ class ResProductMo(models.Model):
|
||||
model_width = fields.Float('模型宽(mm)', digits=(16, 3))
|
||||
model_height = fields.Float('模型高(mm)', digits=(16, 3))
|
||||
model_volume = fields.Float('模型体积(m³)')
|
||||
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='加工精度')
|
||||
model_machining_precision = fields.Selection([
|
||||
('0.10', '±0.10mm'),
|
||||
('0.05', '±0.05mm'),
|
||||
('0.03', '±0.03mm'),
|
||||
('0.02', '±0.02mm'),
|
||||
('0.01', '±0.01mm')], string='加工精度')
|
||||
model_processing_panel = fields.Char('模型加工面板')
|
||||
model_remark = fields.Char('模型备注说明')
|
||||
length = fields.Float('长(mm)', digits=(16, 3))
|
||||
@@ -775,10 +774,6 @@ class ResProductMo(models.Model):
|
||||
# bfm下单
|
||||
manual_quotation = fields.Boolean('人工编程', default=False, readonly=True)
|
||||
part_number = fields.Char(string='零件图号', readonly=True)
|
||||
machining_drawings = fields.Binary('2D加工图纸', readonly=True)
|
||||
quality_standard = fields.Binary('质检标准', readonly=True)
|
||||
machining_drawings_name = fields.Char('2D加工图纸名', readonly=True)
|
||||
quality_standard_name = fields.Char('质检标准名', readonly=True)
|
||||
|
||||
@api.constrains('tool_length')
|
||||
def _check_tool_length_size(self):
|
||||
@@ -840,11 +835,6 @@ class ResProductMo(models.Model):
|
||||
else:
|
||||
return self.env.ref('sf_dlm.product_uom_cubic_millimeter')
|
||||
|
||||
def attachment_update(self, name, res_id, res_field):
|
||||
attachment_info = self.env['ir.attachment'].sudo().search(
|
||||
[('res_id', '=', res_id), ('res_field', '=', res_field)], limit=1)
|
||||
attachment_info.write({'name': name})
|
||||
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
||||
def product_create(self, product_id, item, order_id, order_number, i):
|
||||
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||
@@ -883,11 +873,6 @@ class ResProductMo(models.Model):
|
||||
'manual_quotation': item['manual_quotation'] or False,
|
||||
'part_number': item.get('part_number') or '',
|
||||
'active': True,
|
||||
'machining_drawings_name': item['machining_drawings_name'],
|
||||
'quality_standard_name': item['quality_standard_name'],
|
||||
'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode(
|
||||
item['machining_drawings']),
|
||||
'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']),
|
||||
}
|
||||
tax_id = self.env['account.tax'].sudo().search(
|
||||
[('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')])
|
||||
@@ -895,12 +880,6 @@ class ResProductMo(models.Model):
|
||||
vals.update({'taxes_id': [(6, 0, [int(tax_id)])]})
|
||||
copy_product_id.sudo().write(vals)
|
||||
product_id.product_tmpl_id.active = False
|
||||
if item['machining_drawings'] and item['machining_drawings_name']:
|
||||
self.attachment_update(item['machining_drawings_name'], copy_product_id.product_tmpl_id.id,
|
||||
'machining_drawings')
|
||||
if item['quality_standard'] and item['quality_standard_name']:
|
||||
self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id,
|
||||
'quality_standard')
|
||||
return copy_product_id
|
||||
|
||||
def _get_ids(self, param):
|
||||
|
||||
@@ -182,11 +182,6 @@ class StockRule(models.Model):
|
||||
moves._action_confirm()
|
||||
return True
|
||||
|
||||
def attachment_update(self, name, res_id, res_field):
|
||||
attachment_info = self.env['ir.attachment'].sudo().search(
|
||||
[('res_id', '=', res_id), ('res_field', '=', res_field)], limit=1)
|
||||
attachment_info.write({'name': name})
|
||||
|
||||
@api.model
|
||||
def _run_manufacture(self, procurements):
|
||||
productions_values_by_company = defaultdict(list)
|
||||
@@ -277,16 +272,6 @@ class StockRule(models.Model):
|
||||
if quick_easy_order:
|
||||
production.write({'part_number': quick_easy_order.part_drawing_number,
|
||||
'part_drawing': quick_easy_order.machining_drawings})
|
||||
else:
|
||||
production.write({'part_number': production.product_id.part_number,
|
||||
'part_drawing': production.product_id.machining_drawings,
|
||||
'quality_standard': production.product_id.quality_standard})
|
||||
if production.product_id.machining_drawings and production.product_id.machining_drawings_name:
|
||||
self.attachment_update(production.product_id.machining_drawings_name, production.id,
|
||||
'part_drawing')
|
||||
if production.product_id.quality_standard and production.product_id.quality_standard_name:
|
||||
self.attachment_update(production.product_id.quality_standard_name, production.id,
|
||||
'quality_standard')
|
||||
if sale_order:
|
||||
# sale_order.write({'schedule_status': 'to schedule'})
|
||||
self.env['sf.production.plan'].sudo().with_company(company_id).create({
|
||||
|
||||
@@ -103,20 +103,10 @@ access_mrp_production_split_multi_group_sf_mrp_user,access.mrp.production.split.
|
||||
access_mrp_production_split_group_sf_mrp_user,access.mrp.production.split,mrp.model_mrp_production_split,sf_base.group_sf_mrp_user,1,1,1,0
|
||||
access_mrp_production_split_line_group_sf_mrp_user,access.mrp.production.split.line,mrp.model_mrp_production_split_line,sf_base.group_sf_mrp_user,1,1,1,0
|
||||
access_mrp_workcenter_capacity_manager_group_sf_mrp_user,mrp.workcenter.capacity.manager,mrp.model_mrp_workcenter_capacity,sf_base.group_sf_mrp_user,1,1,1,0
|
||||
access_mrp_workcenter_group_quality,mrp_workcenter_group_quality,model_mrp_workcenter,sf_base.group_quality,1,0,0,0
|
||||
access_mrp_workcenter_group_quality_director,mrp_workcenter_group_quality_director,model_mrp_workcenter,sf_base.group_quality_director,1,0,0,0
|
||||
access_sf_detection_result_group_quality,sf_detection_result_group_quality,model_sf_detection_result,sf_base.group_quality,1,0,1,0
|
||||
access_sf_detection_result_group_quality_director,sf_detection_result_group_quality_director,model_sf_detection_result,sf_base.group_quality_director,1,0,1,0
|
||||
access_mrp_workcenter_productivity_loss_group_quality,mrp_workcenter_productivity_loss_group_quality,mrp.model_mrp_workcenter_productivity_loss,sf_base.group_quality,1,0,0,0
|
||||
access_mrp_workcenter_productivity_loss_group_quality_director,mrp_workcenter_productivity_loss_group_quality_director,mrp.model_mrp_workcenter_productivity_loss,sf_base.group_quality_director,1,0,0,0
|
||||
access_mrp_workcenter_productivity_group_quality,mrp_workcenter_productivity_group_quality,mrp.model_mrp_workcenter_productivity,sf_base.group_quality,1,1,1,0
|
||||
access_mrp_workcenter_productivity_group_quality_director,mrp_workcenter_productivity_group_quality_director,mrp.model_mrp_workcenter_productivity,sf_base.group_quality_director,1,1,1,0
|
||||
|
||||
|
||||
access_mrp_production_group_plan_dispatch,mrp_production,model_mrp_production,sf_base.group_plan_dispatch,1,1,0,0
|
||||
access_mrp_production_group_quality,mrp_production,model_mrp_production,sf_base.group_quality,1,1,0,0
|
||||
access_mrp_production_group_quality_director,mrp_production,model_mrp_production,sf_base.group_quality_director,1,1,0,0
|
||||
access_mrp_workorder_group_quality,mrp_workorder,model_mrp_workorder,sf_base.group_quality,1,1,0,0
|
||||
access_mrp_workorder_group_quality_director,mrp_workorder,model_mrp_workorder,sf_base.group_quality_director,1,1,0,0
|
||||
access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_plan_dispatch,1,1,0,0
|
||||
access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_plan_dispatch,1,1,1,0
|
||||
access_sf_production_line_group_plan_dispatch,sf.production.line,model_sf_production_line,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_production_line_group_plan_director,sf.production.line,model_sf_production_line,sf_base.group_plan_director,1,1,1,0
|
||||
access_sf_production_line,sf.production.line,model_sf_production_line,sf_maintenance.sf_group_equipment_user,1,1,1,0
|
||||
|
||||
|
@@ -98,9 +98,9 @@
|
||||
<field name="production_line_id" readonly="1"/>
|
||||
<!-- <field name="production_line_state" readonly="1"/>-->
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
<field name="part_drawing"/>
|
||||
<field name="tool_state"/>
|
||||
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
|
||||
<field name="deadline_of_delivery" readonly="1"/>
|
||||
<field name="tool_state_remark2" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||
@@ -296,11 +296,8 @@
|
||||
</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet//notebook//page[@name='operations']//field[@name='workorder_ids']"
|
||||
position="replace">
|
||||
<field name="workorder_ids"
|
||||
attrs="{'readonly': ['|', ('state', '!=', 'test_value'), '&', ('state', '=', 'done'), ('is_locked', '=', True)]}"
|
||||
context="{'tree_view_ref': 'mrp.mrp_production_workorder_tree_editable_view', 'default_product_uom_id': product_uom_id, 'from_manufacturing_order': True}"/>
|
||||
<xpath expr="//sheet//notebook//page[@name='operations']//field[@name='workorder_ids']" position="replace">
|
||||
<field name="workorder_ids" attrs="{'readonly': ['|', ('state', '!=', 'test_value'), '&', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'tree_view_ref': 'mrp.mrp_production_workorder_tree_editable_view', 'default_product_uom_id': product_uom_id, 'from_manufacturing_order': True}"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet//notebook//page[@name='operations']" position="after">
|
||||
@@ -328,16 +325,6 @@
|
||||
<xpath expr="//field[@name='components_availability']" position="attributes">
|
||||
<attribute name="string">投料状态</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//notebook" position="inside">
|
||||
<page string="零件图纸">
|
||||
<field name="part_drawing" widget="adaptive_viewer"/>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//notebook" position="inside">
|
||||
<page string="质检标准">
|
||||
<field name="quality_standard" widget="adaptive_viewer"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -361,11 +348,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//tree" position="attributes">
|
||||
<attribute name="default_order">sequence</attribute>
|
||||
<attribute name="decoration-warning">delivery_warning == 'warning'</attribute>
|
||||
<attribute name="decoration-danger">delivery_warning == 'overdue'</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='state']" position="replace">
|
||||
<field name="delivery_warning" invisible="True"/>
|
||||
<field name="state" widget="badge" decoration-warning="state == 'progress'"
|
||||
decoration-success="state == 'done'" decoration-danger="state in ('cancel','rework')"
|
||||
decoration-muted="state == 'to be detected'"
|
||||
@@ -572,12 +556,7 @@
|
||||
</div>
|
||||
<field name="priority" widget="priority"/>
|
||||
</div>
|
||||
<t t-if="record.brand_id.raw_value">
|
||||
<div class="mt-1">
|
||||
品牌:
|
||||
<field name="brand_id"></field>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<div name="product_specification_id" class="mt-1">
|
||||
规格:
|
||||
<field name="specification_id"/>
|
||||
|
||||
@@ -101,9 +101,7 @@
|
||||
<!-- <field name="target">fullscreen</field>-->
|
||||
<field name="target">current</field>
|
||||
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
||||
active_id,'search_default_filter_order_warning':1,'search_default_filter_order_overdue':1}
|
||||
</field>
|
||||
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id': active_id}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_workorder">
|
||||
没有工单要做!
|
||||
@@ -223,52 +221,15 @@
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//label[1]" position="before">
|
||||
<!-- -->
|
||||
<field name="production_id" invisible="0"/>
|
||||
<field name="duration_expected" invisible="1"/>
|
||||
<field name="date_planned_start" invisible="1"/>
|
||||
<field name="date_planned_finished" invisible="1"/>
|
||||
<field name="duration" widget="mrp_timer"
|
||||
invisible="1" sum="real duration"/>
|
||||
<field name="glb_file" readonly="1" widget="Viewer3D" string="加工模型"/>
|
||||
<field name="manual_quotation" readonly="1"
|
||||
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
||||
<field name="processing_panel" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||
<field name="equipment_id" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||
<field name="production_line_id"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||
<field name="production_line_state" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||
|
||||
<field name='routing_type' invisible="1"/>
|
||||
<field name='process_state' invisible="1"/>
|
||||
<field name='routing_type' readonly="1"/>
|
||||
<field name='process_state' attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||
<field name='tag_type' readonly="1" attrs='{"invisible": [("tag_type","=",False)]}'
|
||||
decoration-danger="tag_type == '重新加工'"/>
|
||||
<field name="rfid_code" force_save="1" readonly="0" cache="True"
|
||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||
|
||||
</xpath>
|
||||
<xpath expr="//form//sheet//group//group//div[2]" position="replace">
|
||||
</xpath>
|
||||
<xpath expr="//form//sheet//group//group//div[1]" position="after">
|
||||
<field name="save_name" widget="CopyClipboardChar"
|
||||
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
|
||||
<label for="material_length" string="物料尺寸"/>
|
||||
<div class="o_address_format">
|
||||
<label for="material_length" string="长"/>
|
||||
<field name="material_length" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="material_width" string="宽"/>
|
||||
<field name="material_width" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="material_height" string="高"/>
|
||||
<field name="material_height" class="o_address_zip"/>
|
||||
</div>
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
</xpath>
|
||||
<xpath expr="//label[1]" position="attributes">
|
||||
<attribute name="string">计划加工时间</attribute>
|
||||
</xpath>
|
||||
@@ -285,12 +246,76 @@
|
||||
<field name='materiel_width' string="宽"/>
|
||||
<field name='materiel_height' string="高"/>
|
||||
</xpath>
|
||||
<field name="production_id" position="after" invisible="0">
|
||||
<group>
|
||||
<field name="date_planned_start" invisible="1"/>
|
||||
<field name="date_planned_finished" invisible="1"/>
|
||||
<!-- <field name="production_id" readonly="1"/>-->
|
||||
<field name="duration" widget="mrp_timer"
|
||||
attrs="{'invisible': [('production_state','=', 'draft')], 'readonly': [('is_user_working', '=', True)]}"
|
||||
sum="real duration"/>
|
||||
<field name="glb_file" readonly="1" widget="Viewer3D" string="加工模型"/>
|
||||
<field name="manual_quotation" readonly="1"
|
||||
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
||||
<field name="processing_panel" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||
<field name="equipment_id" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||
<field name="production_line_id"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||
<field name="production_line_state" readonly="1"
|
||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割","装夹预调"))]}'/>
|
||||
<!-- <field name="functional_fixture_id" -->
|
||||
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> -->
|
||||
<!-- <field name="functional_fixture_code" force_save="1" -->
|
||||
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> -->
|
||||
<!-- <field name="functional_fixture_type_id" -->
|
||||
<!-- attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/> -->
|
||||
</group>
|
||||
<!-- <group>-->
|
||||
<!-- <div>-->
|
||||
<!-- <label for="glb_file" string="加工模型"/>-->
|
||||
<!-- <field name="glb_file" readonly="1" widget="Viewer3D"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <!– <field name="glb_file" string="模型" readonly="1" widget="Viewer3D"/>–>-->
|
||||
<!-- </group>-->
|
||||
|
||||
|
||||
<!-- <field name="processing_panel" readonly="1" attrs="{'invisible': [('routing_type', 'in', ('获取CNC加工程序','装夹','解除装夹',-->
|
||||
<!-- '前置三元定位检测','后置三元质量检测','解除装夹'))]}"/>-->
|
||||
</field>
|
||||
<!-- <page string="Components" name="components">-->
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<!-- <page string="装夹托盘" attrs='{"invisible": [("routing_type","!=","装夹")]}'>-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="routing_type" invisible="1"/>-->
|
||||
<!-- <field name="tray_code"/>-->
|
||||
<!-- <field name="tray_id" readonly="1"/>-->
|
||||
<!-- </group>-->
|
||||
<!-- <group>-->
|
||||
<!-- <field name="pro_code" readonly="1" attrs='{"invisible": [("pro_code_ok","=",False)]}'-->
|
||||
<!-- style="color:green"/>-->
|
||||
<!-- <field name="pro_code" readonly="1" attrs='{"invisible": [("pro_code_ok","!=",False)]}'/>-->
|
||||
<!-- <div>-->
|
||||
<!-- <field name="pro_code_ok" invisible="1"/>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- </group>-->
|
||||
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
|
||||
<!-- <button type="object" class="oe_highlight" name="gettray" string="绑定托盘"-->
|
||||
<!-- attrs='{"invisible": ["|","|",("tray_id","!=",False),("state","!=","progress"),("production_id","=",False)]}'/>-->
|
||||
|
||||
<!-- </div>-->
|
||||
<!-- </page>-->
|
||||
<page string="工件装夹" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
|
||||
<group>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<!-- <group string="卡盘">-->
|
||||
<!-- <field name="chuck_serial_number"/>-->
|
||||
<!-- <field name="chuck_name"/>-->
|
||||
<!-- <field name="chuck_brand_id"/>-->
|
||||
<!-- <field name="chuck_type_id"/>-->
|
||||
<!-- <field name="chuck_model_id"/>-->
|
||||
<!-- </group>-->
|
||||
<group string="托盘">
|
||||
<field name="tray_serial_number" readonly="1" string="序列号"/>
|
||||
</group>
|
||||
@@ -305,6 +330,10 @@
|
||||
<field name="tray_model_id" readonly="1" string="型号"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="加工图纸">
|
||||
<!-- 隐藏加工图纸字段名 -->
|
||||
<field name="processing_drawing" widget="pdf_viewer" string="" readonly="1"/>
|
||||
</group>
|
||||
<group string="预调程序信息">
|
||||
<field name="preset_program_information" colspan="2" nolabel="1"
|
||||
placeholder="如有预调程序信息请在此处输入....."/>
|
||||
@@ -491,8 +520,7 @@
|
||||
|
||||
<xpath expr="//form//header" position="inside">
|
||||
<button type="object" class="oe_highlight jikimo_button_confirm" name="get_three_check_datas"
|
||||
string="获取数据"
|
||||
attrs='{"invisible": ["|", ("state","!=","progress"), ("routing_type","!=","装夹预调")]}'/>
|
||||
string="获取数据" attrs='{"invisible": ["|", ("state","!=","progress"), ("routing_type","!=","装夹预调")]}'/>
|
||||
</xpath>
|
||||
|
||||
|
||||
@@ -543,7 +571,9 @@
|
||||
<!-- <field name="button_state" invisible="1"/>-->
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
<group>
|
||||
<field name="cnc_worksheet" string="工作指令" widget="pdf_viewer"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="CMM程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<field name="cmm_ids" widget="one2many" string="CMM程序" readonly="1">
|
||||
@@ -572,60 +602,33 @@
|
||||
|
||||
</page>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//form//sheet//group//group//div[1]" position="after">-->
|
||||
<!-- <label for="date_start" string="实际加工时间"/>-->
|
||||
<!-- <div class="oe_inline">-->
|
||||
<!-- <field name="date_start" class="mr8 oe_inline"/>-->
|
||||
<!-- <strong class="mr8 oe_inline">到</strong>-->
|
||||
<!-- <field name="date_finished" class="oe_inline"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- </xpath>-->
|
||||
<xpath expr="//page[@name='time_tracking']//field[@name='time_ids']//tree//field[@name='date_end']"
|
||||
position="after">
|
||||
<field name="duration" string="实际时长"/>
|
||||
<xpath expr="//form//sheet//group//group//div[1]" position="after">
|
||||
<label for="date_start" string="实际加工时间"/>
|
||||
<div class="oe_inline">
|
||||
<field name="date_start" class="mr8 oe_inline"/>
|
||||
<strong class="mr8 oe_inline">到</strong>
|
||||
<field name="date_finished" class="oe_inline"/>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='time_tracking']" position="attributes">
|
||||
<attribute name="groups">
|
||||
mrp.group_mrp_manager,sf_base.group_sf_mrp_manager,sf_base.group_sf_equipment_user,sf_base.group_sf_order_user
|
||||
</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//notebook" position="inside">
|
||||
<page string="2D加工图纸">
|
||||
<field name="machining_drawings" widget="adaptive_viewer"
|
||||
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//sheet//notebook" position="inside">
|
||||
<page string="质检标准">
|
||||
<field name="quality_standard" widget="adaptive_viewer"
|
||||
attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}"/>
|
||||
</page>
|
||||
<xpath expr="//form//sheet//group//group//div[3]" position="after">
|
||||
<field name="save_name" widget="CopyClipboardChar"
|
||||
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
|
||||
<label for="material_length" string="物料尺寸"/>
|
||||
<div class="o_address_format">
|
||||
<label for="material_length" string="长"/>
|
||||
<field name="material_length" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="material_width" string="宽"/>
|
||||
<field name="material_width" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="material_height" string="高"/>
|
||||
<field name="material_height" class="o_address_zip"/>
|
||||
</div>
|
||||
<field name="part_number" string="成品的零件图号"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_mrp_production_workorder_tray_form_inherit_sf_1" model="ir.ui.view">
|
||||
<field name="name">mrp.production.workorder.tray.form.inherit.sf.1</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//form//sheet//group//group[2]" position="replace">
|
||||
<group string="装夹图纸" attrs="{'invisible': [('routing_type', '!=', '装夹预调')]}">
|
||||
<!-- 隐藏加工图纸字段名 -->
|
||||
<field name="processing_drawing" widget="pdf_viewer" string="" readonly="1"/>
|
||||
<!-- <field name="production_id" invisible="0"/>-->
|
||||
</group>
|
||||
<group string="工作指令" attrs="{'invisible': [('routing_type', '!=', 'CNC加工')]}">
|
||||
<field name="cnc_worksheet" string="" widget="pdf_viewer"/>
|
||||
</group>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//form//sheet//group//group[1]" position="before">-->
|
||||
<!-- <field name="production_id"/>-->
|
||||
<!-- </xpath>-->
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="workcenter_form_workorder_search" model="ir.ui.view">
|
||||
<field name="name">custom.workorder.search</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
@@ -637,12 +640,6 @@
|
||||
<xpath expr="//filter[@name='progress']" position="after">
|
||||
<filter string="待检测" name="state" domain="[('state','=','to be detected')]"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='date_start_filter']" position="before">
|
||||
<separator/>
|
||||
<filter string="预警" name="filter_order_warning" domain="[('delivery_warning', '=', 'warning')]"/>
|
||||
<filter string="逾期" name="filter_order_overdue" domain="[('delivery_warning', '=', 'overdue')]"/>
|
||||
<separator/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -11,13 +11,12 @@
|
||||
""",
|
||||
'category': 'sf',
|
||||
'website': 'https://www.sf.jikimo.com',
|
||||
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock', 'sf_quality', 'mrp'],
|
||||
'depends': ['sale', 'purchase', 'sf_plan', 'jikimo_message_notify', 'stock'],
|
||||
'data': [
|
||||
'data/bussiness_node.xml',
|
||||
'data/cron_data.xml',
|
||||
# 'data/cron_data.xml',
|
||||
'data/template_data.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/mrp_workorder_views.xml',
|
||||
|
||||
],
|
||||
'test': [
|
||||
],
|
||||
|
||||
@@ -15,13 +15,12 @@ class MessageSfMrsConnect(Sf_Mrs_Connect):
|
||||
def get_cnc_processing_create(self, **kw):
|
||||
res = super(MessageSfMrsConnect, self).get_cnc_processing_create(**kw)
|
||||
res = json.loads(res)
|
||||
_logger.info('已进入消息推送:%s' % res)
|
||||
if res.get('production_ids'):
|
||||
try:
|
||||
_logger.info('已编程的制造订单:%s' % res.get('production_ids'))
|
||||
productions = request.env['mrp.production'].sudo().search([('id', 'in', res.get('production_ids'))])
|
||||
# 过滤programming_state为已编程,tool_state为2的制造订单
|
||||
tool_state_valid_productions = productions.filtered(lambda x: x.tool_state == '2')
|
||||
tool_state_valid_productions = productions.filtered(lambda x: x.programming_state == '已编程' and x.tool_state == '2')
|
||||
if tool_state_valid_productions:
|
||||
data = {
|
||||
'name': tool_state_valid_productions[0].programming_no
|
||||
@@ -39,22 +38,3 @@ class MessageSfMrsConnect(Sf_Mrs_Connect):
|
||||
_logger.info('无效用刀异常消息推送接口:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/api/maintenance_logs/notify', type='json', auth='public', methods=['GET', 'POST'], csrf=False, cors="*")
|
||||
def maintenance_logs_notify(self, **kw):
|
||||
res = {'code': 200, 'message': '设备故障日志信息推送成功'}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
log_id = ret.get('log_id')
|
||||
if not log_id:
|
||||
res = {'code': 400, 'message': '设备故障日志id不能为空'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
try:
|
||||
if not isinstance(log_id, list):
|
||||
log_id = [log_id]
|
||||
maintenance_logs = request.env['sf.maintenance.logs'].sudo().search([('id', 'in', [int(id) for id in log_id])])
|
||||
if maintenance_logs:
|
||||
maintenance_logs.add_queue('设备故障')
|
||||
except Exception as e:
|
||||
res = {'code': 400, 'message': '设备故障信息推送失败', 'error': str(e)}
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
|
||||
@@ -12,16 +12,15 @@
|
||||
<field name="model">sale.order</field>
|
||||
</record>
|
||||
|
||||
<record id="bussiness_sale_order_overdue_warning" model="jikimo.message.bussiness.node">
|
||||
<field name="name">销售订单逾期预警</field>
|
||||
<field name="model">sale.order</field>
|
||||
</record>
|
||||
|
||||
<record id="bussiness_sale_order_overdue" model="jikimo.message.bussiness.node">
|
||||
<field name="name">销售订单已逾期</field>
|
||||
<field name="model">sale.order</field>
|
||||
</record>
|
||||
<!-- <record id="bussiness_sale_order_overdue_warning" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">销售订单逾期预警</field>-->
|
||||
<!-- <field name="model">sale.order</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record id="bussiness_sale_order_overdue" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">销售订单已逾期</field>-->
|
||||
<!-- <field name="model">sale.order</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="transfer_inventory" model="jikimo.message.bussiness.node">
|
||||
<field name="name">调拨入库</field>
|
||||
@@ -49,62 +48,42 @@
|
||||
<field name="name">工单已下发通知</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
<!--发货调拨-->
|
||||
<record id="production_completed_warehouse_reminder" model="jikimo.message.bussiness.node">
|
||||
<field name="name">生产完工入库提醒</field>
|
||||
<field name="model">mrp.production</field>
|
||||
</record>
|
||||
<record id="order_delivery_reminder" model="jikimo.message.bussiness.node">
|
||||
<field name="name">订单发货提醒</field>
|
||||
<field name="model">stock.picking</field>
|
||||
</record>
|
||||
<!-- <record id="bussiness_mrp_workorder_pre_overdue_warning" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">装夹预调工单逾期预警</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
<!-- <record id="bussiness_mrp_workorder_pre_overdue" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">装夹预调工单已逾期</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="bussiness_mrp_workorder_pre_overdue_warning" model="jikimo.message.bussiness.node">
|
||||
<field name="name">装夹预调工单逾期预警</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
<record id="bussiness_mrp_workorder_pre_overdue" model="jikimo.message.bussiness.node">
|
||||
<field name="name">装夹预调工单已逾期</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
<!-- <record id="bussiness_mrp_workorder_cnc_overdue_warning" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">CNC工单逾期预警</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
<!-- <record id="bussiness_mrp_workorder_cnc_overdue" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">CNC工单已逾期</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="bussiness_mrp_workorder_cnc_overdue_warning" model="jikimo.message.bussiness.node">
|
||||
<field name="name">CNC加工工单逾期预警</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
<record id="bussiness_mrp_workorder_cnc_overdue" model="jikimo.message.bussiness.node">
|
||||
<field name="name">CNC加工工单已逾期</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
<!-- <record id="bussiness_mrp_workorder_unclamp_overdue_warning" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">解除装夹工单逾期预警</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="bussiness_mrp_workorder_unclamp_overdue_warning" model="jikimo.message.bussiness.node">
|
||||
<field name="name">解除装夹工单逾期预警</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
<!-- <record id="bussiness_mrp_workorder_unclamp_overdue" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">解除装夹工单已逾期</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="bussiness_mrp_workorder_unclamp_overdue" model="jikimo.message.bussiness.node">
|
||||
<field name="name">解除装夹工单已逾期</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
<!-- <record id="bussiness_mrp_workorder_surface_overdue_warning" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">表面工艺工单逾期预警</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<record id="bussiness_mrp_workorder_surface_overdue_warning" model="jikimo.message.bussiness.node">
|
||||
<field name="name">表面工艺工单逾期预警</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
|
||||
<record id="bussiness_mrp_workorder_surface_overdue" model="jikimo.message.bussiness.node">
|
||||
<field name="name">表面工艺工单已逾期</field>
|
||||
<field name="model">mrp.workorder</field>
|
||||
</record>
|
||||
|
||||
<record id="bussiness_quality_cnc_test" model="jikimo.message.bussiness.node">
|
||||
<field name="name">待质量判定</field>
|
||||
<field name="model">quality.cnc.test</field>
|
||||
</record>
|
||||
|
||||
<record id="bussiness_maintenance_logs" model="jikimo.message.bussiness.node">
|
||||
<field name="name">设备故障</field>
|
||||
<field name="model">sf.maintenance.logs</field>
|
||||
</record>
|
||||
<!-- <record id="bussiness_mrp_workorder_surface_overdue" model="jikimo.message.bussiness.node">-->
|
||||
<!-- <field name="name">表面工艺工单已逾期</field>-->
|
||||
<!-- <field name="model">mrp.workorder</field>-->
|
||||
<!-- </record>-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,11 +1,24 @@
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record model="ir.cron" id="ir_cron_sale_order_overdue_warning">
|
||||
<field name="name">检查销售订单是否已逾期预警和逾期</field>
|
||||
<field name="name">销售订单逾期预警</field>
|
||||
<field name="model_id" ref="model_sale_order"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._overdue_or_warning_func()</field>
|
||||
<field name="interval_number">10</field>
|
||||
<field name="code">model._overdue_warning_func()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall" eval="False"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.cron" id="ir_cron_sale_order_overdue">
|
||||
<field name="name">销售订单已逾期</field>
|
||||
<field name="model_id" ref="model_sale_order"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._overdue_func()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall" eval="False"/>
|
||||
@@ -14,11 +27,11 @@
|
||||
</record>
|
||||
|
||||
<record model="ir.cron" id="ir_cron_mrp_workorder_overdue_warning">
|
||||
<field name="name">检查工单是否已逾期预警和逾期</field>
|
||||
<field name="name">装夹预调工单逾期预警</field>
|
||||
<field name="model_id" ref="model_mrp_workorder"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._overdue_or_warning_func()</field>
|
||||
<field name="interval_number">10</field>
|
||||
<field name="code">model._overdue_warning_func()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall" eval="False"/>
|
||||
@@ -26,17 +39,122 @@
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.cron" id="ir_cron_mrp_workorder_recover_time_warning">
|
||||
<field name="name">检查工单是否完成并恢复正常时效</field>
|
||||
<record model="ir.cron" id="ir_cron_mrp_workorder_overdue">
|
||||
<field name="name">工单已逾期</field>
|
||||
<field name="model_id" ref="model_mrp_workorder"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._recover_time_warning_func()</field>
|
||||
<field name="interval_number">10</field>
|
||||
<field name="code">model._overdue_func()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall" eval="False"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
<!-- -->
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_overdue_warning">-->
|
||||
<!-- <field name="name">工单逾期预警</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_warning_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_pre_overdue">-->
|
||||
<!-- <field name="name">工单已逾期</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
<!-- -->
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_pre_overdue_warning">-->
|
||||
<!-- <field name="name">工单逾期预警</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_warning_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_pre_overdue">-->
|
||||
<!-- <field name="name">工单已逾期</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_pre_overdue_warning">-->
|
||||
<!-- <field name="name">工单逾期预警</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_warning_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_pre_overdue">-->
|
||||
<!-- <field name="name">工单已逾期</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
<!-- -->
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_pre_overdue_warning">-->
|
||||
<!-- <field name="name">工单逾期预警</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_warning_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record model="ir.cron" id="ir_cron_mrp_workorder_pre_overdue">-->
|
||||
<!-- <field name="name">工单已逾期</field>-->
|
||||
<!-- <field name="model_id" ref="model_mrp_workorder"/>-->
|
||||
<!-- <field name="state">code</field>-->
|
||||
<!-- <field name="code">model._overdue_func()</field>-->
|
||||
<!-- <field name="interval_number">1</field>-->
|
||||
<!-- <field name="interval_type">minutes</field>-->
|
||||
<!-- <field name="numbercall">-1</field>-->
|
||||
<!-- <field name="doall" eval="False"/>-->
|
||||
<!-- <field name="user_id" ref="base.user_root"/>-->
|
||||
<!-- <field name="active" eval="True"/>-->
|
||||
<!-- </record>-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -2,7 +2,7 @@
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="template_pending_order" model="jikimo.message.template">
|
||||
<record id="template_pending_order" model="jikimo.message.template">
|
||||
<field name="name">待接单</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="model">sale.order</field>
|
||||
@@ -16,7 +16,7 @@
|
||||
</record>
|
||||
|
||||
<record id="template_to_be_confirm" model="jikimo.message.template">
|
||||
<field name="name">待排程提醒</field>
|
||||
<field name="name">确认接单</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_to_be_confirm"/>
|
||||
@@ -27,31 +27,6 @@
|
||||
事项:{{mrp_production_count}}个制造订单待计划排程
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="template_sale_order_overdue_warning" model="jikimo.message.template">
|
||||
<field name="name">销售订单逾期预警</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_sale_order_overdue_warning"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 销售订单逾期预警
|
||||
事项:共有[{{warning_num}}]({{url}})个销售订单有逾期风险
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="template_sale_order_overdue" model="jikimo.message.template">
|
||||
<field name="name">销售订单已逾期</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_sale_order_overdue"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">urgent</field>
|
||||
<field name="content">### 销售订单已逾期提醒
|
||||
事项:共有[{{overdue_num}}]({{url}})个销售订单已逾期
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="template_material_purchase_remind" model="jikimo.message.template">
|
||||
<field name="name">坯料采购提醒</field>
|
||||
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||
@@ -88,107 +63,11 @@
|
||||
事项:共{{number}}个工单已下发,请查收知悉</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_pre_overdue_warning" model="jikimo.message.template">
|
||||
<field name="name">装夹预调工单逾期预警</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_pre_overdue_warning"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单逾期预警
|
||||
事项:共有[{{warning_num}}]({{url}})工单有逾期风险</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_pre_overdue" model="jikimo.message.template">
|
||||
<field name="name">装夹预调工单已逾期</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_pre_overdue"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单已逾期提醒
|
||||
事项:共有[{{overdue_num}}]({{url}})工单已逾期</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_cnc_overdue_warning" model="jikimo.message.template">
|
||||
<field name="name">CNC加工工单逾期预警</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_cnc_overdue_warning"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单逾期预警
|
||||
事项:共有[{{warning_num}}]({{url}})工单有逾期风险</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_cnc_overdue" model="jikimo.message.template">
|
||||
<field name="name">CNC加工工单已逾期</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_cnc_overdue"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单已逾期提醒
|
||||
事项:共有[{{overdue_num}}]({{url}})工单已逾期</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_unclamp_overdue_warning" model="jikimo.message.template">
|
||||
<field name="name">解除装夹工单逾期预警</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_unclamp_overdue_warning"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单逾期预警
|
||||
事项:共有[{{warning_num}}]({{url}})工单有逾期风险</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_unclamp_overdue" model="jikimo.message.template">
|
||||
<field name="name">解除装夹工单已逾期</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_unclamp_overdue"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单已逾期提醒
|
||||
事项:共有[{{overdue_num}}]({{url}})工单已逾期</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_surface_overdue_warning" model="jikimo.message.template">
|
||||
<field name="name">表面工艺工单逾期预警</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_surface_overdue_warning"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单逾期预警
|
||||
事项:共有[{{warning_num}}]({{url}})工单有逾期风险</field>
|
||||
</record>
|
||||
|
||||
<record id="template_mrp_workorder_surface_overdue" model="jikimo.message.template">
|
||||
<field name="name">表面工艺工单已逾期</field>
|
||||
<field name="model_id" ref="mrp_workorder.model_mrp_workorder"/>
|
||||
<field name="model">mrp.workorder</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_mrp_workorder_surface_overdue"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="send_type">timing</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 工单已逾期提醒
|
||||
事项:共有[{{overdue_num}}]({{url}})工单已逾期</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="template_transfer_inventory_remind" model="jikimo.message.template">
|
||||
<!-- <field name="menu_id" ref="stock.menu_stock_root"/>-->
|
||||
<!-- <field name="action_id" ref="stock.action_picking_tree_ready"/>-->
|
||||
<field name="menu_id" ref="stock.menu_stock_root"/>
|
||||
<field name="action_id" ref="stock.action_picking_tree_ready"/>
|
||||
<field name="name">调拨入库</field>
|
||||
<field name="model_id" ref="stock.model_stock_picking"/>
|
||||
<field name="model">stock.picking</field>
|
||||
@@ -196,13 +75,13 @@
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 调拨入库通知:
|
||||
单号:调拨入库单[{{name}}]({{transfer_inventory_special_url}})
|
||||
单号:调拨入库单[{{name}}]({{request_url}})
|
||||
事项:完成刀具物料上架入库</field>
|
||||
</record>
|
||||
|
||||
<record id="template_tool_expired_remind" model="jikimo.message.template">
|
||||
<!-- <field name="menu_id" ref="mrp.menu_mrp_root"/>-->
|
||||
<!-- <field name="action_id" ref="sf_tool_management.sf_functional_tool_dismantle_view_act"/>-->
|
||||
<field name="menu_id" ref="mrp.menu_mrp_root"/>
|
||||
<field name="action_id" ref="sf_tool_management.sf_functional_tool_dismantle_view_act"/>
|
||||
<field name="name">功能刀具寿命到期</field>
|
||||
<field name="model_id" ref="sf_tool_management.model_sf_functional_tool_dismantle"/>
|
||||
<field name="model">sf.functional.tool.dismantle</field>
|
||||
@@ -210,13 +89,13 @@
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 功能刀具寿命到期提醒:
|
||||
单号:拆解单[{{code}}]({{tool_expired_remind_special_url}})
|
||||
单号:拆解单[{{code}}]({{request_url}})
|
||||
事项:{{functional_tool_id.tool_name_id.name}}寿命已到期,需拆解</field>
|
||||
</record>
|
||||
|
||||
<record id="template_tool_assembly_remind" model="jikimo.message.template">
|
||||
<!-- <field name="menu_id" ref="mrp.menu_mrp_root"/>-->
|
||||
<!-- <field name="action_id" ref="sf_tool_management.sf_functional_tool_assembly_view_act"/>-->
|
||||
<field name="menu_id" ref="mrp.menu_mrp_root"/>
|
||||
<field name="action_id" ref="sf_tool_management.sf_functional_tool_assembly_view_act"/>
|
||||
<field name="name">功能刀具组装</field>
|
||||
<field name="model_id" ref="sf_tool_management.model_sf_functional_tool_assembly"/>
|
||||
<field name="model">sf.functional.tool.assembly</field>
|
||||
@@ -224,56 +103,8 @@
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 功能刀具组装通知:
|
||||
单号:组装任务单[{{name}}]({{tool_assembly_special_url}})
|
||||
单号:组装任务单[{{name}}]({{request_url}})
|
||||
事项:{{use_tool_time}}前完成组装</field>
|
||||
</record>
|
||||
<record id="template_production_completed_remind" model="jikimo.message.template">
|
||||
<!-- <field name="menu_id" ref="mrp.menu_mrp_root"/>-->
|
||||
<!-- <field name="action_id" ref="mrp.mrp_production_action"/>-->
|
||||
<field name="name">生产完工入库提醒</field>
|
||||
<field name="model_id" ref="mrp.model_mrp_production"/>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="bussiness_node_id" ref="production_completed_warehouse_reminder"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 生产完工入库提醒:
|
||||
单号:生产入库单[{{name}}]({{request_url}})
|
||||
事项:销售订单{{sale_order_name}}已全部产出,请入库处理</field>
|
||||
</record>
|
||||
<record id="template_order_delivery_remind" model="jikimo.message.template">
|
||||
<!-- <field name="menu_id" ref="stock.menu_stock_root"/>-->
|
||||
<!-- <field name="action_id" ref="stock.action_picking_tree_ready"/>-->
|
||||
<field name="name">订单发货提醒</field>
|
||||
<field name="model_id" ref="stock.model_stock_picking"/>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="bussiness_node_id" ref="order_delivery_reminder"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 订单发货提醒:
|
||||
单号:发料出库单[{{name}}]({{request_url}})
|
||||
事项:销售订单{{sale_order_name}}已全部产出并入库,请及时发货</field>
|
||||
</record>
|
||||
|
||||
<record id="template_quality_cnc_test" model="jikimo.message.template">
|
||||
<field name="name">待质量判定</field>
|
||||
<field name="model_id" ref="sf_quality.model_quality_cnc_test"/>
|
||||
<field name="model">quality.cnc.test</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_quality_cnc_test"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">normal</field>
|
||||
<field name="content">### 待质量判定提醒
|
||||
事项:共有[{{judge_num}}]({{url}})个工单需判定质量结果</field>
|
||||
</record>
|
||||
<record id="template_maintenance_logs" model="jikimo.message.template">
|
||||
<field name="name">设备故障</field>
|
||||
<field name="model_id" ref="sf_maintenance.model_sf_maintenance_logs"/>
|
||||
<field name="model">sf.maintenance.logs</field>
|
||||
<field name="bussiness_node_id" ref="bussiness_maintenance_logs"/>
|
||||
<field name="msgtype">markdown</field>
|
||||
<field name="urgency">urgent</field>
|
||||
<field name="content">### 设备故障及异常提醒:
|
||||
机台号:[{{maintenance_equipment_id.name}}]({{url}})
|
||||
事项:{{create_date}}故障报警</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -7,6 +7,3 @@ from . import sf_message_functional_tool_assembly
|
||||
from . import sf_message_purchase
|
||||
from . import sf_message_workorder
|
||||
from . import sf_message_functional_tool_dismantle
|
||||
from . import sf_message_mrp_production
|
||||
from . import sf_message_quality_cnc_test
|
||||
from . import sf_message_maintenance_logs
|
||||
|
||||
@@ -13,14 +13,3 @@ class SFMessagefunctionalToolAssembly(models.Model):
|
||||
if obj.loading_task_source == '0' and obj.assemble_status == '0':
|
||||
obj.add_queue('功能刀具组装')
|
||||
return result
|
||||
|
||||
|
||||
def get_special_url(self,id,tmplate_name,special_name,model_id):
|
||||
menu_id = 0
|
||||
action_id = 0
|
||||
if tmplate_name=='调拨入库' and special_name== 'tool_assembly_special_url':
|
||||
menu_id = self.env.ref('mrp.menu_mrp_root').id
|
||||
action_id = self.env.ref('sf_tool_management.sf_functional_tool_assembly_view_act').id
|
||||
return super(SFMessagefunctionalToolAssembly, self).get_url(id, menu_id, action_id,model_id)
|
||||
else:
|
||||
return super(SFMessagefunctionalToolAssembly, self).get_special_url(id, tmplate_name, special_name, model_id)
|
||||
@@ -17,13 +17,3 @@ class SFMessagefunctionalToolDismantle(models.Model):
|
||||
if obj.dismantle_cause in ['寿命到期报废', '崩刀报废'] and obj.state == '待拆解':
|
||||
obj.add_queue('功能刀具寿命到期')
|
||||
return result
|
||||
|
||||
def get_special_url(self,id,tmplate_name,special_name,model_id):
|
||||
menu_id = 0
|
||||
action_id = 0
|
||||
if tmplate_name=='调拨入库' and special_name== 'tool_expired_remind_special_url':
|
||||
menu_id = self.env.ref('mrp.menu_mrp_root').id
|
||||
action_id = self.env.ref('sf_tool_management.sf_functional_tool_dismantle_view_act').id
|
||||
return super(SFMessagefunctionalToolDismantle, self).get_url(id, menu_id, action_id,model_id)
|
||||
else:
|
||||
return super(SFMessagefunctionalToolDismantle, self).get_special_url(id, tmplate_name, special_name, model_id)
|
||||
@@ -1,23 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api
|
||||
|
||||
class SFMessageMaintenanceLogs(models.Model):
|
||||
_name = 'sf.maintenance.logs'
|
||||
_inherit = ['sf.maintenance.logs', 'jikimo.message.dispatch']
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
res = super(SFMessageMaintenanceLogs, self).create(vals_list)
|
||||
for rec in res:
|
||||
rec.add_queue('设备故障')
|
||||
return res
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = super(SFMessageMaintenanceLogs, self)._get_message(message_queue_ids)
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
action_id = self.env.ref('sf_maintenance.action_maintenance_logs').id
|
||||
for index, content in enumerate(contents):
|
||||
maintenance_logs_id = self.env['sf.maintenance.logs'].browse(message_queue_ids[index].res_id)
|
||||
url = url + '/web#id=%s&view_type=form&action=%s' % (maintenance_logs_id.id, action_id)
|
||||
contents[index] = content.replace('{{url}}', url)
|
||||
return contents
|
||||
@@ -1,57 +0,0 @@
|
||||
import logging
|
||||
import re
|
||||
from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class SFMessageMrpProduction(models.Model):
|
||||
_name = 'mrp.production'
|
||||
_description = "制造订单"
|
||||
_inherit = ['mrp.production', 'jikimo.message.dispatch']
|
||||
|
||||
@api.depends(
|
||||
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
|
||||
'workorder_ids.state', 'product_qty', 'qty_producing')
|
||||
def _compute_state(self):
|
||||
super(SFMessageMrpProduction, self)._compute_state()
|
||||
for record in self:
|
||||
if record.state in ['scrap', 'done']:
|
||||
# 查询制造订单下的所有未完成的生产订单
|
||||
mrp_production = record.env['mrp.production'].search(
|
||||
[('origin', '=', record.origin), ('state', 'not in', ['scrap', 'done'])])
|
||||
if not mrp_production:
|
||||
mrp_production_queue = self.env["jikimo.message.queue"].search([('res_id', '=', record.id)])
|
||||
if not mrp_production_queue:
|
||||
record.add_queue('生产完工入库提醒')
|
||||
|
||||
# 获取发送消息内容
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
for message_queue_id in message_queue_ids:
|
||||
if message_queue_id.message_template_id.name == '生产完工入库提醒':
|
||||
content = message_queue_id.message_template_id.content
|
||||
mrp_production = self.env['mrp.production'].search([('id', '=', int(message_queue_id.res_id))])
|
||||
if mrp_production and len(mrp_production) > 0:
|
||||
stock_picking_sfp = self.env['stock.picking'].search(
|
||||
[('origin', '=', mrp_production.origin), ('picking_type_id.sequence_code', '=', 'SFP'),
|
||||
('state', '=', 'assigned')], limit=1)
|
||||
if stock_picking_sfp:
|
||||
url = self.request_url(stock_picking_sfp.id)
|
||||
content = content.replace('{{name}}', stock_picking_sfp.name).replace(
|
||||
'{{sale_order_name}}', mrp_production.origin).replace('{{request_url}}', url)
|
||||
contents.append(content)
|
||||
logging.info('生产完工入库提醒: %s' % contents)
|
||||
return contents
|
||||
|
||||
def request_url(self, id):
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.action_picking_tree_all').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id
|
||||
# 查询参数
|
||||
params = {'id': id, 'menu_id': menu_id, 'action': action_id, 'model': 'mrp.production',
|
||||
'view_type': 'form'}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
@@ -1,36 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class SFMessageQualityCncTest(models.Model):
|
||||
_name = 'quality.cnc.test'
|
||||
_inherit = ['quality.cnc.test', 'jikimo.message.dispatch']
|
||||
|
||||
def create(self, vals_list):
|
||||
res = super(SFMessageQualityCncTest, self).create(vals_list)
|
||||
if res:
|
||||
try:
|
||||
logging.info('add_queue res:%s' % res)
|
||||
res.add_queue('待质量判定')
|
||||
except Exception as e:
|
||||
logging.info('add_queue error:%s' % e)
|
||||
return res
|
||||
|
||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
i = 0
|
||||
for item in message_queue_ids:
|
||||
if item.message_template_id.bussiness_node_id.name == '待质量判定':
|
||||
content = item.message_template_id.content
|
||||
i += 1
|
||||
if i >= 1:
|
||||
action_id = self.env.ref('sf_quality.action_quality_cnc_test').id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||
content_template = content.replace('{{judge_num}}', str(i))
|
||||
content_template = content_template.replace('{{url}}', url_with_id)
|
||||
contents.append(content_template)
|
||||
return contents
|
||||
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
@@ -13,7 +12,6 @@ class SFMessageSale(models.Model):
|
||||
res = super(SFMessageSale, self).create(vals_list)
|
||||
if res:
|
||||
try:
|
||||
logging.info('add_queue res:%s' % res)
|
||||
res.add_queue('待接单')
|
||||
except Exception as e:
|
||||
logging.info('add_queue error:%s' % e)
|
||||
@@ -44,20 +42,16 @@ class SFMessageSale(models.Model):
|
||||
# 继承并重写jikimo.message.dispatch的_get_message()
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
bussiness_node = None
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_strf)
|
||||
current_time_datetime = datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S')
|
||||
time_range = timedelta(minutes=2)
|
||||
i = 0
|
||||
for item in message_queue_ids:
|
||||
# 待接单的处理
|
||||
if item.message_template_id.bussiness_node_id.name == '待接单':
|
||||
content = super(SFMessageSale, self)._get_message(item)
|
||||
action_id = self.env.ref('sale.action_quotations_with_onboarding').id
|
||||
url_with_id = f"{url}/web#id={item.res_id}&view_type=form&action={action_id}"
|
||||
content = content[0].replace('{{url}}', url_with_id)
|
||||
url = f"{url}/web#id={item.res_id}&view_type=form&action={action_id}"
|
||||
content = content[0].replace('{{url}}', url)
|
||||
contents.append(content)
|
||||
# 确认接单的处理
|
||||
elif item.message_template_id.bussiness_node_id.name == '确认接单':
|
||||
content = super(SFMessageSale, self)._get_message(item)
|
||||
sale_order_line = self.env['sale.order.line'].search([('order_id', '=', int(item.res_id))])
|
||||
@@ -65,96 +59,16 @@ class SFMessageSale(models.Model):
|
||||
sale_order_line[
|
||||
0].product_id.name
|
||||
action_id = self.env.ref('sf_plan.sf_production_plan_action1').id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||
content = content[0].replace('{{product_id}}', product).replace('{{url}}', url_with_id)
|
||||
url = f"{url}/web#view_type=list&action={action_id}"
|
||||
content = content[0].replace('{{product_id}}', product).replace('{{url}}', url)
|
||||
contents.append(content)
|
||||
elif item.message_template_id.bussiness_node_id.name in ['销售订单逾期预警', '销售订单已逾期']:
|
||||
bussiness_node = item.message_template_id.bussiness_node_id.name
|
||||
for reminder_time in item.message_template_id.reminder_time_ids:
|
||||
content = item.message_template_id.content
|
||||
target_time = datetime.combine(current_time_datetime.date(), datetime.min.time()).replace(
|
||||
hour=reminder_time.time_point,
|
||||
minute=0,
|
||||
second=0,
|
||||
microsecond=0
|
||||
)
|
||||
logging.info(current_time)
|
||||
logging.info(target_time)
|
||||
if target_time - time_range <= current_time_datetime <= target_time + time_range:
|
||||
search_condition = [
|
||||
('delivery_warning', '=', 'warning')] if bussiness_node == '销售订单逾期预警' else [
|
||||
('delivery_warning', '=', 'overdue')]
|
||||
record = self.sudo().search(search_condition + [('id', '=', int(item.res_id))])
|
||||
if record:
|
||||
i += 1
|
||||
if i >= 1:
|
||||
action_id = self.env.ref('sale.action_orders').id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||
content_template = content.replace('{{url}}', url_with_id)
|
||||
if bussiness_node == '销售订单逾期预警':
|
||||
content = content_template.replace('{{warning_num}}', str(i))
|
||||
elif bussiness_node == '销售订单已逾期':
|
||||
content = content_template.replace('{{overdue_num}}', str(i))
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
# # 销售订单逾期预警和已逾期
|
||||
def _overdue_or_warning_func(self):
|
||||
today = datetime.today().date()
|
||||
deadline_check = today + timedelta(days=1)
|
||||
logging.info(f"today: {today}, deadline_check: {deadline_check}")
|
||||
sale_order = self.sudo().search(
|
||||
[('state', 'in', ['sale']), ('deadline_of_delivery', '!=', False), ('delivery_status', '!=', 'full')])
|
||||
for item in sale_order:
|
||||
production = self.env['mrp.production'].search([('origin', '=', item.name)])
|
||||
production_not_done = production.filtered(lambda p: p.state not in ['done', 'scrap', 'cancel'])
|
||||
production_done_count = len(production.filtered(lambda p: p.state in ['done', 'scrap', 'cancel']))
|
||||
if (len(production_not_done) >= 1 and len(production_not_done) != item.mrp_production_count) or len(
|
||||
production_not_done) != production_done_count:
|
||||
logging.info("-----不等于----")
|
||||
logging.info(f"name: {item.name}")
|
||||
logging.info(
|
||||
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||
item.delivery_warning = 'warning'
|
||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||
item.delivery_warning = 'overdue'
|
||||
elif production_done_count == item.mrp_production_count:
|
||||
logging.info("-----等于----")
|
||||
logging.info(f"name: {item.name}")
|
||||
logging.info(
|
||||
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
logging.info(f"deadline_of_delivery: {item.deadline_of_delivery}")
|
||||
if item.delivery_status in ['pending', 'partial']:
|
||||
if deadline_check == item.deadline_of_delivery and item.delivery_warning not in ['warning']:
|
||||
item.delivery_warning = 'warning'
|
||||
elif today >= item.deadline_of_delivery and item.delivery_warning not in ['overdue']:
|
||||
item.delivery_warning = 'overdue'
|
||||
else:
|
||||
logging.info("-----1111111----")
|
||||
logging.info(f"name: {item.name}")
|
||||
logging.info(
|
||||
f"production_not_done: {len(production_not_done)}, production_done_count: {production_done_count}")
|
||||
continue
|
||||
# 获取业务节点
|
||||
business_node_ids = {
|
||||
'warning': self.env.ref('sf_message.bussiness_sale_order_overdue_warning').id,
|
||||
'overdue': self.env.ref('sf_message.bussiness_sale_order_overdue').id
|
||||
}
|
||||
overdue_orders = self.sudo().search([('delivery_warning', 'in', ['warning', 'overdue'])])
|
||||
for wo in overdue_orders:
|
||||
business_node_id = business_node_ids.get(wo.delivery_warning)
|
||||
if business_node_id:
|
||||
message_template = self.env["jikimo.message.template"].search([
|
||||
("model", "=", self._name),
|
||||
("bussiness_node_id", "=", business_node_id)
|
||||
], limit=1)
|
||||
sale_order_has = self.env['jikimo.message.queue'].search([
|
||||
('res_id', '=', wo.id),
|
||||
('message_status', '=', 'pending'),
|
||||
('message_template_id', '=', message_template.id)
|
||||
])
|
||||
if not sale_order_has:
|
||||
message_name = '销售订单逾期预警' if wo.delivery_warning == 'warning' else '销售订单已逾期'
|
||||
wo.add_queue(message_name)
|
||||
# # 销售订单逾期预警
|
||||
# def _overdue_warning_func(self):
|
||||
# sale_order_
|
||||
# return 1
|
||||
#
|
||||
# # 销售订单已逾期
|
||||
# def _overdue_func(self):
|
||||
# return 1
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import logging
|
||||
import re
|
||||
from odoo import models, fields, api, _
|
||||
from urllib.parse import urlencode
|
||||
@@ -24,29 +23,6 @@ class SFMessageStockPicking(models.Model):
|
||||
if record.state == 'assigned' and record.check_in == 'PC':
|
||||
record.add_queue('坯料发料提醒')
|
||||
|
||||
if record.picking_type_id.sequence_code == 'SFP' and record.state == 'done':
|
||||
stock_picking_sfp = record.env['stock.picking'].search(
|
||||
[('origin', '=', record.origin), ('state', '!=', 'done'),
|
||||
('picking_type_id.sequence_code', '=', 'SFP')])
|
||||
if not stock_picking_sfp:
|
||||
stock_picking_send = self.env["jikimo.message.queue"].search([('res_id', '=', record.id)])
|
||||
if not stock_picking_send:
|
||||
record.add_queue('订单发货提醒')
|
||||
|
||||
def deal_stock_picking_sfp(self, message_queue_id): # 处理订单发货提醒
|
||||
content = None
|
||||
stock_picking = self.env['stock.picking'].search([('id', '=', int(message_queue_id.res_id))])
|
||||
stock_picking_out = self.env['stock.picking'].search(
|
||||
[('origin', '=', stock_picking.origin), ('state', '=', 'assigned'),
|
||||
('picking_type_id.sequence_code', '=', 'OUT')])
|
||||
if stock_picking_out and len(stock_picking_out) > 0:
|
||||
content = message_queue_id.message_template_id.content
|
||||
url = self.request_url1(stock_picking_out.id)
|
||||
content = content.replace('{{name}}', stock_picking_out.name).replace(
|
||||
'{{sale_order_name}}', stock_picking_out.origin).replace('{{request_url}}', url)
|
||||
logging.info('订单发货提醒: %s' % content)
|
||||
return content
|
||||
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
product_id = []
|
||||
@@ -70,21 +46,10 @@ class SFMessageStockPicking(models.Model):
|
||||
'{{number}}', str(i)).replace('{{request_url}}', url)
|
||||
product_id.append(mrp_production_info.product_id.id)
|
||||
contents.append(content)
|
||||
elif message_queue_id.message_template_id.name == '订单发货提醒':
|
||||
content = self.deal_stock_picking_sfp(message_queue_id)
|
||||
if content:
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
def get_special_url(self, id, tmplate_name, special_name, model_id):
|
||||
menu_id = 0
|
||||
action_id = 0
|
||||
if tmplate_name == '调拨入库' and special_name == 'transfer_inventory_special_url':
|
||||
menu_id = self.env.ref('stock.menu_stock_root').id
|
||||
action_id = self.env.ref('stock.action_picking_tree_ready').id
|
||||
return super(SFMessageStockPicking, self).get_url(id, menu_id, action_id, model_id)
|
||||
else:
|
||||
return super(SFMessageStockPicking, self).get_special_url(id, tmplate_name, special_name, model_id)
|
||||
return contents
|
||||
else:
|
||||
res = super(SFMessageStockPicking, self)._get_message(message_queue_id)
|
||||
return res
|
||||
|
||||
def request_url(self):
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
@@ -98,16 +63,3 @@ class SFMessageStockPicking(models.Model):
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
def request_url1(self, id):
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
action_id = self.env.ref('stock.action_picking_tree_all').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_theme_treehouse')]).id
|
||||
# 查询参数
|
||||
params = {'id': id, 'menu_id': menu_id, 'action': action_id, 'model': 'stock.picking',
|
||||
'view_type': 'form'}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
@@ -14,6 +14,4 @@ class SfMessageTemplate(models.Model):
|
||||
res.append('sf.functional.tool.dismantle')
|
||||
res.append('purchase.order')
|
||||
res.append('mrp.workorder')
|
||||
res.append('sf.maintenance.logs')
|
||||
res.append('quality.cnc.test')
|
||||
return res
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import models, fields, api, _
|
||||
import logging, json
|
||||
import requests
|
||||
@@ -7,12 +6,11 @@ from urllib.parse import urlencode
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SFMessageWork(models.Model):
|
||||
_name = 'mrp.workorder'
|
||||
_inherit = ['mrp.workorder', 'jikimo.message.dispatch']
|
||||
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids.state', 'production_id.tool_state')
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids.state')
|
||||
def _compute_state(self):
|
||||
super(SFMessageWork, self)._compute_state()
|
||||
for workorder in self:
|
||||
@@ -25,17 +23,6 @@ class SFMessageWork(models.Model):
|
||||
def _get_message(self, message_queue_ids):
|
||||
contents = []
|
||||
product_id = []
|
||||
bussiness_node = None
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
current_time_strf = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_strf)
|
||||
current_time_datetime = datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S')
|
||||
time_range = timedelta(minutes=2)
|
||||
template_names = {
|
||||
'预警': ['装夹预调工单逾期预警', 'CNC加工工单逾期预警', '解除装夹工单逾期预警', '表面工艺工单逾期预警'],
|
||||
'已逾期': ['装夹预调工单已逾期', 'CNC加工工单已逾期', '解除装夹工单已逾期', '表面工艺工单已逾期']
|
||||
}
|
||||
i = 0
|
||||
for message_queue_id in message_queue_ids:
|
||||
if message_queue_id.message_template_id.name == '工单已下发通知':
|
||||
content = message_queue_id.message_template_id.content
|
||||
@@ -50,111 +37,18 @@ class SFMessageWork(models.Model):
|
||||
'{{request_url}}', url)
|
||||
product_id.append(mrp_workorder_line.product_id.id)
|
||||
contents.append(content)
|
||||
elif message_queue_id.message_template_id.name in template_names['预警'] + template_names['已逾期']:
|
||||
item = message_queue_id.message_template_id
|
||||
bussiness_node = item.bussiness_node_id.name
|
||||
for reminder_time in item.reminder_time_ids:
|
||||
content = item.content
|
||||
target_time = datetime.combine(current_time_datetime.date(), datetime.min.time()).replace(
|
||||
hour=reminder_time.time_point,
|
||||
minute=0,
|
||||
second=0,
|
||||
microsecond=0
|
||||
)
|
||||
logging.info(current_time)
|
||||
logging.info(target_time)
|
||||
logging.info(target_time - time_range)
|
||||
logging.info(target_time + time_range)
|
||||
if target_time - time_range <= current_time_datetime <= target_time + time_range:
|
||||
search_condition = [
|
||||
('delivery_warning', '=', 'warning')] if bussiness_node in template_names['预警'] else [
|
||||
('delivery_warning', '=', 'overdue')]
|
||||
record = self.sudo().search(search_condition + [('id', '=', int(item.res_id))])
|
||||
if record:
|
||||
i += 1
|
||||
if i >= 1:
|
||||
action_id = self.env.ref('sf_message.mrp_workorder_action_notify').id
|
||||
url_with_id = f"{url}/web#view_type=list&action={action_id}"
|
||||
content_template = content.replace('{{url}}', url_with_id)
|
||||
if bussiness_node in template_names['预警']:
|
||||
content = content_template.replace('{{warning_num}}', str(i))
|
||||
elif bussiness_node in template_names['已逾期']:
|
||||
content = content_template.replace('{{overdue_num}}', str(i))
|
||||
contents.append(content)
|
||||
return contents
|
||||
|
||||
def request_url(self):
|
||||
url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
action_id = self.env.ref('sf_message.mrp_workorder_issued_action').id
|
||||
action_id = self.env.ref('sf_manufacturing.mrp_workorder_action_tablet').id
|
||||
menu_id = self.env['ir.model.data'].search([('name', '=', 'module_stock_dropshipping')]).id
|
||||
active_id = self.env['mrp.workcenter'].search([('name', '=', '工件装夹中心')]).id
|
||||
# 查询参数
|
||||
params = {'menu_id': menu_id, 'action': action_id, 'model': 'mrp.workorder',
|
||||
'view_type': 'list', 'active_id': active_id}
|
||||
'view_type': 'list', 'active_id': 1}
|
||||
# 拼接查询参数
|
||||
query_string = urlencode(params)
|
||||
# 拼接URL
|
||||
full_url = url + "/web#" + query_string
|
||||
return full_url
|
||||
|
||||
def _overdue_or_warning_func(self):
|
||||
workorders = self.env['mrp.workorder'].search([("state", "in", ["ready", "progress", "to be detected"])])
|
||||
grouped_workorders = {}
|
||||
for workorder in workorders:
|
||||
routing_type = workorder.routing_type
|
||||
if routing_type not in grouped_workorders:
|
||||
grouped_workorders[routing_type] = []
|
||||
grouped_workorders[routing_type].append(workorder)
|
||||
for routing_type, orders in grouped_workorders.items():
|
||||
print(f"Routing Type: {routing_type}, Orders: {len(orders)}")
|
||||
for item in orders:
|
||||
if item.date_planned_finished:
|
||||
current_time_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
current_time = self.env['sf.sync.common'].sudo().get_add_time(current_time_str)
|
||||
current_time_datetime = datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S')
|
||||
date_planned_finished_str = self.env['sf.sync.common'].sudo().get_add_time(
|
||||
item.date_planned_finished.strftime("%Y-%m-%d %H:%M:%S"))
|
||||
date_planned_finished = datetime.strptime(date_planned_finished_str, '%Y-%m-%d %H:%M:%S')
|
||||
twelve_hours_ago = current_time_datetime - timedelta(hours=12)
|
||||
if current_time_datetime >= date_planned_finished and item.delivery_warning not in ['overdue']:
|
||||
logging.info("------overdue-------")
|
||||
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
||||
f"Planned Finish: {date_planned_finished}")
|
||||
item.delivery_warning = 'overdue'
|
||||
elif twelve_hours_ago <= current_time_datetime <= date_planned_finished and item.delivery_warning not in [
|
||||
'warning']:
|
||||
logging.info("------warning-------")
|
||||
logging.info(f"Workorder: {item.production_id.name}, Current Time: {current_time_datetime}, "
|
||||
f"Planned Finish: {date_planned_finished}")
|
||||
item.delivery_warning = 'warning'
|
||||
business_node_ids = {
|
||||
'装夹预调': self.env.ref('sf_message.bussiness_mrp_workorder_pre_overdue_warning').id,
|
||||
'CNC加工': self.env.ref('sf_message.bussiness_mrp_workorder_cnc_overdue_warning').id,
|
||||
'解除装夹': self.env.ref('sf_message.bussiness_mrp_workorder_unclamp_overdue_warning').id,
|
||||
'表面工艺': self.env.ref('sf_message.bussiness_mrp_workorder_surface_overdue_warning').id,
|
||||
}
|
||||
message_templates = {key: self.env["jikimo.message.template"].sudo().search([
|
||||
("model", "=", self._name),
|
||||
("bussiness_node_id", "=", business_node_ids[key])
|
||||
]) for key in business_node_ids}
|
||||
for item in orders:
|
||||
if item.delivery_warning in ['overdue', 'warning']:
|
||||
bussiness_node_id = business_node_ids.get(item.routing_type)
|
||||
if bussiness_node_id and message_templates[item.routing_type]:
|
||||
message_queue_ids = self.env["jikimo.message.queue"].sudo().search([
|
||||
("message_template_id", "=", message_templates[item.routing_type].id),
|
||||
("message_status", "=", "pending"),
|
||||
("res_id", "=", item.id)
|
||||
])
|
||||
if not message_queue_ids:
|
||||
overdue_message = '工单已逾期' if item.delivery_warning == 'overdue' else '工单逾期预警'
|
||||
queue_method_name = f'add_queue'
|
||||
# 构建参数列表,其中包含item.routing_type和overdue_message
|
||||
args = [f'{item.routing_type}{overdue_message}']
|
||||
# 获取add_queue方法并调用它,传入参数列表
|
||||
getattr(item, queue_method_name)(*args)
|
||||
|
||||
def _recover_time_warning_func(self):
|
||||
workorder_done = self.env['mrp.workorder'].search([("state", "in", ["done", "rework", "cancel"])])
|
||||
workorder_overdue = workorder_done.filtered(lambda x: x.delivery_warning in ['overdue', 'warning'])
|
||||
workorder_overdue.write({'delivery_warning': 'normal'})
|
||||
|
||||
@@ -1,28 +1,22 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
|
||||
access_jikimo_message_template_group_sale_salemanager,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sale_salemanager,1,1,1,0
|
||||
access_jikimo_message_template_group_purchase,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_purchase,1,1,1,0
|
||||
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
||||
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,jikimo_message_notify.model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_jikimo_message_template_group_sale_salemanager,jikimo_message_template,model_jikimo_message_template,sf_base.group_sale_salemanager,1,1,1,0
|
||||
access_jikimo_message_template_group_purchase,jikimo_message_template,model_jikimo_message_template,sf_base.group_purchase,1,1,1,0
|
||||
access_jikimo_message_template_group_sf_stock_user,jikimo_message_template,model_jikimo_message_template,sf_base.group_sf_stock_user,1,1,1,0
|
||||
access_jikimo_message_template_group_sf_order_user,jikimo_message_template,model_jikimo_message_template,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_jikimo_message_template_group_sf_tool_user,jikimo_message_template,model_jikimo_message_template,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,jikimo_message_notify.model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_sale_salemanager,jikimo_message_bussiness_node,model_jikimo_message_bussiness_node,sf_base.group_sale_salemanager,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_purchase,jikimo_message_bussiness_node,model_jikimo_message_bussiness_node,sf_base.group_purchase,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_sf_stock_user,jikimo_message_bussiness_node,model_jikimo_message_bussiness_node,sf_base.group_sf_stock_user,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_sf_order_user,jikimo_message_bussiness_node,model_jikimo_message_bussiness_node,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_jikimo_message_bussiness_node_group_sf_tool_user,jikimo_message_bussiness_node,model_jikimo_message_bussiness_node,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
||||
access_jikimo_message_queue_group_purchase,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
||||
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
||||
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,jikimo_message_notify.model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
access_jikimo_message_reminder_time_group_sale_salemanager,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sale_salemanager,1,1,1,0
|
||||
access_jikimo_message_reminder_time_group_purchase,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_purchase,1,1,1,0
|
||||
access_jikimo_message_reminder_time_group_sf_stock_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_stock_user,1,1,1,0
|
||||
access_jikimo_message_reminder_time_group_sf_order_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_jikimo_message_reminder_time_group_sf_tool_user,jikimo_message_reminder_time,jikimo_message_notify.model_jikimo_message_reminder_time,sf_base.group_sf_tool_user,1,1,1,0
|
||||
access_jikimo_message_queue_group_sale_salemanager,jikimo_message_queue,model_jikimo_message_queue,sf_base.group_sale_salemanager,1,1,1,0
|
||||
access_jikimo_message_queue_group_purchase,jikimo_message_queue,model_jikimo_message_queue,sf_base.group_purchase,1,1,1,0
|
||||
access_jikimo_message_queue_group_sf_stock_user,jikimo_message_queue,model_jikimo_message_queue,sf_base.group_sf_stock_user,1,1,1,0
|
||||
access_jikimo_message_queue_group_sf_order_user,jikimo_message_queue,model_jikimo_message_queue,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_jikimo_message_queue_group_sf_tool_user,jikimo_message_queue,model_jikimo_message_queue,sf_base.group_sf_tool_user,1,1,1,0
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record model="ir.actions.act_window" id="mrp_workorder_action_notify">
|
||||
<field name="name">工单</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">mrp.workorder</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp.mrp_production_workorder_tree_editable_view')}) ]"/>
|
||||
<!-- (0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')})-->
|
||||
<!-- <field name="target">fullscreen</field>-->
|
||||
<field name="target">current</field>
|
||||
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
||||
active_id,'search_default_filter_order_warning':1,'search_default_filter_order_overdue':1,
|
||||
'search_default_ready': 1, 'search_default_progress': 1}
|
||||
</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_workorder">
|
||||
没有工单要做!
|
||||
</p>
|
||||
<p>
|
||||
工作订单是作为制造订单的一部分执行的操作。
|
||||
工序在物料清单中定义或直接添加到制造订单中。
|
||||
</p>
|
||||
<p>
|
||||
使用工作台工作中心控制面板直接登记车间中的操作.
|
||||
平板电脑为您的工人提供工作表,并允许他们报废产品,跟踪时间,
|
||||
发起维护请求,执行质量测试等.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="mrp_workorder_issued_action">
|
||||
<field name="name">工单</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">mrp.workorder</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_ids" eval="[(5, 0, 0),
|
||||
(0, 0, {'view_mode': 'tree', 'view_id': ref('mrp.mrp_production_workorder_tree_editable_view')}) ]"/>
|
||||
<!-- (0, 0, {'view_mode': 'kanban', 'view_id': ref('mrp.workcenter_line_kanban')})-->
|
||||
<!-- <field name="target">fullscreen</field>-->
|
||||
<field name="target">current</field>
|
||||
<field name="domain">[('state', '!=', 'cancel'),('schedule_state', '=', '已排')]</field>
|
||||
<field name="context">{'search_default_product': 1, 'search_default_workcenter_id':
|
||||
active_id,'search_default_ready': 1, 'search_default_progress': 1}
|
||||
</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_workorder">
|
||||
没有工单要做!
|
||||
</p>
|
||||
<p>
|
||||
工作订单是作为制造订单的一部分执行的操作。
|
||||
工序在物料清单中定义或直接添加到制造订单中。
|
||||
</p>
|
||||
<p>
|
||||
使用工作台工作中心控制面板直接登记车间中的操作.
|
||||
平板电脑为您的工人提供工作表,并允许他们报废产品,跟踪时间,
|
||||
发起维护请求,执行质量测试等.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- © <2016> <top hy>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
76
sf_message/views/sf_message_template_view.xml
Normal file
76
sf_message/views/sf_message_template_view.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- © <2016> <top hy>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
|
||||
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="sf_message_template_view_form" model="ir.ui.view">
|
||||
<field name="name">sf.message.template.view.form</field>
|
||||
<field name="model">message.template</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="消息模板">
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<label for="name"/>
|
||||
<h1>
|
||||
<field name="name" class="w-100" required="1"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group>
|
||||
<!-- <field name="type"/>-->
|
||||
<field name="notify_model_id"/>
|
||||
<field name="content" widget="html" class="oe-bordered-editor"
|
||||
options="{'style-inline': true, 'codeview': true, 'dynamic_placeholder': true}"/>
|
||||
<field name="description"/>
|
||||
<field name="msgtype"/>
|
||||
<field name="notification_department_id"/>
|
||||
<field name="notification_employee_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_message_template_view_tree" model="ir.ui.view">
|
||||
<field name="name">sf.message.template.view.tree</field>
|
||||
<field name="model">message.template</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="消息模板">
|
||||
<field name="name"/>
|
||||
<!-- <field name="type"/>-->
|
||||
<field name="content"/>
|
||||
<field name="msgtype"/>
|
||||
<field name="notification_department_id"/>
|
||||
<field name="notification_employee_ids" widget="many2many_tags"/>
|
||||
<field name="description"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="sf_message_template_search_view" model="ir.ui.view">
|
||||
<field name="name">sf.message.template.search.view</field>
|
||||
<field name="model">message.template</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name" string="模糊搜索"
|
||||
filter_domain="['|','|',('name','like',self),('description','like',self)]"/>
|
||||
<field name="name"/>
|
||||
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--定义单证类型视图动作-->
|
||||
<record id="sf_message_template_action" model="ir.actions.act_window">
|
||||
<field name="name">消息模板</field>
|
||||
<field name="res_model">message.template</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="sf_message_template_view_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="msg_set_menu" name="消息设置" parent="base.menu_administration" sequence="1"/>
|
||||
<menuitem id="sf_message_template_send_menu" name="消息模板" parent="msg_set_menu"
|
||||
action="sf_message_template_action" sequence="1"/>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -3,12 +3,11 @@ import logging
|
||||
import os
|
||||
import json
|
||||
import base64
|
||||
from odoo import http, fields, models
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from odoo.addons.sf_base.controllers.controllers import MultiInheritController
|
||||
|
||||
|
||||
class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
class Sf_Mrs_Connect(http.Controller):
|
||||
|
||||
@http.route('/api/cnc_processing/create', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
@@ -26,7 +25,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
ret = json.loads(ret['result'])
|
||||
logging.info('下发编程单:%s' % ret)
|
||||
domain = [('programming_no', '=', ret['programming_no'])]
|
||||
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
|
||||
if ret['manufacturing_type'] == 'scrap':
|
||||
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
|
||||
productions = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search(domain)
|
||||
@@ -82,40 +81,26 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
if files_panel:
|
||||
for file in files_panel:
|
||||
file_extension = os.path.splitext(file)[1]
|
||||
logging.info('file_extension:%s' % file_extension)
|
||||
if file_extension.lower() == '.pdf':
|
||||
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||
logging.info('panel_file_path:%s' % panel_file_path)
|
||||
logging.info('更新工作指令:%s' % cnc_workorder)
|
||||
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
logging.info('更新工作指令完成:%s' % cnc_workorder)
|
||||
pre_workorder = productions.workorder_ids.filtered(
|
||||
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
||||
'cancel'] and ap.processing_panel == panel)
|
||||
if pre_workorder:
|
||||
logging.info('更新加工图纸:%s' % pre_workorder)
|
||||
pre_workorder.write(
|
||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
logging.info('更新加工图纸完成:%s' % pre_workorder)
|
||||
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
logging.info('已更新制造订单编程状态:%s' % productions.ids)
|
||||
res.update({
|
||||
'production_ids': productions.ids
|
||||
})
|
||||
|
||||
# 对制造订单所以面的cnc工单的程序用刀进行校验
|
||||
try:
|
||||
logging.info(f'已更新制造订单:{productions}')
|
||||
productions.production_cnc_tool_checkout()
|
||||
except Exception as e:
|
||||
logging.info(f'对cnc工单的程序用刀进行校验报错:{e}')
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
return json.JSONEncoder().encode(res)
|
||||
else:
|
||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
except Exception as e:
|
||||
res = {'status': -1, 'message': '系统解析失败'}
|
||||
request.cr.rollback()
|
||||
logging.info('get_cnc_processing_create error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@@ -84,8 +84,6 @@ class ResConfigSettings(models.TransientModel):
|
||||
_logger.info("同步刀具物料切削速度完成")
|
||||
self.env['sf.feed.per.tooth'].sync_all_feed_per_tooth()
|
||||
_logger.info("同步刀具物料每齿走刀量完成")
|
||||
self.env['sf.machining.accuracy'].sync_machining_accuracy_all()
|
||||
_logger.info("同步加工精度完成")
|
||||
|
||||
except Exception as e:
|
||||
_logger.info("sf_all_sync error: %s" % e)
|
||||
|
||||
@@ -74,8 +74,6 @@ class MrStaticResourceDataSync(models.Model):
|
||||
_logger.info("同步刀具物料切削速度完成")
|
||||
self.env['sf.feed.per.tooth'].sync_feed_per_tooth_yesterday()
|
||||
_logger.info("同步刀具物料每齿走刀量完成")
|
||||
self.env['sf.machining.accuracy'].sync_machining_accuracy_all()
|
||||
_logger.info("同步加工精度完成")
|
||||
except Exception as e:
|
||||
traceback_error = traceback.format_exc()
|
||||
logging.error("同步静态资源库失败:%s" % traceback_error)
|
||||
@@ -3135,36 +3133,3 @@ class CuttingToolBasicParameters(models.Model):
|
||||
})
|
||||
else:
|
||||
raise ValidationError("刀具物料基本参数认证未通过")
|
||||
|
||||
|
||||
class MachiningAccuracySync(models.Model):
|
||||
_inherit = 'sf.machining.accuracy'
|
||||
_description = '加工精度'
|
||||
url = '/api/machining_accuracy/list'
|
||||
|
||||
def sync_machining_accuracy_all(self):
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
|
||||
strUrl = config['sf_url'] + self.url
|
||||
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
_logger.info('加工精度:%s' % result)
|
||||
if result['status'] == 1:
|
||||
machining_accuracy_all_list = result['machining_accuracy_all_list']
|
||||
# 获取同步的id集合
|
||||
ids = [obj['id'] for obj in machining_accuracy_all_list]
|
||||
self.env['sf.machining.accuracy'].sudo().search(
|
||||
[('sync_id', 'not in', ids)]).unlink()
|
||||
for time in machining_accuracy_all_list:
|
||||
machining_accuracy = self.env['sf.machining.accuracy'].sudo().search(
|
||||
[('sync_id', '=', time['id'])])
|
||||
if machining_accuracy:
|
||||
machining_accuracy.name = time['name']
|
||||
machining_accuracy.standard_tolerance = time['standard_tolerance']
|
||||
else:
|
||||
self.env['sf.machining.accuracy'].sudo().create({
|
||||
"sync_id": time['id'],
|
||||
"name": time['name'],
|
||||
"standard_tolerance": time['standard_tolerance'],
|
||||
})
|
||||
|
||||
@@ -75,7 +75,7 @@ class sf_production_plan(models.Model):
|
||||
if self.date_planned_start:
|
||||
self.date_planned_finished = self.date_planned_start + timedelta(hours=1)
|
||||
|
||||
# 处理计划状态非待排程,计划结束时间为空的数据处理
|
||||
#处理计划状态非待排程,计划结束时间为空的数据处理
|
||||
def deal_no_date_planned_finished(self):
|
||||
plans = self.env['sf.production.plan'].search(
|
||||
[('date_planned_finished', '=', False), ('state', 'in', ['processing', 'done', 'finished'])])
|
||||
@@ -90,7 +90,6 @@ class sf_production_plan(models.Model):
|
||||
for item in plans:
|
||||
if item.date_planned_start:
|
||||
item.order_deadline = item.date_planned_start + timedelta(days=7)
|
||||
|
||||
@api.model
|
||||
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
|
||||
|
||||
@@ -227,26 +226,29 @@ class sf_production_plan(models.Model):
|
||||
if not record.production_line_id:
|
||||
raise ValidationError("未选择生产线")
|
||||
else:
|
||||
if record.production_id.workorder_ids:
|
||||
last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
|
||||
for item in record.production_id.workorder_ids:
|
||||
if item.name == 'CNC加工':
|
||||
# 将同一个面的所有工单筛选出来
|
||||
workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
|
||||
routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', 'CNC加工')], limit=1)
|
||||
# 设置一个小的开始时间
|
||||
item.date_planned_start = datetime.now() - timedelta(days=100)
|
||||
item.date_planned_finished = last_cnc_start + timedelta(
|
||||
minutes=routing_workcenter.time_cycle)
|
||||
item.date_planned_start = last_cnc_start
|
||||
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||
item.duration_expected = routing_workcenter.time_cycle
|
||||
pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
|
||||
record.date_planned_finished = item.date_planned_finished
|
||||
# 计算下一个cnc工单的开始时间
|
||||
last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
|
||||
is_schedule = self.deal_processing_schedule(record.date_planned_start)
|
||||
if not is_schedule:
|
||||
raise ValidationError("排程失败")
|
||||
workorder_id_list = record.production_id.workorder_ids.ids
|
||||
if record.production_id:
|
||||
if record.production_id.workorder_ids:
|
||||
for item in record.production_id.workorder_ids:
|
||||
if item.name == 'CNC加工':
|
||||
item.date_planned_finished = datetime.now() + timedelta(days=100)
|
||||
item.date_planned_start = self.date_planned_start if self.date_planned_start else datetime.now()
|
||||
record.sudo().production_id.plan_start_processing_time = item.date_planned_start
|
||||
item.date_planned_finished = item.date_planned_start + timedelta(
|
||||
minutes=record.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', 'CNC加工')]).time_cycle)
|
||||
item.duration_expected = record.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', 'CNC加工')]).time_cycle
|
||||
record.calculate_plan_time_before(item, workorder_id_list)
|
||||
record.calculate_plan_time_after(item, workorder_id_list)
|
||||
record.date_planned_start, record.date_planned_finished = \
|
||||
item.date_planned_start, item.date_planned_finished
|
||||
record.state = 'done'
|
||||
record.date_planned_finished = record.date_planned_start + timedelta(
|
||||
minutes=60) if not record.date_planned_finished else record.date_planned_finished
|
||||
# record.production_id.schedule_state = '已排'
|
||||
record.sudo().production_id.schedule_state = '已排'
|
||||
record.sudo().production_id.process_state = '待装夹'
|
||||
@@ -279,66 +281,54 @@ class sf_production_plan(models.Model):
|
||||
}
|
||||
|
||||
# 处理是否可排程
|
||||
def deal_processing_schedule(self, date_planned_start,):
|
||||
count = len(self)
|
||||
workcenter_ids = self.production_line_id.mrp_workcenter_ids
|
||||
if not workcenter_ids:
|
||||
raise UserError('生产线没有配置工作中心')
|
||||
production_lines = workcenter_ids.filtered(lambda b: "自动生产线" in b.name)
|
||||
if not production_lines: # 判断是否配置了自动生产线
|
||||
raise UserError('生产线没有配置自动生产线')
|
||||
if date_planned_start < datetime.now(): # 判断计划开始时间是否小于当前时间
|
||||
raise UserError('计划开始时间不能小于当前时间')
|
||||
if all(not production_line.deal_with_workcenter_calendar(date_planned_start) for production_line in
|
||||
production_lines): # 判断计划开始时间是否在配置的工作中心的工作日历内
|
||||
raise UserError('当前计划开始时间不能预约排程,请在工作时间内排程')
|
||||
if not production_lines.deal_available_default_capacity(date_planned_start): # 判断生产线是否可排程
|
||||
raise UserError('当前计划开始时间不能预约排程,生产线今日没有可排程的资源')
|
||||
if not production_lines.deal_available_single_machine_capacity(date_planned_start, count): # 判断生产线是否可排程
|
||||
raise UserError('当前计划开始时间不能预约排程,生产线该时间段没有可排程的资源')
|
||||
def deal_processing_schedule(self, date_planned_start):
|
||||
for record in self:
|
||||
workcenter_ids = record.production_line_id.mrp_workcenter_ids
|
||||
if not workcenter_ids:
|
||||
raise UserError('生产线没有配置工作中心')
|
||||
production_lines = workcenter_ids.filtered(lambda b: "自动生产线" in b.name)
|
||||
if not production_lines: # 判断是否配置了自动生产线
|
||||
raise UserError('生产线没有配置自动生产线')
|
||||
if date_planned_start < datetime.now(): # 判断计划开始时间是否小于当前时间
|
||||
raise UserError('计划开始时间不能小于当前时间')
|
||||
if all(not production_line.deal_with_workcenter_calendar(date_planned_start) for production_line in
|
||||
production_lines): # 判断计划开始时间是否在配置的工作中心的工作日历内
|
||||
raise UserError('当前计划开始时间不能预约排程,请在工作时间内排程')
|
||||
if not production_lines.deal_available_default_capacity(date_planned_start): # 判断生产线是否可排程
|
||||
raise UserError('当前计划开始时间不能预约排程,生产线今日没有可排程的资源')
|
||||
if not production_lines.deal_available_single_machine_capacity(date_planned_start): # 判断生产线是否可排程
|
||||
raise UserError('当前计划开始时间不能预约排程,生产线该时间段没有可排程的资源')
|
||||
return True
|
||||
|
||||
def calculate_plan_time(self, item, workorder_list):
|
||||
def calculate_plan_time_before(self, item, workorder_id_list):
|
||||
"""
|
||||
根据CNC工单的时间去计算之前的其他工单的开始结束时间
|
||||
"""
|
||||
item_position = 0
|
||||
for index, workorder in enumerate(workorder_list):
|
||||
if workorder.id == item.id:
|
||||
item_position = index
|
||||
break
|
||||
routing_workcenters = self.env['mrp.routing.workcenter'].sudo().search([])
|
||||
# 记录所有前序工序时长
|
||||
previous_workorder_duration = 0
|
||||
for i in range(item_position, -1, -1):
|
||||
if i < 1:
|
||||
break
|
||||
current_workorder = workorder_list[i]
|
||||
next_workorder = workorder_list[i - 1]
|
||||
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
||||
# 设置一个小的开始时间
|
||||
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
||||
next_workorder.date_planned_finished = current_workorder.date_planned_start
|
||||
next_workorder.date_planned_start = next_workorder.date_planned_finished - timedelta(
|
||||
minutes=routing_workcenter.time_cycle)
|
||||
next_workorder.duration_expected = routing_workcenter.time_cycle
|
||||
previous_workorder_duration += routing_workcenter.time_cycle
|
||||
# 记录所有后续工序时长
|
||||
next_workorder_duration = 0
|
||||
for i in range(item_position, len(workorder_list) - 1):
|
||||
if i > len(workorder_list) - 1:
|
||||
break
|
||||
current_workorder = workorder_list[i]
|
||||
next_workorder = workorder_list[i + 1]
|
||||
routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0]
|
||||
# 设置一个小的开始时间
|
||||
next_workorder.date_planned_start = datetime.now() - timedelta(days=100)
|
||||
next_workorder.date_planned_finished = current_workorder.date_planned_finished + timedelta(
|
||||
minutes=routing_workcenter.time_cycle)
|
||||
next_workorder.date_planned_start = current_workorder.date_planned_finished
|
||||
next_workorder.duration_expected = routing_workcenter.time_cycle
|
||||
next_workorder_duration += routing_workcenter.time_cycle
|
||||
return previous_workorder_duration, next_workorder_duration
|
||||
sequence = workorder_id_list.index(item.id) - 1
|
||||
# 计算CNC加工之前工单的开始结束时间
|
||||
for i in range(1 if sequence == 0 else 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 = 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(
|
||||
[('name', '=', current_workorder_obj.name)]).time_cycle)
|
||||
work_order.date_planned_finished = old_workorder_obj.date_planned_start
|
||||
work_order.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', current_workorder_obj.name)]).time_cycle
|
||||
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])])
|
||||
if second_workorder.date_planned_start < first_workorder.date_planned_finished:
|
||||
item.date_planned_start += timedelta(minutes=60)
|
||||
item.date_planned_finished += timedelta(minutes=60)
|
||||
item.duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', 'CNC加工')]).time_cycle
|
||||
self.calculate_plan_time_before(item, workorder_id_list)
|
||||
|
||||
def calculate_plan_time_after(self, item, workorder_id_list):
|
||||
"""
|
||||
|
||||
@@ -31,24 +31,20 @@ class Action_Plan_All_Wizard(models.TransientModel):
|
||||
# 确认排程按钮
|
||||
def action_plan_all(self):
|
||||
# 使用传递过来的计划ID
|
||||
self.plan_ids.production_line_id = self.production_line_id.id
|
||||
self.plan_ids.date_planned_start = self.date_planned_start
|
||||
temp_plan_ids = self.plan_ids
|
||||
# 在这里添加您的逻辑来处理这些ID
|
||||
# 判断能否排成
|
||||
self.plan_ids.deal_processing_schedule(self.date_planned_start)
|
||||
self.plan_ids.do_production_schedule()
|
||||
# for plan in temp_plan_ids:
|
||||
# # 处理每个计划
|
||||
# # 比如更新计划状态、分配资源等
|
||||
# # 示例:plan.state = 'scheduled'
|
||||
# print('处理计划:', plan.id)
|
||||
# # 拿到计划对象
|
||||
# plan_obj = self.env['sf.production.plan'].browse(plan.id)
|
||||
# plan_obj.production_line_id = self.production_line_id.id
|
||||
# plan.date_planned_start = self.date_planned_start
|
||||
# plan_obj.do_production_schedule()
|
||||
for plan in temp_plan_ids:
|
||||
# 处理每个计划
|
||||
# 比如更新计划状态、分配资源等
|
||||
# 示例:plan.state = 'scheduled'
|
||||
print('处理计划:', plan.id)
|
||||
# 拿到计划对象
|
||||
plan_obj = self.env['sf.production.plan'].browse(plan.id)
|
||||
plan_obj.production_line_id = self.production_line_id.id
|
||||
plan.date_planned_start = self.date_planned_start
|
||||
plan_obj.do_production_schedule()
|
||||
# plan_obj.state = 'done'
|
||||
_logger.info('处理计划: %s 完成', self.plan_ids.ids)
|
||||
print('处理计划:', plan.id, '完成')
|
||||
|
||||
# # 获取当前生产线
|
||||
# production_line_id = self.production_line_id
|
||||
@@ -75,14 +71,4 @@ class Action_Plan_All_Wizard(models.TransientModel):
|
||||
# if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list):
|
||||
# raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!')
|
||||
# # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错
|
||||
# if all(production_order_plan_state == '已暂停' for production_order_plan_state in production_order_plan_state_list):
|
||||
# raise UserError('当前生产线的所有生产订单都已暂停,请勿重复排程!')
|
||||
# # 如果当前生产线的所有生产订单的排程状态都是已完成,则报错
|
||||
# if all(production_order_plan_state == '已完成' for production_order_plan_state in production_order_plan_state_list):
|
||||
# raise UserError('当前生产线的所有生产订单都已完成,请勿重复排程!')
|
||||
# # 如果当前生产线的所有生产订单的排程状态都是已取消,则报错
|
||||
# if all(production_order_plan_state == '已取消' for production_order_plan_state in production_order_plan_state_list):
|
||||
# raise UserError('当前生产线的所有生产订单都已取消,请勿重复排程!')
|
||||
# # 如果当前生产线的所有生产订单的排程状态都是已暂停,则报错
|
||||
# if all(production_order_plan_state == '已暂停' for production_order_plan_state in production_order_plan_state_list):
|
||||
# raise UserError('当前生产线的所有生产订单都已暂停,请勿重复排程!')
|
||||
# if all(production_order_plan_state == '已暂停' for production_order_plan_state in production
|
||||
|
||||
@@ -13,11 +13,10 @@
|
||||
'author': 'jikimo',
|
||||
'website': 'https://sf.cs.jikimo.com',
|
||||
# 此处依赖sf_manufacturing是因为我要重写其中的一个字段operation_id的string,故需要sf_manufacturing先安装
|
||||
'depends': ['quality_control', 'web_widget_model_viewer', 'sf_manufacturing'],
|
||||
'depends': ['quality_control'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/view.xml',
|
||||
'views/quality_cnc_test_view.xml'
|
||||
'views/view.xml'
|
||||
],
|
||||
|
||||
'assets': {
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
|
||||
from . import custom_quality
|
||||
from . import quality
|
||||
from . import quality_cnc_test
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class SfQualityCncTest(models.Model):
|
||||
_name = 'quality.cnc.test'
|
||||
_description = 'CNC加工质检'
|
||||
|
||||
name = fields.Char('单号', default=lambda self: self.env['ir.sequence'].next_by_code('quality.cnc.test'))
|
||||
workorder_id = fields.Many2one('mrp.workorder')
|
||||
production_id = fields.Many2one(related='workorder_id.production_id', string='制造订单')
|
||||
product_id = fields.Many2one(related='workorder_id.product_id', string='产品')
|
||||
model_file = fields.Binary(related='workorder_id.glb_file', string='加工模型')
|
||||
processing_panel = fields.Char(related='workorder_id.processing_panel', string='加工面')
|
||||
equipment_id = fields.Many2one(related='workorder_id.equipment_id', string='加工设备')
|
||||
production_line_id = fields.Many2one(related='workorder_id.production_line_id',
|
||||
string='生产线')
|
||||
part_number = fields.Char(related='workorder_id.part_number', string='成品零件图号')
|
||||
detection_report = fields.Binary(related='workorder_id.detection_report', readonly=True, string='检测报告')
|
||||
state = fields.Selection([
|
||||
('waiting', '待判定'),
|
||||
('done', '已完成')], string='状态', default='waiting')
|
||||
result = fields.Selection([
|
||||
('pass', '合格'),
|
||||
('fail', '不合格')], string='判定结果')
|
||||
number = fields.Integer('数量', default=1)
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果")
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
||||
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因")
|
||||
detailed_reason = fields.Text('详细原因')
|
||||
|
||||
machining_drawings = fields.Binary('2D加工图纸', related='workorder_id.machining_drawings', readonly=True)
|
||||
quality_standard = fields.Binary('质检标准', related='workorder_id.quality_standard', readonly=True)
|
||||
|
||||
def submit_pass(self):
|
||||
if self.test_results in ['返工', '报废']:
|
||||
raise UserError(_('请重新选择【判定结果】-【检测结果】'))
|
||||
self.write({'result': 'pass', 'test_results': '合格', 'state': 'done'})
|
||||
self.workorder_id.write({'test_results': self.test_results})
|
||||
self.workorder_id.button_finish()
|
||||
|
||||
def submit_fail(self):
|
||||
if not self.test_results:
|
||||
raise UserError(_('请填写【判定结果】里的信息'))
|
||||
if self.test_results == '合格':
|
||||
raise UserError(_('请重新选择【判定结果】-【检测结果】'))
|
||||
self.write({'result': 'fail', 'test_results': self.test_results, 'state': 'done'})
|
||||
self.workorder_id.write(
|
||||
{'test_results': self.test_results, 'reason': self.reason, 'detailed_reason': self.detailed_reason})
|
||||
self.workorder_id.button_finish()
|
||||
|
||||
@api.onchange('test_results')
|
||||
def _onchange_test_results(self):
|
||||
if self.test_results == '合格':
|
||||
self.reason = False
|
||||
self.detailed_reason = False
|
||||
|
||||
|
||||
class SfQualityWorkOrder(models.Model):
|
||||
_inherit = 'mrp.workorder'
|
||||
|
||||
def button_finish(self):
|
||||
super(SfQualityWorkOrder, self).button_finish()
|
||||
if self.routing_type == 'CNC加工':
|
||||
quality_cnc_test = self.env['quality.cnc.test'].search([('workorder_id', '=', self.id)])
|
||||
if quality_cnc_test:
|
||||
quality_cnc_test.write({'result': 'fail' if self.test_results in ['返工', '报废'] else 'pass',
|
||||
'test_results': self.test_results, 'state': 'done',
|
||||
'reason': self.reason,
|
||||
'detailed_reason': self.detailed_reason,
|
||||
'detection_report': self.detection_report})
|
||||
|
||||
def write(self, vals):
|
||||
res = super(SfQualityWorkOrder, self).write(vals)
|
||||
for item in self:
|
||||
if item.state == 'to be detected':
|
||||
quality_cnc_test = self.env['quality.cnc.test'].search([('workorder_id', '=', item.id)])
|
||||
if not quality_cnc_test:
|
||||
self.env['quality.cnc.test'].sudo().create({'workorder_id': item.id})
|
||||
return res
|
||||
@@ -67,11 +67,5 @@ access_quality_alert_stage,quality.alert.stage,quality.model_quality_alert_stage
|
||||
access_stock_move_group_quality,stock_move_group_quality,stock.model_stock_move,sf_base.group_quality,1,1,0,0
|
||||
access_stock_move_group_quality_director,stock_move_group_quality_director,stock.model_stock_move,sf_base.group_quality_director,1,1,0,0
|
||||
|
||||
access_quality_cnc_test_group_quality,quality_cnc_test_group_quality,model_quality_cnc_test,sf_base.group_quality,1,1,0,0
|
||||
access_quality_cnc_test_group_quality_director,quality_cnc_test_group_quality_director,model_quality_cnc_test,sf_base.group_quality_director,1,1,0,0
|
||||
|
||||
access_quality_cnc_test_group_sf_equipment_user,quality_cnc_test_group_sf_equipment_user,model_quality_cnc_test,sf_base.group_sf_equipment_user,1,1,0,0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user