Browse Source

export cdr

master
root 1 year ago
parent
commit
51aec8f46c
5 changed files with 191 additions and 101 deletions
  1. +3
    -1
      __manifest__.py
  2. +3
    -39
      views/accounting_file.xml
  3. +56
    -0
      views/accounting_file_cdr.xml
  4. +89
    -61
      wizard/accounting_file_wizard_cdr.py
  5. +40
    -0
      wizard/accounting_file_wizard_cdr.xml

+ 3
- 1
__manifest__.py View File

@ -73,7 +73,9 @@
'views/mediatheque.xml',
'views/account.xml',
'views/accounting_file.xml',
'wizard/accounting_file_wizard.xml'
'views/accounting_file_cdr.xml',
'wizard/accounting_file_wizard.xml',
'wizard/accounting_file_wizard_cdr.xml'
#'views/payment_views.xml'


+ 3
- 39
views/accounting_file.xml View File

@ -15,19 +15,6 @@
</field>
</record>
<record model="ir.ui.view" id="kalachakra.cdr_accounting_file_list">
<field name="name">CDR kalachakra_accounting file list</field>
<field name="model">cdr.accounting.file</field>
<field name="arch" type="xml">
<tree default_order='create_date desc'>
<field name="create_date"/>
<field name="start_date"/>
<field name="exported_date"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="kalachakra.accounting_file_form">
<field name="name">kalachakra_accounting_file form</field>
@ -49,25 +36,7 @@
</field>
</record>
<record model="ir.ui.view" id="kalachakra.cdr_accounting_file_form">
<field name="name">CDR kalachakra_accounting_file form</field>
<field name="model">cdr.accounting.file</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="create_date"/>
<field name="create_uid"/>
<field name="accounting_file" filename="document_fname" widget="binary"/>
<field name="document_fname" invisible="1"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="exported_date"/>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="accounting_file_action">
<field name="name">Accounting files</field>
@ -75,19 +44,14 @@
<field name="view_mode">tree,form,pivot</field>
</record>
<record model="ir.actions.act_window" id="cdr_accounting_file_action">
<field name="name">CDR accounting files</field>
<field name="res_model">cdr.accounting.file</field>
<field name="view_mode">tree,form,pivot</field>
</record>
<menuitem id="accounting_file_menu" action="accounting_file_action"
parent="account.menu_finance_entries_accounting_miscellaneous" sequence="10"/>
<menuitem id="cdr_accounting_file_menu" action="cdr_accounting_file_action"
parent="account.menu_finance_entries_accounting_miscellaneous" sequence="11"/>
</data>
</odoo>

+ 56
- 0
views/accounting_file_cdr.xml View File

@ -0,0 +1,56 @@
<odoo>
<data>
<record model="ir.ui.view" id="kalachakra.cdr_accounting_file_list">
<field name="name">CDR kalachakra_accounting file list</field>
<field name="model">cdr.accounting.file</field>
<field name="arch" type="xml">
<tree default_order='create_date desc'>
<field name="create_date"/>
<field name="start_date"/>
<field name="exported_date"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="kalachakra.cdr_accounting_file_form">
<field name="name">CDR kalachakra_accounting_file form</field>
<field name="model">cdr.accounting.file</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="create_date"/>
<field name="create_uid"/>
<field name="accounting_file" filename="document_fname" widget="binary"/>
<field name="document_fname" invisible="1"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="exported_date"/>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="cdr_accounting_file_action">
<field name="name">CDR accounting files</field>
<field name="res_model">cdr.accounting.file</field>
<field name="view_mode">tree,form,pivot</field>
</record>
<menuitem id="cdr_accounting_file_menu" action="cdr_accounting_file_action"
parent="account.menu_finance_entries_accounting_miscellaneous" sequence="11"/>
</data>
</odoo>

+ 89
- 61
wizard/accounting_file_wizard_cdr.py View File

