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

[add] new model scop_bordereau

parent f3dc4caa
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"security/security_rules.xml", "security/security_rules.xml",
"security/ir.model.access.csv", "security/ir.model.access.csv",
"views/res_config_settings.xml", "views/res_config_settings.xml",
"views/scop_bordereau_cg.xml",
"views/scop_cotisation_cg.xml", "views/scop_cotisation_cg.xml",
"views/union_regionale.xml", "views/union_regionale.xml",
] ]
......
...@@ -4,5 +4,6 @@ ...@@ -4,5 +4,6 @@
from . import account_invoice from . import account_invoice
from . import res_company from . import res_company
from . import res_config_settings from . import res_config_settings
from . import scop_bordereau_cg
from . import scop_cotisation_cg from . import scop_cotisation_cg
from . import union_regionale from . import union_regionale
...@@ -10,4 +10,8 @@ class ScopAccountInvoiceCG(models.Model): ...@@ -10,4 +10,8 @@ class ScopAccountInvoiceCG(models.Model):
cotisation_cg_id = fields.Many2one( cotisation_cg_id = fields.Many2one(
comodel_name='scop.cotisation.cg', comodel_name='scop.cotisation.cg',
string='Base de cotisation CG Scop') string='Base de cotisation CG Scop')
bordereau_id = fields.Many2one(
comodel_name='scop.bordereau',
string='Bordereau de rattachement',
required=False,
ondelete='cascade')
# © 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, api
class Bordereau (models.Model):
_name = 'scop.bordereau'
_description = 'Bordereau des cotisations CG'
name = fields.Char(
string='Nom',
compute='_compute_name')
base_cotisation_cg = fields.Many2one(
comodel_name='scop.cotisation.cg',
string='Base de cotisation CG',
required=False,
ondelete='cascade')
partner_id = fields.Many2one(
comodel_name='res.partner',
string='',
required=False)
payment_term_id = fields.Many2one(
comodel_name='account.payment.term',
string="Conditions de paiement",
required=True
)
account_invoice_ids = fields.One2many(
comodel_name='account.invoice',
inverse_name='bordereau_id',
string='Cotisations',
required=False)
state = fields.Selection([
('new', 'Brouillon'),
('ongoing', 'Validé'),
('end', 'Payé')],
string="Statut",
default='new',
store=True)
@api.multi
def _compute_name(self):
for bordereau in self:
bordereau.name = "Bordereau %s - %s" % (
bordereau.partner_id.name,
bordereau.base_cotisation_cg.year)
...@@ -261,14 +261,19 @@ class ScopCotisation(models.Model): ...@@ -261,14 +261,19 @@ class ScopCotisation(models.Model):
for member in members_to_invoice: for member in members_to_invoice:
liasse_id = self._get_liasse(member) liasse_id = self._get_liasse(member)
# Bordereau
bordereau_id = self.create_bordereau(member)
# Invoice cotiz CG # Invoice cotiz CG
amount_cg = self.get_cotiz_cg(member, liasse_id) amount_cg = self.get_cotiz_cg(member, liasse_id)
invoice_cotiz_cg = self.create_contribution( invoice_cotiz_cg = self.create_contribution(
product_cg, member, liasse_id, amount_cg) product_cg, member, liasse_id, amount_cg)
invoice_cotiz_cg.write({ invoice_cotiz_cg.write({
'type_contribution_id': type_cotisation_cg.id, 'type_contribution_id': type_cotisation_cg.id,
'cotisation_cg_id': self.id 'cotisation_cg_id': self.id,
'bordereau_id': bordereau_id.id
}) })
# Invoice cotiz Fede # Invoice cotiz Fede
if member.is_federation_com: if member.is_federation_com:
amount_fede = self.get_cotiz_fede(member, liasse_id) amount_fede = self.get_cotiz_fede(member, liasse_id)
...@@ -276,7 +281,8 @@ class ScopCotisation(models.Model): ...@@ -276,7 +281,8 @@ class ScopCotisation(models.Model):
product_fede, member, liasse_id, amount_fede) product_fede, member, liasse_id, amount_fede)
invoice_cotiz_fede.write({ invoice_cotiz_fede.write({
'type_contribution_id': type_cotisation_fede.id, 'type_contribution_id': type_cotisation_fede.id,
'cotisation_cg_id': self.id 'cotisation_cg_id': self.id,
'bordereau_id': bordereau_id.id
}) })
# Invoice cotiz UR HDF # Invoice cotiz UR HDF
...@@ -286,7 +292,8 @@ class ScopCotisation(models.Model): ...@@ -286,7 +292,8 @@ class ScopCotisation(models.Model):
product_hdf, member, liasse_id, amount_hdf) product_hdf, member, liasse_id, amount_hdf)
invoice_cotiz_hdf.write({ invoice_cotiz_hdf.write({
'type_contribution_id': type_cotisation_ur.id, 'type_contribution_id': type_cotisation_ur.id,
'cotisation_cg_id': self.id 'cotisation_cg_id': self.id,
'bordereau_id': bordereau_id.id
}) })
# Invoice cotiz UR Med # Invoice cotiz UR Med
...@@ -296,7 +303,8 @@ class ScopCotisation(models.Model): ...@@ -296,7 +303,8 @@ class ScopCotisation(models.Model):
product_med, member, liasse_id, amount_med) product_med, member, liasse_id, amount_med)
invoice_cotiz_med.write({ invoice_cotiz_med.write({
'type_contribution_id': type_cotisation_ur.id, 'type_contribution_id': type_cotisation_ur.id,
'cotisation_cg_id': self.id 'cotisation_cg_id': self.id,
'bordereau_id': bordereau_id.id
}) })
invoice_view = self.cotiz_view() invoice_view = self.cotiz_view()
...@@ -328,6 +336,25 @@ class ScopCotisation(models.Model): ...@@ -328,6 +336,25 @@ class ScopCotisation(models.Model):
'target': 'current', 'target': 'current',
} }
def create_bordereau(self, member):
"""
Création du bordereau de cotisations
:param member:
:return bordereau_id:
"""
existing_bordereau = self.env['scop.bordereau'].search([
('partner_id', '=', member.id)
])
if not existing_bordereau:
bordereau = self.env['scop.bordereau'].create({
'partner_id': member.id,
'payment_term_id': self.payment_term_id.id,
'base_cotisation_cg': self.id,
})
return bordereau
else:
return existing_bordereau
# ------------------------------------------------------ # ------------------------------------------------------
# Global functions # Global functions
# ------------------------------------------------------ # ------------------------------------------------------
...@@ -524,7 +551,8 @@ class ScopCotisation(models.Model): ...@@ -524,7 +551,8 @@ class ScopCotisation(models.Model):
# Taux de sociétariat # Taux de sociétariat
if partner.staff_ids: if partner.staff_ids:
staff_id = partner.staff_ids.sorted(key=lambda l: l.year)[-1] staff_id = partner.staff_ids.sorted(
key=lambda l: l.effective_date)[-1]
if staff_id.staff_count > 0: if staff_id.staff_count > 0:
societariat_rate =\ societariat_rate =\
staff_id.staff_shareholder_count / staff_id.staff_count staff_id.staff_shareholder_count / staff_id.staff_count
......
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_scop_cotisation_cg,access_scop_cotisation_cg,model_scop_cotisation_cg,account.group_account_manager,1,1,1,0 access_scop_cotisation_cg,access_scop_cotisation_cg,model_scop_cotisation_cg,account.group_account_manager,1,1,1,0
admin_access_scop_cotisation_cg,admin_access_scop_cotisation_cg,model_scop_cotisation_cg,cgscop_partner.group_cg_administrator,1,1,1,1 admin_access_scop_cotisation_cg,admin_access_scop_cotisation_cg,model_scop_cotisation_cg,cgscop_partner.group_cg_administrator,1,1,1,1
access_scop_bordereau,access_scop_bordereau,model_scop_bordereau,account.group_account_manager,1,1,1,0
admin_access_scop_bordereau,admin_access_scop_bordereau,model_scop_bordereau,cgscop_partner.group_cg_administrator,1,1,1,1
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2021 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<record id="scop_bordereau_form_view" model="ir.ui.view">
<field name="name">scop.bordereau.form</field>
<field name="model">scop.bordereau</field>
<field name="arch" type="xml">
<form string="Bordereaux">
<header>
<field name="state" widget="statusbar" clickable="False"/>
</header>
<sheet>
<div class="oe_title">
<label for="name"/>
<h1>
<field name="name"
placeholder="Title"/>
</h1>
</div>
<group>
<group>
<field name="partner_id"/>
<field name="base_cotisation_cg"/>
</group>
<group>
<field name="base_cotisation_cg"/>
<field name="payment_term_id"/>
</group>
<group>
<field name="account_invoice_ids"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="scop_bordereau_tree_view" model="ir.ui.view">
<field name="name">scop.bordereau.tree</field>
<field name="model">scop.bordereau</field>
<field name="arch" type="xml">
<tree string="Bordereaux">
<field name="name"/>
<field name="base_cotisation_cg"/>
</tree>
</field>
</record>
<!-- <record id="ModelName_search_view" model="ir.ui.view">-->
<!-- <field name="name">ProjectName.ModelName.search</field>-->
<!-- <field name="model">ProjectName.ModelName</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <search string="ModelTitle">-->
<!-- <group expand="1" string="Group By">-->
<!-- <filter string="Example Field" name="example_field"-->
<!-- domain="[]"-->
<!-- context="{'group_by':'example_field'}"/>-->
<!-- </group>-->
<!-- </search>-->
<!-- </field>-->
<!-- </record>-->
<record id="scop_bordereau_act_window" model="ir.actions.act_window">
<field name="name">Bodereaux</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">scop.bordereau</field>
<!-- <field name="view_type">form</field>-->
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Bordereaux" id="scop_bordereau_menu" parent="cgscop_cotisation.menu_scop_cotisation"
action="scop_bordereau_act_window"/>
</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