diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 9f5a7733..96a35221 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -455,7 +455,8 @@ class ProductionLot(models.Model): [('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', product.name)], limit=1, order='name desc') move_line_id = self.env['stock.move.line'].sudo().search( - [('product_id', '=', product.id), ('lot_name', 'ilike', product.name)], limit=1, order='lot_name desc') + [('company_id', '=', company.id), ('product_id', '=', product.id), ('lot_name', 'ilike', product.name)], + limit=1, order='lot_name desc') if last_serial or move_line_id: return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name if ( not move_line_id or @@ -899,8 +900,8 @@ class ReStockMove(models.Model): lot_code = '%s-%s-%s' % ('%s-T-DJWL-%s' % ( product.cutting_tool_model_id.code.split('-')[0], product.cutting_tool_material_id.code), datetime.now().strftime("%Y%m%d"), origin) - move_line_ids = self.env['stock.move.line'].sudo().search([('lot_name', 'like', lot_code)], limit=1, - order='id desc') + move_line_ids = self.env['stock.move.line'].sudo().search( + [('company_id', '=', company.id), ('lot_name', 'like', lot_code)], limit=1, order='id desc') if not move_line_ids: lot_code = '%s-001' % lot_code else: @@ -937,7 +938,8 @@ class ReStockMove(models.Model): [('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', origin)], limit=1, order='id DESC') move_line_id = self.env['stock.move.line'].sudo().search( - [('product_id', '=', product.id), ('lot_name', 'ilike', origin)], limit=1, order='lot_name desc') + [('company_id', '=', company.id), ('product_id', '=', product.id), ('lot_name', 'ilike', origin)], + limit=1, order='lot_name desc') split_codes = product.cutting_tool_model_id.code.split('-') if last_serial or move_line_id: return "%s-T-%s-%s-%03d" % ( diff --git a/sf_quality/models/quality.py b/sf_quality/models/quality.py index fb8518e2..ebe30a71 100644 --- a/sf_quality/models/quality.py +++ b/sf_quality/models/quality.py @@ -40,6 +40,14 @@ class QualityCheck(models.Model): operation_id = fields.Many2one('mrp.routing.workcenter', '作业', store=True, compute='_compute_operation_id') is_inspect = fields.Boolean('需送检', related='point_id.is_inspect') + lot_name = fields.Char('批次/序列号 名称', compute='_compute_lot_name', store=True) + + @api.depends('move_line_id', 'move_line_id.lot_name') + def _compute_lot_name(self): + for qc in self: + if qc.move_line_id: + qc.lot_name = qc.move_line_id.lot_name + @api.depends('point_id.operation_id') def _compute_operation_id(self): for qc in self: