Merge branch 'feature/同步接口优化' into feature/库存优化_1

This commit is contained in:
yuxianghui
2025-02-17 12:42:55 +08:00

View File

@@ -611,6 +611,18 @@ class StockPicking(models.Model):
return sequence_id return sequence_id
def button_validate(self): def button_validate(self):
# 校验“收料入库单、客供料入库单”是否已经分配序列号,如果没有分配则自动分配
if self.picking_type_id.use_existing_lots is False and self.picking_type_id.use_create_lots is True:
for move in self.move_ids:
if not move.move_line_nosuggest_ids:
move.action_show_details()
else:
# 对已经生成的序列号做唯一性校验,如果重复则重新生成新的序列号
line_lot_name = [line_id.lot_name for line_id in move.move_line_nosuggest_ids]
lot_ids = self.env['stock.lot'].sudo().search([('name', 'in', line_lot_name)])
if lot_ids:
move.action_clear_lines_show_details()
move.action_show_details()
res = super().button_validate() res = super().button_validate()
picking_type_in = self.env.ref('sf_manufacturing.outcontract_picking_in').id picking_type_in = self.env.ref('sf_manufacturing.outcontract_picking_in').id
if res is True and self.picking_type_id.id == picking_type_in: if res is True and self.picking_type_id.id == picking_type_in:
@@ -844,7 +856,8 @@ class ReStockMove(models.Model):
self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin) self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin)
else: else:
self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id)
if self.picking_type_id.sequence_code == 'DL' and not self.move_line_nosuggest_ids: if (self.picking_type_id.use_existing_lots is False
and self.picking_type_id.use_create_lots is True and not self.move_line_nosuggest_ids):
self.action_assign_serial_show_details() self.action_assign_serial_show_details()
elif self.product_id.tracking == "lot": elif self.product_id.tracking == "lot":
self._put_tool_lot(self.company_id, self.product_id, self.origin) self._put_tool_lot(self.company_id, self.product_id, self.origin)