fix smart button Generated Lots error

This commit is contained in:
Suherdy Yacob 2025-12-29 10:54:25 +07:00
parent e912961a2d
commit 816bd3bd71
8 changed files with 21 additions and 3 deletions

Binary file not shown.

View File

@ -39,13 +39,31 @@ class StockPicking(models.Model):
subcontract_moves = self.move_ids.filtered('is_subcontract')
lot_ids = subcontract_moves.move_line_ids.mapped('lot_id').ids
if not lot_ids:
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': 'No Lots Found',
'message': 'No lots have been generated for subcontract moves yet.',
'type': 'info',
'sticky': False,
}
}
# Create a simple action to view the lots
return {
'name': 'Generated Lots',
'name': f'Generated Lots ({len(lot_ids)})',
'type': 'ir.actions.act_window',
'res_model': 'stock.lot',
'view_mode': 'tree,form',
'view_mode': 'list,form',
'views': [(False, 'list'), (False, 'form')],
'domain': [('id', 'in', lot_ids)],
'context': {'create': False},
'context': {
'create': False,
'edit': False,
},
'target': 'current',
}
def action_auto_generate_lots_subcontract(self):