@ -39,7 +39,7 @@ class CdrAccountingFileWizard(models.TransientModel):
return datetime(date_today.year,date_today.month,1)
def action_create_accounting_file(self):
def action_create_cdr_accounting_file(self):
global total_debit
global total_credit
total_debit=0
@ -84,7 +84,7 @@ class CdrAccountingFileWizard(models.TransientModel):
vals['exported_date']=fields.Date.context_today(self)
vals['start_date']=self.start_date
vals['end_date']=self.end_date
res=self.env['accounting.file'].create(vals)
res=self.env['cdr.accounting.file'].create(vals)
f.close
os.unlink(filename)
@ -93,7 +93,7 @@ class CdrAccountingFileWizard(models.TransientModel):
'name': 'Account deposit form',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'accounting.file',
'res_model': 'cdr.accounting.file',
'res_id': int(res.id),
'type': 'ir.actions.act_window',
'target': 'current'
@ -111,6 +111,7 @@ class CdrAccountingFileWizard(models.TransientModel):
global total_credit
global no_mvt
#écritures pour les dons validés (donc payés), non déjà exportés
donation=self.env['donation.donation'].search([('date_compta','=',False),('state','=','done')])
#raise UserError(donation)
for d in donation:
@ -129,10 +130,10 @@ class CdrAccountingFileWizard(models.TransientModel):
if not self.debug_mode: d.date_compta=date_compta
#if not d.payment_mode_id: raise UserError(_("no payment mode found for donation %r ",donation.number))
#if not d.payment_mode_id.fixed_journal_id: raise UserError(_("no account found for payment mode %r",d.payment_mode_id.name))
account_debit_number=self._file_format(str(d.payment_mode_id.fixed_journal_id.default_account_id.code),6)
if d.transaction_id.acquirer_id.name=='Paypal':
#account_debit_number=self._file_format(str(d.payment_mode_id.fixed_journal_id.default_account_id.code),6)
# if d.transaction_id.acquirer_id.name=='Paypal':
account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','Paypal')]).fixed_journal_id.default_account_id.code),6)
# account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','Paypal')]).fixed_journal_id.default_account_id.code),6)
firstname=d.partner_id.firstname
name=d.partner_id.name
@ -154,9 +155,11 @@ class CdrAccountingFileWizard(models.TransientModel):
affectation=line.product_id.name
amount=line.amount
#if not line.product_id.property_account_income_id: raise UserError(_("no credit account found for product %r",line.product_id.name))
account_credit_number=self._file_format(line.product_id.property_account_income_id.code,6)
account_debit_number=self._file_format(line.product_id.property_account_income_id.code,6)
account_credit_number=self._file_format(line.product_id.cdr_property_account_income_id.code,6)
break
if account_debit_number!='170000':continue
#credit line
lib2=self._file_format(affectation,13)
lib=lib1+' '+lib2
@ -281,14 +284,19 @@ class CdrAccountingFileWizard(models.TransientModel):
registration=self.env['event.registration'].search([])
membership_amount=0
donation_amount=0
membership_credit_line=False
#membership_credit_line=False
donation_credit_line=False
#if not reg.event_id.participation_product_id.property_account_income_id: raise UserError(_("no credit account found for product %r",reg.event_id.participation_product_id.name))
account_credit_number=self._file_format('170000',6)
for reg in registration:
if reg.event_id.booking_event:
if reg.event_id.individual_booking_event:
account_credit_number=self._file_format('754799',6)
else:
account_credit_number=self._file_format('754700',6)
#si pas de facture d'acompte et facture payée:
if reg.invoice_id.amount_total>0 and reg.invoice_id.payment_state=='paid' and reg.date_compta==False :
@ -321,13 +329,17 @@ class CdrAccountingFileWizard(models.TransientModel):
global total_credit
global no_mvt
membership_amount=0
#membership_amount=0
donation_amount=0
membership_credit_line=False
#membership_credit_line=False
donation_credit_line=False
#if not reg.event_id.participation_product_id.property_account_income_id: raise UserError(_("no credit account found for product %r",reg.event_id.participation_product_id.name))
account_credit_number=self._file_format('170000',6)
if reg.event_id.individual_booking_event:
account_credit_number=self._file_format('754799',6)
else:
account_credit_number=self._file_format('754700',6)
firstname=reg.partner_id.firstname
name=reg.partner_id.name
@ -342,20 +354,23 @@ class CdrAccountingFileWizard(models.TransientModel):
down_payment=False
balance_payment=True
account_debit_number=''
for p in reg.balance_invoice_id.payment_ids:
account_debit_number=self._file_format(str(self.env['account.journal'].search([('id','=',int(p.journal_id))]).default_account_id.code),6)
break
# account_debit_number=''
# for p in reg.balance_invoice_id.payment_ids:
# account_debit_number=self._file_format(str(self.env['account.journal'].search([('id','=',int(p.journal_id))]).default_account_id.code),6)
# break
account_debit_number=self._file_format('170000',6)
date_line=self._payment_date(reg.balance_invoice_id)
#recherche de l'adhésion
membership_credit_line=False
membership=self.env['kalachakra.membership'].search([('date_compta','=',False),('balance_invoice_id','=',int(reg.balance_invoice_id))])
if membership:
membership_credit_line=True
membership_amount=membership.amount
# membership_credit_line=False
# membership=self.env['kalachakra.membership'].search([('date_compta','=',False),('balance_invoice_id','=',int(reg.balance_invoice_id))])
# if membership:
# membership_credit_line=True
# membership_amount=membership.amount
#recherche de dons
donation_credit_line=False
@ -381,7 +396,7 @@ class CdrAccountingFileWizard(models.TransientModel):
total_debit+=amount
if not amount: amount=0
amount=reg.balance_invoice_id.amount_total-membership_amount-donation_amount
amount=reg.balance_invoice_id.amount_total-donation_amount
debit=''
credit=str(amount)
account_number=account_credit_number
@ -390,21 +405,21 @@ class CdrAccountingFileWizard(models.TransientModel):
no_mvt=no_mvt+1
total_credit+=amount
if membership_credit_line:
debit=''
credit=str(membership_amount)
account_number=self._file_format('756100',6)
fic_line=self._accounting_line(no_mvt,date_line,account_number,lib,debit,credit,lib_piece)
f.write(fic_line)
no_mvt=no_mvt+1
total_credit+=membership_amount
# if membership_credit_line:
# debit=''
# credit=str(membership_amount)
# account_number=self._file_format('756100',6)
# fic_line=self._accounting_line(no_mvt,date_line,account_number,lib,debit,credit,lib_piece)
# f.write(fic_line)
# no_mvt=no_mvt+1
# total_credit+=membership_amount
if donation_credit_line:
for d in donations :
debit=''
credit=''
amount=d.amount_total
credit=str(amount)
account_number=account_credit_number
debit=str(amount)
account_number='170000'
fic_line=self._accounting_line(no_mvt,date_line,account_number,lib,debit,credit,lib_piece)
f.write(fic_line)
no_mvt=no_mvt+1
@ -425,7 +440,11 @@ class CdrAccountingFileWizard(models.TransientModel):
donation_credit_line=False
#if not reg.event_id.participation_product_id.property_account_income_id: raise UserError(_("no credit account found for product %r",reg.event_id.participation_product_id.name))
account_credit_number=self._file_format('170000',6)
if reg.event_id.individual_booking_event:
account_credit_number=self._file_format('754799',6)
else:
account_credit_number=self._file_format('754700',6)
firstname=reg.partner_id.firstname
name=reg.partner_id.name
@ -442,7 +461,10 @@ class CdrAccountingFileWizard(models.TransientModel):
donation_credit_line=False
membership_credit_line=False
account_debit_number=self._file_format(str(reg.down_payment_invoice_id.payment_mode_id.fixed_journal_id.default_account_id.code),6)
#account_debit_number=self._file_format(str(reg.down_payment_invoice_id.payment_mode_id.fixed_journal_id.default_account_id.code),6)
account_debit_number=self._file_format('170000',6)
trans=self.env['payment.transaction'].search([('invoice_ids','in',reg.down_payment_invoice_id.id),('state','=','done')],limit=1)
if trans and trans.acquirer_id.name=='Paypal': account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','Paypal')]).fixed_journal_id.default_account_id.code),6)
if trans and trans.acquirer_id.name=='Paiement par carte bancaire': account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','CB')]).fixed_journal_id.default_account_id.code),6)
@ -499,7 +521,11 @@ class CdrAccountingFileWizard(models.TransientModel):
donation_credit_line=False
#if not reg.event_id.participation_product_id.property_account_income_id: raise UserError(_("no credit account found for product %r",reg.event_id.participation_product_id.name))
account_credit_number=self._file_format('170000',6)
if reg.event_id.individual_booking_event:
account_credit_number=self._file_format('754799',6)
else:
account_credit_number=self._file_format('754700',6)
firstname=reg.partner_id.firstname
name=reg.partner_id.name
@ -515,22 +541,24 @@ class CdrAccountingFileWizard(models.TransientModel):
down_payment=False
balance_payment=False
#if not reg.invoice_id.payment_mode_id.fixed_journal_id: raise UserError(_("no account found payment mode %r",reg.invoice_id.payment_mode_id.name))
account_debit_number=self._file_format(str(reg.invoice_id.payment_mode_id.fixed_journal_id.default_account_id.code),6)
trans=self.env['payment.transaction'].search([('invoice_ids','in',reg.invoice_id.id),('state','=','done')],limit=1)
if trans and trans.acquirer_id.name=='Paypal':
# account_debit_number=self._file_format(str(reg.invoice_id.payment_mode_id.fixed_journal_id.default_account_id.code),6)
# trans=self.env['payment.transaction'].search([('invoice_ids','in',reg.invoice_id.id),('state','=','done')],limit=1)
# if trans and trans.acquirer_id.name=='Paypal':
account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','Paypal')]).fixed_journal_id.default_account_id.code),6)
# account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','Paypal')]).fixed_journal_id.default_account_id.code),6)
if trans and trans.acquirer_id.name=='Paiement par carte bancaire':
# if trans and trans.acquirer_id.name=='Paiement par carte bancaire':
account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','CB')]).fixed_journal_id.default_account_id.code),6)
# account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','CB')]).fixed_journal_id.default_account_id.code),6)
account_debit_number=self._file_format('170000',6)
#recherche de l'adhésion
membership_credit_line=False
membership=self.env['kalachakra.membership'].search([('invoice_id','=',int(reg.invoice_id))])
if membership:
membership_credit_line=True
membership_amount=membership.amount
# membership_credit_line=False
# membership=self.env['kalachakra.membership'].search([('invoice_id','=',int(reg.invoice_id))])
# if membership:
# membership_credit_line=True
# membership_amount=membership.amount
#recherche de dons
donation_credit_line=False
@ -568,7 +596,7 @@ class CdrAccountingFileWizard(models.TransientModel):
#participation credit line
if not amount: amount=0
amount=amount-membership_amount-donation_amount
amount=amount-donation_amount
debit=''
credit=str(amount)
account_number=account_credit_number
@ -577,21 +605,21 @@ class CdrAccountingFileWizard(models.TransientModel):
no_mvt=no_mvt+1
total_credit+=amount
if membership_credit_line:
debit=''
credit=str(membership_amount)
account_number=self._file_format('756100',6)
fic_line=self._accounting_line(no_mvt,date_line,account_number,lib,debit,credit,lib_piece)
f.write(fic_line)
no_mvt=no_mvt+1
total_credit+=membership_amount
# if membership_credit_line:
# debit=''
# credit=str(membership_amount)
# account_number=self._file_format('756100',6)
# fic_line=self._accounting_line(no_mvt,date_line,account_number,lib,debit,credit,lib_piece)
# f.write(fic_line)
# no_mvt=no_mvt+1
# total_credit+=membership_amount
if donation_credit_line:
for d in donations :
debit=''
credit=''
amount=d.amount_total
credit=str(amount)
account_number=account_credit_number
debit=str(amount)
account_number='170000'
fic_line=self._accounting_line(no_mvt,date_line,account_number,lib,debit,credit,lib_piece)
f.write(fic_line)
no_mvt=no_mvt+1
@ -626,7 +654,7 @@ class CdrAccountingFileWizard(models.TransientModel):
lib_piece=self._file_format(invoice.name,20)
#écriture de débit
amount=invoice.amount_total
account_debit_number='170000'
account_debit_number='754700'
date_line=self._date_format(invoice.invoice_date)
if amount==0: continue
debit=str(amount)
@ -681,7 +709,7 @@ class CdrAccountingFileWizard(models.TransientModel):
#écriture de débit
amount=invoice.amount_total
account_debit_number='170000'
account_debit_number='411900'
#date du paiement
#_logger.error(self._payment_date_ok(invoice.out_invoice_id))


+ 40
- 0
wizard/accounting_file_wizard_cdr.xml View File

@ -0,0 +1,40 @@
<odoo>
<record id="cdr_accounting_file_wizard_view" model="ir.ui.view">
<field name="name">cdr accounting_file_wizard view</field>
<field name="model">cdr.accounting.file.wizard</field>
<field name="arch" type="xml">
<form string="Accounting file wizard">
<group>
<field name="start_date" widget="date"/>
<field name="end_date" widget="date"/>
<field name="debug_mode"/>
<field name="export_donation_lines"/>
<field name="export_booking_event_lines"/>
<field name="export_out_refund_lines"/>
<field name="export_end_of_stay_lines"/>
</group>
<footer>
<button name="action_create_cdr_accounting_file" string="generate accounting file" type="object"/>
<button string="Cancel" class="btn btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="generate_cdr_accounting_file_action">
<field name="name">Generate cdr accounting file</field>
<field name="res_model">cdr.accounting.file.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem id="cdr_accounting_file_generate_menu" action="generate_cdr_accounting_file_action"
parent="account.menu_finance_entries_accounting_miscellaneous" sequence="12"/>
</odoo>

Loading…
Cancel
Save