Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
282d00cc
Commit
282d00cc
authored
Jun 04, 2024
by
François COLOMBIER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout fonctionnalité Export du capital détenu à une date donnée
parent
9904fbbe
Pipeline
#3496
failed with stage
in 1 minute 26 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
compta.py
outils/lib/compta.py
+12
-0
urls.py
outils/urls.py
+2
-0
views.py
outils/views.py
+42
-0
No files found.
outils/lib/compta.py
View file @
282d00cc
...
...
@@ -304,3 +304,14 @@ def get_odoo_account_export_report (export_id, final_format):
else
:
report
=
generate_arithmethique_compatible_file
(
res
[
0
])
return
report
def
get_members_capital_at_date
(
date
,
only_active
):
try
:
if
only_active
==
'on'
:
only_active
=
1
else
:
only_active
=
0
return
OdooAPI
()
.
execute
(
"lacagette.exports"
,
'get_members_capital_at_date'
,
{
'date'
:
date
,
'only_active'
:
only_active
})
except
Exception
as
e
:
coop_logger
.
error
(
"Erreur get_members_capital_at_date :
%
s"
,
str
(
e
))
return
None
\ No newline at end of file
outils/urls.py
View file @
282d00cc
...
...
@@ -21,6 +21,7 @@ from .views import FieldsView
from
.views
import
ExportCompta
from
.views
import
ExportPOS
from
.views
import
ExportOrders
from
.views
import
ExportCapital
urlpatterns
=
[
...
...
@@ -33,6 +34,7 @@ urlpatterns = [
url
(
r'^export_compta$'
,
ExportCompta
.
as_view
(),
name
=
'export_compta'
),
url
(
r'^export_pos$'
,
ExportPOS
.
as_view
(),
name
=
'Export POS'
),
url
(
r'^export_orders$'
,
ExportOrders
.
as_view
(),
name
=
'export_orders'
),
url
(
r'^export_capital$'
,
ExportCapital
.
as_view
(),
name
=
'export_capital'
),
url
(
r'^monitor/$'
,
monitor
.
index
),
url
(
r'^monitor/js_errors$'
,
monitor
.
js_errors
),
url
(
r'^members/'
,
include
(
'members.urls'
)),
...
...
outils/views.py
View file @
282d00cc
...
...
@@ -435,3 +435,45 @@ class ExportOrders(View):
error
=
"Une erreur est survenue, merci de contacter le service informatique."
coop_logger
.
error
(
"Erreur export_orders :
%
s"
,
str
(
e
))
return
JsonResponse
({
'erreur'
:
error
,
'details'
:
str
(
e
)})
class
ExportCapital
(
View
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
u"""Display form"""
template
=
loader
.
get_template
(
'outils/export_capital.html'
)
context
=
{
'title'
:
'Export Capital détenu'
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
u"""Generate capital export at given date"""
date
=
request
.
POST
.
get
(
'date'
)
only_active
=
request
.
POST
.
get
(
'only_active'
)
capital_by_member_list_query
=
get_members_capital_at_date
(
date
,
only_active
)
if
'data'
in
capital_by_member_list_query
:
try
:
wb
=
Workbook
()
ws1
=
wb
.
active
ws1
.
title
=
"Capital détenu par les membres à la date
%
s"
%
date
ws1
.
append
([
'Membre'
,
'Capital détenu (en euros)'
])
for
line
in
capital_by_member_list_query
[
'data'
]:
ws1
.
append
([
line
[
'membre'
],
line
[
'capital_detenu'
]])
wb_name
=
'export_capital_'
+
date
+
'.xlsx'
response
=
HttpResponse
(
content
=
save_virtual_workbook
(
wb
),
content_type
=
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
response
[
'Content-Disposition'
]
=
'attachment; filename='
+
wb_name
return
response
except
Exception
as
e
:
error
=
"Une erreur est survenue, merci de contacter le service informatique."
coop_logger
.
error
(
"Erreur export_capital :
%
s"
,
str
(
e
))
return
JsonResponse
({
'erreur'
:
error
,
'details'
:
str
(
e
)})
else
:
details
=
''
if
'error'
in
capital_by_member_list_query
:
details
=
capital_by_member_list_query
[
'error'
]
return
JsonResponse
({
'erreur'
:
"La requête n'a pas aboutie"
,
'details'
:
details
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment