Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cgscop_cotisation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hervé Silvant - CGScop
cgscop_cotisation
Commits
b1fd1bec
Commit
b1fd1bec
authored
3 years ago
by
jordan
Browse files
Options
Downloads
Patches
Plain Diff
[update] report invoice and contribution deal with multi-modules (cg, riga, idf)
parent
5677ce33
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
report/scop_contribution_report.py
+37
-21
37 additions, 21 deletions
report/scop_contribution_report.py
with
37 additions
and
21 deletions
report/scop_contribution_report.py
+
37
−
21
View file @
b1fd1bec
...
...
@@ -13,6 +13,11 @@ class ScopContributionReport(models.Model):
name
=
fields
.
Char
(
compute
=
'
_compute_name
'
)
year
=
fields
.
Char
(
'
Année de cotisation
'
)
source
=
fields
.
Selection
(
string
=
'
Source
'
,
selection
=
[(
'
odoo
'
,
'
Odoo
'
)],
required
=
True
,)
type_contribution_id
=
fields
.
Many2one
(
comodel_name
=
"
scop.contribution.type
"
,
string
=
"
Type de cotisation
"
,
...
...
@@ -38,6 +43,7 @@ class ScopContributionReport(models.Model):
def
_select_invoice
(
self
):
select_str
=
"""
SELECT
'
odoo
'
as source,
CAST(i.year AS VARCHAR),
i.type_contribution_id,
i.partner_id,
...
...
@@ -87,6 +93,7 @@ class ScopContributionReport(models.Model):
select_str
=
"""
SELECT
ROW_NUMBER() OVER(ORDER BY c.year, c.partner_id) AS id,
c.source,
c.year,
c.type_contribution_id,
c.partner_id,
...
...
@@ -102,7 +109,8 @@ class ScopContributionReport(models.Model):
GROUP BY
c.year,
c.type_contribution_id,
c.partner_id
c.partner_id,
c.source
"""
def
_query_order
(
self
):
...
...
@@ -160,13 +168,9 @@ class ScopContributionReport(models.Model):
def
_get_payment
(
self
):
self
.
ensure_one
()
invoice_ids
=
self
.
env
[
'
account.invoice
'
].
sudo
().
search
([
(
'
year
'
,
'
=
'
,
int
(
self
.
year
)),
(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
),
(
'
type_contribution_id
'
,
'
=
'
,
self
.
type_contribution_id
.
id
),
(
'
type
'
,
'
=
'
,
'
out_invoice
'
),
(
'
bordereau_id.state
'
,
'
not in
'
,
(
'
cancel
'
,))
])
payments_html
=
False
if
self
.
source
==
'
odoo
'
:
invoice_ids
=
self
.
get_invoice_contribution
()
payment_ids
=
invoice_ids
.
mapped
(
'
payment_move_line_ids
'
)
if
payment_ids
:
payments
=
payment_ids
.
mapped
(
lambda
p
:
{
...
...
@@ -183,10 +187,22 @@ class ScopContributionReport(models.Model):
'
class
'
:
'
text-danger
'
})
payments_html
=
self
.
_get_html_table
(
payments
)
else
:
if
not
payments_html
:
payments_html
=
"
<p>Il n
'
y a pas de paiements associés à cette cotisation</p>
"
return
payments_html
def
get_invoice_contribution
(
self
):
invoice_ids
=
self
.
env
[
'
account.invoice
'
].
sudo
().
search
([
(
'
year
'
,
'
=
'
,
int
(
self
.
year
)),
(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
),
(
'
type_contribution_id
'
,
'
=
'
,
self
.
type_contribution_id
.
id
),
(
'
type
'
,
'
=
'
,
'
out_invoice
'
),
'
|
'
,
(
'
bordereau_id.state
'
,
'
not in
'
,
(
'
cancel
'
,)),
(
'
bordereau_id
'
,
'
=
'
,
False
)
])
return
invoice_ids
def
_get_html_table
(
self
,
payments
):
"""
:param payments: list of dict {date, name, ref, amount}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment