Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
C
cgscop_cotisation_cg
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_cg
Validations
05416780
Valider
05416780
rédigé
22 nov. 2021
par
Benjamin - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[update] export wizard to add partner selection
parent
473fe6fa
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
controllers/main.py
+14
-7
14 ajouts, 7 suppressions
controllers/main.py
wizard/export_journal_wizard.py
+16
-7
16 ajouts, 7 suppressions
wizard/export_journal_wizard.py
wizard/export_journal_wizard_view.xml
+3
-0
3 ajouts, 0 suppression
wizard/export_journal_wizard_view.xml
avec
33 ajouts
et
14 suppressions
controllers/main.py
+
14
−
7
Voir le fichier @
05416780
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl.html).
import
re
import
csv
import
csv
import
unidecode
from
datetime
import
date
,
datetime
from
datetime
import
date
,
datetime
from
io
import
BytesIO
,
StringIO
from
io
import
StringIO
from
odoo
import
http
from
odoo
import
http
from
odoo.http
import
request
from
odoo.http
import
request
from
odoo.addons.web.controllers.main
import
serialize_exception
from
odoo.addons.web.controllers.main
import
serialize_exception
from
odoo.addons.web.controllers.main
import
content_disposition
from
odoo.addons.web.controllers.main
import
content_disposition
from
odoo.tools.misc
import
xlwt
class
ExportJournalCg
(
http
.
Controller
):
class
ExportJournalCg
(
http
.
Controller
):
...
@@ -20,7 +19,7 @@ class ExportJournalCg(http.Controller):
...
@@ -20,7 +19,7 @@ class ExportJournalCg(http.Controller):
@http.route
(
'
/web/export_journal_cg/
'
,
type
=
'
http
'
,
auth
=
"
user
"
)
@http.route
(
'
/web/export_journal_cg/
'
,
type
=
'
http
'
,
auth
=
"
user
"
)
@serialize_exception
@serialize_exception
def
export_journal_cg
(
def
export_journal_cg
(
self
,
type
,
date_start
,
date_end
,
company_id
,
**
kwargs
):
self
,
date_start
,
date_end
,
company_id
,
partner_ids
,
**
kwargs
):
"""
"""
Sélectionne les account.move.line correspondants aux journaux
Sélectionne les account.move.line correspondants aux journaux
et à la plage de date définis
et à la plage de date définis
...
@@ -48,6 +47,10 @@ class ExportJournalCg(http.Controller):
...
@@ -48,6 +47,10 @@ class ExportJournalCg(http.Controller):
if
type
==
'
empty
'
:
if
type
==
'
empty
'
:
domain
+=
[(
'
date_export
'
,
'
=
'
,
False
)]
domain
+=
[(
'
date_export
'
,
'
=
'
,
False
)]
# adds partner in domain
if
partner_ids
:
domain
+=
[(
'
partner_id
'
,
'
in
'
,
list
(
map
(
int
,
partner_ids
.
split
(
"
,
"
))))]
export_line_ids
=
request
.
env
[
'
account.move.line
'
].
search
(
domain
)
export_line_ids
=
request
.
env
[
'
account.move.line
'
].
search
(
domain
)
lines_to_export
=
[]
lines_to_export
=
[]
...
@@ -164,6 +167,8 @@ class ExportJournalCg(http.Controller):
...
@@ -164,6 +167,8 @@ class ExportJournalCg(http.Controller):
if
line
.
name
:
if
line
.
name
:
description
+=
'
-
'
+
line
.
name
.
upper
()
description
+=
'
-
'
+
line
.
name
.
upper
()
description
=
unidecode
.
unidecode
(
description
)
if
journal
:
if
journal
:
journal_code
=
journal
journal_code
=
journal
else
:
else
:
...
@@ -205,7 +210,9 @@ class ExportJournalCg(http.Controller):
...
@@ -205,7 +210,9 @@ class ExportJournalCg(http.Controller):
fp
=
StringIO
()
fp
=
StringIO
()
export_file
=
csv
.
writer
(
export_file
=
csv
.
writer
(
fp
,
fp
,
delimiter
=
'
;
'
,)
delimiter
=
'
;
'
,
dialect
=
'
excel
'
,
)
# Add header line
# Add header line
for
line
in
lines_to_export
:
for
line
in
lines_to_export
:
# Format date value
# Format date value
...
@@ -220,7 +227,7 @@ class ExportJournalCg(http.Controller):
...
@@ -220,7 +227,7 @@ class ExportJournalCg(http.Controller):
filename
=
filename_
+
'
.txt
'
filename
=
filename_
+
'
.txt
'
csvhttpheaders
=
[
csvhttpheaders
=
[
(
'
Content-Type
'
,
'
text/
csv
;charset=iso-8859-1
'
),
(
'
Content-Type
'
,
'
text/
plain
;charset=iso-8859-1
'
),
(
'
Content-Disposition
'
,
content_disposition
(
filename
)),
(
'
Content-Disposition
'
,
content_disposition
(
filename
)),
]
]
return
request
.
make_response
(
data
,
headers
=
csvhttpheaders
)
return
request
.
make_response
(
data
,
headers
=
csvhttpheaders
)
Ce diff est replié.
Cliquez pour l'agrandir.
wizard/export_journal_wizard.py
+
16
−
7
Voir le fichier @
05416780
# Copyright 2020 Le Filament (<http://www.le-filament.com>)
# Copyright 2020 Le Filament (<http://www.le-filament.com>)
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3 or later (http://www.gnu.org/licenses/agpl.html).
from
odoo
import
models
,
fields
,
api
,
http
from
urllib.parse
import
urlencode
from
odoo.exceptions
import
UserError
from
odoo
import
models
,
fields
,
api
class
ExportJournalWizard
(
models
.
TransientModel
):
class
ExportJournalWizard
(
models
.
TransientModel
):
...
@@ -29,6 +30,11 @@ class ExportJournalWizard(models.TransientModel):
...
@@ -29,6 +30,11 @@ class ExportJournalWizard(models.TransientModel):
comodel_name
=
'
res.company
'
,
comodel_name
=
'
res.company
'
,
default
=
_get_default_company
default
=
_get_default_company
)
)
partner_ids
=
fields
.
Many2many
(
comodel_name
=
'
res.partner
'
,
string
=
'
Coopératives
'
,
domain
=
[(
'
is_cooperative
'
,
'
=
'
,
True
)]
)
export_type
=
fields
.
Selection
(
export_type
=
fields
.
Selection
(
[(
'
empty
'
,
'
Ecritures non exportées
'
),
(
'
all
'
,
'
Toutes les écritures
'
)],
[(
'
empty
'
,
'
Ecritures non exportées
'
),
(
'
all
'
,
'
Toutes les écritures
'
)],
string
=
'
Ecritures à exporter
'
,
default
=
"
empty
"
)
string
=
'
Ecritures à exporter
'
,
default
=
"
empty
"
)
...
@@ -38,12 +44,15 @@ class ExportJournalWizard(models.TransientModel):
...
@@ -38,12 +44,15 @@ class ExportJournalWizard(models.TransientModel):
Appelle l
'
url de traitement et de téléchargement
Appelle l
'
url de traitement et de téléchargement
:return: ir.actions.act_url
:return: ir.actions.act_url
"""
"""
datas
=
{
'
export_type
'
:
self
.
export_type
,
'
date_start
'
:
self
.
date_start
,
'
date_end
'
:
self
.
date_end
,
'
company_id
'
:
self
.
company_id
.
id
,
'
partner_ids
'
:
'
,
'
.
join
(
str
(
x
)
for
x
in
self
.
partner_ids
.
ids
),
}
return
{
return
{
'
type
'
:
'
ir.actions.act_url
'
,
'
type
'
:
'
ir.actions.act_url
'
,
'
url
'
:
'
url
'
:
'
/web/export_journal_cg?
'
+
urlencode
(
datas
),
'
/web/export_journal_cg?format=csv&type=%s
'
%
(
self
.
export_type
,)
+
'
&date_start=%s&date_end=%s&company_id=%d
'
%
(
self
.
date_start
,
self
.
date_end
,
self
.
company_id
.
id
),
'
target
'
:
'
new
'
,
'
target
'
:
'
new
'
,
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
wizard/export_journal_wizard_view.xml
+
3
−
0
Voir le fichier @
05416780
...
@@ -21,6 +21,9 @@
...
@@ -21,6 +21,9 @@
<field
name=
"date_end"
/>
<field
name=
"date_end"
/>
</group>
</group>
</group>
</group>
<group>
<field
name=
"partner_ids"
widget=
"many2many_tags"
options=
"{'no_create': True, 'no_edit': True}"
/>
</group>
<footer>
<footer>
<button
class=
"btn btn-sm btn-primary"
name=
"get_cg_export"
string=
"Télécharger"
type=
"object"
/>
<button
class=
"btn btn-sm btn-primary"
name=
"get_cg_export"
string=
"Télécharger"
type=
"object"
/>
<button
class=
"btn btn-sm btn-default"
special=
"cancel"
string=
"Fermer"
/>
<button
class=
"btn btn-sm btn-default"
special=
"cancel"
string=
"Fermer"
/>
...
...
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