处理由客供料入库单生成的质检单没有批次序列号问题

This commit is contained in:
yuxianghui
2025-02-25 11:22:41 +08:00
parent 6e94dc45a9
commit 0fd33831f1
2 changed files with 14 additions and 4 deletions

View File

@@ -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" % (

View File

@@ -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: