Skip to content

Commit

Permalink
[ADD] p13n_cmr: sipreco_subsidies
Browse files Browse the repository at this point in the history
  • Loading branch information
mav-adhoc committed Oct 9, 2023
1 parent 51c840f commit 5bf898b
Show file tree
Hide file tree
Showing 20 changed files with 439 additions and 5 deletions.
6 changes: 3 additions & 3 deletions public_budget/models/expedient.py
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions public_budget/security/public_budget_group.xml
Expand Up @@ -47,6 +47,13 @@
<field name="category_id" ref="category_public_budget_portal"/>
</record>

<record id="group_portal_subsidy" model="res.groups">
<field name="name">Portal - Subsidios</field>
<field name="share" eval="True"/>
<field name="implied_ids" eval="[(6, 0, [ref('base.group_portal')])]"/>
<field name="category_id" ref="category_public_budget_portal"/>
</record>

<record model="ir.module.category" id="category_secretaria">
<field name="name">Secretaria</field>
<field name="description">Secretaria</field>
Expand Down
2 changes: 1 addition & 1 deletion public_budget/views/expedient_views.xml
Expand Up @@ -74,7 +74,7 @@
<field name="final_location" states="closed,annulled"/>
<field name="pages"/>
<field name="parliamentary_expedient"/>
<field name="subsidy_expedient"/>
<field name="subsidy_expedient" invisible="1"/>
<field name="subsidy_recipient_doc" attrs="{'invisible': [('subsidy_expedient', '!=', True)]}" />
<field name="subsidy_amount" attrs="{'invisible': [('subsidy_expedient', '!=', True)]}" />
<field name="subsidy_approved" attrs="{'invisible': [('subsidy_expedient', '!=', True)]}" />
Expand Down
1 change: 1 addition & 0 deletions sipreco_subsidy_management/__init__.py
@@ -1 +1,2 @@
from . import models
from . import wizards
9 changes: 8 additions & 1 deletion 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',
Expand All @@ -12,22 +12,29 @@
'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',
'demo/subsidy_demo.xml',
],
'depends': [
'public_budget',
'helpdesk'
],
'installable': True,
}
16 changes: 16 additions & 0 deletions sipreco_subsidy_management/data/ir_actions_server_data.xml
@@ -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 Expediente</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>
2 changes: 2 additions & 0 deletions sipreco_subsidy_management/models/__init__.py
Expand Up @@ -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
18 changes: 18 additions & 0 deletions 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
71 changes: 71 additions & 0 deletions 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
Binary file not shown.
49 changes: 49 additions & 0 deletions sipreco_subsidy_management/reports/report_ticket_template.xml
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">

<!-- Printed Invoice -->
<record id="action_aeroo_subsidy_tickets_resolution_report" model="ir.actions.report">
<field name="name">Reporte Tabla Resoluciones de Subsidios</field>
<field name="model">helpdesk.ticket</field>
<field name="report_name">subsidy_tickets_resolution_report</field>
<field name="report_type">aeroo</field>
<field name="in_format">oo-ods</field>
<field name="report_file">sipreco_subsidy_management/reports/report_subsidy_tickets_resolution.ods</field>
<field name="tml_source">file</field>
<field name="out_format" ref="report_aeroo.report_mimetypes_xls_odt"/>
<field name="styles_mode">specified</field>
<field name="stylesheet_id" ref="public_budget.sipreco_stylesheet"/>
<field name="binding_model_id" ref="model_helpdesk_ticket"/>
<field name="binding_type">report</field>
</record>

<record id="action_aeroo_subsidy_tickets_resolution_INSTIT" model="ir.actions.report">
<field name="name">Resolucion INSTIT</field>
<field name="model">helpdesk.ticket</field>
<field name="report_name">subsidy_tickets_resolution_INSTIT</field>
<field name="report_type">aeroo</field>
<field name="in_format">oo-odt</field>
<field name="report_file">sipreco_subsidy_management/reports/subsidy_tickets_resolution_INSTIT.odt</field>
<field name="tml_source">file</field>
<field name="out_format" ref="report_aeroo.report_mimetypes_doc_odt"/>
<field name="styles_mode">specified</field>
<field name="stylesheet_id" ref="public_budget.sipreco_stylesheet"/>
<field name="binding_model_id" ref="model_helpdesk_ticket"/>
<field name="binding_type">report</field>
</record>

<record id="action_aeroo_subsidy_tickets_resolution_COMUN_report" model="ir.actions.report">
<field name="name">Resolucion COMUN</field>
<field name="model">helpdesk.ticket</field>
<field name="report_name">subsidy_tickets_resolution_report_COMUN</field>
<field name="report_type">aeroo</field>
<field name="in_format">oo-odt</field>
<field name="report_file">sipreco_subsidy_management/reports/subsidy_tickets_resolution_COMUN.odt</field>
<field name="tml_source">file</field>
<field name="out_format" ref="report_aeroo.report_mimetypes_doc_odt"/>
<field name="styles_mode">specified</field>
<field name="stylesheet_id" ref="public_budget.sipreco_stylesheet"/>
<field name="binding_model_id" ref="model_helpdesk_ticket"/>
<field name="binding_type">report</field>
</record>
</odoo>
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions sipreco_subsidy_management/security/ir.model.access.csv
Expand Up @@ -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
19 changes: 19 additions & 0 deletions sipreco_subsidy_management/views/expedient_views.xml
@@ -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>
14 changes: 14 additions & 0 deletions sipreco_subsidy_management/views/subsidy_ticket_director_views.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="subsidy_ticket_director_view_form" model="ir.ui.view">
<field name="name">subsidy.ticket.director.form</field>
<field name="model">helpdesk.ticket</field>
<field name="groups_id" eval="[(4, ref('public_budget.group_secretary_director'))]"/>
<field name="inherit_id" ref="subsidy_ticket_view_form"/>
<field name="arch" type="xml">
<field name="expedient_id" position="attributes">
<attribute name="readonly">0</attribute>
</field>
</field>
</record>
</odoo>

0 comments on commit 5bf898b

Please sign in to comment.