Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
C
cgscop_cotisation
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Le Filament
Confédération Générale des SCOP
cgscop_cotisation
Validations
def39e58
Valider
def39e58
rédigé
28 avr. 2021
par
Benjamin - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[update] scop.contribution creation
parent
7fedb124
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
models/account_invoice.py
+37
-44
37 ajouts, 44 suppressions
models/account_invoice.py
models/scop_contribution.py
+9
-5
9 ajouts, 5 suppressions
models/scop_contribution.py
models/scop_cotisation.py
+21
-6
21 ajouts, 6 suppressions
models/scop_cotisation.py
avec
67 ajouts
et
55 suppressions
models/account_invoice.py
+
37
−
44
Voir le fichier @
def39e58
...
@@ -46,6 +46,9 @@ class ScopAccountInvoice(models.Model):
...
@@ -46,6 +46,9 @@ class ScopAccountInvoice(models.Model):
related
=
'
partner_id.ur_id
'
,
related
=
'
partner_id.ur_id
'
,
store
=
True
store
=
True
)
)
contribution_id
=
fields
.
Many2one
(
comodel_name
=
'
scop.contribution
'
,
string
=
'
Ligne de cotisation
'
)
nb_quarter
=
fields
.
Selection
(
nb_quarter
=
fields
.
Selection
(
string
=
'
Nombre de trimestres de cotisation
'
,
string
=
'
Nombre de trimestres de cotisation
'
,
selection
=
[(
1
,
'
1
'
),
selection
=
[(
1
,
'
1
'
),
...
@@ -81,18 +84,6 @@ class ScopAccountInvoice(models.Model):
...
@@ -81,18 +84,6 @@ class ScopAccountInvoice(models.Model):
# ------------------------------------------------------
# ------------------------------------------------------
# Override Parent
# Override Parent
# ------------------------------------------------------
# ------------------------------------------------------
def
get_last_maturity_date
(
self
,
months
,
account_move_line_ids
):
"""
Get the last maturity date from account_move_line
for a certain period (months = [])
:param months:
:param account_move_line_ids:
:return: last date_maturity
"""
line_ids
=
account_move_line_ids
.
filtered
(
lambda
l
:
l
.
date_maturity
.
month
in
months
)
return
line_ids
[
-
1
].
date_maturity
if
line_ids
else
None
@api.multi
@api.multi
def
action_invoice_open
(
self
):
def
action_invoice_open
(
self
):
"""
"""
...
@@ -101,7 +92,7 @@ class ScopAccountInvoice(models.Model):
...
@@ -101,7 +92,7 @@ class ScopAccountInvoice(models.Model):
"""
"""
results
=
super
(
ScopAccountInvoice
,
self
).
action_invoice_open
()
results
=
super
(
ScopAccountInvoice
,
self
).
action_invoice_open
()
for
inv
in
self
:
for
inv
in
self
:
if
inv
.
is_contribution
and
inv
.
type
==
'
out_invoice
'
:
if
inv
.
is_contribution
:
inv
.
set_scop_contribution
()
inv
.
set_scop_contribution
()
return
results
return
results
...
@@ -251,37 +242,39 @@ class ScopAccountInvoice(models.Model):
...
@@ -251,37 +242,39 @@ class ScopAccountInvoice(models.Model):
"""
"""
Création d
'
une ligne dans scop.contribution
Création d
'
une ligne dans scop.contribution
"""
"""
for
inv
in
self
:
self
.
ensure_one
()
if
inv
.
is_contribution
:
if
self
.
is_contribution
:
year
=
inv
.
year
year
=
self
.
year
account_type_receivable_ids
=
inv
.
env
[
# Get existing contribution for this year
'
account.account
'
].
search
([
contrib_id
=
self
.
env
[
'
scop.contribution
'
].
search
([
(
'
user_type_id
'
,
'
=
'
,
inv
.
env
.
ref
(
(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
),
'
account.data_account_type_receivable
'
).
id
)
(
'
year
'
,
'
=
'
,
year
),
]).
mapped
(
'
id
'
)
(
'
type_id
'
,
'
=
'
,
self
.
type_contribution_id
.
id
)
account_move_line_ids
=
inv
.
env
[
'
account.move.line
'
].
search
([
])
(
'
invoice_id
'
,
'
=
'
,
inv
.
id
),
(
'
account_id
'
,
'
in
'
,
account_type_receivable_ids
)
]).
filtered
(
lambda
l
:
l
.
date_maturity
.
year
==
year
)
inv
.
env
[
'
scop.contribution
'
].
create
({
# Create scop.contribution line if not exists
'
partner_id
'
:
inv
.
partner_id
.
id
,
# for year, partner and type
'
type_id
'
:
inv
.
type_contribution_id
.
id
,
if
not
contrib_id
:
'
year
'
:
inv
.
year
,
contrib_line
=
self
.
env
[
'
scop.contribution
'
].
create
({
'
partner_id
'
:
self
.
partner_id
.
id
,
'
type_id
'
:
self
.
type_contribution_id
.
id
,
'
year
'
:
self
.
year
,
'
calculation_date
'
:
fields
.
Datetime
.
now
(),
'
calculation_date
'
:
fields
.
Datetime
.
now
(),
'
amount_calculated
'
:
inv
.
amount_total
,
'
amount_calculated
'
:
self
.
amount_total
,
'
amount_called
'
:
inv
.
amount_total
,
'
amount_called
'
:
self
.
amount_total
,
'
spreading
'
:
inv
.
nb_quarter
,
'
spreading
'
:
self
.
nb_quarter
,
'
spreading
'
:
len
(
'
invoice_id
'
:
self
.
id
,
account_move_line_ids
.
mapped
(
'
date_maturity
'
)),
'
quarter_1
'
:
inv
.
get_last_maturity_date
(
[
1
,
2
,
3
],
account_move_line_ids
),
'
quarter_2
'
:
inv
.
get_last_maturity_date
(
[
4
,
5
,
6
],
account_move_line_ids
),
'
quarter_3
'
:
inv
.
get_last_maturity_date
(
[
7
,
8
,
9
],
account_move_line_ids
),
'
quarter_4
'
:
inv
.
get_last_maturity_date
(
[
10
,
11
,
12
],
account_move_line_ids
),
'
invoice_id
'
:
inv
.
id
,
})
})
return
True
else
:
contrib_line
=
self
.
set_scop_contribution_hook
(
contrib_id
)
self
.
contribution_id
=
contrib_line
.
id
return
contrib_line
return
False
def
set_scop_contribution_hook
(
self
,
contrib_id
):
"""
Function that can be inherited if a contrib line already exists
:param contrib_id: scop.contribution line
:return: scop.contribution
"""
return
contrib_id
Ce diff est replié.
Cliquez pour l'agrandir.
models/scop_contribution.py
+
9
−
5
Voir le fichier @
def39e58
...
@@ -7,10 +7,15 @@ from odoo import models, fields, api
...
@@ -7,10 +7,15 @@ from odoo import models, fields, api
class
ScopContributions
(
models
.
Model
):
class
ScopContributions
(
models
.
Model
):
_inherit
=
"
scop.contribution
"
_inherit
=
"
scop.contribution
"
# TODO: remove after migration
invoice_id
=
fields
.
Many2one
(
invoice_id
=
fields
.
Many2one
(
comodel_name
=
'
account.invoice
'
,
comodel_name
=
'
account.invoice
'
,
string
=
'
Facture liée
'
,
string
=
'
Facture liée
'
,
ondelete
=
'
cascade
'
)
ondelete
=
'
cascade
'
)
invoice_ids
=
fields
.
One2many
(
comodel_name
=
'
account.invoice
'
,
inverse_name
=
'
contribution_id
'
,
string
=
'
Factures liées
'
)
amount_paid
=
fields
.
Float
(
amount_paid
=
fields
.
Float
(
compute
=
'
_compute_amount_paid
'
,
store
=
True
)
compute
=
'
_compute_amount_paid
'
,
store
=
True
)
amount_remaining
=
fields
.
Float
(
amount_remaining
=
fields
.
Float
(
...
@@ -25,13 +30,14 @@ class ScopContributions(models.Model):
...
@@ -25,13 +30,14 @@ class ScopContributions(models.Model):
@api.multi
@api.multi
def
_compute_amount_paid
(
self
):
def
_compute_amount_paid
(
self
):
for
r
in
self
:
for
r
in
self
:
r
.
amount_paid
=
r
.
invoice_id
.
amount_
total
-
r
.
amount_remaining
r
.
amount_paid
=
r
.
amount_
called
-
r
.
amount_remaining
@api.depends
(
'
invoice_id.residual
'
)
@api.depends
(
'
invoice_id
s
'
,
'
invoice_ids
.residual
_signed
'
)
@api.multi
@api.multi
def
_compute_amount_remaining_previous
(
self
):
def
_compute_amount_remaining_previous
(
self
):
for
r
in
self
:
for
r
in
self
:
r
.
amount_remaining
=
r
.
invoice_id
.
residual
r
.
amount_remaining
=
sum
(
r
.
invoice_ids
.
mapped
(
'
residual_signed
'
))
@api.multi
@api.multi
def
_compute_is_exempt
(
self
):
def
_compute_is_exempt
(
self
):
...
@@ -54,8 +60,6 @@ class ScopContributions(models.Model):
...
@@ -54,8 +60,6 @@ class ScopContributions(models.Model):
(
'
refund_invoice_id
'
,
'
=
'
,
self
.
invoice_id
.
id
),
(
'
refund_invoice_id
'
,
'
=
'
,
self
.
invoice_id
.
id
),
(
'
state
'
,
'
in
'
,
[
'
open
'
,
'
paid
'
])
(
'
state
'
,
'
in
'
,
[
'
open
'
,
'
paid
'
])
])
])
print
(
refund_ids
)
print
(
tree_id
)
return
{
return
{
'
type
'
:
'
ir.actions.act_window
'
,
'
type
'
:
'
ir.actions.act_window
'
,
'
name
'
:
'
Exonérations
'
,
'
name
'
:
'
Exonérations
'
,
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
models/scop_cotisation.py
+
21
−
6
Voir le fichier @
def39e58
...
@@ -81,9 +81,24 @@ class ScopCotisation(models.AbstractModel):
...
@@ -81,9 +81,24 @@ class ScopCotisation(models.AbstractModel):
# ------------------------------------------------------
# ------------------------------------------------------
# Global functions
# Global functions
# ------------------------------------------------------
# ------------------------------------------------------
def
create_contribution
(
self
,
product
,
partner
,
type_contribution
,
def
create_contribution
(
liasse
=
None
,
amount
=
0
,
date
=
False
,
self
,
product
,
partner
,
type_contribution
,
liasse
=
None
,
amount
=
0
,
journal_id
=
False
,
account_id
=
False
):
date
=
False
,
journal_id
=
False
,
account_id
=
False
,
type_invoice
=
'
out_invoice
'
,
is_regul
=
False
):
"""
Create invoice from Contribution Base
:param product: product_id
:param partner: partner_id
:param type_contribution: type_contribution (CG, UR, Fédé)
:param liasse: liasse_fiscale_id (reference)
:param amount: contribution amount (float)
:param date: date invoice
:param journal_id: journal
:param account_id: customer_account_id
:param type_invoice: invoice or refund
:param is_regul: used for CG Scop regul
:return: invoice
"""
Invoice
=
self
.
env
[
'
account.invoice
'
]
Invoice
=
self
.
env
[
'
account.invoice
'
]
InvoiceLine
=
self
.
env
[
'
account.invoice.line
'
]
InvoiceLine
=
self
.
env
[
'
account.invoice.line
'
]
...
@@ -92,7 +107,7 @@ class ScopCotisation(models.AbstractModel):
...
@@ -92,7 +107,7 @@ class ScopCotisation(models.AbstractModel):
(
'
year
'
,
'
=
'
,
self
.
year
),
(
'
year
'
,
'
=
'
,
self
.
year
),
(
'
type_contribution_id
'
,
'
=
'
,
type_contribution
)
(
'
type_contribution_id
'
,
'
=
'
,
type_contribution
)
])
])
if
not
exisiting_invoice
:
if
not
exisiting_invoice
or
is_regul
:
date_invoice
=
date
if
date
else
self
.
date_cotisation
date_invoice
=
date
if
date
else
self
.
date_cotisation
journal_id
=
self
.
company_id
.
contribution_journal_id
\
journal_id
=
self
.
company_id
.
contribution_journal_id
\
if
not
journal_id
else
journal_id
if
not
journal_id
else
journal_id
...
@@ -101,7 +116,7 @@ class ScopCotisation(models.AbstractModel):
...
@@ -101,7 +116,7 @@ class ScopCotisation(models.AbstractModel):
member_invoice
=
Invoice
.
create
({
member_invoice
=
Invoice
.
create
({
'
partner_id
'
:
partner
.
id
,
'
partner_id
'
:
partner
.
id
,
'
liasse_fiscale_id
'
:
liasse
.
id
,
'
liasse_fiscale_id
'
:
liasse
.
id
,
'
type
'
:
'
out
_invoice
'
,
'
type
'
:
type
_invoice
,
'
year
'
:
self
.
year
,
'
year
'
:
self
.
year
,
'
is_contribution
'
:
True
,
'
is_contribution
'
:
True
,
'
type_contribution_id
'
:
type_contribution
,
'
type_contribution_id
'
:
type_contribution
,
...
@@ -120,7 +135,7 @@ class ScopCotisation(models.AbstractModel):
...
@@ -120,7 +135,7 @@ class ScopCotisation(models.AbstractModel):
(
'
invoice_id
'
,
'
=
'
,
member_invoice
.
id
),
(
'
invoice_id
'
,
'
=
'
,
member_invoice
.
id
),
(
'
product_id
'
,
'
=
'
,
product
.
id
)
(
'
product_id
'
,
'
=
'
,
product
.
id
)
])
])
if
not
exisiting_invoice_line_ids
:
if
not
exisiting_invoice_line_ids
or
is_regul
:
InvoiceLine
.
create
({
InvoiceLine
.
create
({
'
invoice_id
'
:
member_invoice
.
id
,
'
invoice_id
'
:
member_invoice
.
id
,
'
product_id
'
:
product
.
id
,
'
product_id
'
:
product
.
id
,
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter