Skip to content

Commit

Permalink
[ADD] sipreco_subsidy_management: tickets stages constrains
Browse files Browse the repository at this point in the history
closes #541

Signed-off-by: Juan Carreras <jc@adhoc.com.ar>
  • Loading branch information
mav-adhoc committed May 7, 2024
1 parent 64f5289 commit a7e5923
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 9 additions & 1 deletion sipreco_subsidy_management/models/subsidy_ticket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from odoo import fields, models, api, _
import odoo.http as http
from odoo.exceptions import ValidationError
from odoo.exceptions import ValidationError, UserError
import stdnum

class PublicBudgetSubsidyTicket(models.Model):
Expand Down Expand Up @@ -95,3 +95,11 @@ def name_get(self):
name_with_year = "%s (#%d) - %d" % (ticket.name, ticket._origin.id, year)
result.append((ticket.id, name_with_year))
return result

@api.constrains('stage_id')
def _check_expedient(self):
''' Check if tickets has an expedient associated in order to change to the expedient stage '''
if not self.expedient_id and self.stage_id.name == "Tramite Administrativo":
raise UserError(_('El ticket debe tener un tramite administrativo asociado para pasarlo a esta etapa'))
if self.expedient_id and self.stage_id.name != "Tramite Administrativo":
raise UserError(_('El ticket tiene un tramite administrativo asociado, por lo tanto no puede retroceder una etapa'))
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ def confirm(self):

expedient = self.env['public_budget.expedient'].create(vals)
tickets.write({'expedient_id': expedient.id})
# El cambio de etapa queda como comentario por ahora por pedido del cmr
# stage = self.env['helpdesk.stage'].search([('name', '=', "Tramite Administrativo")], limit=1)
# tickets.write({'stage_id': stage.id})
stage = self.env['helpdesk.stage'].search([('name', '=', "Tramite Administrativo")], limit=1)
tickets.write({'stage_id': stage.id})

action = self.env["ir.actions.actions"]._for_xml_id(
'public_budget.action_public_budget_expedient_expedients')
Expand Down

0 comments on commit a7e5923

Please sign in to comment.