Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化制造订单报废流程
# Conflicts: # sf_manufacturing/models/mrp_production.py
This commit is contained in:
@@ -408,12 +408,12 @@ class MrpProduction(models.Model):
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str('', production, route))
|
||||
production.workorder_ids = workorders_values
|
||||
if is_fetchcnc is False and scrap_production:
|
||||
production.write({'programming_no': scrap_production.programming_no,
|
||||
'programming_state': '已编程'})
|
||||
if production_programming.programming_state == '已编程':
|
||||
logging.info("production_programming: %s" % production_programming.name)
|
||||
production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').write({
|
||||
'cnc_ids': scrap_production.workorder_ids.filtered(
|
||||
lambda t1: t1.routing_type == 'CNC加工').cnc_ids})
|
||||
'cnc_ids': production_programming.workorder_ids.filtered(
|
||||
lambda
|
||||
t1: t1.routing_type == 'CNC加工').cnc_ids})
|
||||
for workorder in production.workorder_ids:
|
||||
workorder.duration_expected = workorder._get_duration_expected()
|
||||
|
||||
@@ -507,8 +507,7 @@ class MrpProduction(models.Model):
|
||||
|
||||
def _reset_work_order_sequence(self):
|
||||
for rec in self:
|
||||
product_routing_sequence_list = {} # 成品
|
||||
embryo_routing_sequence_list = {} # 坯料
|
||||
sequence_list = {}
|
||||
model_type_id = rec.product_id.product_model_type_id
|
||||
if model_type_id:
|
||||
tmpl_num = 1
|
||||
@@ -516,7 +515,7 @@ class MrpProduction(models.Model):
|
||||
product_routing_tmpl_ids = model_type_id.product_routing_tmpl_ids
|
||||
if product_routing_tmpl_ids:
|
||||
for tmpl_id in product_routing_tmpl_ids:
|
||||
product_routing_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||
tmpl_num += 1
|
||||
# 表面工艺工序
|
||||
# 模型类型的表面工艺工序模版
|
||||
@@ -527,7 +526,6 @@ class MrpProduction(models.Model):
|
||||
if model_process_parameters_ids:
|
||||
for process_parameters_id in model_process_parameters_ids:
|
||||
process_id = process_parameters_id.process_id
|
||||
surface_tmpl_name = ''
|
||||
for surface_tmpl_id in surface_tmpl_ids:
|
||||
if process_id == surface_tmpl_id.route_workcenter_id.surface_technics_id:
|
||||
surface_tmpl_name = surface_tmpl_id.route_workcenter_id.name
|
||||
@@ -535,30 +533,23 @@ class MrpProduction(models.Model):
|
||||
surface_tmpl_name, process_parameters_id.name)})
|
||||
process_list = sorted(process_dict.keys())
|
||||
for process_num in process_list:
|
||||
product_routing_sequence_list.update({process_dict.get(process_num): tmpl_num})
|
||||
sequence_list.update({process_dict.get(process_num): tmpl_num})
|
||||
tmpl_num += 1
|
||||
# 坯料工序
|
||||
tmpl_num = 1
|
||||
embryo_routing_tmpl_ids = model_type_id.embryo_routing_tmpl_ids
|
||||
if embryo_routing_tmpl_ids:
|
||||
for tmpl_id in embryo_routing_tmpl_ids:
|
||||
embryo_routing_sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||
sequence_list.update({tmpl_id.route_workcenter_id.name: tmpl_num})
|
||||
tmpl_num += 1
|
||||
else:
|
||||
raise ValidationError('该产品没有选择【模版类型】!')
|
||||
|
||||
if rec.product_id.categ_id.name == '成品':
|
||||
for work in rec.workorder_ids:
|
||||
if product_routing_sequence_list.get(work.name):
|
||||
work.sequence = product_routing_sequence_list[work.name]
|
||||
else:
|
||||
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||
elif rec.product_id.categ_id.name == '坯料':
|
||||
for work in rec.workorder_ids:
|
||||
if embryo_routing_sequence_list.get(work.name):
|
||||
work.sequence = embryo_routing_sequence_list[work.name]
|
||||
else:
|
||||
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||
for work in rec.workorder_ids:
|
||||
if sequence_list.get(work.name):
|
||||
work.sequence = sequence_list[work.name]
|
||||
else:
|
||||
raise ValidationError('工序【%s】在产品选择的模版类型中不存在!' % work.name)
|
||||
# if work.name == '获取CNC加工程序':
|
||||
# work.button_start()
|
||||
# #work.fetchCNC()
|
||||
|
||||
@@ -1348,9 +1348,18 @@ class WorkPieceDelivery(models.Model):
|
||||
def create(self, vals):
|
||||
if vals.get('name', '/') == '/' or vals.get('name', '/') is False:
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('sf.workpiece.delivery') or '/'
|
||||
else:
|
||||
vals['type'] = '运送空料架'
|
||||
obj = super(WorkPieceDelivery, self).create(vals)
|
||||
return obj
|
||||
|
||||
@api.constrains('name')
|
||||
def _check_name(self):
|
||||
if self.type == '运送空料架':
|
||||
wd = self.sudo().search([('name', '=', self.name), ('id', '!=', self.id)])
|
||||
if wd:
|
||||
raise UserError("该名称已存在")
|
||||
|
||||
def action_delivery_history(self):
|
||||
return {
|
||||
'name': _('配送历史'),
|
||||
@@ -1531,7 +1540,7 @@ class WorkPieceDelivery(models.Model):
|
||||
'task_delivery_time': fields.Datetime.now(),
|
||||
'status': '待配送'
|
||||
})
|
||||
if delivery_item == "上产线":
|
||||
if delivery_item.type == "上产线":
|
||||
delivery_item.workorder_id.write({'is_delivery': True})
|
||||
else:
|
||||
raise UserError(ret['message'])
|
||||
|
||||
59
sf_manufacturing/models/tray.py
Normal file
59
sf_manufacturing/models/tray.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of SmartGo. See LICENSE file for full copyright and licensing details.
|
||||
import base64
|
||||
from io import BytesIO
|
||||
from odoo import api, fields, models, SUPERUSER_ID, _
|
||||
from pystrich.code128 import Code128Encoder
|
||||
|
||||
|
||||
class Tray(models.Model):
|
||||
_inherit = 'sf.tray'
|
||||
_description = '托盘'
|
||||
qr_image = fields.Binary(string="托盘二维码", compute='compute_qr_image')
|
||||
production_id = fields.Many2one('mrp.production', string='制造订单',
|
||||
related='workorder_id.production_id'
|
||||
)
|
||||
workorder_id = fields.Many2one('mrp.workorder', string="工单"
|
||||
)
|
||||
|
||||
@api.onchange('production_id')
|
||||
def updateTrayState(self):
|
||||
if self.workorder_id != False and self.create_date != False:
|
||||
|
||||
self.state = '占用'
|
||||
else:
|
||||
self.state = '空闲'
|
||||
|
||||
def unclamp(self):
|
||||
self.workorder_id = False
|
||||
self.production_id = False
|
||||
self.state = '空闲'
|
||||
|
||||
@api.depends('code')
|
||||
def compute_qr_image(self):
|
||||
for item in self:
|
||||
if not item.code:
|
||||
item.qr_image = False
|
||||
continue
|
||||
# 根据code动态生成二维码图片
|
||||
# qr = qrcode.QRCode(
|
||||
# version=1,
|
||||
# error_correction=qrcode.constants.ERROR_CORRECT_L,
|
||||
# box_size=10,
|
||||
# border=4,
|
||||
# )
|
||||
# qr.add_data(item.code)
|
||||
# qr.make(fit=True)
|
||||
# img = qr.make_image()
|
||||
# 生成条形码文件
|
||||
# bar = barcode.get("ean13", "123456789102", writer=ImageWriter())
|
||||
# a = bar.get_fullcode()
|
||||
# b = bar.save('occ')
|
||||
# 生成条形码图片
|
||||
partner_encoder = Code128Encoder(item.code)
|
||||
# 转换bytes流
|
||||
temp = BytesIO()
|
||||
partner_encoder.save(temp)
|
||||
# img.save(temp, format='PNG')
|
||||
qr_image = base64.b64encode(temp.getvalue())
|
||||
item.qr_image = qr_image
|
||||
Reference in New Issue
Block a user