Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
341 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import models | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
sipreco_subsidy_management/data/ir_actions_server_data.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<!-- Generar expédientes --> | ||
<record model="ir.actions.server" id="action_generate_expedient"> | ||
<field name="name">Generar Expedientes</field> | ||
<field name="model_id" ref="helpdesk.model_helpdesk_ticket"/> | ||
<field name="binding_model_id" ref="helpdesk.model_helpdesk_ticket"/> | ||
<field name="state">code</field> | ||
<field name="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} | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from odoo import fields, models, api, _ | ||
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, | ||
|
||
) | ||
|
||
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<!-- Add contextual button on partner form view --> | ||
<record id="view_expedients_form" model="ir.ui.view"> | ||
<field name="name">public_budget.expedient.form</field> | ||
<field name="model">public_budget.expedient</field> | ||
<field name="inherit_id" ref="public_budget.view_public_budget_expedient_form"/> | ||
<field name="arch" type="xml"> | ||
<div name="button_box" position="inside"> | ||
<button class="oe_stat_button" type="object" | ||
name="action_open_subsidy_ticket" context="{'default_partner_id': active_id}" icon="fa-life-ring"> | ||
<div class="o_stat_info"> | ||
<span class="o_stat_text"> Subsidies</span> | ||
</div> | ||
</button> | ||
</div> | ||
</field> | ||
</record> | ||
</odoo> |
111 changes: 111 additions & 0 deletions
111
sipreco_subsidy_management/views/subsidy_ticket_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="subsidy_ticket_view_form" model="ir.ui.view"> | ||
<field name="name">subsidy.ticket.form</field> | ||
<field name="model">helpdesk.ticket</field> | ||
<field name="inherit_id" ref="helpdesk.helpdesk_ticket_view_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="company_id" position="after"> | ||
<field name="dni"/> | ||
<field name="amount" string="Monto" widget="monetary"/> | ||
<field name="cbu"/> | ||
<field name="photo_dni" widget="image" style="margin-top: 25px; margin-bottom: 25px;"/> | ||
<label for="description" string="Motivo"></label> | ||
</field> | ||
<field name="ticket_type_id" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
<field name="tag_ids" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
<field name="priority" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
<field name="team_id" position="before"> | ||
<field name="expedient_id"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="subsidy_ticket_view_tree" model="ir.ui.view"> | ||
<field name="name">subsidy.ticket.tree</field> | ||
<field name="model">helpdesk.ticket</field> | ||
<field name="inherit_id" ref="helpdesk.helpdesk_tickets_view_tree"/> | ||
<field name="arch" type="xml"> | ||
<field name="display_name" position="after"> | ||
<field name="expedient_id"/> | ||
</field> | ||
<field name="partner_id" position="after"> | ||
<field name="dni"/> | ||
<field name="amount" string="Monto"/> | ||
</field> | ||
<field name="activity_ids" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
<field name="priority" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
<field name="sla_deadline" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<record id="subsidy_ticket_view_kanban" model="ir.ui.view"> | ||
<field name="name">subsidy.ticket.kanban</field> | ||
<field name="model">helpdesk.ticket</field> | ||
<field name="inherit_id" ref="helpdesk.helpdesk_ticket_view_kanban"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//templates//field[@name='priority']" position="after"> | ||
<group> | ||
DNI: | ||
<field name="dni" string="DNI"/> | ||
</group> | ||
<group> | ||
$ | ||
<field name="amount" string="Monto" widget="monetary"/> | ||
</group> | ||
</xpath> | ||
<xpath expr="//templates//field[@name='ticket_type_id']" position="after"> | ||
<group> | ||
Expediente: | ||
<field name="expedient_id"/> | ||
</group> | ||
</xpath> | ||
<xpath expr="//templates//field[@name='activity_ids']" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</xpath> | ||
<xpath expr="//templates//field[@name='priority']" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</xpath> | ||
<xpath expr="//templates//field[@name='sla_deadline']" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</xpath> | ||
<xpath expr="//templates//field[@name='kanban_state']" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</xpath> | ||
<xpath expr="//templates//field[@name='user_id']" position="attributes"> | ||
<attribute name="invisible">1</attribute> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="subsidy_tickets_view_search" model="ir.ui.view"> | ||
<field name="name">subsidy.ticket.search</field> | ||
<field name="model">helpdesk.ticket</field> | ||
<field name="inherit_id" ref="helpdesk.helpdesk_tickets_view_search"/> | ||
<field name="arch" type="xml"> | ||
<search> | ||
<field name="dni" string="DNI"/> | ||
<field name="cbu" string="CBU"/> | ||
<field name="amount" string="Monto"/> | ||
<field name="expedient_id" string="Expediente"/> | ||
<group expand="0" string="Group By"> | ||
<filter string="Expediente" name="expedient_id" context="{'group_by': 'expedient_id'}"/> | ||
</group> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import create_expedients_wizard |
75 changes: 75 additions & 0 deletions
75
sipreco_subsidy_management/wizards/create_expedients_wizard.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not tickets: | ||
raise UserError(_('It has not approved the ticket/s to generate an expedient')) | ||
if tickets.expedient_id: | ||
raise UserError(_('One of the tickets has already an expedient associated')) | ||
if len(set(tickets.mapped('dni'))) != len(tickets.mapped('dni')): | ||
raise UserError('No puede haber dos 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 |
34 changes: 34 additions & 0 deletions
34
sipreco_subsidy_management/wizards/create_expedients_wizard_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="view_create_expedients_wizard_form" model="ir.ui.view"> | ||
<field name="name">Create Expedients Wizard</field> | ||
<field name="model">public_budget.create.expedients.wizard</field> | ||
<field name="arch" type="xml"> | ||
<form string="Asistente de Generacion de Expedientes"> | ||
<group> | ||
<field name="reference"/> | ||
<field name="founder_id"/> | ||
</group> | ||
<group> | ||
<field name="category_id"/> | ||
<field name="user_location_ids" invisible="1"/> | ||
<field name="first_location_id" domain="[('id', 'in',user_location_ids)]"/> | ||
<field name="pages"/> | ||
</group> | ||
<footer> | ||
<button name="confirm" string="Confirmar" type="object" class="oe_highlight"/> | ||
o | ||
<button string="Cancelar" class="oe_link" special="cancel" /> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_create_expedients_wizard" model="ir.actions.act_window"> | ||
<field name="name">Asistente de creacion de Expedientes</field> | ||
<field name="res_model">public_budget.create.expedients.wizard</field> | ||
<field name="view_mode">form</field> | ||
<field name="target">new</field> | ||
</record> | ||
|
||
</odoo> |