Skip to content
Extraits de code Groupes Projets
Valider 4da09897 rédigé par jordan's avatar jordan
Parcourir les fichiers

[add] button to change year of dossier adhésion

parent c6f099a3
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import wizard
......@@ -14,9 +14,11 @@
],
"data": [
"security/ir.model.access.csv",
# datas
"datas/ir_sequence_data.xml",
"datas/res_partner_federation_data.xml",
"datas/scop_adhesion_file_data.xml",
# views
"views/assets.xml",
"views/res_config_settings.xml",
"views/res_partner.xml",
......@@ -24,6 +26,9 @@
"views/res_partner_naf.xml",
"views/res_partner_project_invoicing_status.xml",
"views/scop_adhesion_file.xml",
# report
"report/report_scop_adhesion.xml",
# wizard
"wizard/scop_adhesion_year_wizard.xml",
]
}
......@@ -51,6 +51,14 @@ class ScopPartner(models.Model):
"Date de transmission du dossier à la CG")
date_bureau_validation = fields.Date("Date du bureau de validation")
lm_adhesion_id = fields.Many2one(
comodel_name='liste.ministere',
string='Liste Minsitère adhésion')
lm_adhesion_year = fields.Integer(
string="Année dossier adhésion",
related='lm_adhesion_id.year'
)
# Dossier UE
file_fse_open = fields.Boolean("Dossier FSE ouvert Oui/Non")
is_id_card = fields.Boolean("Carte d'identité reçue")
......@@ -99,7 +107,8 @@ class ScopPartner(models.Model):
:return: Form View LM
"""
self.ensure_one()
lm_adhesion = self.get_lm_adhesion()
if not self.lm_adhesion_id:
self.lm_adhesion_id = self.get_lm_adhesion()
form_id = self.env.ref(
"cgscop_liste_ministere.view_liste_ministere_delegue_form")
return {
......@@ -107,7 +116,7 @@ class ScopPartner(models.Model):
'res_model': 'liste.ministere',
'view_mode': 'form',
'views': [[form_id.id, 'form']],
'res_id': lm_adhesion.id,
'res_id': self.lm_adhesion_id.id,
}
def scop_liasse_adhesion(self):
......@@ -116,8 +125,9 @@ class ScopPartner(models.Model):
:return LF attached to LM adhesion or create new one type prévi
"""
self.ensure_one()
lm_adhesion = self.get_lm_adhesion()
liasse_adhesion = self.get_liasse_adhesion(lm_adhesion)
if not self.lm_adhesion_id:
self.lm_adhesion_id = self.get_lm_adhesion()
liasse_adhesion = self.get_liasse_adhesion(self.lm_adhesion_id)
year_adhesion = self.date_1st_sign.year
if not liasse_adhesion.year == year_adhesion:
liasse_adhesion.update({
......@@ -133,10 +143,26 @@ class ScopPartner(models.Model):
})
return action
def scop_change_year_dossier(self):
"""
Open wizard to change year dossier adhesion
:return:
"""
wizard = self.env['scop.adhesion.year.wizard']. \
create({'lm_adhesion_id': self.lm_adhesion_id.id})
return {
'name': "Modifier l'année du dossier",
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'scop.adhesion.year.wizard',
'res_id': wizard.id,
'target': 'new'
}
# ------------------------------------------------------
# Business methods
# ------------------------------------------------------
def get_lm_adhesion(self):
def get_lm_adhesion(self, year=False):
"""
- LM renouvellement existante en année N → on rattache à cette LM
- Pas de LM existante en année N
......@@ -145,19 +171,14 @@ class ScopPartner(models.Model):
- Pas de LM connue → on créée une LM inscription
"""
self.ensure_one()
if not self.date_1st_sign:
raise ValidationError(
"Pas de date de première signature en coop connue !")
if not self.date_realisation:
raise ValidationError(
"Pas de date de réalisation prévue !")
year_inscription = self.date_realisation.year
last_lm_ids = self.get_last_lm()
lm_adhesion = None
year = fields.Date.today().year if not year else year
if last_lm_ids:
lm_adhesion = last_lm_ids.filtered(
lambda lm: lm.year == year_inscription)
lambda lm: lm.year == year)
if not lm_adhesion:
if not last_lm_ids:
......@@ -170,7 +191,7 @@ class ScopPartner(models.Model):
type_lm = dossier_type_renouvellement_id
lm_adhesion = self.env['liste.ministere'].create({
'partner_id': self.id,
'year': year_inscription,
'year': year,
'type_id': type_lm
})
lm_adhesion.action_publish_without_extranet()
......
......@@ -36,12 +36,15 @@
<page name='scop_contacts' position="before">
<page name="adhesion_processus1" string="Processus d'Adhésion" attrs="{'invisible': ['|', ('is_cooperative', '!=', True), ('project_status','=','6_suivi')]}">
<header>
<button string="Dossier d'adhésion" type="object" name="scop_lm_adhesion" class="btn-warning"
<button string="Dossier d'adhésion" type="object" name="scop_lm_adhesion" class="btn-info"
attrs="{'invisible': [('project_status', 'not in', ('4_adhesion', '5_cg'))]}"
groups="cgscop_partner.group_add_period"/>
<button string="Données financières" type="object" name="scop_liasse_adhesion" class="btn-warning"
<button string="Données financières" type="object" name="scop_liasse_adhesion" class="btn-info"
attrs="{'invisible': [('project_status', 'not in', ('4_adhesion', '5_cg'))]}"
groups="cgscop_partner.group_add_period"/>
<button string="Modifier l'année du dossier" type="object" name="scop_change_year_dossier" class="btn-warning"
attrs="{'invisible': ['|', ('project_status', '!=', '4_adhesion'), ('lm_adhesion_id', '=', False)]}"
groups="cgscop_partner.group_add_period"/>
</header>
<div class="alert alert-danger" role="alert" attrs="{'invisible':['|', '|', ('write_date', '=', False), ('list_logs', '=', False), ('project_status', 'not in', ('4_adhesion', '5_cg'))]}">
<field class="o_field_header" name="list_logs" readonly="1"/>
......@@ -84,6 +87,8 @@
<field name="amount_convention" widget="monetary"/>
</group>
<group string="Phase d'adhésion" attrs="{'invisible':[('project_status','in',('1_information','2_pre-diagnostic','3_accompagnement'))]}">
<field name="lm_adhesion_id" invisible="1"/>
<field name="lm_adhesion_year"/>
<field name="file_full" widget="boolean_toggle"/>
<field name="date_transmission_cg"/>
<field name="date_bureau_validation"/>
......
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import scop_adhesion_year_wizard
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ScopAdhesionYearWizard(models.TransientModel):
_name = 'scop.adhesion.year.wizard'
_description = "Wizard: Changer l'année du dossier d'adhésion"
lm_adhesion_id = fields.Many2one(
comodel_name='liste.ministere',
string='Lm_adhesion_id',
required=False)
current_year = fields.Integer(
string='Année actuelle',
related='lm_adhesion_id.year')
choosen_year = fields.Selection(
[(year, str(year)) for year in
range(fields.Date.today().year - 3, fields.Date.today().year + 2)],
string='Année choisie')
# ------------------------------------------------------
# Actions / Buttons
# ------------------------------------------------------
def change_year(self):
"""
Change l'année du dossier d'adhésion pour le partner
:return:
"""
partner = self.lm_adhesion_id.partner_id
partner.lm_adhesion_id = partner.get_lm_adhesion(self.choosen_year)
return {'type': 'ir.actions.act_window_close'}
<?xml version="1.0"?>
<!-- Copyright 2021 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<record model="ir.ui.view" id="scop_adhesion_year_wizard_form_view">
<field name="name">scop.adhesion.year.wizard.form</field>
<field name="model">scop.adhesion.year.wizard</field>
<field name="arch" type="xml">
<form string="Changer l'année du dossier d'adhésion">
<group>
<field name="current_year"/>
<field name="choosen_year" required="1"/>
</group>
<footer>
<button name="change_year" type="object"
string="Valider" class="oe_highlight"/>
<button special="cancel" string="Annuler"/>
</footer>
</form>
</field>
</record>
</data>
</odoo>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter