From 37161e2e20757202dc3e8a9cd4b2b3dd02caf291 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 25 Jan 2024 17:51:57 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=B7=A5=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E6=89=98=E7=9B=98=E5=BA=8F=E5=88=97=E5=8F=B7=EF=BC=8C=E6=89=98?= =?UTF-8?q?=E7=9B=98=E5=90=8D=E7=A7=B0=EF=BC=8C=E6=89=98=E7=9B=98=E5=93=81?= =?UTF-8?q?=E7=89=8C=EF=BC=8C=E6=89=98=E7=9B=98=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E6=89=98=E7=9B=98=E5=9E=8B=E5=8F=B7=E5=AD=97=E6=AE=B5=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E4=B8=94=E9=A1=B5=E9=9D=A2=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=94=B9=E4=B8=BA=E5=8F=AA=E8=AF=BB=202.?= =?UTF-8?q?=E8=A3=85=E5=A4=B9=E9=A2=84=E8=B0=83=E5=B7=A5=E5=8D=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=89=AB=E6=9D=A1=E5=BD=A2=E7=A0=81=EF=BC=8C=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E6=97=B6=E5=AF=B9=E8=AF=A5=E5=B7=A5=E5=8D=95=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E8=87=AA=E5=8A=A8=E5=BC=80=E5=A7=8B=E5=B9=B6=E5=B0=86?= =?UTF-8?q?=E6=9D=A1=E7=A0=81=E9=87=8C=E5=AF=B9=E5=BA=94=E7=9A=84=E6=89=98?= =?UTF-8?q?=E7=9B=98=E4=BA=A7=E5=93=81=E4=BF=A1=E6=81=AF=E5=9B=9E=E5=A1=AB?= =?UTF-8?q?=E5=88=B0=E6=89=98=E7=9B=98=E5=BA=8F=E5=88=97=E5=8F=B7=EF=BC=8C?= =?UTF-8?q?=E6=89=98=E7=9B=98=E5=90=8D=E7=A7=B0=EF=BC=8C=E6=89=98=E7=9B=98?= =?UTF-8?q?=E5=93=81=E7=89=8C=EF=BC=8C=E6=89=98=E7=9B=98=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E6=89=98=E7=9B=98=E5=9E=8B=E5=8F=B7=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=B8=8A=EF=BC=8C=E7=82=B9=E5=87=BB=E5=AE=8C=E6=88=90=E6=97=B6?= =?UTF-8?q?=E5=AF=B9=E5=89=8D=E7=BD=AE=E4=B8=89=E5=85=83=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=8F=82=E6=95=B0=E8=BF=9B=E8=A1=8C=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=203.=E7=A0=94=E7=A9=B6=E6=89=93=E5=8D=B0=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8F=B7=EF=BC=88=E5=A4=9A=E4=B8=AA=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 73 ++++++------------- sf_manufacturing/models/stock.py | 12 ++- sf_manufacturing/views/mrp_workorder_view.xml | 17 +++-- 3 files changed, 42 insertions(+), 60 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 7a77fc5c..712940f0 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -122,10 +122,10 @@ 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]") @@ -552,6 +552,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: @@ -721,54 +724,22 @@ 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: + 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() class WorkPieceDelivery(models.Model): diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index a39bd0f4..f13abf6b 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -375,8 +375,18 @@ class ReStockMove(models.Model): def print_serial_numbers(self): if not self.next_serial: raise UserError(_("请先分配序列号再进行打印")) + label_data = [] for item in self.move_line_ids: - print(item.lot_name) + 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): diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 42b58149..502b33a2 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -117,7 +117,7 @@ attrs="{'invisible': ['|', '|', ('production_state', 'in', ('draft', 'done', 'cancel')), ('working_state', '=', 'blocked'), ('is_user_working', '=', False)]}"/>