diff --git a/public_budget/models/expedient.py b/public_budget/models/expedient.py
index 5464a30f..ae76541c 100644
--- a/public_budget/models/expedient.py
+++ b/public_budget/models/expedient.py
@@ -260,10 +260,10 @@ def _compute_year(self):
@api.depends('supplier_ids', 'description')
def _compute_cover(self):
for rec in self:
- supplier_names = [x.name for x in rec.supplier_ids]
+ # supplier_names = [x.name for x in rec.supplier_ids]
cover = rec.description
- if supplier_names:
- cover += ' - ' + ', '.join(supplier_names)
+ # if supplier_names:
+ # cover += ' - ' + ', '.join(supplier_names)
rec.cover = cover
def action_cancel_open(self):
diff --git a/public_budget/security/public_budget_group.xml b/public_budget/security/public_budget_group.xml
index 96b650e7..e43e4160 100644
--- a/public_budget/security/public_budget_group.xml
+++ b/public_budget/security/public_budget_group.xml
@@ -47,6 +47,13 @@
+
+ Portal - Subsidios
+
+
+
+
+
Secretaria
Secretaria
diff --git a/public_budget/views/expedient_views.xml b/public_budget/views/expedient_views.xml
index c860961b..65fd469f 100644
--- a/public_budget/views/expedient_views.xml
+++ b/public_budget/views/expedient_views.xml
@@ -74,7 +74,7 @@
-
+
diff --git a/sipreco_subsidy_management/__init__.py b/sipreco_subsidy_management/__init__.py
index 0650744f..aee8895e 100644
--- a/sipreco_subsidy_management/__init__.py
+++ b/sipreco_subsidy_management/__init__.py
@@ -1 +1,2 @@
from . import models
+from . import wizards
diff --git a/sipreco_subsidy_management/__manifest__.py b/sipreco_subsidy_management/__manifest__.py
index c3627ffe..f5dc38f1 100644
--- a/sipreco_subsidy_management/__manifest__.py
+++ b/sipreco_subsidy_management/__manifest__.py
@@ -1,6 +1,6 @@
{
'name': 'Public Budget Subsidy Management',
- 'version': "15.0.1.0.0",
+ 'version': "15.0.1.2.0",
'author': 'ADHOC SA,Odoo Community Association (OCA)',
'website': 'www.adhoc.com.ar',
'category': 'Accounting & Finance',
@@ -12,15 +12,21 @@
'reports/subsidy_form_report.xml',
'reports/subsidy_report.xml',
'reports/subsidy_report_resolution.xml',
+ 'reports/report_ticket_template.xml',
'views/subsidy_views.xml',
+ 'views/subsidy_ticket_views.xml',
'views/transaction_type_views.xml',
'views/subsidy_approval_arrangement_views.xml',
'views/subsidy_note_type_views.xml',
'views/subsidy_resolution_views.xml',
+ 'views/subsidy_ticket_director_views.xml',
'security/ir.model.access.csv',
'data/sequence_data.xml',
'data/subsidy_note_type_data.xml',
'data/cron.xml',
+ 'data/ir_actions_server_data.xml',
+ 'wizards/create_expedients_wizard_views.xml',
+ 'views/expedient_views.xml'
],
'demo': [
'demo/public_budget.transaction_type.csv',
@@ -28,6 +34,7 @@
],
'depends': [
'public_budget',
+ 'helpdesk'
],
'installable': True,
}
diff --git a/sipreco_subsidy_management/data/ir_actions_server_data.xml b/sipreco_subsidy_management/data/ir_actions_server_data.xml
new file mode 100644
index 00000000..2c7fb175
--- /dev/null
+++ b/sipreco_subsidy_management/data/ir_actions_server_data.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ Generar Expediente
+
+
+ code
+
+action = env["ir.actions.act_window"]._for_xml_id('sipreco_subsidy_management.action_create_expedients_wizard')
+helpdesk_tickets = records.filtered(lambda x: x.stage_id.name in ['Ticket', 'Aprobado'])
+action['context'] = {'active_ids': helpdesk_tickets.ids}
+
+
+
+
diff --git a/sipreco_subsidy_management/models/__init__.py b/sipreco_subsidy_management/models/__init__.py
index d428dd73..acabced8 100644
--- a/sipreco_subsidy_management/models/__init__.py
+++ b/sipreco_subsidy_management/models/__init__.py
@@ -5,4 +5,6 @@
from . import subsidy_note_type
from . import subsidy_resolution
from . import subsidy_resolution_line
+from . import subsidy_ticket
from . import transaction_type
+from . import expedient
diff --git a/sipreco_subsidy_management/models/expedient.py b/sipreco_subsidy_management/models/expedient.py
new file mode 100644
index 00000000..3b9c1e79
--- /dev/null
+++ b/sipreco_subsidy_management/models/expedient.py
@@ -0,0 +1,18 @@
+from odoo import models, fields
+
+
+class PublicBudgetExpedient(models.Model):
+
+ _inherit = 'public_budget.expedient'
+
+ purchase_order_ids = fields.One2many(
+ 'helpdesk.ticket',
+ 'expedient_id',
+ )
+
+ def action_open_subsidy_ticket(self):
+ action = self.env["ir.actions.actions"]._for_xml_id("helpdesk.helpdesk_ticket_action_main_tree")
+ action['context'] = {}
+ all_child = self.with_context(active_test=False).search([('id', 'child_of', self.ids)])
+ action['domain'] = [('expedient_id', 'in', self.ids)]
+ return action
diff --git a/sipreco_subsidy_management/models/subsidy_ticket.py b/sipreco_subsidy_management/models/subsidy_ticket.py
new file mode 100644
index 00000000..5dfef91d
--- /dev/null
+++ b/sipreco_subsidy_management/models/subsidy_ticket.py
@@ -0,0 +1,71 @@
+from odoo import fields, models, api, _
+import odoo.http as http
+from odoo.exceptions import ValidationError
+import stdnum
+
+class PublicBudgetSubsidyTicket(models.Model):
+
+ _inherit = 'helpdesk.ticket'
+
+ dni = fields.Char(
+ size=8,
+ string="DNI",
+ required=True,
+ )
+ currency_id = fields.Many2one(
+ 'res.currency',
+ related='company_id.currency_id',
+ readonly=True,
+ )
+ amount = fields.Monetary(
+ required=True,
+ currency_field='currency_id',
+ )
+ cbu = fields.Char(
+ size=22,
+ string="CBU",
+ required=True,
+ )
+ photo_dni = fields.Binary(
+ string="Foto DNI",
+ store=True,
+ )
+ expedient_id = fields.Many2one(
+ "public_budget.expedient",
+ string="Expediente",
+ copy=False,
+ readonly=True,
+ )
+ responsible_user = fields.Many2one(
+ 'res.users',
+ string="Usuario Responsable",
+ readonly=True,
+ )
+
+ @api.constrains('cbu')
+ def _check_cbu_length(self):
+ for partner in self:
+ if partner.cbu and len(partner.cbu) != 22:
+ raise ValidationError("El CBU debe tener 22 caracteres.")
+
+ @api.constrains('dni')
+ def _check_dni_length(self):
+ for partner in self:
+ if partner.dni and len(partner.dni) != 8:
+ raise ValidationError("El DNI debe tener 8 caracteres.")
+
+ # def action_view_ticket(self):
+ # self.ensure_one()
+ # action = self.env["ir.actions.act_window"]._for_xml_id(
+ # 'sipreco_subsidy_management.action_sipreco_subsidy_management_subsidy_tickets')
+ # action['domain'] = [('id', 'in', self.ticket_ids.ids)]
+ # return action
+
+ @api.model_create_multi
+ def create(self, list_value):
+ tickets = super().create(list_value)
+ for ticket in tickets:
+ user = http.request.env.user
+ if user:
+ ticket.responsible_user = user
+ return tickets
diff --git a/sipreco_subsidy_management/reports/report_subsidy_tickets_resolution.ods b/sipreco_subsidy_management/reports/report_subsidy_tickets_resolution.ods
new file mode 100644
index 00000000..9e58ceec
Binary files /dev/null and b/sipreco_subsidy_management/reports/report_subsidy_tickets_resolution.ods differ
diff --git a/sipreco_subsidy_management/reports/report_ticket_template.xml b/sipreco_subsidy_management/reports/report_ticket_template.xml
new file mode 100644
index 00000000..79f515b0
--- /dev/null
+++ b/sipreco_subsidy_management/reports/report_ticket_template.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+ Reporte Tabla Resoluciones de Subsidios
+ helpdesk.ticket
+ subsidy_tickets_resolution_report
+ aeroo
+ oo-ods
+ sipreco_subsidy_management/reports/report_subsidy_tickets_resolution.ods
+ file
+
+ specified
+
+
+ report
+
+
+
+ Resolucion INSTIT
+ helpdesk.ticket
+ subsidy_tickets_resolution_INSTIT
+ aeroo
+ oo-odt
+ sipreco_subsidy_management/reports/subsidy_tickets_resolution_INSTIT.odt
+ file
+
+ specified
+
+
+ report
+
+
+
+ Resolucion COMUN
+ helpdesk.ticket
+ subsidy_tickets_resolution_report_COMUN
+ aeroo
+ oo-odt
+ sipreco_subsidy_management/reports/subsidy_tickets_resolution_COMUN.odt
+ file
+
+ specified
+
+
+ report
+
+
diff --git a/sipreco_subsidy_management/reports/subsidy_tickets_resolution_COMUN.odt b/sipreco_subsidy_management/reports/subsidy_tickets_resolution_COMUN.odt
new file mode 100644
index 00000000..f2996d1e
Binary files /dev/null and b/sipreco_subsidy_management/reports/subsidy_tickets_resolution_COMUN.odt differ
diff --git a/sipreco_subsidy_management/reports/subsidy_tickets_resolution_INSTIT.odt b/sipreco_subsidy_management/reports/subsidy_tickets_resolution_INSTIT.odt
new file mode 100644
index 00000000..d279ae2a
Binary files /dev/null and b/sipreco_subsidy_management/reports/subsidy_tickets_resolution_INSTIT.odt differ
diff --git a/sipreco_subsidy_management/security/ir.model.access.csv b/sipreco_subsidy_management/security/ir.model.access.csv
index abf7b8e7..799489df 100644
--- a/sipreco_subsidy_management/security/ir.model.access.csv
+++ b/sipreco_subsidy_management/security/ir.model.access.csv
@@ -15,3 +15,4 @@ access_public_budget_subsidy_note_type_account_manager,access_public_budget_subs
access_public_budget_subsidy_note_type_all,access_public_budget_subsidy_note_type_all,model_public_budget_subsidy_note_type,,1,0,0,0
access_public_budget_subsidy_resolution_secretary_user,access_public_budget_subsidy_resolution_secretary_user,model_public_budget_subsidy_resolution,public_budget.group_secretary_usuario,1,1,1,1
access_public_budget_subsidy_resolution_line_secretary_user,access_public_budget_subsidy_resolution_line_secretary_user,model_public_budget_subsidy_resolution_line,public_budget.group_secretary_usuario,1,1,1,1
+access_public_budget_create_expedients_wizard,access_public_budget_create_expedients_wizard,model_public_budget_create_expedients_wizard,base.group_user,1,1,1,0
diff --git a/sipreco_subsidy_management/views/expedient_views.xml b/sipreco_subsidy_management/views/expedient_views.xml
new file mode 100644
index 00000000..84389bde
--- /dev/null
+++ b/sipreco_subsidy_management/views/expedient_views.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ public_budget.expedient.form
+ public_budget.expedient
+
+
+
+
+
+
diff --git a/sipreco_subsidy_management/views/subsidy_ticket_director_views.xml b/sipreco_subsidy_management/views/subsidy_ticket_director_views.xml
new file mode 100644
index 00000000..4dee02af
--- /dev/null
+++ b/sipreco_subsidy_management/views/subsidy_ticket_director_views.xml
@@ -0,0 +1,14 @@
+
+
+
+ subsidy.ticket.director.form
+ helpdesk.ticket
+
+
+
+
+ 0
+
+
+
+
diff --git a/sipreco_subsidy_management/views/subsidy_ticket_views.xml b/sipreco_subsidy_management/views/subsidy_ticket_views.xml
new file mode 100644
index 00000000..254bb397
--- /dev/null
+++ b/sipreco_subsidy_management/views/subsidy_ticket_views.xml
@@ -0,0 +1,119 @@
+
+
+
+
+ subsidy.ticket.form
+ helpdesk.ticket
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+ 1
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+
+ subsidy.ticket.tree
+ helpdesk.ticket
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+ 1
+
+
+ 1
+
+
+ 1
+
+
+
+
+
+ subsidy.ticket.kanban
+ helpdesk.ticket
+
+
+
+
+ DNI:
+
+
+
+ $
+
+
+
+
+
+ Expediente:
+
+
+
+
+ 1
+
+
+ 1
+
+
+ 1
+
+
+ 1
+
+
+ 1
+
+
+
+
+
+ subsidy.ticket.search
+ helpdesk.ticket
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sipreco_subsidy_management/wizards/__init__.py b/sipreco_subsidy_management/wizards/__init__.py
new file mode 100644
index 00000000..22a272d1
--- /dev/null
+++ b/sipreco_subsidy_management/wizards/__init__.py
@@ -0,0 +1 @@
+from . import create_expedients_wizard
diff --git a/sipreco_subsidy_management/wizards/create_expedients_wizard.py b/sipreco_subsidy_management/wizards/create_expedients_wizard.py
new file mode 100644
index 00000000..ce3040d1
--- /dev/null
+++ b/sipreco_subsidy_management/wizards/create_expedients_wizard.py
@@ -0,0 +1,75 @@
+from odoo import models, fields, api, _, Command
+from odoo.exceptions import UserError
+
+
+class PublicBudgetCreateExepedientsWizard(models.TransientModel):
+ _name = "public_budget.create.expedients.wizard"
+ _description = "public_budget.create.expedients.wizard"
+
+ reference = fields.Char(
+ required=False
+ )
+ founder_id = fields.Many2one(
+ 'public_budget.expedient_founder',
+ required=True
+ )
+ category_id = fields.Many2one(
+ 'public_budget.expedient_category',
+ required=True
+ )
+ first_location_id = fields.Many2one(
+ 'public_budget.location',
+ required=True,
+ )
+ user_location_ids = fields.Many2many(
+ 'public_budget.location',
+ 'public_budget_create_expedients_location_rel',
+ default=lambda self: self.env.user.location_ids.ids,
+ )
+ pages = fields.Integer(
+ required=True,
+ )
+ helpdesk_ticket_ids = fields.Many2one(
+ 'helpdesk.ticket',
+ # default=lambda self: self._default_helpdesk_tickets(),
+ )
+
+ # def _default_helpdesk_tickets(self):
+ # active_tickets_ids = self._context.get('active_ids') or []
+ # helpdesk_tickets = self.env['helpdesk.ticket'].browse(active_tickets_ids)
+ # return helpdesk_tickets.ids
+
+ def confirm(self):
+ active_tickets_ids = self._context.get('active_ids') or []
+ tickets = self.env['helpdesk.ticket'].browse(active_tickets_ids)
+ if tickets.expedient_id:
+ raise UserError(_('Uno de los tickets ya tiene un expediente asociado'))
+ if not tickets:
+ raise UserError(_('Los tickets deben estar aprobados para poder generar un expeiente'))
+ if len(set(tickets.mapped('dni'))) != len(tickets.mapped('dni')):
+ raise UserError('No puede haber varios tickets con el mismo DNI en el mismo expediente.')
+ vals = {
+ 'description': tickets[0].name,
+ 'supplier_ids': [Command.set(tickets.partner_id.ids)],
+ 'reference': self.reference,
+ 'founder_id': self.founder_id.id,
+ 'category_id': self.category_id.id,
+ 'first_location_id': self.first_location_id.id,
+ 'pages': self.pages,
+ }
+
+ expedient = self.env['public_budget.expedient'].create(vals)
+ # we do with sudo because in case that an user to only allow to read PO try to create an expedient
+ # if came from an requisition.
+ tickets.write({'expedient_id': expedient.id})
+ stage = self.env['helpdesk.stage'].search([('name', '=', "Resolucion")], limit=1)
+ tickets.write({'stage_id': stage.id})
+
+ action = self.env["ir.actions.actions"]._for_xml_id(
+ 'public_budget.action_public_budget_expedient_expedients')
+
+ if expedient:
+ res = self.env.ref('public_budget.view_public_budget_expedient_form', False)
+ action['views'] = [(res and res.id or False, 'form')]
+ action['res_id'] = expedient.id
+ return action
diff --git a/sipreco_subsidy_management/wizards/create_expedients_wizard_views.xml b/sipreco_subsidy_management/wizards/create_expedients_wizard_views.xml
new file mode 100644
index 00000000..abe8bfa7
--- /dev/null
+++ b/sipreco_subsidy_management/wizards/create_expedients_wizard_views.xml
@@ -0,0 +1,34 @@
+
+
+
+ Create Expedients Wizard
+ public_budget.create.expedients.wizard
+
+
+
+
+
+
+ Asistente de creacion de Expedientes
+ public_budget.create.expedients.wizard
+ form
+ new
+
+
+