Skip to content
Extraits de code Groupes Projets
Valider bb1c9194 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[add] instances management

parent 7e26ca93
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -22,6 +22,7 @@
"views/scop_bordereau_cg.xml",
"views/scop_cotisation_cg_exo.xml",
"views/scop_cotisation_cg_exo_ur_notice.xml",
"views/scop_instance.xml",
# templates
"templates/report_scop_exo.xml"
]
......
......@@ -7,3 +7,4 @@ from . import scop_cotisation_cg
from . import scop_cotisation_cg_exo_ur_notice
from . import scop_cotisation_cg_exo
from . import scop_cotisation_cg_exo_line
from . import scop_instance
......@@ -310,6 +310,18 @@ class ScopCotisationExo(models.Model):
else:
raise UserError("Il est nécessaire de renseigner un avis final pour valider")
def set_favorable(self):
"""
Button function to set exo favorable on instance tree view
"""
self.final_notice = 'favorable'
def set_unfavorable(self):
"""
Button function to set exo unfavorable on instance tree view
"""
self.final_notice = 'unfavorable'
# ------------------------------------------------------
# Override ORM
# ------------------------------------------------------
......
# © 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from datetime import timedelta
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError
class ScopInstance(models.Model):
_inherit = "scop.instance"
is_type_exo = fields.Boolean("Exonérations")
exo_ids = fields.One2many(
comodel_name="scop.cotisation.cg.exo",
inverse_name="instance_id",
string="Exonérations"
)
all_exo_validated = fields.Boolean(compute="_compute_all_exo_validated", default=False)
# ------------------------------------------------------
# Computed fields / Search Fields
# ------------------------------------------------------
@api.multi
def _compute_all_exo_validated(self):
for instance in self:
exo_states = instance.exo_ids.mapped('state')
if not list(set(exo_states) - set(['done', 'cancel'])):
instance.all_exo_validated = True
else:
instance.all_exo_validated = False
# ------------------------------------------------------
# Button
# ------------------------------------------------------
def scop_valid_exo(self):
for exo in self.exo_ids:
if exo.state not in ['done', 'cancel']:
if not exo.date_exo_ok:
exo.date_exo_ok = fields.Date.to_date(self.date)
if not exo.final_notice:
exo.final_notice = 'favorable'
exo.validate_exo()
......@@ -105,7 +105,8 @@
Le nombre saisi dans le champ ci-dessous correspond au <strong>pourcentage de réduction</strong> appliqué aux échéances.
</div>
<field name="percent_quarter" attrs="{'invisible': [('type_exo', '!=', 'percent')]}"/>
<button name="create_lines" type="object" class="btn btn-info" string="Créer/Mettre à jour les lignes" attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}"></button>
<button name="create_lines" type="object" class="btn btn-info" string="Créer/Mettre à jour les lignes"
attrs="{'invisible': ['|', '|', ('state', 'in', ('done', 'cancel')), '&amp;', ('amount_quarter', '=', 0), ('type_exo', '=', 'amount'), '&amp;', ('percent_quarter', '=', 0), ('type_exo', '=', 'percent')]}"></button>
<div colspan="2">
<field name="exo_line_ids" attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}">
......
<?xml version="1.0"?>
<!-- Copyright 2021 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<record id="scop_instance_exo_form_view" model="ir.ui.view">
<field name="name">scop.instance.exo.form</field>
<field name="model">scop.instance</field>
<field name="inherit_id" ref="cgscop_instance.scop_instance_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='instance_type']" position="inside">
<field name="is_type_exo" widget="boolean_toggle"/>
</xpath>
<xpath expr="//page[@name='membership']" position="after">
<page name="exo" string="Exonérations" attrs="{'invisible':[('is_type_exo','!=',True)]}">
<field name="all_exo_validated" invisible="1"/>
<button name="scop_valid_exo"
type="object"
string="Valider toutes les exonérations"
confirm="Confirmez-vous la validation des exonérations ?"
class="btn-outline-info"
attrs="{'invisible': [('all_exo_validated', '=', True)]}"
/>
<field name="exo_ids" widget="many2many" domain="[('instance_id', '=', False)]" options="{'no_create': 1}">
<tree decoration-danger="final_notice == 'unfavorable'" decoration-success="final_notice == 'favorable'">
<field name="date_request"/>
<field name="partner_id"/>
<field name="source"/>
<field name="ur_notice"/>
<field name="date_exo_start"/>
<field name="date_exo_end"/>
<field name="nb_quarter"/>
<field name="amount_quarter" widget="monetary"/>
<field name="final_notice"/>
<field name="state"/>
<button name="set_favorable" type="object" icon="fa-check-circle-o" class="btn-outline-success"
attrs="{'invisible': ['|', ('final_notice', '=', 'favorable'), ('state', 'in', ['done', 'cancel'])]}"/>
<button name="set_unfavorable" type="object" icon="fa-times-circle-o" class="btn-outline-danger"
attrs="{'invisible': ['|', ('final_notice', '=', 'unfavorable'), ('state', 'in', ['done', 'cancel'])]}"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>
</data>
</odoo>
\ No newline at end of file
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