X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=wizard%2Faccount_export_csv.py;h=0052b918e059fd45c3439472d76e6cb1f2384fef;hb=HEAD;hp=547c15121f95c2c8f0c1e7bec0b20536cb547110;hpb=41dc75f3e98ded3722031150354b54c7348c7f8b;p=burette%2Fetudesetchantiersidf.git diff --git a/wizard/account_export_csv.py b/wizard/account_export_csv.py index 547c151..bcd82e9 100644 --- a/wizard/account_export_csv.py +++ b/wizard/account_export_csv.py @@ -3,7 +3,7 @@ # # etudesetchantiersidf module for OpenERP, Custom module for Étude et # Chantiers île-de-France -# Copyright (C) 2014-2022 etudesetchantiersidf +# Copyright (C) 2014-2023 etudesetchantiersidf # () # # This file is a part of etudesetchantiersidf @@ -32,7 +32,6 @@ import calendar import datetime import string -import openerp.exceptions from openerp.osv import osv from openerp.tools.translate import _ from openerp.addons.account_export_csv.wizard.account_export_csv import AccountUnicodeWriter @@ -118,13 +117,10 @@ class AccountCSVExport(osv.osv_memory): journal_ids, account_ids=None, context=None): - fiscalyear_obj = self.pool.get('account.fiscalyear') - fiscalyear_code = fiscalyear_obj.browse(cr, uid, fiscalyear_id, context=context) - fiscalyear_code = fiscalyear_obj.browse(cr, uid, fiscalyear_id, context=context).code - period_obj = self.pool.get('account.period') journal_obj = self.pool.get('account.journal') account_obj = self.pool.get('account.account') + account_type_obj = self.pool.get('account.account.type') numero_piece = 0 prev_period = 0 prev_journal = 0 @@ -155,25 +151,29 @@ class AccountCSVExport(osv.osv_memory): 'journal_ids': tuple(journal_ids), 'account_ids': tuple(account_ids), } - ) + ) res = cr.fetchall() rows = [] for line in res: dico = {} journal = journal_obj.browse(cr, uid, line[1], context=context) dico['journal_code'] = journal.code[0:2] + if dico['journal_code'] in ('BQ', 'CB'): + dico['journal_code'] = 'OD' period = period_obj.browse(cr, uid, line[0], context=context) if prev_journal != journal or prev_period != period: numero_piece += 1 year = int(period.code[3:7]) month = int(period.code[0:2]) day = calendar.monthrange(year, month)[1] - dico['date'] = datetime.datetime(year, month, day).strftime("%d/%m/%Y") + dico['date'] = datetime.datetime(year, month, day).strftime( + "%d/%m/%Y") account = account_obj.browse(cr, uid, line[2], context=context) dico['account_code'] = account.code - preformatted_client_name = journal.name.split(" - ", 1)[1].upper().replace(' ','') + preformatted_client_name = journal.name.split(" - ", 1)[1].upper().replace(' ', '') for char in string.punctuation: - preformatted_client_name = preformatted_client_name.replace(char,'') + preformatted_client_name = preformatted_client_name.replace( + char, '') dico['client_name'] = preformatted_client_name if account.type in ("receivable", "payable"): dico['compte_tiers'] = dico['client_name'] @@ -183,24 +183,23 @@ class AccountCSVExport(osv.osv_memory): dico['analytic_account'] = "" dico['debit'] = line[3] dico['credit'] = line[4] - if dico['debit'] == dico['credit']: - pass - else: + if dico['debit']: + row = self.format_row_sage(dico, numero_piece, "D") + rows.append(row) + if dico['credit']: + row = self.format_row_sage(dico, numero_piece, "C") + rows.append(row) + account_type = account_type_obj.browse( + cr, uid, account.user_type.id, context=context) + if account_type.code in ("expense", "income"): + dico['general_analytic'] = "A" + dico['analytic_account'] = journal.code[2:] if dico['debit']: row = self.format_row_sage(dico, numero_piece, "D") rows.append(row) if dico['credit']: row = self.format_row_sage(dico, numero_piece, "C") rows.append(row) - if account.type == "other": - dico['general_analytic'] = "A" - dico['analytic_account'] = journal.code[3:] - if dico['debit']: - row = self.format_row_sage(dico, numero_piece, "D") - rows.append(row) - if dico['credit']: - row = self.format_row_sage(dico, numero_piece, "C") - rows.append(row) prev_journal = journal prev_period = period