diff --git a/sf_bf_connect/models/process_status.py b/sf_bf_connect/models/process_status.py index 09fecfae..69eb84f1 100644 --- a/sf_bf_connect/models/process_status.py +++ b/sf_bf_connect/models/process_status.py @@ -36,6 +36,8 @@ class StatusChange(models.Model): # 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法) try: res = super(StatusChange, self).action_confirm() + # 修改销售订单状态为【加工中】 + self.write({'state': 'processing'}) logging.info('原生方法返回结果:%s' % res) # 原有方法执行后,进行额外的操作(如调用外部API) process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 904aac56..936afaaf 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -40,6 +40,7 @@ 'views/res_config_settings_views.xml', 'views/sale_order_views.xml', 'views/mrp_workorder_batch_replan.xml', + 'views/purchase_order_view.xml', ], 'assets': { diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index d440d5bc..0ddd3631 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -769,7 +769,8 @@ class MrpProduction(models.Model): }] if production.product_id.categ_id.type in ['成品', '坯料']: # # 根据工序设计生成工单 - for route in production.technology_design_ids: + technology_design_ids = sorted(production.technology_design_ids, key=lambda x: x.sequence) + for route in technology_design_ids: workorder_has = self.env['mrp.workorder'].search( [('technology_design_id', '=', route.id), ('production_id', '=', production.id)]) if not workorder_has: @@ -963,10 +964,11 @@ class MrpProduction(models.Model): work_ids = workorder_ids.filtered(lambda item: item.sequence == 0) # 对工单进行逐个插入 for work_id in work_ids: - for order_id in rec.workorder_ids.filtered(lambda item: item.sequence > 0): - if work_id.name == order_id.name and work_id.processing_panel == order_id.processing_panel: - work_id.sequence = order_id.sequence + 1 - break + order_rework_ids = rec.workorder_ids.filtered( + lambda item: (item.sequence > 0 and work_id.name == item.name + and work_id.processing_panel == item.processing_panel)) + order_rework_ids = sorted(order_rework_ids, key=lambda item: item.sequence, reverse=True) + work_id.sequence = order_rework_ids[0].sequence + 1 # 对该工单之后的工单工序进行加一 work_order_ids = rec.workorder_ids.filtered( lambda item: item.sequence >= work_id.sequence and item.id != work_id.id) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 52fa30c8..410f8d1b 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -138,7 +138,8 @@ class ResMrpWorkOrder(models.Model): is_subcontract = fields.Boolean(string='是否外协') surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数") - picking_ids = fields.Many2many('stock.picking', string='外协出入库单', compute='_compute_surface_technics_picking_ids') + picking_ids = fields.Many2many('stock.picking', string='外协出入库单', + compute='_compute_surface_technics_picking_ids') purchase_id = fields.Many2many('purchase.order', string='外协采购单') surface_technics_picking_count = fields.Integer("外协出入库", compute='_compute_surface_technics_picking_ids') @@ -327,7 +328,7 @@ class ResMrpWorkOrder(models.Model): 'view_mode': 'form', } return result - + def _get_surface_technics_purchase_ids(self): domain = [('origin', '=', self.production_id.name), ('purchase_type', '=', 'consignment')] purchase_orders = self.env['purchase.order'].search(domain) @@ -1429,6 +1430,8 @@ class ResMrpWorkOrder(models.Model): rfid_code = workorder.rfid_code workorder.write({'rfid_code_old': rfid_code, 'rfid_code': False}) + self.env['stock.lot'].sudo().search([('rfid', '=', rfid_code)]).write( + {'tool_material_status': '可用'}) if workorder.rfid_code: raise ValidationError(f'【{workorder.name}】工单解绑失败,请重新点击完成按钮!!!') # workorder.rfid_code_old = rfid_code @@ -1567,7 +1570,7 @@ class ResMrpWorkOrder(models.Model): 'default_confirm_button': '确认解除', # 'default_feeder_station_start_id': feeder_station_start_id, }} - + move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件') @@ -1778,6 +1781,7 @@ class SfWorkOrderBarcodes(models.Model): if workorder_rfid: for item in workorder_rfid: item.write({'rfid_code': barcode}) + lot.sudo().write({'tool_material_status': '在用'}) logging.info("Rfid[%s]绑定成功!!!" % barcode) else: raise UserError('该Rfid【%s】绑定的是【%s】, 不是托盘!!!' % (barcode, lot.product_id.name)) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 460fd994..4b927596 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -774,11 +774,10 @@ class ResProductMo(models.Model): # bfm下单 manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) - part_number = fields.Char(string='零件图号', readonly=True) machining_drawings = fields.Binary('2D加工图纸', readonly=True) quality_standard = fields.Binary('质检标准', readonly=True) part_name = fields.Char(string='零件名称', readonly=True) - + part_number = fields.Char(string='零件图号', readonly=True) @api.constrains('tool_length') def _check_tool_length_size(self): if self.tool_length > 1000000: @@ -892,7 +891,7 @@ class ResProductMo(models.Model): 'machining_drawings': '' if not item['machining_drawings'] else base64.b64decode( item['machining_drawings']), 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), - 'part_name': item['part_name'], + 'part_name': item.get('part_name') or '', } tax_id = self.env['account.tax'].sudo().search( [('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')]) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index e54e96bf..1ffed728 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -10,7 +10,6 @@ from odoo.tools import OrderedSet # _get_surface_technics_purchase_ids class PurchaseOrder(models.Model): _inherit = 'purchase.order' - def button_confirm(self): super().button_confirm() workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id)]) @@ -29,3 +28,6 @@ class PurchaseOrder(models.Model): if not mo.move_line_ids: self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder)) return True +class PurchaseOrderLine(models.Model): + _inherit = 'purchase.order.line' + part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True) diff --git a/sf_manufacturing/models/sale_order.py b/sf_manufacturing/models/sale_order.py index 3cc8e587..8113ddae 100644 --- a/sf_manufacturing/models/sale_order.py +++ b/sf_manufacturing/models/sale_order.py @@ -196,7 +196,7 @@ class SaleOrder(models.Model): return new_picking class SaleOrderLine(models.Model): _inherit = 'sale.order.line' - + part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True) # 供货方式 supply_method = fields.Selection([ ('automation', "自动化产线加工"), diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index d08ff81f..567930dd 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -18,9 +18,12 @@ + + +