Accept Merge Request #1846: (feature/库存优化_6 -> develop)

Merge Request: Merge branch 'feature/库存优化_5' into feature/库存优化_6

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1846
This commit is contained in:
禹翔辉
2025-02-25 11:30:39 +08:00
committed by Coding
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: