diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 43f8112b..f62f7d6a 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1526,8 +1526,7 @@ class MrpProduction(models.Model): 重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建 """ product_group_id = {} - group_id = False - is_first = False + is_custemer_group_id = {} # 客供料与非客供料 for vals in vals_list: if not vals.get('name', False) or vals['name'] == _('New'): picking_type_id = vals.get('picking_type_id') @@ -1537,15 +1536,16 @@ class MrpProduction(models.Model): vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id() product_id = self.env['product.product'].browse(vals['product_id']) is_self_process = product_id.materials_type_id and product_id.materials_type_id.gain_way and product_id.materials_type_id.gain_way != '自加工' - if not is_first and is_self_process: - is_first = True - group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id + is_customer_provided = product_id.is_customer_provided + if not is_custemer_group_id.get(is_customer_provided): + is_custemer_group_id[is_customer_provided] = self.env["procurement.group"].create({'name': vals.get('name')}).id + # if not (is_first_customer or is_first_not_customer) and is_self_process: + # is_first = True + # group_id = self.env["procurement.group"].create({'name': vals.get('name')}).id if not vals.get('procurement_group_id'): if product_id.product_tmpl_id.single_manufacturing: - if product_id.categ_id.name == '成品' and is_self_process: - - vals['procurement_group_id'] = group_id + vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided] continue if product_id.id not in product_group_id.keys(): procurement_group_vals = self._prepare_procurement_group_vals(vals) @@ -1555,7 +1555,7 @@ class MrpProduction(models.Model): else: vals['procurement_group_id'] = product_group_id[product_id.id] else: - vals['procurement_group_id'] = group_id + vals['procurement_group_id'] = is_custemer_group_id[is_customer_provided] return super(MrpProduction, self).create(vals_list) @api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 96c2ea84..0f29d2fd 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -44,7 +44,9 @@ class ResMrpWorkOrder(models.Model): ('ZM', 'ZM'), ('FM', 'FM'), ('YC', 'YC'), - ('QC', 'QC')], string="加工面", compute='_compute_processing_panel_selection', store=True) + ('QC', 'QC'), + ('HC', 'HC'), + ('ZC', 'ZC')], string="加工面", compute='_compute_processing_panel_selection', store=True) sequence = fields.Integer(string='工序') routing_type = fields.Selection([ ('装夹预调', '装夹预调'), @@ -71,7 +73,7 @@ class ResMrpWorkOrder(models.Model): @api.depends('processing_panel') def _compute_processing_panel_selection(self): for record in self: - if record.processing_panel in ['ZM', 'FM', 'YC', 'QC']: + if record.processing_panel in ['ZM', 'FM', 'YC', 'QC', 'HC', 'ZC']: record.processing_panel_selection = record.processing_panel else: record.processing_panel_selection = False @@ -1268,13 +1270,14 @@ class ResMrpWorkOrder(models.Model): # 生成工件配送单 record.workpiece_delivery_ids = record._json_workpiece_delivery_list() if record.routing_type == 'CNC加工' or record.individuation_page_PTD is True: - record.process_state = '待解除装夹' - # record.write({'process_state': '待加工'}) - record.production_id.process_state = '待解除装夹' - self.env['sf.production.plan'].sudo().search([('name', '=', record.production_id.name)]).write({ - 'state': 'finished', - 'actual_end_time': datetime.now() - }) + if record.routing_type == 'CNC加工': + record.process_state = '待解除装夹' + # record.write({'process_state': '待加工'}) + record.production_id.process_state = '待解除装夹' + self.env['sf.production.plan'].sudo().search([('name', '=', record.production_id.name)]).write({ + 'state': 'finished', + 'actual_end_time': datetime.now() + }) record.production_id.write({'detection_result_ids': [(0, 0, { 'rework_reason': record.reason, 'detailed_reason': record.detailed_reason, @@ -1363,7 +1366,7 @@ class ResMrpWorkOrder(models.Model): if record.check_ids.filtered(lambda qc: qc.quality_state in ('waiting', 'none')): check_ids = record.check_ids.filtered(lambda qc: qc.quality_state in ('waiting', 'none')) if record.test_results == '合格': - check_ids.write({'test_results': None}) + check_ids.write({'test_results': record.test_results}) for check_id in check_ids: check_id.do_pass() elif record.test_results in ('返工', '报废'): diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index ad2e7fe4..205f56cc 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -87,7 +87,7 @@ - False + false diff --git a/sf_quality/models/quality.py b/sf_quality/models/quality.py index bacf7031..b76adaa8 100644 --- a/sf_quality/models/quality.py +++ b/sf_quality/models/quality.py @@ -17,6 +17,7 @@ class QualityCheck(models.Model): ('fail', '失败的')], string='状态', tracking=True, store=True, default='none', copy=False, compute='_compute_quality_state') + work_state = fields.Selection(related='workorder_id.state', string='工单状态') processing_panel = fields.Char(related='workorder_id.processing_panel', string='加工面') production_line_id = fields.Many2one(related='workorder_id.production_line_id', diff --git a/sf_quality/views/quality_check_view.xml b/sf_quality/views/quality_check_view.xml index c1b2ae40..48da0d37 100644 --- a/sf_quality/views/quality_check_view.xml +++ b/sf_quality/views/quality_check_view.xml @@ -6,6 +6,8 @@ + + - - - - + + + + + + @@ -44,6 +48,12 @@ + + {'invisible': ['|',('quality_state', '!=', 'fail'),('work_state','=', 'done')]} + + + {'invisible': ['|',('quality_state', '!=', 'pass'),('work_state','=', 'done')]} + @@ -66,6 +76,10 @@ + + + + \ No newline at end of file diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 2aa6f644..73837271 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -371,15 +371,15 @@ class RePurchaseOrder(models.Model): pp.purchase_id = [(6, 0, [purchase_order.id])] # self.env.cr.commit() - @api.onchange('order_line') - def _onchange_order_line(self): - for order in self: - if order.order_line: - line = order.order_line - product = line.product_id - product_id = product.ids - if len(product_id) != len(line): - raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name) + # @api.onchange('order_line') + # def _onchange_order_line(self): + # for order in self: + # if order.order_line: + # line = order.order_line + # product = line.product_id + # product_id = product.ids + # if len(product_id) != len(line): + # raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name) def button_confirm(self): result = super(RePurchaseOrder, self).button_confirm() diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 9fcfbd9e..1c96bf59 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -285,7 +285,7 @@ create_date desc - False + false delivery_warning == 'warning' delivery_warning == 'overdue'