Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/刀具物料与夹具物料的反注册
# Conflicts: # sf_base/views/base_view.xml # sf_base/views/common_view.xml # sf_tool_management/models/base.py
This commit is contained in:
@@ -8,7 +8,7 @@ class MrpProduction(models.Model):
|
||||
_description = "制造订单"
|
||||
_order = 'create_date desc'
|
||||
|
||||
tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
||||
# tray_ids = fields.One2many('sf.tray', 'production_id', string="托盘")
|
||||
maintenance_count = fields.Integer(compute='_compute_maintenance_count', string="Number of maintenance requests")
|
||||
request_ids = fields.One2many('maintenance.request', 'production_id')
|
||||
model_file = fields.Binary('模型文件', related='product_id.model_file')
|
||||
|
||||
@@ -99,7 +99,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果")
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工")
|
||||
tray_code = fields.Char(string="托盘")
|
||||
tray_code = fields.Char(string="托盘编码")
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
is_subcontract = fields.Boolean(string='是否外协')
|
||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||
@@ -252,32 +252,32 @@ class ResMrpWorkOrder(models.Model):
|
||||
'domain': [('workorder_id', '=', self.id)]
|
||||
}
|
||||
|
||||
tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True)
|
||||
# tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True)
|
||||
|
||||
# 扫码绑定托盘方法
|
||||
|
||||
def gettray(self):
|
||||
if self.tray_code != False:
|
||||
values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
||||
if values:
|
||||
if values.state == "占用":
|
||||
raise UserError('该托盘已占用')
|
||||
if values.state == "报损":
|
||||
raise UserError('该托盘已损坏')
|
||||
else:
|
||||
values.update({
|
||||
'workorder_id': self,
|
||||
'production_id': self.production_id,
|
||||
'state': '占用',
|
||||
})
|
||||
self.work_state = "已绑定"
|
||||
orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
for a in orders:
|
||||
a.tray_id = values
|
||||
else:
|
||||
raise UserError('该托盘编码已失效')
|
||||
else:
|
||||
raise UserError('托盘码不能为空')
|
||||
# def gettray(self):
|
||||
# if self.tray_code != False:
|
||||
# values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
||||
# if values:
|
||||
# if values.state == "占用":
|
||||
# raise UserError('该托盘已占用')
|
||||
# if values.state == "报损":
|
||||
# raise UserError('该托盘已损坏')
|
||||
# else:
|
||||
# values.update({
|
||||
# 'workorder_id': self,
|
||||
# 'production_id': self.production_id,
|
||||
# 'state': '占用',
|
||||
# })
|
||||
# self.work_state = "已绑定"
|
||||
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
# for a in orders:
|
||||
# a.tray_id = values
|
||||
# else:
|
||||
# raise UserError('该托盘编码已失效')
|
||||
# else:
|
||||
# raise UserError('托盘码不能为空')
|
||||
|
||||
# 验证坯料序列号是否正确
|
||||
def pro_code_is_ok(self, barcode):
|
||||
@@ -293,50 +293,50 @@ class ResMrpWorkOrder(models.Model):
|
||||
pro_code_ok = fields.Boolean(default=False)
|
||||
|
||||
# 托盘扫码绑定
|
||||
def gettray_auto(self, barcode):
|
||||
if barcode != False:
|
||||
values = self.env['sf.tray'].search([("code", "=", barcode)])
|
||||
|
||||
if values:
|
||||
if values.state == "占用":
|
||||
raise UserError('该托盘已占用')
|
||||
if values.state == "报损":
|
||||
raise UserError('该托盘已损坏')
|
||||
else:
|
||||
values.update({
|
||||
'workorder_id': self,
|
||||
'production_id': self.production_id,
|
||||
'state': '占用',
|
||||
})
|
||||
self.work_state = "已绑定"
|
||||
orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
for a in orders:
|
||||
a.tray_id = values
|
||||
|
||||
return values
|
||||
|
||||
# return {
|
||||
# 'name': _('New Maintenance Request'),
|
||||
# 'view_mode': 'form',
|
||||
# 'res_model': 'maintenance.request',
|
||||
# 'type': 'ir.actions.act_window',
|
||||
# 'context': {
|
||||
# 'default_company_id': self.company_id.id,
|
||||
# 'default_production_id': self.id,
|
||||
# },
|
||||
# 'domain': [('production_id', '=', self.id)],
|
||||
# }
|
||||
else:
|
||||
raise UserError('该托盘编码已失效')
|
||||
else:
|
||||
raise UserError('托盘码不能为空')
|
||||
# def gettray_auto(self, barcode):
|
||||
# if barcode != False:
|
||||
# values = self.env['sf.tray'].search([("code", "=", barcode)])
|
||||
#
|
||||
# if values:
|
||||
# if values.state == "占用":
|
||||
# raise UserError('该托盘已占用')
|
||||
# if values.state == "报损":
|
||||
# raise UserError('该托盘已损坏')
|
||||
# else:
|
||||
# values.update({
|
||||
# 'workorder_id': self,
|
||||
# 'production_id': self.production_id,
|
||||
# 'state': '占用',
|
||||
# })
|
||||
# self.work_state = "已绑定"
|
||||
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||
# for a in orders:
|
||||
# a.tray_id = values
|
||||
#
|
||||
# return values
|
||||
#
|
||||
# # return {
|
||||
# # 'name': _('New Maintenance Request'),
|
||||
# # 'view_mode': 'form',
|
||||
# # 'res_model': 'maintenance.request',
|
||||
# # 'type': 'ir.actions.act_window',
|
||||
# # 'context': {
|
||||
# # 'default_company_id': self.company_id.id,
|
||||
# # 'default_production_id': self.id,
|
||||
# # },
|
||||
# # 'domain': [('production_id', '=', self.id)],
|
||||
# # }
|
||||
# else:
|
||||
# raise UserError('该托盘编码已失效')
|
||||
# else:
|
||||
# raise UserError('托盘码不能为空')
|
||||
|
||||
# 解除托盘绑定
|
||||
def unbindtray(self):
|
||||
tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)])
|
||||
if tray:
|
||||
tray.unclamp()
|
||||
self.tray_id = False
|
||||
# def unbindtray(self):
|
||||
# tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)])
|
||||
# if tray:
|
||||
# tray.unclamp()
|
||||
# self.tray_id = False
|
||||
|
||||
# return {
|
||||
# 'name': _('New Maintenance Request'),
|
||||
@@ -682,51 +682,51 @@ 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)
|
||||
# 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)
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
# -*- 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
|
||||
#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
|
||||
# # -*- 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
|
||||
# #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