diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index c548222a..63fd4f57 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -238,7 +238,7 @@ class Manufacturing_Connect(http.Controller): workorder = request.env['mrp.workorder'].sudo().search( [('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1) if workorder: - workorder.test_result = ret['Quality'] + # workorder.test_results = ret['Quality'] logging.info('制造订单:%s' % workorder.production_id.name) if 'ReportPaht' in ret: download_state = request.env['mrp.workorder'].with_user( @@ -261,8 +261,7 @@ class Manufacturing_Connect(http.Controller): ('picking_id', '=', stock_picking.id)]) if quality_check: logging.info('质检单:%s' % quality_check.name) - quality_check.write({'report_pdf': workorder.detection_report, - 'report_result': workorder.test_result}) + quality_check.write({'report_pdf': workorder.detection_report}) elif download_state == 2: res = {'Succeed': False, 'ErrorCode': 205, 'Error': 'ReportPaht中的工件号与制造订单%s不匹配,请检查ReportPaht是否正确' % workorder.production_id.name} diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml index 6bd0fe53..72559691 100644 --- a/sf_manufacturing/data/stock_data.xml +++ b/sf_manufacturing/data/stock_data.xml @@ -67,5 +67,21 @@ search="[('barcode','=','WH-PREPRODUCTION')]"/> + + + 表面工艺外协 + + True + 11 + + + + + + + + + + diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 3b6e8ead..81580db7 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -98,7 +98,8 @@ class ResMrpWorkOrder(models.Model): Y10_axis = fields.Float(default=0) Z10_axis = fields.Float(default=0) X_deviation_angle = fields.Integer(string="X轴偏差度", default=0) - test_result = fields.Char("检测结果") + test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格', + string="检测结果") cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工程序") cmm_ids = fields.One2many("sf.cmm.program", 'workorder_id', string="CMM程序") tray_code = fields.Char(string="托盘编码") @@ -143,6 +144,7 @@ class ResMrpWorkOrder(models.Model): production_line_state = fields.Selection(related='production_id.production_line_state', string='上/下产线', store=True) detection_report = fields.Binary('检测报告', readonly=True) + is_remanufacture = fields.Boolean(string='是否重新生成制造订单', default=True) def get_plan_workorder(self, production_line): tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d") @@ -446,7 +448,7 @@ class ResMrpWorkOrder(models.Model): """ 重新生成制造订单或者重新生成工单 """ - if self.test_result == '报废': + if self.test_results == '报废': values = self.env['mrp.production'].create_production1_values(self.production_id) productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company( self.production_id.company_id).create( @@ -478,7 +480,7 @@ class ResMrpWorkOrder(models.Model): 'mail.message_origin_link', values={'self': production, 'origin': origin_production}, subtype_id=self.env.ref('mail.mt_note').id) - if self.test_result == '返工': + if self.test_results == '返工': productions = self.production_id # self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) # self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) @@ -608,6 +610,8 @@ class ResMrpWorkOrder(models.Model): if self.routing_type == '装夹预调': if not self.material_center_point and self.X_deviation_angle > 0: raise UserError("请对前置三元检测定位参数进行计算定位") + if not self.rfid_code: + raise UserError("请扫RFID码进行绑定") if self.picking_out_id: picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)]) if picking_out.workorder_out_id: @@ -849,6 +853,38 @@ class SfWorkOrderBarcodes(models.Model): for item in workorder_rfid: item.write({'rfid_code': barcode}) 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('工件生产线不一致,请重新确认') + else: + workorder_rfid = self.env['mrp.workorder'].search( + [('production_id', '=', workorder.production_id.id)]) + if workorder_rfid: + for item in workorder_rfid: + if item.state == "progress": + item.write({'rfid_code': barcode}) raise UserError('该托盘信息不存在!!!') # stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)]) # if stock_move_line.product_id.categ_type == '夹具': diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 1489cddd..f3cba150 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -6,11 +6,11 @@ import os from odoo import models, fields, api, _ from odoo.exceptions import ValidationError from odoo.modules import get_resource_path - from OCC.Extend.DataExchange import read_step_file from OCC.Extend.DataExchange import write_stl_file + class ResProductMo(models.Model): _inherit = 'product.template' diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 5833b095..80a334ce 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -17,6 +17,50 @@ from io import BytesIO from odoo.exceptions import ValidationError +class stockWarehouse(models.Model): + _inherit = 'stock.warehouse' + + subcontracting_surface_technology_pull_out_id = fields.Many2one( + 'stock.rule', '表面工艺规则1') + subcontracting_surface_technology_pull_in_id = fields.Many2one( + 'stock.rule', '表面工艺规则2' + ) + + def _get_global_route_rules_values(self): + rules = super(stockWarehouse, self)._get_global_route_rules_values() + location_virtual_id = self.env.ref( + 'sf_manufacturing.stock_location_locations_virtual_outcontract').id, + location_pre_id = self.env['stock.location'].search( + [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id, + rules.update({ + 'subcontracting_surface_technology_pull_in_id': { + 'create_values': { + 'action': 'pull', + 'picking_type_id': self.env.ref('sf_manufacturing.outcontract_picking_in').id, + 'group_propagation_option': 'none', + 'company_id': self.company_id.id, + 'location_src_id': location_virtual_id, + 'location_dest_id': location_pre_id, + 'route_id': self._find_global_route('sf_manufacturing.route_surface_technology_outsourcing', + _('表面工艺外协')).id, + } + }, + 'subcontracting_surface_technology_pull_out_id': { + 'create_values': { + 'action': 'pull', + 'picking_type_id': self.env.ref('sf_manufacturing.outcontract_picking_out').id, + 'group_propagation_option': 'none', + 'company_id': self.company_id.id, + 'location_src_id': location_pre_id, + 'location_dest_id': location_virtual_id, + 'route_id': self._find_global_route('sf_manufacturing.route_surface_technology_outsourcing', + _('表面工艺外协')).id, + } + } + }) + return rules + + class StockRule(models.Model): _inherit = 'stock.rule' diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index b1ca9946..9a747791 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -104,18 +104,14 @@ - +