Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/产品的权限优化

# Conflicts:
#	sf_dlm_management/views/product_template_management_view.xml
#	sf_sale/models/quick_easy_order.py
#	sf_sale/models/sale_order.py
#	sf_sale/views/purchase_order_view.xml
This commit is contained in:
jinling.yang
2024-02-22 09:35:18 +08:00
194 changed files with 9912 additions and 3459 deletions

View File

@@ -1 +1,3 @@
from . import models
from . import controllers
from . import wizard

View File

@@ -15,7 +15,9 @@
'data/stock_data.xml',
'security/group_security.xml',
'security/ir.model.access.csv',
'wizard/workpiece_delivery_views.xml',
'views/mrp_views_menus.xml',
'views/stock_lot_views.xml',
'views/mrp_production_addional_change.xml',
'views/mrp_routing_workcenter_view.xml',
'views/production_line_view.xml',

View File

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

View File

@@ -0,0 +1,217 @@
# -*- coding: utf-8 -*-
import logging
import json
from odoo import http
from odoo.http import request
class Manufacturing_Connect(http.Controller):
@http.route('/AutoDeviceApi/GetWoInfo', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def get_Work_Info(self, **kw):
"""
自动化传递工单号获取工单信息
:param kw:
:return:
"""
logging.info('get_Work_Info:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('RfidCode:%s' % ret['RfidCode'])
workorder = request.env['mrp.workorder'].sudo().search(
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', '装夹预调')])
if workorder:
for item in workorder:
res['Datas'].append({
'BillId': item.production_id.name,
'ProductionLine': item.production_line,
'CraftName': item.name,
'Quantity': 1,
'MaterialId': item.product_id.default_code,
'MaterialName': item.product_id.name,
'Spec': '%s×%s×%s' % (item.move_raw_ids.materiel_length, item.move_raw_ids.materiel_width,
item.move_raw_ids.materiel_height),
'Material': item.product_id.materials_type_id.name
})
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_Work_Info error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/GetShiftPlan', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def get_ShiftPlan(self, **kw):
"""
自动化每天获取机台日计划
:param kw:
:return:
"""
logging.info('get_ShiftPlan:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
ret = json.loads(ret['result'])
logging.info('RfidCode:%s' % ret)
workorder = request.env['mrp.workorder'].sudo().search([('name', '=', ret['ProductionLine'])])
if workorder:
for item in workorder:
date_planned_start = ''
date_planned_finished = ''
if item.date_planned_start is not False:
planned_start = item.date_planned_start.strftime("%Y-%m-%d %H:%M:%S")
date_planned_start = request.env['sf.sync.common'].sudo().get_add_time(planned_start)
if item.date_planned_finished is not False:
planned_finished = item.date_planned_finished.strftime("%Y-%m-%d %H:%M:%S")
date_planned_finished = request.env['sf.sync.common'].sudo().get_add_time(planned_finished)
res['Datas'].append({
'BillId': item.production_id.name,
'RfidCode': item.RfidCode,
'CraftName': item.name,
'Quantity': 1,
'WortkStart': date_planned_start,
'WorkEnd': date_planned_finished,
'MaterialId': item.product_id.default_code,
'MaterialName': item.product_id.name,
# 'Spec':item.mat,
'Material': item.materials_type_id.name
})
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_ShiftPlan error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def get_qcCheck(self, **kw):
"""
工件预调(前置三元检测)
1、前置三元检测在产线外三元检测设备把测量信息上传给MES
MES生成检测定位数据。中控系统传递RFID编号给MES获取测量偏置结果。来源为三元检测工单上的字段
:param kw:
:return:
"""
logging.info('get_qcCheck:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
ret = json.loads(ret['result'])
logging.info('RfidCode:%s' % ret)
workorder = request.env['mrp.workorder'].sudo().search([('routing_type', '=', '前置三元定位检测')])
if workorder:
for item in workorder:
res['Datas'].append({
'XOffset': item.production_id.name,
'YOffset': item.RfidCode,
'ZOffet': item.name,
'COffset': 1
})
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_qcCheck error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/FeedBackStart', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def button_Work_START(self, **kw):
"""
工单任务开始
:param kw:
:return:
"""
logging.info('button_Work_START:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
workorder.button_start()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('button_Work_START error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/FeedBackEnd', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def button_Work_End(self, **kw):
"""
工单任务结束
:param kw:
:return:
"""
logging.info('button_Work_End:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
workorder.button_finish()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('button_Work_End error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def Workorder_QcCheck(self, **kw):
"""
零件质检
:param kw:
:return:
"""
logging.info('Workorder_QcCheck:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
if not ret['Quality']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传检测结果'}
return json.JSONEncoder().encode(res)
if not ret['ReportPaht']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传检查报告文件(地址)'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('Workorder_QcCheck error:%s' % e)
return json.JSONEncoder().encode(res)

View File

@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="sequence_routing_workcenter" model="ir.sequence">
<field name="name">工序编码规则</field>
<field name="code">mrp.routing.workcenter</field>
<field name="padding">4</field>
<field name="company_id" eval="False"/>
</record>
<record id="sequence_stock_picking_out" model="ir.sequence">
<field name="name">YourCompany Sequence ocout</field>
<field name="prefix">WH/OCOUT/</field>

View File

@@ -1,6 +1,12 @@
# -*- coding: utf-8 -*-
import base64
import logging
import re
import requests
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.addons.sf_base.commons.common import Common
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
class MrpProduction(models.Model):
@@ -12,11 +18,80 @@ class MrpProduction(models.Model):
maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests")
request_ids = fields.One2many('maintenance.request', 'production_id')
model_file = fields.Binary('模型文件', related='product_id.model_file')
schedule_state = fields.Selection([('未排', '未排'), ('已排', '已排')],
schedule_state = fields.Selection([('未排', '未排'), ('已排', '已排'), ('已完成', '已完成')],
string='排程状态', default='未排')
# state = fields.Selection(selection_add=[
# ('pending_scheduling', '待排程'),
# ('pending_processing', '待加工'),
# ('completed', '已完工')
# ])
state = fields.Selection([
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('progress', '待排程'),
('pending_processing', '待加工'),
('completed', '已完工'),
('to_close', 'To Close'),
('done', 'Done'),
('cancel', 'Cancelled')], string='State',
compute='_compute_state', copy=False, index=True, readonly=True,
store=True, tracking=True,
help=" * Draft: The MO is not confirmed yet.\n"
" * Confirmed: The MO is confirmed, the stock rules and the reordering of the components are trigerred.\n"
" * In Progress: The production has started (on the MO or on the WO).\n"
" * To Close: The production is done, the MO has to be closed.\n"
" * Done: The MO is closed, the stock moves are posted. \n"
" * Cancelled: The MO has been cancelled, can't be confirmed anymore.")
check_status = fields.Boolean(string='启用状态', default=False, readonly=True)
active = fields.Boolean(string='已归档', default=True)
programming_no = fields.Char('编程单号')
work_state = fields.Char('业务状态')
programming_state = fields.Char('编程状态')
glb_file = fields.Binary("glb模型文件")
production_line_id = fields.Many2one('sf.production.line', string='生产线')
plan_start_processing_time = fields.Datetime('计划开始加工时间')
@api.depends(
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
def _compute_state(self):
for production in self:
if not production.state or not production.product_uom_id:
production.state = 'draft'
elif production.state == 'cancel' or (production.move_finished_ids and all(
move.state == 'cancel' for move in production.move_finished_ids)):
production.state = 'cancel'
elif (
production.state == 'done'
or (production.move_raw_ids and all(
move.state in ('cancel', 'done') for move in production.move_raw_ids))
and all(move.state in ('cancel', 'done') for move in production.move_finished_ids)
):
production.state = 'done'
elif production.workorder_ids and all(
wo_state in ('done', 'cancel') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'to_close'
elif not production.workorder_ids and float_compare(production.qty_producing, production.product_qty,
precision_rounding=production.product_uom_id.rounding) >= 0:
production.state = 'to_close'
elif any(wo_state in ('progress', 'done') for wo_state in production.workorder_ids.mapped('state')):
production.state = 'progress'
elif production.product_uom_id and not float_is_zero(production.qty_producing,
precision_rounding=production.product_uom_id.rounding):
production.state = 'progress'
elif any(not float_is_zero(move.quantity_done,
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
for move in production.move_raw_ids):
production.state = 'progress'
# 新添加的状态逻辑
if production.state == 'progress' and production.schedule_state == '已排':
production.state = 'pending_processing'
elif production.state == 'progress' and production.schedule_state == '已完成':
production.state = 'completed'
def action_check(self):
"""
@@ -47,6 +122,47 @@ class MrpProduction(models.Model):
for production in self:
production.maintenance_count = len(production.request_ids)
# cnc程序获取
def fetchCNC(self):
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
try:
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
'production_no': cnc.name,
'machine_tool_code': "",
'material_code': self.env['sf.production.materials'].search(
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
'material_type_code': self.env['sf.materials.model'].search(
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
'machining_processing_panel': cnc.product_id.model_processing_panel,
'machining_precision': cnc.product_id.model_machining_precision,
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
'order_no': cnc.origin,
'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0],
'user': cnc.env.user.name,
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
cnc.product_id.model_file).decode('utf-8')
}
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'])
url = '/api/intelligent_programming/create'
config_url = configsettings['sf_url'] + url
res['token'] = configsettings['token']
# res_str = json.dumps(res)
ret = requests.post(config_url, json={}, data=res, headers=config_header)
ret = ret.json()
logging.info('fetchCNC-ret:%s' % ret)
if ret['status'] == 1:
self.write(
{'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
else:
raise UserError(ret['message'])
except Exception as e:
logging.info('fetchCNC error:%s' % e)
raise UserError("cnc程序获取编程单失败,请联系管理员")
# 维修模块按钮
def button_maintenance_req(self):
self.ensure_one()
@@ -134,6 +250,7 @@ class MrpProduction(models.Model):
'state': 'pending',
}]
if production.product_id.categ_id.type == '成品':
production.fetchCNC()
# 根据加工面板的面数及对应的工序模板生成工单
i = 0
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
@@ -144,9 +261,6 @@ class MrpProduction(models.Model):
)
i += 1
for route in product_routing_workcenter:
if i == 1 and route.routing_type == '获取CNC加工程序':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route))
if route.is_repeat is True:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str(k, production, route))
@@ -339,10 +453,10 @@ class MrpProduction(models.Model):
for route in routingworkcenter:
if route.routing_type == '后置三元质量检测':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str1(k, production, route)
)
# if route.routing_type == '后置三元质量检测':
# workorders_values.append(
# self.env['mrp.workorder'].json_workorder_str1(k, production, route)
# )
if route.routing_type == 'CNC加工':
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
@@ -364,12 +478,104 @@ class MrpProduction(models.Model):
for work in rec.workorder_ids:
work.sequence = current_sequence
current_sequence += 1
if work.name == '获取CNC加工程序':
work.button_start()
work.fetchCNC()
# if work.name == '获取CNC加工程序':
# work.button_start()
# #work.fetchCNC()
# work.button_finish()
# 创建工单并进行排序
def _create_workorder(self):
self._create_workorder3()
self._reset_work_order_sequence()
return True
# 修改标记已完成方法
def button_mark_done1(self):
self._button_mark_done_sanity_checks()
if not self.env.context.get('button_mark_done_production_ids'):
self = self.with_context(button_mark_done_production_ids=self.ids)
res = self._pre_button_mark_done()
if res is not True:
return res
if self.env.context.get('mo_ids_to_backorder'):
productions_to_backorder = self.browse(self.env.context['mo_ids_to_backorder'])
productions_not_to_backorder = self - productions_to_backorder
else:
productions_not_to_backorder = self
productions_to_backorder = self.env['mrp.production']
backorders = productions_to_backorder and productions_to_backorder._split_productions()
backorders = backorders - productions_to_backorder
productions_not_to_backorder._post_inventory(cancel_backorder=True)
productions_to_backorder._post_inventory(cancel_backorder=True)
# if completed products make other confirmed/partially_available moves available, assign them
done_move_finished_ids = (
productions_to_backorder.move_finished_ids | productions_not_to_backorder.move_finished_ids).filtered(
lambda m: m.state == 'done')
done_move_finished_ids._trigger_assign()
# Moves without quantity done are not posted => set them as done instead of canceling. In
# case the user edits the MO later on and sets some consumed quantity on those, we do not
# want the move lines to be canceled.
(productions_not_to_backorder.move_raw_ids | productions_not_to_backorder.move_finished_ids).filtered(
lambda x: x.state not in ('done', 'cancel')).write({
'state': 'done',
'product_uom_qty': 0.0,
})
for production in self:
production.write({
'date_finished': fields.Datetime.now(),
'product_qty': production.qty_produced,
'priority': '0',
'is_locked': True,
'state': 'done',
})
for workorder in self.workorder_ids.filtered(lambda w: w.state not in ('done', 'cancel')):
workorder.duration_expected = workorder._get_duration_expected()
if not backorders:
if self.env.context.get('from_workorder'):
return {
'type': 'ir.actions.act_window',
'res_model': 'mrp.production',
'views': [[self.env.ref('mrp.mrp_production_form_view').id, 'form']],
'res_id': self.id,
'target': 'main',
}
if self.user_has_groups(
'mrp.group_mrp_reception_report') and self.picking_type_id.auto_show_reception_report:
lines = self.move_finished_ids.filtered(lambda
m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
if lines:
if any(mo.show_allocation for mo in self):
action = self.action_view_reception_report()
return action
return True
context = self.env.context.copy()
context = {k: v for k, v in context.items() if not k.startswith('default_')}
for k, v in context.items():
if k.startswith('skip_'):
context[k] = False
action = {
'res_model': 'mrp.production',
'type': 'ir.actions.act_window',
'context': dict(context, mo_ids_to_backorder=None, button_mark_done_production_ids=None)
}
if len(backorders) == 1:
action.update({
'view_mode': 'form',
'res_id': backorders[0].id,
})
else:
action.update({
'name': _("Backorder MO"),
'domain': [('id', 'in', backorders.ids)],
'view_mode': 'tree,form',
})
return action

View File

@@ -1,16 +1,17 @@
import logging
from odoo import fields, models
from odoo import fields, models, api
from odoo.exceptions import UserError
class ResMrpRoutingWorkcenter(models.Model):
_inherit = 'mrp.routing.workcenter'
routing_type = fields.Selection([
('获取CNC加工程序', '获取CNC加工程序'),
('装夹', '装夹'),
('前置三元定位检测', '前置三元定位检测'),
# ('获取CNC加工程序', '获取CNC加工程序'),
('装夹预调', '装夹预调'),
# ('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
# ('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
('切割', '切割'),
('表面工艺', '表面工艺')
@@ -21,13 +22,17 @@ class ResMrpRoutingWorkcenter(models.Model):
bom_id = fields.Many2one('mrp.bom', required=False)
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
def generate_code(self):
return self.env['ir.sequence'].next_by_code('mrp.routing.workcenter')
code = fields.Char('编码', default=generate_code)
# 获得当前登陆者公司
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)
# 排产的时候, 根据坯料的长宽高比对一下机床的最大加工尺寸.不符合就不要分配给这个加工中心(机床).
# 工单对应的工作中心,根据工序中的工作中心去匹配,
# 如果只配置了一个工作中心,则默认采用该工作中心;

View File

@@ -22,7 +22,7 @@ class ResWorkcenter(models.Model):
equipment_status = fields.Selection(
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"),("空闲", "空闲"),("封存(报废)", "封存(报废)")],
string="设备状态", related='equipment_id.state')
# @api.depends('equipment_id')

View File

@@ -31,11 +31,11 @@ class ResMrpWorkOrder(models.Model):
processing_panel = fields.Char('加工面')
sequence = fields.Integer(string='工序')
routing_type = fields.Selection([
('获取CNC加工程序', '获取CNC加工程序'),
('装夹', '装夹'),
('前置三元定位检测', '前置三元定位检测'),
# ('获取CNC加工程序', '获取CNC加工程序'),
('装夹预调', '装夹预调'),
# ('前置三元定位检测', '前置三元定位检测'),
('CNC加工', 'CNC加工'),
('后置三元质量检测', '后置三元质量检测'),
# ('后置三元质量检测', '后置三元质量检测'),
('解除装夹', '解除装夹'),
('切割', '切割'), ('表面工艺', '表面工艺')
], string="工序类型")
@@ -122,22 +122,28 @@ class ResMrpWorkOrder(models.Model):
chuck_type_id = fields.Char(string="卡盘类型")
chuck_model_id = fields.Char(string="卡盘型号")
tray_serial_number = fields.Char(string="托盘序列号")
tray_name = fields.Char(string="托盘名称")
tray_product_id = fields.Many2one('product.product', string="托盘名称")
tray_brand_id = fields.Many2one('sf.machine.brand', string="托盘品牌")
tray_type_id = fields.Char(string="托盘类型")
tray_model_id = fields.Char(string="托盘型号")
tray_type_id = fields.Many2one('sf.fixture.material', string="托盘类型")
tray_model_id = fields.Many2one('sf.fixture.model', string="托盘型号")
total_wight = fields.Float(string="总重量")
maximum_carrying_weight = fields.Char(string="最大承载重量[kg]")
maximum_clamping_force = fields.Char(string="最大夹持力[n]")
production_line = fields.Char(string="生产线")
preset_program_information = fields.Char(string="预调程序信息")
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
is_delivery = fields.Boolean('是否配送完成', default=False)
rfid_code = fields.Char('RFID')
@api.onchange('is_ok')
def _onchange_inspection_user_id(self):
"""
检测is_ok(是否合格)被修改的话就将当前用户赋值给inspection_user_id
"""
self.inspection_user_id = self.env.user.id
if not self.inspection_user_id:
self.inspection_user_id = self.env.user.id
else:
self.inspection_user_id = False
@api.onchange('functional_fixture_id')
def _onchange_functional_fixture_id(self):
@@ -192,30 +198,41 @@ class ResMrpWorkOrder(models.Model):
work = workorder.production_id.workorder_ids
work.compensation_value_x = eval(self.material_center_point)[0]
work.compensation_value_y = eval(self.material_center_point)[1]
workorder.button_finish()
except:
raise UserError("参数计算有误")
def button_workpiece_delivery(self):
if self.routing_type == '装夹预调':
for item in self.workpiece_delivery_ids:
if not item.feeder_station_start:
raise UserError('【工件配送】明细中请输入起点接驳站')
# if not item.workpiece_code:
# raise UserError('请对【同运工件】进行扫描')
else:
item.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'})
# 拼接工单对象属性值
def json_workorder_str(self, k, production, route):
# 计算预计时长duration_expected
if route.routing_type == '切割':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '切割')]).time_cycle
elif route.routing_type == '获取CNC加工程序':
# elif route.routing_type == '获取CNC加工程序':
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
# [('name', '=', '获取CNC加工程序')]).time_cycle
elif route.routing_type == '装夹预调':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '获取CNC加工程序')]).time_cycle
elif route.routing_type == '工件装夹':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '工件装夹')]).time_cycle
elif route.routing_type == '前置三元定位检测':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '前置三元定位检测')]).time_cycle
[('name', '=', '装夹预调')]).time_cycle
# elif route.routing_type == '前置三元定位检测':
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
# [('name', '=', '前置三元定位检测')]).time_cycle
elif route.routing_type == 'CNC加工':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', 'CNC加工')]).time_cycle
elif route.routing_type == '后置三元质量检测':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '后置三元质量检测')]).time_cycle
# elif route.routing_type == '后置三元质量检测':
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
# [('name', '=', '后置三元质量检测')]).time_cycle
elif route.routing_type == '解除装夹':
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
[('name', '=', '解除装夹')]).time_cycle
@@ -229,7 +246,7 @@ class ResMrpWorkOrder(models.Model):
'processing_panel': k,
'quality_point_ids': route.route_workcenter_id.quality_point_ids,
'routing_type': route.routing_type,
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
'work_state': '待发起',
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
route.routing_type,
production.product_id),
@@ -237,7 +254,9 @@ class ResMrpWorkOrder(models.Model):
'date_planned_finished': False,
'duration_expected': duration_expected,
'duration': 0,
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self.env[
'sf.workpiece.delivery'].create(
{'production_id': production.id})
}]
return workorders_values_str
@@ -447,7 +466,7 @@ class ResMrpWorkOrder(models.Model):
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
'order_no': cnc.production_id.origin,
'model_order_no': cnc.product_id.default_code.rsplit('-', 1)[0],
'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0],
'user': self.env.user.name,
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
cnc.product_id.model_file).decode('utf-8')
@@ -492,7 +511,7 @@ class ResMrpWorkOrder(models.Model):
# 重写工单开始按钮方法
def button_start(self):
if self.routing_type == '装夹' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
if self.routing_type == '装夹预调' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
# 外协出库单,从“正在等待”变为“就绪”状态
if self.is_subcontract is True:
@@ -548,6 +567,9 @@ class ResMrpWorkOrder(models.Model):
raise UserError(_('请先完成上一步工单'))
def button_finish(self):
if self.routing_type == '装夹预调':
if not self.material_center_point and self.X_deviation_angle > 0:
raise UserError("请对前置三元检测定位参数进行计算定位")
if self.picking_out_id:
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
if picking_out.workorder_out_id:
@@ -571,6 +593,15 @@ class ResMrpWorkOrder(models.Model):
'order_line': order_line_ids,
})
super().button_finish()
is_production_id = True
for workorder in self.production_id.workorder_ids:
if workorder.state != 'done':
is_production_id = False
if is_production_id == True and self.name == '解除装夹':
for move_raw_id in self.production_id.move_raw_ids:
move_raw_id.quantity_done = move_raw_id.product_uom_qty
self.production_id.button_mark_done1()
# self.production_id.state = 'done'
class CNCprocessing(models.Model):
@@ -581,6 +612,7 @@ class CNCprocessing(models.Model):
cnc_id = fields.Many2one('ir.attachment')
sequence_number = fields.Char('序号')
program_name = fields.Char('程序名')
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
cutting_tool_name = fields.Char('刀具名称')
cutting_tool_no = fields.Char('刀号')
processing_type = fields.Char('加工类型')
@@ -592,6 +624,7 @@ class CNCprocessing(models.Model):
estimated_processing_time = fields.Char('预计加工时间')
remark = fields.Text('备注')
workorder_id = fields.Many2one('mrp.workorder', string="工单")
production_id = fields.Many2one('mrp.production', string="制造订单")
button_state = fields.Boolean(string='是否已经下发')
# mrs下发编程单创建CNC加工
@@ -601,6 +634,8 @@ class CNCprocessing(models.Model):
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', ret['production_order_no']),
('processing_panel', '=', obj['processing_panel']),
('routing_type', '=', 'CNC加工')])
logging.info('workorder:%s' % workorder)
logging.info('obj:%s' % obj)
cnc_processing = self.env['sf.cnc.processing'].create({
'workorder_id': workorder.id,
'sequence_number': obj['sequence_number'],
@@ -616,19 +651,19 @@ class CNCprocessing(models.Model):
'estimated_processing_time': obj['estimated_processing_time'],
'remark': obj['remark']
})
self.get_cnc_processing_file(ret['folder_name'], cnc_processing, workorder.processing_panel)
cnc_workorder.state = 'done'
cnc_processing.get_cnc_processing_file(ret['folder_name'], cnc_processing, workorder.processing_panel)
# cnc_workorder.state = 'done'
cnc_workorder.work_state = '已编程'
cnc_workorder.programming_state = '已编程'
cnc_workorder.time_ids.date_end = datetime.now()
cnc_workorder.button_finish()
# cnc_workorder.time_ids.date_end = datetime.now()
# cnc_workorder.button_finish()
# 根据程序名和加工面匹配到ftp里对应的Nc程序名
def get_cnc_processing_file(self, folder_name, cnc_processing, processing_panel):
logging.info('folder_name:%s' % folder_name)
serverdir = os.path.join('/tmp', folder_name, 'return', processing_panel)
logging.info('serverdir:%s' % serverdir)
for root, files in os.walk(serverdir):
for root, dirs, files in os.walk(serverdir):
for f in files:
logging.info('f:%s' % f)
if os.path.splitext(f)[1] == ".pdf":
@@ -663,6 +698,7 @@ class CNCprocessing(models.Model):
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
ftp_resconfig['ftp_password'])
download_state = ftp.download_file_tree(remotepath, serverdir)
logging.info('download_state:%s' % download_state)
return download_state
# 将nc文件存到attach的datas里
@@ -703,51 +739,107 @@ class SfWorkOrderBarcodes(models.Model):
_name = "mrp.workorder"
_inherit = ["mrp.workorder", "barcodes.barcode_events_mixin"]
# def on_barcode_scanned(self, barcode):
# workorder = self.env['mrp.workorder'].browse(self.ids)
# if "*" not in barcode:
# if self.routing_type == '装夹':
# tray_code = self.env['sf.tray'].search([('code', '=', barcode)])
# self.tray_code = tray_code.code
# self.tray_id = workorder.gettray_auto(barcode)
# elif self.routing_type == '前置三元定位检测':
# print('我是前置三元检测')
# logging.info('我是前置三元检测')
# elif self.routing_type == 'CNC加工':
# if barcode == 'UP-ALL':
# print("我是一键合并下发")
# logging.info('我是一键合并下发')
# self.up_merge_all()
# else:
# print('CNC加工')
# # print(barcode)
# # a = self.env['sf.tray'].search([('code', '=', barcode)])
# # print(a)
# # # workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)], limit=1)
# # workorder_obj = self.env['mrp.workorder'].search([('tray_code', '=', barcode)])
# # e = workorder_obj.id
# # print(workorder_obj)
# # action = {
# # 'name': '工单',
# # 'type': 'ir.actions.act_window',
# # # 'view_type': 'form',
# # 'view_mode': 'form',
# # 'res_model': 'mrp.workorder',
# # 'view_id': self.env.ref('mrp.mrp_production_workorder_form_view_inherit').id,
# # # 'res_id': workorder_obj.id,
# # 'res_id': 1023,
# # 'target': 'current',
# # # 'context': self.env.context,
# # # 'flags': {'initial_mode': 'edit'},
# # }
# # return action
#
# elif self.routing_type == '后置三元质量检测':
# print('后置三元检测')
# elif self.routing_type == '解除装夹':
# print("我是解除装夹")
# else:
# pass
#
# else:
# self.pro_code_ok = workorder.pro_code_is_ok(barcode)
def on_barcode_scanned(self, barcode):
workorder = self.env['mrp.workorder'].browse(self.ids)
# workorder = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)])
if workorder:
if workorder.routing_type == '装夹预调':
stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
if stock_move_line.product_id.categ_type == '夹具':
workorder.write({
'tray_serial_number': stock_move_line.lot_name,
'tray_product_id': stock_move_line.product_id.id,
'tray_brand_id': stock_move_line.product_id.brand_id.id,
'tray_type_id': stock_move_line.product_id.fixture_material_id.id,
'tray_model_id': stock_move_line.product_id.fixture_model_id.id
})
workorder.button_start()
# return {
# 'type': 'ir.actions.act_window',
# 'res_model': 'mrp.workorder',
# 'view_mode': 'form',
# 'domain': [('id', 'in', workorder.id)],
# 'target': 'current'
# }
else:
embryo_stock_lot = self.env['stock.lot'].search([('name', '=', barcode)])
if embryo_stock_lot:
embryo_stock_move_line = self.env['stock.move.line'].search(
[('product_id', '=', embryo_stock_lot.product_id.id),
('reference', '=', workorder.production_id.name),
('lot_id', '=', embryo_stock_lot.id),
('product_category_name', '=', '坯料')])
if embryo_stock_move_line:
bom_production = self.env['mrp.production'].search(
[('product_id', '=', embryo_stock_lot.product_id.id),
('origin', '=', workorder.production_id.name)], limit=1, order='id asc')
workpiece_delivery = self.env['sf.workpiece.delivery'].search(
[('workorder_id', '=', workorder.id)], limit=1, order='id asc')
if workpiece_delivery:
embryo_workpiece_code = workpiece_delivery.workpiece_code
if bom_production:
if workpiece_delivery.workpiece_code and bom_production.name not in \
workpiece_delivery.workpiece_code:
embryo_workpiece_code = workpiece_delivery.workpiece_code + ',' + \
bom_production.name
if not workpiece_delivery.workpiece_code:
embryo_workpiece_code = bom_production.name
workpiece_delivery.write({'workpiece_code': embryo_workpiece_code})
else:
raise UserError('工件生产线不一致,请重新确认')
class WorkPieceDelivery(models.Model):
_name = "sf.workpiece.delivery"
_description = '工件配送'
workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
production_id = fields.Many2one('mrp.production', string='制造订单', readonly=True)
production_line_id = fields.Many2one('sf.production.line', compute='_compute_production_line_id',
string='目的生产线', readonly=True,
store=True)
plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True)
workpiece_code = fields.Char('同运工件编码')
feeder_station_start = fields.Char('起点接驳站')
feeder_station_destination = fields.Char('目的接驳站')
task_delivery_time = fields.Datetime('任务下发时间')
task_completion_time = fields.Datetime('任务完成时间')
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
status = fields.Selection(
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
default='待下发')
# 工件配送
def button_delivery(self):
if self.status == '待下发':
return {
'name': _('确认'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'sf.workpiece.delivery.wizard',
'target': 'new',
'context': {
'default_delivery_id': self.id,
}}
else:
raise UserError('状态为【待下发】的工件记录可进行配送')
# 配送至avg小车
def _delivery_avg(self):
self.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'})
@api.depends('production_id.production_line_id')
def _compute_production_line_id(self):
if self.production_id.production_line_id:
self.production_line_id = self.production_id.production_line_id.id
self.plan_start_processing_time = self.production_id.plan_start_processing_time
@api.depends('task_delivery_time', 'task_completion_time')
def _compute_delivery_duration(self):
for obj in self:
if obj.task_delivery_time and obj.task_completion_time:
obj.delivery_duration = round(
(obj.task_completion_time - obj.task_delivery_time).total_seconds() / 60.0, 2)
else:
obj.delivery_duration = 0.0

View File

@@ -62,7 +62,6 @@ class ResProductMo(models.Model):
tool_thickness = fields.Float('厚度(mm)')
tool_weight = fields.Float('重量(kg)')
tool_hardness = fields.Integer('硬度(hrc)')
coating_material = fields.Char('涂层材质')
# 整体式刀具特有字段
cutting_tool_total_length = fields.Float('总长度(mm)', digits=(6, 1))
@@ -97,8 +96,8 @@ class ResProductMo(models.Model):
handle_type_id = fields.Many2one('maintenance.equipment.image', '柄部类型', domain=[('type', '=', '柄部类型')])
cutting_direction_ids = fields.Many2many('maintenance.equipment.image', 'rel_cutting_product_template',
'走刀方向', domain=[('type', '=', '走刀方向')])
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolant_product_template',
'适合冷却', domain=[('type', '=', '冷却')])
suitable_coolant_ids = fields.Many2many('maintenance.equipment.image', 'rel_coolants_product_template',
'适合冷却方式', domain=[('type', '=', '冷却方式')])
compaction_way_id = fields.Many2one('maintenance.equipment.image',
'压紧方式', domain=[('type', '=', '压紧方式')])
@@ -202,8 +201,6 @@ class ResProductMo(models.Model):
self.feed_per_tooth_ids = self.cutting_tool_model_id.feed_per_tooth_ids.filtered(
lambda r: int(r.blade_diameter) == int(self.specification_id.blade_diameter))
elif self.cutting_tool_type == '夹头':
self.cutting_tool_clamping_length = self.specification_id.clamping_length
self.cutting_tool_clamping_tolerance = self.specification_id.clamping_tolerance
self.cutting_tool_clamping_diameter_min = self.specification_id.min_clamping_diameter
self.cutting_tool_clamping_diameter_min = self.specification_id.max_clamping_diameter
self.cutting_tool_clamping_way = self.specification_id.clamping_mode
@@ -214,7 +211,7 @@ class ResProductMo(models.Model):
self.cutting_tool_jump_accuracy = self.specification_id.run_out_accuracy
self.cutting_tool_max_load_capacity = self.specification_id.max_load_capacity
self.cutting_tool_er_size_model = self.specification_id.er_size_model
self.cutting_tool_handle_ids = self.cutting_tool_model_id.handle_ids
self.cutting_tool_handle_id = self.cutting_tool_model_id.handle_id.id
self.cooling_suit_type_ids = self.specification_id.cooling_jacket
elif self.cutting_tool_type == '刀片':
self.cutting_tool_total_length = self.specification_id.total_length
@@ -228,14 +225,12 @@ class ResProductMo(models.Model):
self.cutting_tool_inscribed_circle_tolerance = self.specification_id.inscribed_circle_tolerance
self.cutting_tool_install_aperture_diameter = self.specification_id.install_aperture_diameter
self.cutting_tool_chip_breaker_groove = self.specification_id.chip_breaker_groove
# self.cutting_tool_cut_depth_max = self.specification_id.blade_blade_number
self.cutting_tool_chip_breaker_type_code = self.specification_id.chip_breaker_type_code
self.cutting_tool_blade_blade_number = self.specification_id.blade_blade_number
self.cutting_tool_blade_width = self.specification_id.blade_width
self.cutting_tool_rear_angle = self.specification_id.relief_angle
self.cutting_tool_main_included_angle = self.specification_id.main_included_angle
self.cutting_tool_top_angle = self.specification_id.top_angle
self.cutting_tool_blade_tip_dip_angle = self.specification_id.blade_tip_dip_angle
self.cutting_tool_side_cutting_edge_angle = self.specification_id.side_cutting_edge_angle
self.cutting_tool_pitch = self.specification_id.pitch
self.cutting_tool_bladed_teeth_model = self.specification_id.blade_teeth_model
self.cutting_tool_thickness_tolerance = self.specification_id.thickness_tolerance
@@ -257,13 +252,20 @@ class ResProductMo(models.Model):
self.cutting_tool_inscribed_circle_tolerance = self.specification_id.inscribed_circle_tolerance
self.cutting_tool_install_aperture_diameter = self.specification_id.install_aperture_diameter
self.cutting_tool_chip_breaker_groove = self.specification_id.chip_breaker_groove
# self.cutting_tool_cut_depth_max = self.specification_id.blade_blade_number
self.cutting_tool_chip_breaker_type_code = self.specification_id.chip_breaker_type_code
self.cutting_tool_blade_blade_number = self.specification_id.blade_blade_number
self.cutting_tool_blade_width = self.specification_id.blade_width
self.cutting_tool_rear_angle = self.specification_id.relief_angle
self.cutting_tool_main_included_angle = self.specification_id.main_included_angle
self.cutting_tool_top_angle = self.specification_id.top_angle
self.cutting_tool_blade_tip_dip_angle = self.specification_id.blade_tip_dip_angle
self.cutting_tool_screw = self.specification_id.screw
self.cutting_tool_wrench = self.specification_id.spanner
self.cutting_tool_blade_id = self.specification_id.blade_id.id
self.cutting_tool_is_cooling_hole = self.specification_id.is_cooling_hole
self.cutting_tool_locating_slot_code = self.specification_id.locating_slot_code
self.cutting_tool_install_blade_tip_num = self.specification_id.install_blade_tip_num
self.cutting_tool_installing_structure = self.specification_id.installing_structure
self.cutting_tool_cut_depth_max = self.specification_id.cut_depth_max
if self.cutting_tool_type == '刀盘':
self.cutting_tool_blade_length = self.specification_id.blade_length
self.cutting_tool_cutter_head_diameter = self.specification_id.cutter_head_diameter
@@ -272,17 +274,27 @@ class ResProductMo(models.Model):
self.cutting_tool_knife_head_height = self.specification_id.knife_head_height
self.cutting_tool_knife_head_width = self.specification_id.knife_head_width
self.cutting_tool_knife_head_length = self.specification_id.knife_head_length
self.cutting_tool_tool_shim = self.specification_id.tool_shim
self.cutting_tool_cotter_pin = self.specification_id.cotter_pin
self.cutting_tool_pressing_plate = self.specification_id.pressing_plate
elif self.cutting_tool_type == '刀柄':
self.cutting_tool_total_length = self.specification_id.total_length
self.cutting_tool_standard_speed = self.specification_id.standard_rotate_speed
self.cutting_tool_speed_max = self.specification_id.max_rotate_speed
self.cutting_tool_change_time = self.specification_id.tool_changing_time
self.cutting_tool_total_length = self.specification_id.total_length
self.cutting_tool_clamping_diameter_max = self.specification_id.max_clamping_diameter
self.cutting_tool_clamping_diameter_min = self.specification_id.min_clamping_diameter
self.cutting_tool_flange_length = self.specification_id.flange_shank_length
self.cutting_tool_shank_outer_diameter = self.specification_id.handle_external_diameter
self.cutting_tool_shank_inner_diameter = self.specification_id.handle_inside_diameter
self.cutting_tool_flange_diameter = self.specification_id.flange_diameter
self.cutting_tool_fit_chuck_size = self.specification_id.fit_chuck_size
self.cutting_tool_dynamic_balance_class = self.specification_id.dynamic_balance_class
self.cutting_tool_is_high_speed_cutting = self.specification_id.is_quick_cutting
self.cutting_tool_is_safety_lock = self.specification_id.is_safe_lock
self.cutting_tool_fit_nut_model = self.specification_id.nut
self.cutting_tool_wrench = self.specification_id.spanner
self.cutting_tool_chuck_id = self.specification_id.chuck_id.id
self.cutting_tool_jump_accuracy = self.specification_id.diameter_slip_accuracy
self.cutting_tool_taper_shank_model = self.specification_id.taper_shank_model
self.suitable_machining_method_ids = [(6, 0, [])] if not \
self.cutting_tool_model_id.suitable_machining_method_ids \
else [(6, 0, self.cutting_tool_model_id.suitable_machining_method_ids.ids)]
@@ -350,12 +362,12 @@ class ResProductMo(models.Model):
raise ValidationError("请选择压紧方式")
if self.cutting_tool_type == '刀片':
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却")
raise ValidationError("请选择适合冷却方式")
elif self.cutting_tool_type == '整体式刀具':
if not self.handle_type_id:
raise ValidationError("请选择柄部类型")
if not self.suitable_coolant_ids:
raise ValidationError("请选择适合冷却")
raise ValidationError("请选择适合冷却方式")
if not self.suitable_machining_method_ids:
raise ValidationError("请选择适合加工方式")
if not self.blade_tip_characteristics_id:
@@ -369,11 +381,8 @@ class ResProductMo(models.Model):
cutting_tool_rear_angle = fields.Integer('后角(°)')
cutting_tool_main_included_angle = fields.Integer('主偏角(°)')
# 适用夹头型号可以多选
cutting_tool_chuck_ids = fields.Many2many(
cutting_tool_chuck_id = fields.Many2one(
'sf.cutting_tool.standard.library',
relation='product_cutting_tool_library_handle_chuck_rel',
column1='model_id_1',
column2='model_id_2',
domain="[('cutting_tool_type', '=', '夹头')]",
string='适用夹头型号')
# 刀片参数
@@ -384,6 +393,7 @@ class ResProductMo(models.Model):
cutting_tool_install_aperture_diameter = fields.Float('安装孔直径(mm)')
cutting_tool_chip_breaker_groove = fields.Selection([('', ''), ('单面', '单面'), ('双面', '双面')],
string='有无断屑槽')
cutting_tool_chip_breaker_type_code = fields.Char('断屑槽型代号')
cutting_tool_bladed_teeth_model = fields.Selection(
[('', ''), ('V牙型', 'V牙型'), ('米制全牙型', '米制全牙型'), ('美制全牙型', '美制全牙型'),
('惠氏全牙型', '惠氏全牙型'), ('BSPT全牙型', 'BSPT全牙型'), ('NPT全牙型', 'NPT全牙型'),
@@ -395,8 +405,6 @@ class ResProductMo(models.Model):
('7', '7'), ('8', '8'), ('9', '9'), ('10', '10')],
string='刀片的刃数(个)')
cutting_tool_blade_tip_dip_angle = fields.Integer('刀尖倾角(°)')
cutting_tool_side_cutting_edge_angle = fields.Integer('侧切削角(°)')
cutting_tool_thread_model = fields.Selection([('', ''), ('外螺纹', '外螺纹'), ('内螺纹', '内螺纹')],
string='螺纹类型')
cutting_tool_thread_num = fields.Float('每英寸螺纹数(tpi)')
@@ -429,13 +437,10 @@ class ResProductMo(models.Model):
cutting_tool_blade_diameter = fields.Float('刃径/刃部直径(mm)')
cutting_tool_cutter_arbor_diameter = fields.Float('刀杆直径(mm)')
cutting_tool_min_machining_aperture = fields.Integer('最小加工孔径(mm)')
cutting_tool_install_blade_tip_num = fields.Integer('可装刀片数/齿数(个)', size=20)
cutting_tool_install_blade_tip_num = fields.Integer('可装刀片数/齿数(个)')
cutting_tool_installing_structure = fields.Char('安装结构', size=20)
cutting_tool_blade_ids = fields.Many2many(
cutting_tool_blade_id = fields.Many2one(
'sf.cutting_tool.standard.library',
relation='product_cutting_tool_library_pad_blade_rel',
column1='model_id_1',
column2='model_id_2',
domain="[('cutting_tool_type', '=', '刀片')]",
string='适用刀片型号' # 使用空列表作为默认值
)
@@ -451,24 +456,22 @@ class ResProductMo(models.Model):
cutting_tool_interface_diameter = fields.Float('接口直径(mm)')
# 刀柄参数
cutting_tool_shank_outer_diameter = fields.Float('柄部外径(mm)')
cutting_tool_shank_inner_diameter = fields.Float('柄部内径(mm)')
cutting_tool_clamping_length = fields.Float('夹持长度(mm)')
cutting_tool_clamping_tolerance = fields.Float('夹持公差(mm)')
cutting_tool_clamping_diameter_max = fields.Float('最大夹持直径')
cutting_tool_clamping_diameter_min = fields.Float('最小夹持直径')
cutting_tool_flange_length = fields.Float('法兰柄长(mm)')
cutting_tool_flange_diameter = fields.Float('法兰直径(mm)')
cutting_tool_is_rough_finish = fields.Boolean('可粗加工', default=False)
cutting_tool_is_finish = fields.Boolean('可精加工', default=False)
cutting_tool_is_drill_hole = fields.Boolean('可钻孔', default=False)
cutting_tool_is_safety_lock = fields.Boolean('有无安全锁', default=False)
cutting_tool_is_high_speed_cutting = fields.Boolean('可高速切削', default=False)
cutting_tool_change_time = fields.Integer('换刀时间(s)')
cutting_tool_clamping_way = fields.Char('夹持方式')
cutting_tool_fit_chuck_size = fields.Char('适配夹头尺寸')
cutting_tool_taper_shank_model = fields.Char('锥柄型号')
cutting_tool_standard_speed = fields.Integer('标准转速(n/min)')
cutting_tool_speed_max = fields.Integer('最大转速(n/min)')
cutting_tool_cooling_type = fields.Char('冷却类型')
cutting_tool_dynamic_balance_class = fields.Char('动平衡等级')
cutting_tool_fit_nut_model = fields.Char('适用锁紧螺母型号')
# 夹头参数
cutting_tool_taper = fields.Integer('锥度(°)')
cutting_tool_top_diameter = fields.Float('顶部直径')
@@ -476,38 +479,22 @@ class ResProductMo(models.Model):
cutting_tool_inner_diameter = fields.Float('内径(mm)')
cooling_suit_type_ids = fields.Char('适用冷却套型号')
cutting_tool_max_load_capacity = fields.Float('最大负载能力(kg)')
cutting_tool_er_size_model = fields.Char('ER尺寸型号')
cutting_tool_handle_ids = fields.Many2many(
cutting_tool_er_size_model = fields.Char('尺寸型号')
# cutting_tool_handle_ids = fields.Many2many(
# 'sf.cutting_tool.standard.library',
# relation='product_cutting_tool_library_chuck_handle_rel',
# column1='model_id_1',
# column2='model_id_2',
# domain="[('cutting_tool_type', '=', '刀柄')]",
# string='适用刀柄型号'
# )
cutting_tool_handle_id = fields.Many2one(
'sf.cutting_tool.standard.library',
relation='product_cutting_tool_library_chuck_handle_rel',
column1='model_id_1',
column2='model_id_2',
domain="[('cutting_tool_type', '=', '刀柄')]",
string='适用刀柄型号'
)
# 夹具参数
fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料")
fixture_model_id = fields.Many2one('sf.fixture.model', string="夹具型号")
fixture_material_type = fields.Char(string="夹具物料类型", related='fixture_material_id.name')
fixture_multi_mounting_type_id = fields.Many2one('sf.multi_mounting.type', string="联装类型")
fixture_clamping_way = fields.Char(string="装夹方式")
fixture_port_type = fields.Char(string="接口类型")
fixture_model_file = fields.Binary(string="3D模型图")
fixture_clamp_workpiece_length_max = fields.Integer(string="夹持工件长度max(mm)")
fixture_clamp_workpiece_width_max = fields.Integer(string="夹持工件宽度max(mm)")
fixture_clamp_workpiece_height_max = fields.Integer(string="夹持工件高度max(mm)")
fixture_clamp_workpiece_diameter_max = fields.Float(string="夹持工件直径max(mm)", digits=(16, 6))
fixture_maximum_carrying_weight = fields.Float(string="最大承载重量(kg)", digits=(16, 4))
fixture_maximum_clamping_force = fields.Integer(string="最大夹持力(n)")
fixture_driving_way = fields.Char(string="驱动方式")
fixture_apply_machine_tool_type_ids = fields.Many2many('sf.machine_tool.type', 'rel_product_machine_tool_type',
string="适用机床型号")
fixture_through_hole_size = fields.Integer(string="过孔大小(mm)")
fixture_screw_size = fields.Integer(string="螺牙大小(mm)")
# 注册状态
register_state = fields.Selection([('未注册', '未注册'), ('已注册', '已注册'), ('注册失败', '注册失败')],
string='注册状态', default='未注册')
@@ -533,48 +520,12 @@ class ResProductMo(models.Model):
if self.tool_thickness > 1000000:
raise ValidationError("厚度不能超过1000000")
@api.constrains('fixture_clamp_workpiece_length_max')
def _check_fixture_clamp_workpiece_length_max_size(self):
if self.fixture_clamp_workpiece_length_max > 1000000:
raise ValidationError("夹持工件长度MAX不能超过1000000")
@api.constrains('fixture_clamp_workpiece_width_max')
def _check_fixture_clamp_workpiece_width_max_size(self):
if self.fixture_clamp_workpiece_width_max > 1000000:
raise ValidationError("夹持工件宽度MAX不能超过1000000")
@api.constrains('fixture_clamp_workpiece_height_max')
def _check_fixture_clamp_workpiece_height_max_size(self):
if self.fixture_clamp_workpiece_height_max > 1000000:
raise ValidationError("夹持工件高度MAX不能超过1000000")
@api.constrains('fixture_maximum_clamping_force')
def _check_fixture_maximum_clamping_force_size(self):
if self.fixture_maximum_clamping_force > 100000000:
raise ValidationError("最大夹持力不能超过100000000")
@api.constrains('fixture_through_hole_size')
def _check_fixture_through_hole_size_size(self):
if self.fixture_through_hole_size > 1000000:
raise ValidationError("过孔大小不能超过1000000")
@api.constrains('fixture_screw_size')
def _check_fixture_through_hole_size_size(self):
if self.fixture_screw_size > 1000000:
raise ValidationError("螺牙大小不能超过1000000")
def _json_apply_machine_tool_type_item_code(self, item):
code_arr = []
for i in item.product_id.fixture_apply_machine_tool_type_ids:
code_arr.append(i.code)
return code_arr
def _json_chuck_item_code(self, item):
code_arr = []
for i in item.product_id.cutting_tool_chuck_ids:
code_arr.append(i.code)
return code_arr
def _json_cutter_bar_item_code(self, item):
code_arr = []
for i in item.product_id.cutting_tool_cutter_bar_ids:
@@ -587,18 +538,6 @@ class ResProductMo(models.Model):
code_arr.append(i.code)
return code_arr
def _json_blade_item_code(self, item):
code_arr = []
for i in item.product_id.cutting_tool_blade_ids:
code_arr.append(i.code)
return code_arr
def _json_handle_item_code(self, item):
code_arr = []
for i in item.product_id.cutting_tool_handle_ids:
code_arr.append(i.code)
return code_arr
def _get_ids(self, param):
type_ids = []
if not param:
@@ -614,42 +553,6 @@ class ResProductMo(models.Model):
self.detailed_type = 'product'
self.sale_ok = False
@api.onchange('fixture_material_id')
def _onchange_fixture_material_id(self):
for item in self:
if item.fixture_material_id.id != item.fixture_model_id.fixture_material_id.id:
item.fixture_model_id = False
@api.onchange('fixture_model_id')
def _onchange_fixture_model_id(self):
for item in self:
if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']:
item.brand_id = item.fixture_model_id.brand_id.id
item.fixture_multi_mounting_type_id = item.fixture_model_id.multi_mounting_type_id.id
item.fixture_model_file = item.fixture_model_id.model_file
item.tool_length = item.fixture_model_id.length
item.tool_width = item.fixture_model_id.width
item.tool_height = item.fixture_model_id.height
item.tool_weight = item.fixture_model_id.weight
item.materials_type_id = item.fixture_model_id.materials_model_id.id
item.fixture_maximum_carrying_weight = item.fixture_model_id.maximum_carrying_weight
item.fixture_maximum_clamping_force = item.fixture_model_id.maximum_clamping_force
if self.fixture_material_type in ['零点卡盘', '转接板(锁板)夹具']:
item.fixture_clamping_way = item.fixture_model_id.clamping_way
item.fixture_port_type = item.fixture_model_id.port_type
if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具']:
item.fixture_driving_way = item.fixture_model_id.driving_way
if self.fixture_material_type in ['气动夹具', '磁吸夹具', '虎钳夹具', '零点卡盘']:
item.fixture_through_hole_size = item.fixture_model_id.through_hole_size
item.fixture_screw_size = item.fixture_model_id.screw_size
if self.fixture_material_type in ['气动夹具', '转接板(锁板)夹具', '磁吸夹具', '虎钳夹具']:
item.fixture_clamp_workpiece_length_max = item.fixture_model_id.clamp_workpiece_length_max
item.fixture_clamp_workpiece_width_max = item.fixture_model_id.clamp_workpiece_width_max
item.fixture_clamp_workpiece_height_max = item.fixture_model_id.clamp_workpiece_height_max
item.fixture_clamp_workpiece_diameter_max = item.fixture_model_id.clamp_workpiece_diameter_max
item.fixture_apply_machine_tool_type_ids = self._get_ids(
item.fixture_model_id.apply_machine_tool_type_ids)
def _get_volume_uom_id_from_ir_config_parameter(self):
product_length_in_feet_param = self.env['ir.config_parameter'].sudo().get_param('product.volume_in_cubic_feet')
if product_length_in_feet_param == '1':
@@ -826,6 +729,121 @@ class ResProductMo(models.Model):
return base64_data
class ResProductFixture(models.Model):
_inherit = 'product.template'
_description = '夹具产品信息'
fixture_model_id = fields.Many2one('sf.fixture.model', '夹具型号')
specification_fixture_id = fields.Many2one('sf.fixture.materials.basic.parameters', '夹具规格')
fixture_material_id = fields.Many2one('sf.fixture.material', string="夹具物料")
fixture_material_type = fields.Char(string="夹具物料类型", related='fixture_material_id.name')
multi_mounting_type_id = fields.Many2one('sf.multi_mounting.type', string="联装类型")
model_file = fields.Binary(string="3D模型图")
# 夹具物料基本参数
diameter = fields.Float('直径(mm)', digits=(16, 2))
# '零点卡盘' 字段
weight = fields.Float('重量(mm)', digits=(16, 2))
orientation_dish_diameter = fields.Float('定位盘直径(mm)', digits=(16, 2))
clamping_diameter = fields.Float('装夹直径(mm)', digits=(16, 2))
clamping_num = fields.Selection([('1', '1'), ('2', '2'), ('4', '4'), ('6', '6'), ('8', '8')], string='装夹单元数')
chucking_power_max = fields.Float('最大夹持力(KN)', digits=(16, 2))
repeated_positioning_accuracy = fields.Char('重复定位精度(mm)', size=20)
boolean_transposing_hole = fields.Boolean('是否有转位孔')
unlocking_method = fields.Selection(
[('手动', '手动'), ('气动', '气动'), ('液压', '液压'), ('电动', '电动'), ('其他', '其他')], string='解锁方式')
boolean_chip_blowing_function = fields.Boolean('是否有吹屑功能')
carrying_capacity_max = fields.Float('最大承载重量(kg)', digits=(16, 2))
rigidity = fields.Integer('硬度HRC')
materials_model_id = fields.Many2one('sf.materials.model', '夹具材质')
machine_tool_type_id = fields.Many2one('sf.machine_tool.type', '适用机床型号')
# ’零点托盘‘ 字段
connector_diameter = fields.Selection([('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('8', '8')],
string='连接头直径(mm)')
way_to_install = fields.Selection(
[('接口式', '接口式'), ('螺栓固定', '螺栓固定'), ('磁吸式', '磁吸式'), ('其他', '其他')], string='安装方式')
type_of_drive = fields.Selection(
[('气动式', '气动式'), ('液压式', '液压式'), ('机械式', '机械式'), ('电动式', '电动式'), ('其他', '其他')],
string='驱动方式')
# ’气动夹具‘ 字段
gripper_length_min = fields.Float('夹持工件最小长度(mm)', digits=(16, 2))
gripper_width_min = fields.Float('夹持工件最小宽度(mm)', digits=(16, 2))
gripper_height_min = fields.Float('夹持工件最小高度(mm)', digits=(16, 2))
gripper_diameter_min = fields.Float('夹持工件最小直径(mm)', digits=(16, 2))
gripper_length_max = fields.Float('夹持工件最大长度(mm)', digits=(16, 2))
gripper_width_max = fields.Float('夹持工件最大宽度(mm)', digits=(16, 2))
gripper_height_max = fields.Float('夹持工件最大高度(mm)', digits=(16, 2))
gripper_diameter_max = fields.Float('夹持工件最大直径(mm)', digits=(16, 2))
rated_air_pressure = fields.Float('额定气压(Mpa)', digits=(16, 2))
interface_materials_model_id = fields.Many2one('sf.materials.model', '接口类型')
# ‘虎钳夹具' 字段
transverse_groove = fields.Float('横向配合槽n(mm)', digits=(16, 2))
longitudinal_fitting_groove = fields.Float('纵向配合槽l(mm)', digits=(16, 2))
# '磁吸夹具' 字段
height_tolerance_value = fields.Char('高度公差(mm)')
rated_adsorption_force = fields.Float('额定吸附力(N/cm²)', digits=(16, 2))
magnetic_field_height = fields.Float('磁场高度(mm)', digits=(16, 2))
magnetic_pole_plate_grinding_allowance = fields.Float('磁极板磨削余量(mm)', digits=(16, 2))
# '转接板(锁板)夹具' 字段
screw_size = fields.Float('螺牙大小(mm)', digits=(16, 2))
via_hole_diameter = fields.Float('过孔直径(mm)', digits=(16, 2))
# '三爪卡盘' 字段
mounting_hole_depth = fields.Float('安装孔深度(mm)', digits=(16, 2))
centering_diameter = fields.Float('定心直径(mm)', digits=(16, 2))
@api.onchange('specification_fixture_id')
def _onchange_specification_fixture_id(self):
if self.specification_fixture_id:
self.length = self.specification_fixture_id.length
self.width = self.specification_fixture_id.width
self.height = self.specification_fixture_id.height
self.weight = self.specification_fixture_id.weight
self.diameter = self.specification_fixture_id.diameter
self.orientation_dish_diameter = self.specification_fixture_id.orientation_dish_diameter
self.clamping_diameter = self.specification_fixture_id.clamping_diameter
self.clamping_num = self.specification_fixture_id.clamping_num
self.chucking_power_max = self.specification_fixture_id.chucking_power_max
self.repeated_positioning_accuracy = self.specification_fixture_id.repeated_positioning_accuracy
self.boolean_transposing_hole = self.specification_fixture_id.boolean_transposing_hole
self.unlocking_method = self.specification_fixture_id.unlocking_method
self.boolean_chip_blowing_function = self.specification_fixture_id.boolean_chip_blowing_function
self.carrying_capacity_max = self.specification_fixture_id.carrying_capacity_max
self.rigidity = self.specification_fixture_id.rigidity
self.materials_model_id = self.specification_fixture_id.materials_model_id
self.machine_tool_type_id = self.specification_fixture_id.machine_tool_type_id
self.connector_diameter = self.specification_fixture_id.connector_diameter
self.way_to_install = self.specification_fixture_id.way_to_install
self.type_of_drive = self.specification_fixture_id.type_of_drive
self.gripper_length_min = self.specification_fixture_id.gripper_length_min
self.gripper_width_min = self.specification_fixture_id.gripper_width_min
self.gripper_height_min = self.specification_fixture_id.gripper_height_min
self.gripper_diameter_min = self.specification_fixture_id.gripper_diameter_min
self.gripper_length_max = self.specification_fixture_id.gripper_length_max
self.gripper_width_max = self.specification_fixture_id.gripper_width_max
self.gripper_height_max = self.specification_fixture_id.gripper_height_max
self.gripper_diameter_max = self.specification_fixture_id.gripper_diameter_max
self.rated_air_pressure = self.specification_fixture_id.rated_air_pressure
self.interface_materials_model_id = self.specification_fixture_id.interface_materials_model_id
self.transverse_groove = self.specification_fixture_id.transverse_groove
self.longitudinal_fitting_groove = self.specification_fixture_id.longitudinal_fitting_groove
self.height_tolerance_value = self.specification_fixture_id.height_tolerance_value
self.rated_adsorption_force = self.specification_fixture_id.rated_adsorption_force
self.magnetic_field_height = self.specification_fixture_id.magnetic_field_height
self.magnetic_pole_plate_grinding_allowance = self.specification_fixture_id.magnetic_pole_plate_grinding_allowance
self.screw_size = self.specification_fixture_id.screw_size
self.via_hole_diameter = self.specification_fixture_id.via_hole_diameter
self.mounting_hole_depth = self.specification_fixture_id.mounting_hole_depth
self.centering_diameter = self.specification_fixture_id.centering_diameter
class SfMaintenanceEquipmentAndProductTemplate(models.Model):
_inherit = 'maintenance.equipment'
_description = '设备'
@@ -852,6 +870,11 @@ class SfMaintenanceEquipmentTool(models.Model):
_description = '机床刀位'
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
code = fields.Char('机床刀位号')
name = fields.Char('刀位号', compute='_compute_name')
# 待删除字段
product_template_id = fields.Many2one('product.template', string='功能刀具名称',
domain="[('categ_type', '=', '刀具')]")
image_1920 = fields.Binary('图片', related='product_template_id.image_1920')
@@ -864,9 +887,6 @@ class SfMaintenanceEquipmentTool(models.Model):
life_value_max = fields.Char('最大寿命值')
alarm_value = fields.Char('报警值')
used_value = fields.Char('已使用值')
code = fields.Char('机床刀位号')
name = fields.Char('', compute='_compute_name')
@api.depends('code')
def _compute_name(self):

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import base64
import qrcode
from collections import defaultdict, namedtuple
import logging
import json
@@ -12,6 +13,7 @@ from odoo.tools import float_compare
from odoo.addons.stock.models.stock_rule import ProcurementException
from odoo.addons.sf_base.commons.common import Common
from odoo.exceptions import UserError
from io import BytesIO
class StockRule(models.Model):
@@ -202,8 +204,7 @@ class StockRule(models.Model):
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
if sale_order:
sale_order.write({'schedule_status': 'to schedule'})
self.env['sf.production.plan'].sudo().with_company(company_id). \
create({
self.env['sf.production.plan'].sudo().with_company(company_id).create({
'name': production.name,
'order_deadline': sale_order.deadline_of_delivery,
'production_id': production.id,
@@ -265,6 +266,60 @@ class ProductionLot(models.Model):
return "%s-%s-%03d" % (product.cutting_tool_model_id.code, now, 1)
return "%s-%03d" % (product.name, 1)
qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code')
@api.depends('name')
def _generate_qr_code(self):
for record in self:
# Generate QR code
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(record.name)
qr.make(fit=True)
qr_image = qr.make_image(fill_color="black", back_color="white")
# Encode the image data in base64
image_stream = BytesIO()
qr_image.save(image_stream, format="PNG")
encoded_image = base64.b64encode(image_stream.getvalue())
record.qr_code_image = encoded_image
def print_qr_code(self):
self.ensure_one() # 确保这个方法只为一个记录调用
# if not self.lot_id:
# raise UserError("没有找到序列号。")
# 假设_lot_qr_code方法已经生成了二维码并保存在字段中
qr_code_data = self.qr_code_image
if not qr_code_data:
raise UserError("没有找到二维码数据。")
# 生成下载链接或直接触发下载
# 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
attachment = self.env['ir.attachment'].sudo().create({
'datas': self.qr_code_image,
'type': 'binary',
'description': '二维码图片',
'name': self.name + '.png',
# 'res_id': invoice.id,
# 'res_model': 'stock.picking',
'public': True,
'mimetype': 'application/x-png',
# 'model_name': 'stock.picking',
})
# 返回附件的下载链接
download_url = '/web/content/%s?download=true' % attachment.id
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
return {
'type': 'ir.actions.act_url',
'url': str(base_url) + download_url,
'target': 'self',
}
class StockPicking(models.Model):
_inherit = 'stock.picking'
@@ -360,7 +415,6 @@ class ReStockMove(models.Model):
materiel_height = fields.Float(string='物料高度', digits=(16, 4))
def _get_new_picking_values_Res(self, item, sorted_workorders, rescode):
logging.info('new_picking-rescode: %s' % rescode)
return {
'name': self.env['stock.picking']._get_name_Res(rescode),
'origin': item.name,
@@ -374,167 +428,21 @@ class ReStockMove(models.Model):
'state': 'confirmed',
}
# 将采购到的夹具注册到Cloud
def _register_fixture(self):
create_url = '/api/factory_fixture_material/create'
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strurl = config['sf_url'] + create_url
for item in self:
val = {
'token': config['token'],
'name': item.product_id.name,
'brand_code': self.env['sf.machine.brand'].search([('id', '=', item.product_id.brand_id.id)]).code,
'fixture_material_code': self.env['sf.fixture.material'].search(
[('id', '=', item.product_id.fixture_material_id.id)]).code,
'fixture_multi_mounting_type_code': self.env['sf.multi_mounting.type'].search(
[('id', '=', item.product_id.fixture_multi_mounting_type_id.id)]).code,
'fixture_materials_type_code': self.env['sf.materials.model'].search(
[('id', '=', item.product_id.materials_type_id.id)]).materials_no,
'fixture_clamping_way': item.product_id.fixture_clamping_way,
'fixture_port_type': item.product_id.fixture_port_type,
'fixture_length': item.product_id.tool_length,
'fixture_width': item.product_id.tool_width,
'fixture_height': item.product_id.tool_height,
'fixture_weight': item.product_id.tool_weight,
'fixture_amount': int(item.quantity_done),
'fixture_model_file': '' if not item.product_id.fixture_model_file else base64.b64encode(
item.product_id.fixture_model_file).decode(
'utf-8'),
'fixture_clamp_workpiece_length_max': item.product_id.fixture_clamp_workpiece_length_max,
'fixture_clamp_workpiece_width_max': item.product_id.fixture_clamp_workpiece_width_max,
'fixture_clamp_workpiece_height_max': item.product_id.fixture_clamp_workpiece_height_max,
'fixture_clamp_workpiece_diameter_max': item.product_id.fixture_clamp_workpiece_diameter_max,
'fixture_maximum_carrying_weight': item.product_id.fixture_maximum_carrying_weight,
'fixture_maximum_clamping_force': item.product_id.fixture_maximum_clamping_force,
'fixture_driving_way': '' if not item.product_id.fixture_driving_way
else item.product_id.fixture_driving_way,
'fixture_apply_machine_tool_type_codes': self.env[
'product.template']._json_apply_machine_tool_type_item_code(item),
'fixture_through_hole_size': item.product_id.fixture_through_hole_size,
'fixture_screw_size': item.product_id.fixture_screw_size,
}
try:
if item.product_id.industry_code:
val['industry_code'] = item.product_id.industry_code
ret = requests.post(strurl, json={}, data=val, headers=headers)
ret = ret.json()
if ret['status'] == 200:
if not item.product_id.industry_code:
item.product_id.write({'register_state': '已注册', 'industry_code': ret['industry_code']})
else:
item.product_id.write({'register_state': '已注册'})
else:
item.product_id.write({'register_state': '注册失败'})
except Exception as e:
raise UserError("注册夹具到云端失败,请联系管理员!")
# 将采购到的刀具注册到Cloud
def _register_cutting_tool(self):
create_url = '/api/factory_cutting_tool_material/create'
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strurl = config['sf_url'] + create_url
for item in self:
val = {
'token': config['token'],
'name': item.product_id.name,
'brand_code': self.env['sf.machine.brand'].search([('id', '=', item.product_id.brand_id.id)]).code,
'cutting_tool_material_code': self.env['sf.cutting.tool.material'].search(
[('id', '=', item.product_id.cutting_tool_material_id.id)]).code,
'cutting_tool_type_code': self.env['sf.cutting.tool.type'].search(
[('id', '=', item.product_id.cutting_tool_type_id.id)]).code,
'material_model_code': self.env['sf.materials.model'].search(
[('id', '=', item.product_id.materials_type_id.id)]).materials_no,
'tool_length': item.product_id.tool_length,
'tool_width': item.product_id.tool_width,
'tool_height': item.product_id.tool_height,
'tool_thickness': item.product_id.tool_thickness,
'tool_weight': item.product_id.tool_weight,
'tool_hardness': item.product_id.tool_hardness,
'coating_material': item.product_id.coating_material,
'amount': int(item.quantity_done),
# 'model_file': '' if not item.product_id.fixture_model_file else base64.b64encode(
# item.product_id.fixture_model_file).decode(
# 'utf-8'),
'total_length': item.product_id.cutting_tool_total_length,
'shank_length': item.product_id.cutting_tool_shank_length,
'blade_length': item.product_id.cutting_tool_blade_length,
'neck_length': item.product_id.cutting_tool_neck_length,
'neck_diameter': item.product_id.cutting_tool_neck_diameter,
'shank_diameter': item.product_id.cutting_tool_shank_diameter,
'blade_tip_diameter': item.product_id.cutting_tool_blade_tip_diameter,
'blade_tip_taper': item.product_id.cutting_tool_blade_tip_taper,
'blade_helix_angle': item.product_id.cutting_tool_blade_helix_angle,
'blade_type': item.product_id.cutting_tool_blade_type,
'coarse_medium_fine': '' if item.product_id.cutting_tool_coarse_medium_fine is False
else item.product_id.cutting_tool_coarse_medium_fine,
'run_out_accuracy_max': item.product_id.cutting_tool_run_out_accuracy_max,
'run_out_accuracy_min': item.product_id.cutting_tool_run_out_accuracy_min,
'head_diameter': item.product_id.cutting_tool_head_diameter,
'diameter': item.product_id.cutting_tool_diameter,
'blade_number': '' if item.product_id.cutting_tool_blade_number is False
else item.product_id.cutting_tool_blade_number,
'front_angle': item.product_id.cutting_tool_front_angle,
'rear_angle': item.product_id.cutting_tool_rear_angle,
'main_included_angle': item.product_id.cutting_tool_main_included_angle,
'chuck_codes': self.env['product.template']._json_chuck_item_code(item),
'cutter_bar_codes': self.env['product.template']._json_cutter_bar_item_code(item),
'cutter_pad_codes': self.env['product.template']._json_cutter_pad_item_code(item),
'blade_codes': self.env['product.template']._json_blade_item_code(item),
'handle_codes': self.env['product.template']._json_handle_item_code(item),
'nut': item.product_id.cutting_tool_nut,
'top_angle': item.product_id.cutting_tool_top_angle,
'jump_accuracy': item.product_id.cutting_tool_jump_accuracy,
'working_hardness': item.product_id.cutting_tool_working_hardness,
'blade_diameter': item.product_id.cutting_tool_blade_diameter,
'wrench': item.product_id.cutting_tool_wrench,
'accuracy_level': item.product_id.cutting_tool_accuracy_level,
'clamping_way': item.product_id.cutting_tool_clamping_way,
'clamping_length': item.product_id.cutting_tool_clamping_length,
'clamping_tolerance': item.product_id.cutting_tool_clamping_tolerance,
'diameter_max': item.product_id.cutting_tool_diameter_max,
'clamping_diameter_min': item.product_id.cutting_tool_clamping_diameter_min,
'clamping_diameter_max': item.product_id.cutting_tool_clamping_diameter_max,
'detection_accuracy_max': item.product_id.cutting_tool_detection_accuracy_max,
'detection_accuracy_min': item.product_id.cutting_tool_detection_accuracy_min,
'is_rough_finish': item.product_id.cutting_tool_is_rough_finish,
'is_finish': item.product_id.cutting_tool_is_finish,
'is_drill_hole': item.product_id.cutting_tool_is_drill_hole,
'is_safety_lock': item.product_id.cutting_tool_is_safety_lock,
'is_high_speed_cutting': item.product_id.cutting_tool_is_high_speed_cutting,
'dynamic_balance_class': item.product_id.cutting_tool_dynamic_balance_class,
'change_time': item.product_id.cutting_tool_change_time,
'standard_speed': item.product_id.cutting_tool_standard_speed,
'speed_max': item.product_id.cutting_tool_speed_max,
'cooling_type': item.product_id.cutting_tool_cooling_type,
'body_accuracy': item.product_id.cutting_tool_body_accuracy,
'apply_lock_nut_model': item.product_id.apply_lock_nut_model,
'apply_lock_wrench_model': item.product_id.apply_lock_wrench_model,
'tool_taper': item.product_id.cutting_tool_taper,
'flange_length': item.product_id.cutting_tool_flange_length,
'flange_diameter': item.product_id.cutting_tool_flange_diameter,
'outer_diameter': item.product_id.cutting_tool_outer_diameter,
'inner_diameter': item.product_id.cutting_tool_inner_diameter,
'cooling_suit_type_ids': item.product_id.cooling_suit_type_ids,
'er_size_model': item.product_id.cutting_tool_er_size_model,
'image': '' if not item.product_id.image_1920 else
base64.b64encode(item.product_id.image_1920).decode('utf-8'),
}
try:
if item.product_id.industry_code:
val['industry_code'] = item.product_id.industry_code
ret = requests.post(strurl, json={}, data=val, headers=headers)
ret = ret.json()
if ret['status'] == 200:
if not item.product_id.industry_code:
item.product_id.write({'register_state': '已注册', 'industry_code': ret['industry_code']})
else:
item.product_id.write({'register_state': '已注册'})
else:
item.product_id.write({'register_state': '注册失败'})
except Exception as e:
raise UserError("注册刀具到云端失败,请联系管理员!")
def print_serial_numbers(self):
if not self.next_serial:
raise UserError(_("请先分配序列号再进行打印"))
label_data = []
for item in self.move_line_ids:
label_data.append({
'item_id': item.id,
})
if label_data:
report_template = self.env.ref('stock.label_package_template')
res = report_template.report_action(label_data)
res['id'] = report_template.id
return res
else:
raise UserError(_("没有可打印的标签数据"))
class ReStockQuant(models.Model):

View File

@@ -3,13 +3,16 @@ access_sf_cnc_processing,sf_cnc_processing,model_sf_cnc_processing,sf_base.group
access_sf_cnc_processing_manager,sf_cnc_processing,model_sf_cnc_processing,sf_base.group_sf_mrp_manager,1,1,1,0
access_sf_model_type,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_model_type_manager,sf_model_type,model_sf_model_type,sf_base.group_sf_mrp_manager,1,1,1,0
access_sf_model_type_group_sale_director,sf_model_type_group_sale_director,model_sf_model_type,sf_base.group_sale_director,1,0,0,0
access_sf_model_type_group_purchase_director,sf_model_type_group_purchase_director,model_sf_model_type,sf_base.group_purchase_director,1,0,0,0
access_sf_model_type_group_plan_director,sf_model_type_group_plan_director,model_sf_model_type,sf_base.group_plan_director,1,0,0,0
access_sf_product_model_type_routing_sort,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_product_model_type_routing_sort_manager,sf_product_model_type_routing_sort,model_sf_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0
access_sf_embryo_model_type_routing_sort,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_embryo_model_type_routing_sort_manager,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,1
access_sf_embryo_model_type_routing_sort_manager,sf_embryo_model_type_routing_sort,model_sf_embryo_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0
access_sf_surface_technics_model_type_routing_sort,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_surface_technics_model_type_routing_sort_manager,sf_surface_technics_model_type_routing_sort,model_sf_surface_technics_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0
access_sf_production_line,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_user,1,0,0,0
access_sf_production_line,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_user,1,1,1,0
access_sf_production_line_manager,sf.production.line,model_sf_production_line,sf_base.group_sf_mrp_manager,1,1,1,0
access_maintenance_equipment_tool,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_user,1,0,0,0
access_maintenance_equipment_tool_manager,maintenance_equipment_tool,model_maintenance_equipment_tool,sf_base.group_sf_mrp_manager,1,1,1,0
@@ -22,7 +25,12 @@ access_mrp_workcenter,mrp_workcenter,model_mrp_workcenter,sf_base.group_sf_mrp_u
access_mrp_workcenter_manager,mrp_workcenter,model_mrp_workcenter,sf_base.group_sf_mrp_manager,1,1,1,0
access_mrp_workcenter_productivity,mrp_workcenter_productivity,model_mrp_workcenter_productivity,sf_base.group_sf_mrp_user,1,0,0,0
access_mrp_workcenter_productivity_manager,mrp_workcenter_productivity,model_mrp_workcenter_productivity,sf_base.group_sf_mrp_manager,1,1,1,0
access_sf_workpiece_delivery_group_sf_order_user,sf_workpiece_delivery_group_sf_order_user,model_sf_workpiece_delivery,sf_base.group_sf_order_user,1,1,0,0
access_sf_workpiece_delivery_group_sf_equipment_user,sf_workpiece_delivery_group_sf_equipment_user,model_sf_workpiece_delivery,sf_base.group_sf_equipment_user,1,1,0,0
access_sf_workpiece_delivery_manager,sf_workpiece_delivery,model_sf_workpiece_delivery,sf_base.group_sf_mrp_manager,1,1,0,0
access_sf_workpiece_delivery_admin,sf_workpiece_delivery_admin,model_sf_workpiece_delivery,base.group_system,1,1,1,0
access_sf_workpiece_delivery_wizard_group_sf_order_user,sf_workpiece_delivery_wizard_group_sf_order_user,model_sf_workpiece_delivery_wizard,sf_base.group_sf_order_user,1,1,1,0
access_mrp_workcenter_productivity_loss_manager,mrp.workcenter.productivity.loss,mrp.model_mrp_workcenter_productivity_loss,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_workcenter_productivity_loss,mrp.workcenter.productivity.loss,mrp.model_mrp_workcenter_productivity_loss,sf_base.group_sf_mrp_user,1,0,0,0
access_mrp_workcenter_productivity_loss_type,mrp.workcenter.productivity.loss.type,mrp.model_mrp_workcenter_productivity_loss_type,sf_base.group_sf_mrp_user,1,0,0,0
@@ -37,12 +45,16 @@ access_mrp_workcenter_manager,mrp.workcenter.manager,mrp.model_mrp_workcenter,sf
access_mrp_routing_workcenter_manager,mrp.routing.workcenter.manager,mrp.model_mrp_routing_workcenter,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_bom_manager,mrp.bom.manager,mrp.model_mrp_bom,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_bom_line_manager,mrp.bom.line.manager,mrp.model_mrp_bom_line,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_bom_line_group_plan_director,mrp_bom_line_group_plan_director,mrp.model_mrp_bom_line,sf_base.group_plan_director,1,1,1,0
access_mrp_bom_line_group_sale_director,mrp_bom_line_group_sale_director,mrp.model_mrp_bom_line,sf_base.group_sale_director,1,1,1,0
access_mrp_bom_line_group_purchase_director,mrp_bom_line_group_purchase_director,mrp.model_mrp_bom_line,sf_base.group_purchase_director,1,1,1,0
access_mrp_bom_byproduct_manager,mrp.bom.byproduct manager,mrp.model_mrp_bom_byproduct,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_production_stock_worker,mrp.production stock_worker,mrp.model_mrp_production,stock.group_stock_user,1,0,0,0
access_product_product_user,product.product user,product.model_product_product,sf_base.group_sf_mrp_user,1,0,0,0
access_product_template_user,product.template user,product.model_product_template,sf_base.group_sf_mrp_user,1,0,0,0
access_uom_uom_user,uom.uom user,uom.model_uom_uom,sf_base.group_sf_mrp_user,1,0,0,0
access_product_supplierinfo_user,product.supplierinfo user,product.model_product_supplierinfo,sf_base.group_sf_mrp_user,1,1,1,0
access_product_supplierinfo_user,product.supplierinfo user,product.model_product_supplierinfo,sf_base.group_sf_mrp_user,1,0,0,0
access_res_partner,res.partner,base.model_res_partner,sf_base.group_sf_mrp_user,1,0,0,0
access_mrp_workorder_mrp_user,mrp.workorder.user,mrp.model_mrp_workorder,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_workorder_mrp_manager,mrp.workorder,mrp.model_mrp_workorder,sf_base.group_sf_mrp_user,1,1,1,0
@@ -87,14 +99,18 @@ access_mrp_production_split,access.mrp.production.split,mrp.model_mrp_production
access_mrp_production_split_line,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,mrp.workcenter.capacity.manager,mrp.model_mrp_workcenter_capacity,sf_base.group_sf_mrp_user,1,1,1,0
access_mrp_production,mrp_production,model_mrp_production,sf_base.group_plan_dispatch,1,1,1,0
access_mrp_production_group_plan_dispatch,mrp_production,model_mrp_production,sf_base.group_plan_dispatch,1,0,0,0
access_mrp_workorder,mrp_workorder,model_mrp_workorder,sf_base.group_plan_dispatch,1,1,1,0
access_sf_production_line,sf.production.line,model_sf_production_line,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
access_mrp_workcenter,mrp_workcenter,model_mrp_workcenter,sf_base.group_plan_dispatch,1,1,1,0
access_mrp_bom,mrp.bom,mrp.model_mrp_bom,sf_base.group_plan_dispatch,1,1,1,0
access_mrp_bom_line,mrp.bom.line,mrp.model_mrp_bom_line,sf_base.group_plan_dispatch,1,0,0,0
access_mrp_unbuild,mrp.unbuild,mrp.model_mrp_unbuild,sf_base.group_plan_dispatch,1,1,1,0
access_stock_scrap,stock.scrap,stock.model_stock_scrap,sf_base.group_plan_dispatch,1,1,1,0
access_stock_scrap_group_plan_dispatch,stock.scrap,stock.model_stock_scrap,sf_base.group_plan_dispatch,1,0,0,0
access_sf_model_type,sf.model.type,model_sf_model_type,sf_base.group_plan_dispatch,1,1,1,0
access_mrp_routing_workcenter,mrp.routing.workcenter,mrp.model_mrp_routing_workcenter,sf_base.group_plan_dispatch,1,1,1,0
access_mrp_document,mrp.document,mrp.model_mrp_document,sf_base.group_plan_dispatch,1,0,0,0
@@ -106,4 +122,5 @@ access_sf_cnc_processing,sf.cnc.processing,model_sf_cnc_processing,sf_base.group
access_mrp_workcenter_productivity,mrp.workcenter.productivity,mrp.model_mrp_workcenter_productivity,sf_base.group_plan_dispatch,1,0,0,0
access_mrp_workcenter_productivity,mrp.workcenter.productivity,mrp.model_mrp_workcenter_productivity,sf_base.group_plan_dispatch,1,0,0,0
access_maintenance_equipment_tool_group_plan_dispatch,maintenance.equipment.tool,sf_manufacturing.model_maintenance_equipment_tool,sf_base.group_plan_dispatch,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
3 access_sf_cnc_processing_manager sf_cnc_processing model_sf_cnc_processing sf_base.group_sf_mrp_manager 1 1 1 0
4 access_sf_model_type sf_model_type model_sf_model_type sf_base.group_sf_mrp_user 1 0 0 0
5 access_sf_model_type_manager sf_model_type model_sf_model_type sf_base.group_sf_mrp_manager 1 1 1 0
6 access_sf_model_type_group_sale_director sf_model_type_group_sale_director model_sf_model_type sf_base.group_sale_director 1 0 0 0
7 access_sf_model_type_group_purchase_director sf_model_type_group_purchase_director model_sf_model_type sf_base.group_purchase_director 1 0 0 0
8 access_sf_model_type_group_plan_director sf_model_type_group_plan_director model_sf_model_type sf_base.group_plan_director 1 0 0 0
9 access_sf_product_model_type_routing_sort sf_product_model_type_routing_sort model_sf_product_model_type_routing_sort sf_base.group_sf_mrp_user 1 0 0 0
10 access_sf_product_model_type_routing_sort_manager sf_product_model_type_routing_sort model_sf_product_model_type_routing_sort sf_base.group_sf_mrp_manager 1 1 1 0
11 access_sf_embryo_model_type_routing_sort sf_embryo_model_type_routing_sort model_sf_embryo_model_type_routing_sort sf_base.group_sf_mrp_user 1 0 0 0
12 access_sf_embryo_model_type_routing_sort_manager sf_embryo_model_type_routing_sort model_sf_embryo_model_type_routing_sort sf_base.group_sf_mrp_manager 1 1 1 1 0
13 access_sf_surface_technics_model_type_routing_sort sf_surface_technics_model_type_routing_sort model_sf_surface_technics_model_type_routing_sort sf_base.group_sf_mrp_user 1 0 0 0
14 access_sf_surface_technics_model_type_routing_sort_manager sf_surface_technics_model_type_routing_sort model_sf_surface_technics_model_type_routing_sort sf_base.group_sf_mrp_manager 1 1 1 0
15 access_sf_production_line sf.production.line model_sf_production_line sf_base.group_sf_mrp_user 1 0 1 0 1 0
16 access_sf_production_line_manager sf.production.line model_sf_production_line sf_base.group_sf_mrp_manager 1 1 1 0
17 access_maintenance_equipment_tool maintenance_equipment_tool model_maintenance_equipment_tool sf_base.group_sf_mrp_user 1 0 0 0
18 access_maintenance_equipment_tool_manager maintenance_equipment_tool model_maintenance_equipment_tool sf_base.group_sf_mrp_manager 1 1 1 0
25 access_mrp_workcenter_manager mrp_workcenter model_mrp_workcenter sf_base.group_sf_mrp_manager 1 1 1 0
26 access_mrp_workcenter_productivity mrp_workcenter_productivity model_mrp_workcenter_productivity sf_base.group_sf_mrp_user 1 0 0 0
27 access_mrp_workcenter_productivity_manager mrp_workcenter_productivity model_mrp_workcenter_productivity sf_base.group_sf_mrp_manager 1 1 1 0
28 access_sf_workpiece_delivery_group_sf_order_user sf_workpiece_delivery_group_sf_order_user model_sf_workpiece_delivery sf_base.group_sf_order_user 1 1 0 0
29 access_sf_workpiece_delivery_group_sf_equipment_user sf_workpiece_delivery_group_sf_equipment_user model_sf_workpiece_delivery sf_base.group_sf_equipment_user 1 1 0 0
30 access_mrp_workcenter_productivity_loss_manager access_sf_workpiece_delivery_manager mrp.workcenter.productivity.loss sf_workpiece_delivery mrp.model_mrp_workcenter_productivity_loss model_sf_workpiece_delivery sf_base.group_sf_mrp_user sf_base.group_sf_mrp_manager 1 1 1 0 0
31 access_sf_workpiece_delivery_admin sf_workpiece_delivery_admin model_sf_workpiece_delivery base.group_system 1 1 1 0
32 access_sf_workpiece_delivery_wizard_group_sf_order_user sf_workpiece_delivery_wizard_group_sf_order_user model_sf_workpiece_delivery_wizard sf_base.group_sf_order_user 1 1 1 0
33 access_mrp_workcenter_productivity_loss_manager mrp.workcenter.productivity.loss mrp.model_mrp_workcenter_productivity_loss sf_base.group_sf_mrp_user 1 1 1 0
34 access_mrp_workcenter_productivity_loss mrp.workcenter.productivity.loss mrp.model_mrp_workcenter_productivity_loss sf_base.group_sf_mrp_user 1 0 0 0
35 access_mrp_workcenter_productivity_loss_type mrp.workcenter.productivity.loss.type mrp.model_mrp_workcenter_productivity_loss_type sf_base.group_sf_mrp_user 1 0 0 0
36 access_mrp_workcenter_productivity mrp.workcenter.productivity mrp.model_mrp_workcenter_productivity sf_base.group_sf_mrp_user 1 1 1 0
45 access_mrp_bom_manager mrp.bom.manager mrp.model_mrp_bom sf_base.group_sf_mrp_user 1 1 1 0
46 access_mrp_bom_line_manager mrp.bom.line.manager mrp.model_mrp_bom_line sf_base.group_sf_mrp_user 1 1 1 0
47 access_mrp_bom_byproduct_manager access_mrp_bom_line_group_plan_director mrp.bom.byproduct manager mrp_bom_line_group_plan_director mrp.model_mrp_bom_byproduct mrp.model_mrp_bom_line sf_base.group_sf_mrp_user sf_base.group_plan_director 1 1 1 0
48 access_mrp_bom_line_group_sale_director mrp_bom_line_group_sale_director mrp.model_mrp_bom_line sf_base.group_sale_director 1 1 1 0
49 access_mrp_bom_line_group_purchase_director mrp_bom_line_group_purchase_director mrp.model_mrp_bom_line sf_base.group_purchase_director 1 1 1 0
50 access_mrp_bom_byproduct_manager mrp.bom.byproduct manager mrp.model_mrp_bom_byproduct sf_base.group_sf_mrp_user 1 1 1 0
51 access_mrp_production_stock_worker mrp.production stock_worker mrp.model_mrp_production stock.group_stock_user 1 0 0 0
52 access_mrp_production_stock_worker access_product_product_user mrp.production stock_worker product.product user mrp.model_mrp_production product.model_product_product stock.group_stock_user sf_base.group_sf_mrp_user 1 0 0 0
53 access_product_product_user access_product_template_user product.product user product.template user product.model_product_product product.model_product_template sf_base.group_sf_mrp_user 1 0 0 0
54 access_product_template_user access_uom_uom_user product.template user uom.uom user product.model_product_template uom.model_uom_uom sf_base.group_sf_mrp_user 1 0 0 0
55 access_uom_uom_user access_product_supplierinfo_user uom.uom user product.supplierinfo user uom.model_uom_uom product.model_product_supplierinfo sf_base.group_sf_mrp_user 1 0 0 0
56 access_product_supplierinfo_user access_res_partner product.supplierinfo user res.partner product.model_product_supplierinfo base.model_res_partner sf_base.group_sf_mrp_user 1 1 0 1 0 0
57 access_res_partner access_mrp_workorder_mrp_user res.partner mrp.workorder.user base.model_res_partner mrp.model_mrp_workorder sf_base.group_sf_mrp_user 1 0 1 0 1 0
58 access_mrp_workorder_mrp_user access_mrp_workorder_mrp_manager mrp.workorder.user mrp.workorder mrp.model_mrp_workorder sf_base.group_sf_mrp_user 1 1 1 0
59 access_mrp_workorder_mrp_manager access_resource_calendar_leaves_user mrp.workorder mrp.resource.calendar.leaves.user mrp.model_mrp_workorder resource.model_resource_calendar_leaves sf_base.group_sf_mrp_user 1 1 1 0
60 access_resource_calendar_leaves_user access_resource_calendar_leaves_manager mrp.resource.calendar.leaves.user mrp.resource.calendar.leaves.manager resource.model_resource_calendar_leaves sf_base.group_sf_mrp_user 1 1 0 1 0 0
99 access_mrp_workcenter_capacity_manager access_mrp_production_group_plan_dispatch mrp.workcenter.capacity.manager mrp_production mrp.model_mrp_workcenter_capacity model_mrp_production sf_base.group_sf_mrp_user sf_base.group_plan_dispatch 1 1 0 1 0 0
100 access_mrp_production access_mrp_workorder mrp_production mrp_workorder model_mrp_production model_mrp_workorder sf_base.group_plan_dispatch 1 1 1 0
101 access_mrp_workorder access_sf_production_line_group_plan_dispatch mrp_workorder sf.production.line model_mrp_workorder model_sf_production_line sf_base.group_plan_dispatch 1 1 0 1 0 0
102 access_sf_production_line access_sf_production_line_group_plan_director sf.production.line model_sf_production_line sf_base.group_plan_dispatch sf_base.group_plan_director 1 1 1 0
103 access_sf_production_line sf.production.line model_sf_production_line sf_maintenance.sf_group_equipment_user 1 1 1 0
104 access_mrp_workcenter mrp_workcenter model_mrp_workcenter sf_base.group_plan_dispatch 1 1 1 0
105 access_mrp_bom mrp.bom mrp.model_mrp_bom sf_base.group_plan_dispatch 1 1 1 0
106 access_mrp_bom_line mrp.bom.line mrp.model_mrp_bom_line sf_base.group_plan_dispatch 1 0 0 0
107 access_mrp_unbuild mrp.unbuild mrp.model_mrp_unbuild sf_base.group_plan_dispatch 1 1 1 0
108 access_mrp_bom_line access_stock_scrap_group_plan_dispatch mrp.bom.line stock.scrap mrp.model_mrp_bom_line stock.model_stock_scrap sf_base.group_plan_dispatch 1 0 0 0
109 access_mrp_unbuild access_sf_model_type mrp.unbuild sf.model.type mrp.model_mrp_unbuild model_sf_model_type sf_base.group_plan_dispatch 1 1 1 0
110 access_stock_scrap access_mrp_routing_workcenter stock.scrap mrp.routing.workcenter stock.model_stock_scrap mrp.model_mrp_routing_workcenter sf_base.group_plan_dispatch 1 1 1 0
111 access_sf_model_type access_mrp_document sf.model.type mrp.document model_sf_model_type mrp.model_mrp_document sf_base.group_plan_dispatch 1 1 0 1 0 0
112 access_mrp_routing_workcenter access_sf_product_model_type_routing_sort mrp.routing.workcenter sf.product.model.type.routing.sort mrp.model_mrp_routing_workcenter model_sf_product_model_type_routing_sort sf_base.group_plan_dispatch 1 1 0 1 0 0
113 access_sf_embryo_model_type_routing_sort sf.embryo.model.type.routing.sort model_sf_embryo_model_type_routing_sort sf_base.group_plan_dispatch 1 0 0 0
114 access_mrp_document access_sf_surface_technics_model_type_routing_sort mrp.document sf.surface_technics.model.type.routing.sort mrp.model_mrp_document model_sf_surface_technics_model_type_routing_sort sf_base.group_plan_dispatch 1 0 0 0
115 access_sf_product_model_type_routing_sort access_mrp_workcenter_capacity sf.product.model.type.routing.sort mrp.workcenter.capacity model_sf_product_model_type_routing_sort mrp.model_mrp_workcenter_capacity sf_base.group_plan_dispatch 1 0 0 0
116 access_sf_embryo_model_type_routing_sort access_sf_cnc_processing sf.embryo.model.type.routing.sort sf.cnc.processing model_sf_embryo_model_type_routing_sort model_sf_cnc_processing sf_base.group_plan_dispatch 1 0 0 0
122
123
124
125
126

View File

@@ -18,19 +18,21 @@
<field name="product_qty" sum="Total Qty" string="数量" readonly="1" optional="show"/>
</xpath>
<xpath expr="//field[@name='product_qty']" position="after">
<field name="product_uom_id" string="计量单位" options="{'no_open':True,'no_create':True}" groups="uom.group_uom" optional="show"/>
<field name="product_uom_id" string="计量单位" options="{'no_open':True,'no_create':True}"
groups="uom.group_uom" optional="show"/>
</xpath>
<xpath expr="//field[@name='date_planned_start']" position="replace">
<field name="date_planned_start" optional="show"/>
<field name="date_planned_finished" string="计划结束时间"/>
<!-- <field name="date_deadline" widget="remaining_days" attrs="{'invisible': [('state', 'in', ['done', 'cancel'])]}" optional="show"/> -->
<!-- <field name="date_deadline" widget="remaining_days" attrs="{'invisible': [('state', 'in', ['done', 'cancel'])]}" optional="show"/> -->
</xpath>
<xpath expr="//field[@name='production_real_duration']" position="after">
<field name="reservation_state" optional="hide" decoration-danger="reservation_state == 'confirmed'" decoration-success="reservation_state == 'assigned'"/>
</xpath>
<xpath expr="//field[@name='state']" position="before">
<field name="schedule_state" optional="show"/>
<field name="reservation_state" optional="hide" decoration-danger="reservation_state == 'confirmed'"
decoration-success="reservation_state == 'assigned'"/>
</xpath>
<!-- <xpath expr="//field[@name='state']" position="before"> -->
<!-- <field name="schedule_state" optional="show"/> -->
<!-- </xpath> -->
<xpath expr="//field[@name='activity_ids']" position="replace">
<field name="activity_ids" string="下一个活动" widget="list_activity" optional="hide"/>
</xpath>
@@ -39,58 +41,315 @@
</xpath>
<xpath expr="//field[@name='components_availability']" position="replace">
<field name="components_availability" options='{"lazy": true}'
attrs="{'invisible': [('state', 'not in', ['confirmed', 'progress'])]}"
optional="hide"
decoration-success="reservation_state == 'assigned' or components_availability_state == 'available'"
decoration-warning="reservation_state != 'assigned' and components_availability_state in ('expected', 'available')"
decoration-danger="reservation_state != 'assigned' and components_availability_state == 'late'"/>
attrs="{'invisible': [('state', 'not in', ['confirmed', 'progress'])]}"
optional="hide"
decoration-success="reservation_state == 'assigned' or components_availability_state == 'available'"
decoration-warning="reservation_state != 'assigned' and components_availability_state in ('expected', 'available')"
decoration-danger="reservation_state != 'assigned' and components_availability_state == 'late'"/>
</xpath>
<!-- <xpath expr="//field[@name='state']" position="after"> -->
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//field[@name='state']" position="after"> -->
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
<!-- </xpath> -->
</field>
</record>
<!-- 增加权限相关的按钮 -->
<!-- 增加权限相关的按钮 -->
<!-- 制造订单的操作按钮只让制造用户可见 -->
<record id="custom_mrp_production_form_view" model="ir.ui.view">
<field name="name">custom.mrp.production.form</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<xpath expr="//form//header//button[@name='action_confirm']" position="after">
<field name="active" invisible="1"/>
<field name="check_status" invisible="1"/>
<!-- <button name="archive" type="object" string="归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', False)]}"/> -->
<!-- <button name="unarchive" type="object" string="取消归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', True)]}"/> -->
<button name="action_check" string="审核" type="object" class="oe_highlight" attrs="{'invisible': [('check_status', '=', True)]}" groups="sf_base.group_plan_director"/>
<!-- <button name="action_uncheck" string="禁用" type="object" class="oe_highlight" attrs="{'invisible': [('check_status', '=', False)]}" groups="sf_base.group_plan_director"/> -->
<xpath expr="//field[@name='state']" position="attributes">
<attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done
</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="programming_no" readonly="1"/>
<field name="work_state" invisible="1"/>
<field name="programming_state" readonly="1"/>
<field name="production_line_id" readonly="1"/>
<field name="plan_start_processing_time" readonly="1"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', True)]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[1]" position="replace">
<button name="button_mark_done"
attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '!=', [])]}"
string="验证" type="object" class="oe_highlight"
confirm="There are no components to consume. Are you still sure you want to continue?"
data-hotkey="g" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[2]" position="replace">
<button name="button_mark_done"
attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '=', [])]}"
string="验证" type="object" class="oe_highlight" data-hotkey="g"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[3]" position="replace">
<button name="button_mark_done" attrs="{'invisible': [
'|',
('move_raw_ids', '=', []),
'&amp;',
'|',
('state', 'not in', ('confirmed', 'progress')),
('qty_producing', '!=', 0),
('state', '!=', 'to_close')]}" string="标记完成" type="object" class="oe_highlight"
data-hotkey="g" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[4]" position="replace">
<button name="button_mark_done" attrs="{'invisible': [
'|',
('move_raw_ids', '!=', []),
'&amp;',
'|',
('state', 'not in', ('confirmed', 'progress')),
('qty_producing', '!=', 0),
('state', '!=', 'to_close')]}" string="标记完成" type="object" class="oe_highlight"
data-hotkey="g"
confirm="There are no components to consume. Are you still sure you want to continue?"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_unplan']" position="replace">
<button name="button_unplan" type="object" string="取消安排"
attrs="{'invisible': ['|', ('is_planned', '=', False), ('state', '=', 'cancel')]}"
data-hotkey="x" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_scrap']" position="replace">
<button name="button_scrap" type="object" string="报废"
attrs="{'invisible': [('state', 'in', ('cancel', 'draft'))]}" data-hotkey="y"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_confirm']" position="replace">
<button name="action_confirm" attrs="{'invisible': [('state', '!=', 'draft')]}" string="确认"
type="object" class="oe_highlight" data-hotkey="v" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_plan']" position="replace">
<button name="button_plan"
attrs="{'invisible': ['|', '|', ('state', 'not in', ('confirmed', 'progress', 'to_close')), ('workorder_ids', '=', []), ('is_planned', '=', True)]}"
type="object" string="Plan" class="oe_highlight" data-hotkey="x"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_assign']" position="replace">
<button name="action_assign"
attrs="{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('reserve_visible', '=', False)]}"
string="Check availability" type="object" data-hotkey="q"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='do_unreserve']" position="replace">
<button name="do_unreserve" type="object" string="Unreserve"
attrs="{'invisible': [('unreserve_visible', '=', False)]}" data-hotkey="w"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
<button name="action_toggle_is_locked"
attrs="{'invisible': ['|', ('show_lock', '=', False), ('is_locked', '=', False)]}"
string="Unlock" groups="sf_base.group_sf_mrp_user" type="object"
help="Unlock the manufacturing order to adjust what has been consumed or produced."
data-hotkey="l"/>
</xpath>
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
<button name="action_toggle_is_locked"
attrs="{'invisible': ['|', ('show_lock', '=', False), ('is_locked', '=', True)]}"
string="Lock" groups="sf_base.group_sf_mrp_user" type="object"
help="Lock the manufacturing order to prevent changes to what has been consumed or produced."
data-hotkey="l"/>
</xpath>
<xpath expr="//header//button[@name='action_serial_mass_produce_wizard']" position="replace">
<button name="action_serial_mass_produce_wizard"
attrs="{'invisible': [('show_serial_mass_produce', '=', False)]}" string="Mass Produce"
type="object" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="Cancel" data-hotkey="z"
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', False)]}"
confirm="Some product moves have already been confirmed, this manufacturing order can't be completely cancelled. Are you still sure you want to process ?"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_unbuild']" position="replace">
<button name="button_unbuild" type="object" string="拆单"
attrs="{'invisible': [('state', '!=', 'done')]}" data-hotkey="shift+v"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_plan']" position="replace">
<!-- <button name="button_plan" attrs="{'invisible': ['|', '|', ('state', 'not in', ('confirmed', 'progress', 'to_close')), ('workorder_ids', '=', []), ('is_planned', '=', True)]}" type="object" string="Plan" class="oe_highlight" data-hotkey="x" groups="sf_base.group_sf_mrp_user"/> -->
</xpath>
<xpath expr="//header//button[@name='action_assign']" position="replace">
<button name="action_assign"
attrs="{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('reserve_visible', '=', False)]}"
string="检查可用量" type="object" data-hotkey="q" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='do_unreserve']" position="replace">
<button name="do_unreserve" type="object" string="取消保留"
attrs="{'invisible': [('unreserve_visible', '=', False)]}" data-hotkey="w"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
<button name="action_toggle_is_locked"
attrs="{'invisible': ['|', ('show_lock', '=', False), ('is_locked', '=', False)]}"
string="取消阻塞" groups="sf_base.group_sf_mrp_user" type="object"
help="Unlock the manufacturing order to adjust what has been consumed or produced."
data-hotkey="l"/>
</xpath>
<xpath expr="//header//button[@name='action_toggle_is_locked']" position="replace">
<button name="action_toggle_is_locked"
attrs="{'invisible': ['|', ('show_lock', '=', False), ('is_locked', '=', True)]}"
string="阻塞" groups="sf_base.group_sf_mrp_user" type="object"
help="Lock the manufacturing order to prevent changes to what has been consumed or produced."
data-hotkey="l"/>
</xpath>
<xpath expr="//header//button[@name='action_serial_mass_produce_wizard']" position="replace">
<button name="action_serial_mass_produce_wizard"
attrs="{'invisible': [('show_serial_mass_produce', '=', False)]}" string="批量生产"
type="object" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
attrs="{'invisible': ['|', '|', ('id', '=', False), ('state', 'in', ('done', 'cancel')), ('confirm_cancel', '=', False)]}"
confirm="Some product moves have already been confirmed, this manufacturing order can't be completely cancelled. Are you still sure you want to process ?"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='button_unbuild']" position="replace">
<button name="button_unbuild" type="object" string="拆单"
attrs="{'invisible': [('state', '!=', 'done')]}" data-hotkey="shift+v"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
</field>
</record>
<!-- 工单的操作按钮只让制造用户可见 -->
<record id="sf_mrp_production_workorder_tree_editable_view" model="ir.ui.view">
<field name="name">sf.mrp.production.workorder.tree.editable</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_tree_editable_view"/>
<field name="arch" type="xml">
<xpath expr="//tree//button[@name='button_start']" position="replace">
<button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_pending']" position="replace">
<button name="button_pending" type="object" string="Pause" class="btn-warning"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_finish']" position="replace">
<button name="button_finish" type="object" string="Done" class="btn-success"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="Block"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked')]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_unblock']" position="replace">
<button name="button_unblock" type="object" string="Unblock"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='action_open_wizard']" position="replace">
<button name="action_open_wizard" type="object" icon="fa-external-link" class="oe_edit_only"
title="Open Work Order"
context="{'default_workcenter_id': workcenter_id}" groups="sf_base.group_sf_mrp_user"/>
=======
<button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|', ('production_state','in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')), ('is_user_working', '!=', False)]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_pending']" position="replace">
<button name="button_pending" type="object" string="暂停" class="btn-warning"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_finish']" position="replace">
<button name="button_finish" type="object" string="完成" class="btn-success"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='%(mrp.act_mrp_block_workcenter_wo)d']" position="replace">
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="阻塞"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked')]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='button_unblock']" position="replace">
<button name="button_unblock" type="object" string="取消阻塞"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked')]}"
groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//tree//button[@name='action_open_wizard']" position="replace">
<button name="action_open_wizard" type="object" icon="fa-external-link" class="oe_edit_only"
title="未完成工单"
context="{'default_workcenter_id': workcenter_id}" groups="sf_base.group_sf_mrp_user"/>
</xpath>
</field>
</record>
<!-- 制造订单列表视图header内的按钮只让制造用户可见 -->
<record id="sf_mrp_production_tree_view" model="ir.ui.view">
<field name="name">sf.mrp.production.tree</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//header//button[@name='button_plan']" position="replace">
<!-- <button name="button_plan" type="object" string="安排" groups="sf_base.group_sf_mrp_user"/> -->
</xpath>
<xpath expr="//header//button[@name='do_unreserve']" position="replace">
<button name="do_unreserve" type="object" string="取消保留" groups="sf_base.group_sf_mrp_user"/>
</xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="取消" groups="sf_base.group_sf_mrp_user"/>
</xpath>
</field>
</record>
<!-- <record id="custom_mrp_production_form_view" model="ir.ui.view"> -->
<!-- <field name="name">custom.mrp.production.form</field> -->
<!-- <field name="model">mrp.production</field> -->
<!-- <field name="inherit_id" ref="mrp.mrp_production_form_view"/> -->
<!-- <field name="arch" type="xml"> -->
<!-- <xpath expr="//header//field[@name='state']" position="replace"> -->
<!-- <field name="state" widget="statusbar" statusbar_visible="draft,confirmed,已排程,progress,done"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//header" position="inside"> -->
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//sheet//group//group//field[@name='product_id']" position="after"> -->
<!-- <field name="production_line_id"/> -->
<!-- <field name="date_planned_finished" string="计划结束时间"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//sheet//group//group//field[@name='date_planned_start']" position="after"> -->
<!-- <field name="date_planned_finished"/> -->
<!-- </xpath> -->
<!-- </field> -->
<!-- </record> -->
<!-- <record id="custom_mrp_production_form_view" model="ir.ui.view"> -->
<!-- <field name="name">custom.mrp.production.form</field> -->
<!-- <field name="model">mrp.production</field> -->
<!-- <field name="inherit_id" ref="mrp.mrp_production_form_view"/> -->
<!-- <field name="arch" type="xml"> -->
<!-- <xpath expr="//header//field[@name='state']" position="replace"> -->
<!-- <field name="state" widget="statusbar" statusbar_visible="draft,confirmed,已排程,progress,done"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//header" position="inside"> -->
<!-- <button name="action_view_production_schedule" string="生产排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','已排程','progress','done','to_close'])]}"/> -->
<!-- <button name="cancel_plan" string="取消排程" type="object" attrs="{'invisible': [('state', 'in', ['draft', 'cancel','progress','done','to_close','confirmed'])]}"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//sheet//group//group//field[@name='product_id']" position="after"> -->
<!-- <field name="production_line_id"/> -->
<!-- <field name="date_planned_finished" string="计划结束时间"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//sheet//group//group//field[@name='date_planned_start']" position="after"> -->
<!-- <field name="date_planned_finished"/> -->
<!-- </xpath> -->
<!-- </field> -->
<!-- </record> -->
<record id="custom_view_mrp_production_filter" model="ir.ui.view">
<field name="name">custom.mrp.production.select</field>
@@ -106,24 +365,24 @@
</field>
</record>
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已完成" name="filter_done" domain="[('state', '=', 'done')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已取消" name="filter_cancel" domain="[('state', '=', 'cancel')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="进行中" name="filter_progress" domain="[('state', '=', 'progress')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已确认" name="filter_confirmed" domain="[('state', '=', 'confirmed')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="草稿" name="filter_draft" domain="[('state', '=', 'draft')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已完成" name="filter_done" domain="[('state', '=', 'done')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已取消" name="filter_cancel" domain="[('state', '=', 'cancel')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="进行中" name="filter_progress" domain="[('state', '=', 'progress')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="已确认" name="filter_confirmed" domain="[('state', '=', 'confirmed')]"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//filter[@name='filter_draft']" position="after"> -->
<!-- <filter string="草稿" name="filter_draft" domain="[('state', '=', 'draft')]"/> -->
<!-- </xpath> -->
<!-- 产品模板修改>>>增加“规格”字段specification_id -->
<!-- 产品模板修改>>>增加“规格”字段specification_id -->
<record id="custom_product_template_kanban_view" model="ir.ui.view">
<field name="name">custom.Product.template.product.kanban</field>
<field name="model">product.template</field>
@@ -131,44 +390,52 @@
<field name="arch" type="xml">
<xpath expr="//kanban" position="replace">
<kanban sample="1" class="o_kanban_product_template">
<field name="id"/>
<field name="product_variant_count"/>
<field name="currency_id"/>
<field name="activity_state"/>
<progressbar field="activity_state" colors='{"planned": "success", "today": "warning", "overdue": "danger"}'/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_card oe_kanban_global_click">
<div class="o_kanban_image me-1">
<img t-att-src="kanban_image('product.template', 'image_128', record.id.raw_value)" alt="Product" class="o_image_64_contain"/>
</div>
<div class="oe_kanban_details">
<div class="o_kanban_record_top mb-0">
<div class="o_kanban_record_headings">
<strong class="o_kanban_record_title">
<field name="name"/>
<field name="id"/>
<field name="product_variant_count"/>
<field name="currency_id"/>
<field name="activity_state"/>
<progressbar field="activity_state"
colors='{"planned": "success", "today": "warning", "overdue": "danger"}'/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_card oe_kanban_global_click">
<div class="o_kanban_image me-1">
<img t-att-src="kanban_image('product.template', 'image_128', record.id.raw_value)"
alt="Product" class="o_image_64_contain"/>
</div>
<div class="oe_kanban_details">
<div class="o_kanban_record_top mb-0">
<div class="o_kanban_record_headings">
<strong class="o_kanban_record_title">
<field name="name"/>
</strong>
</div>
<field name="priority" widget="priority"/>
</div>
<div name="product_specification_id" class="mt-1">
规格:
<field name="specification_id"></field>
</div>
<t t-if="record.default_code.value">[<field name="default_code"/>]
</t>
<div t-if="record.product_variant_count.value &gt; 1"
groups="product.group_product_variant">
<strong>
<t t-esc="record.product_variant_count.value"/>
Variants
</strong>
</div>
<field name="priority" widget="priority"/>
</div>
<div name="product_specification_id" class="mt-1">
规格: <field name="specification_id"></field>
</div>
<t t-if="record.default_code.value">[<field name="default_code"/>]</t>
<div t-if="record.product_variant_count.value &gt; 1" groups="product.group_product_variant">
<strong>
<t t-esc="record.product_variant_count.value"/> Variants
</strong>
</div>
<div name="product_lst_price" class="mt-1">
价格: <field name="list_price" widget="monetary" options="{'currency_field': 'currency_id', 'field_digits': True}"></field>
<div name="product_lst_price" class="mt-1">
价格:
<field name="list_price" widget="monetary"
options="{'currency_field': 'currency_id', 'field_digits': True}"></field>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</t>
</templates>
</kanban>
</xpath>
</field>
</record>

View File

@@ -6,6 +6,9 @@
<field name="model">mrp.routing.workcenter</field>
<field name="inherit_id" ref="mrp.mrp_routing_workcenter_form_view"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="code" readonly="1"/>
</field>
<field name="workcenter_id" position="replace">
<field name="workcenter_ids" widget="many2many_tags" string="工作中心" required="0"/>
<field name="surface_technics_id"

View File

@@ -6,9 +6,9 @@
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<button name="action_cancel" position="before">
<button name="button_maintenance_req" type="object" string="维修请求"/>
</button>
<!-- <button name="action_cancel" position="before"> -->
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
<!-- </button> -->
<div name="button_box" position="inside">
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
attrs="{'invisible': [('maintenance_count', '=', 0)]}"
@@ -376,9 +376,9 @@
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<button name="action_cancel" position="before">
<button name="button_maintenance_req" type="object" string="维修请求"/>
</button>
<!-- <button name="action_cancel" position="before"> -->
<!-- <button name="button_maintenance_req" type="object" string="维修请求"/> -->
<!-- </button> -->
<div name="button_box" position="inside">
<button name="open_maintenance_request_mo" type="object" class="oe_stat_button" icon="fa-wrench"
attrs="{'invisible': [('maintenance_count', '=', 0)]}"

View File

@@ -104,22 +104,31 @@
<field name='user_permissions' invisible="1"/>
<field name='name' invisible="1"/>
<field name='routing_type' invisible="1"/>
<field name='is_delivery' invisible="1"/>
<button name="button_start" type="object" string="开始" class="btn-success"
attrs="{'invisible': ['|', '|', '|','|','|', ('production_state','in', ('draft', 'done',
attrs="{'invisible': ['|', '|', '|','|',('production_state','in', ('draft', 'done',
'cancel')), ('working_state', '=', 'blocked'), ('state', 'in', ('done', 'cancel')),
('is_user_working', '!=', False),('user_permissions','=',False),('name','=','获取CNC加工程序')]}"/>
('is_user_working', '!=', False),('user_permissions','=',False)]}"
groups="sf_base.group_sf_mrp_user"/>
<button name="button_pending" type="object" string="暂停" class="btn-warning"
attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False),('name','=','获取CNC加工程序')]}"/>
groups="sf_base.group_sf_mrp_user"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
<button name="button_finish" type="object" string="完成" class="btn-success"
groups="sf_base.group_sf_mrp_user"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>
<button name="%(mrp.act_mrp_block_workcenter_wo)d" type="action" string="停工"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'),('user_permissions','=',False),('name','=','获取CNC加工程序')]}"/>
groups="sf_base.group_sf_mrp_user"
attrs="{'invisible': ['|', '|','|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'),('user_permissions','=',False),('state','=','done')]}"/>
<button name="button_unblock" type="object" string="Unblock"
context="{'default_workcenter_id': workcenter_id}" class="btn-danger"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('name','=','获取CNC加工程序')]}"/>
groups="sf_base.group_sf_mrp_user"
attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '!=', 'blocked'),('state','=','done')]}"/>
<button name="button_workpiece_delivery" type="object" string="工件配送" class="btn-primary"
attrs="{'invisible': ['|',('routing_type','!=','装夹预调'),('is_delivery','=',True)]}"/>
</xpath>
<xpath expr="//page[1]" position="before">
<xpath expr="//page[1]" position="before">
<page string="开料要求" attrs='{"invisible": [("routing_type","!=","切割")]}'>
<group>
<group>
@@ -162,11 +171,13 @@
<field name="equipment_id"
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
<field name="functional_fixture_id"
attrs='{"invisible": [("routing_type","!=","装夹")]}'/>
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="functional_fixture_code" force_save="1"
attrs='{"invisible": [("routing_type","!=","装夹")]}'/>
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="functional_fixture_type_id" force_save="1"
attrs='{"invisible": [("routing_type","!=","装夹")]}'/>
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
<field name="rfid_code"
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
</group>
<group attrs='{"invisible": [("routing_type","=","获取CNC加工程序")]}'>
<div>
@@ -219,7 +230,7 @@
<!-- </div>-->
<!-- </page>-->
<page string="工件装夹" attrs='{"invisible": [("routing_type","!=","装夹")]}'>
<page string="工件装夹" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
<group>
<group string="卡盘">
<field name="chuck_serial_number"/>
@@ -229,11 +240,12 @@
<field name="chuck_model_id"/>
</group>
<group string="托盘">
<field name="tray_serial_number"/>
<field name="tray_name"/>
<field name="tray_brand_id"/>
<field name="tray_type_id"/>
<field name="tray_model_id"/>
<field name="_barcode_scanned" widget="barcode_handler"/>
<field name="tray_serial_number" readonly="1" string="序列号"/>
<field name="tray_product_id" readonly="1" string="名称"/>
<field name="tray_brand_id" readonly="1" string="品牌"/>
<field name="tray_type_id" readonly="1" string="类型"/>
<field name="tray_model_id" readonly="1" string="型号"/>
</group>
</group>
<group string="预调程序信息">
@@ -241,10 +253,7 @@
placeholder="如有预调程序信息请在此处输入....."/>
</group>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="前置三元检测定位参数" attrs='{"invisible": [("routing_type","!=","前置三元定位检测")]}'>
<page string="前置三元检测定位参数" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
<div>左面:</div>
<div class="o_address_format">
@@ -393,12 +402,41 @@
</div>
<group>
<field name="material_center_point"/>
<field name='X_deviation_angle'/>
<field name="material_center_point" readonly="1"/>
<field name='X_deviation_angle' readonly="1"/>
</group>
</page>
<page string="工件配送" attrs='{"invisible": [("routing_type","!=","装夹预调")]}'>
<field name="workpiece_delivery_ids">
<tree editable="bottom">
<field name="production_id" invisible="1"/>
<field name="workpiece_code"/>
<field name="feeder_station_start" force_save="1"/>
<field name="feeder_station_destination"/>
<field name="production_line_id"/>
<field name="task_delivery_time" readonly="1"/>
<field name="task_completion_time" readonly="1"/>
</tree>
</field>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<field name="results" invisible="1"/>
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<group>
<field name="test_results" widget="selection" attrs='{"invisible":[("results","!=",False)]}'/>
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
</group>
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
string="检测确认"
attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>
</div>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
<field name="cnc_ids" widget="one2many" string="工作程序">
@@ -424,32 +462,18 @@
</group>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<field name="results" invisible="1"/>
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
<group>
<field name="test_results" widget="selection" attrs='{"invisible":[("results","!=",False)]}'/>
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
</group>
<div class="col-12 col-lg-6 o_setting_box">
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
string="检测确认"
attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>
</div>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
<!-- <field name="tray_id" readonly="1"/>-->
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
<!-- <button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"-->
<!-- attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>-->
<!-- </div>-->
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
<!-- <button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"-->
<!-- string="打印标签"-->
<!-- attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>-->
<!-- </div>-->
<!-- <field name="tray_id" readonly="1"/>-->
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
<!-- <button type="object" class="oe_highlight" name="unbindtray" string="解除装夹"-->
<!-- attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>-->
<!-- </div>-->
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
<!-- <button type="action" class="oe_highlight" name="sf_manufacturing.label_sf_tray_code1"-->
<!-- string="打印标签"-->
<!-- attrs='{"invisible": ["|",("state","!=","progress"),("user_permissions","=",False)]}'/>-->
<!-- </div>-->
</page>
</xpath>
@@ -479,14 +503,68 @@
<field name="domain">[('schedule_state', '=', '已排')]</field>
</record>
<!-- <menuitem id="menu_mrp_workorder_schedule_todo" -->
<!-- name="工单" -->
<!-- action="mrp_workorder_action_schedule" -->
<!-- parent="mrp.menu_mrp_manufacturing" -->
<!-- sequence="15"/> -->
<!-- <menuitem id="menu_mrp_workorder_schedule_todo" -->
<!-- name="工单" -->
<!-- action="mrp_workorder_action_schedule" -->
<!-- parent="mrp.menu_mrp_manufacturing" -->
<!-- sequence="15"/> -->
<record id="mrp.menu_mrp_workorder_todo" model="ir.ui.menu">
<field name="active" eval="False"/>
</record>
<!--=========================================工件配送单列表======================================-->
<record id="sf_workpiece_delivery_tree" model="ir.ui.view">
<field name="name">工件配送</field>
<field name="model">sf.workpiece.delivery</field>
<field name="arch" type="xml">
<tree string="工件配送">
<header>
<button name="button_delivery" type="object" string="配送"/>
</header>
<field name="status" widget="badge"
decoration-success="status == '已配送'"
decoration-warning="status == '待下发'"
decoration-danger="status == '待配送'"/>
<field name="production_id" string="工件编码"/>
<field name="workpiece_code"/>
<field name="production_line_id"/>
<field name="feeder_station_start"/>
<field name="feeder_station_destination"/>
<field name="task_delivery_time"/>
<field name="task_completion_time"/>
<field name="delivery_duration" widget="float_time"/>
</tree>
</field>
</record>
<record id="sf_workpiece_delivery_search" model="ir.ui.view">
<field name="name">工件配送</field>
<field name="model">sf.workpiece.delivery</field>
<field name="arch" type="xml">
<search string="工件配送">
<field name="production_id"/>
<field name="workpiece_code"/>
<field name="feeder_station_start"/>
<field name="production_line_id"/>
<field name="task_delivery_time"/>
<field name="feeder_station_destination"/>
<field name="task_completion_time"/>
<field name="delivery_duration"/>
<field name="status"/>
<searchpanel>
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
<field name="status" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
</field>
</record>
<record id="sf_workpiece_delivery_act" model="ir.actions.act_window">
<field name="name">工件配送</field>
<field name="res_model">sf.workpiece.delivery</field>
<field name="view_mode">tree,search</field>
</record>
</odoo>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- 设备增加刀具库位table-->
设备增加刀具库位table
<record id="sf_manufacturing_hr_equipment_view_form" model="ir.ui.view">
<field name="name">sf_manufacturing_equipment.form</field>
<field name="model">maintenance.equipment</field>
@@ -13,17 +13,6 @@
<field name = 'product_template_ids' >
<tree editable='bottom'>
<field name="code"/>
<field name="product_template_id"/>
<field name="image_1920" widget="image"/>
<field name="categ_type"/>
<field name="diameter"/>
<field name="precision"/>
<field name="tool_code"/>
<field name="hilt_name"/>
<field name="hilt_code"/>
<field name="life_value_max"/>
<field name="alarm_value"/>
<field name="used_value"/>
</tree>
</field>
</page>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="stock_production_lot_form_generate_qr_code" model="ir.ui.view">
<field name="name">stock.lot.form.quality</field>
<field name="model">stock.lot</field>
<field name="inherit_id" ref="stock.view_production_lot_form"/>
<field name="arch" type="xml">
<xpath expr="//form//sheet//group//group[2]" position="inside">
<field name="qr_code_image" widget="image"/>
</xpath>
<xpath expr="//sheet" position="before">
<header>
<button string="打印二维码" name="print_qr_code" type="object" class="btn-primary"/>
</header>
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,6 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record id="view_stock_move_operations_inherit_sf" model="ir.ui.view">
<field name="name">stock.move.operations.form.inherit.sf</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_stock_move_operations"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_assign_serial_show_details']" position="after">
<button name="print_serial_numbers" string="序列号打印" type="object"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="view_picking_form_inherit_sf">
<field name="name">stock.picking.form.inherit.sf</field>
<field name="model">stock.picking</field>

View File

@@ -0,0 +1 @@
from . import workpiece_delivery_wizard

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="workpiece_delivery_wizard_form_view">
<field name="name">sf.workpiece.delivery.wizard.form.view</field>
<field name="model">sf.workpiece.delivery.wizard</field>
<field name="arch" type="xml">
<form>
<field name="delivery_id" invisible="True"/>
<div>
是否确定配送?
</div>
<footer>
<button string="确认" name="confirm" type="object" class="oe_highlight"/>
<button string="取消" class="btn btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_workpiece_delivery_wizard" model="ir.actions.act_window">
<field name="name">工件配送向导</field>
<field name="res_model">sf.workpiece.delivery.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Part of YiZuo. See LICENSE file for full copyright and licensing details.
from odoo.exceptions import UserError, ValidationError
from datetime import datetime
from odoo import models, api, fields
class WorkpieceDeliveryWizard(models.TransientModel):
_name = 'sf.workpiece.delivery.wizard'
_description = '工件配送'
delivery_id = fields.Many2one('sf.workpiece.delivery', string='配送')
def confirm(self):
self.delivery_id._delivery_avg()