From cdcf86e5d0280c0f013cf5c2608b29e976efb24e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 29 Jul 2023 23:02:54 +0200 Subject: [PATCH] accounting file --- wizard/accounting_file_wizard.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wizard/accounting_file_wizard.py b/wizard/accounting_file_wizard.py index a423dc4..4690186 100644 --- a/wizard/accounting_file_wizard.py +++ b/wizard/accounting_file_wizard.py @@ -84,7 +84,7 @@ class AccountingFileWizard(models.TransientModel): tmstp=secrets.token_hex(16) filename='/tmp/accounting_file_'+tmstp+'.csv' - f = open(filename, "ab") + f = open(filename, "a",encoding="cp1252") #N° mouvement 1-5 @@ -98,7 +98,7 @@ class AccountingFileWizard(models.TransientModel): fic_line='"N° mouvement;Code du journal;Date;N° de compte;Libellé;Débit;Crédit;N° de pièce'+'"'+"\n" - fic_line=fic_line.encode(encoding="utf-8",errors='ignore') + #fic_line=fic_line.encode(encoding="cp1252",errors='ignore') f.write(fic_line) @@ -109,14 +109,14 @@ class AccountingFileWizard(models.TransientModel): if self.export_out_refund_lines:self.out_refund_lines(f) if self.export_end_of_stay_lines:self.end_of_stay_lines(f) fic_line="TOTAL_DEBIT="+str(total_debit)+ " TOTAL CREDIT="+str(total_credit) - fic_line=fic_line.encode(encoding="utf-8",errors='ignore') + #fic_line=fic_line.encode(encoding="cp1252",errors='ignore') f.write(fic_line) f.close - f = open(filename, "r") - data = str.encode(f.read(), 'utf-8') + f = open(filename, "rb") + data = f.read() #raise UserError('gg'+f.read()) - vals={} + vals={} vals['accounting_file']=base64.encodebytes(data) vals['document_fname']='export_comptable.csv' vals['exported_date']=fields.Date.context_today(self) @@ -141,7 +141,7 @@ class AccountingFileWizard(models.TransientModel): str_line='"'+str(no_mvt)+';'+'IN'+';'+date_line+';'+account_number+';'+lib+';'+debit+';'+credit+';'+lib_piece+'"'+'\n' - return str_line.encode(encoding="utf-8",errors='ignore') + return str_line def donation_lines(self,f): global total_debit