Browse Source

account deposit

master
root 3 years ago
parent
commit
826449b3ef
17 changed files with 421 additions and 13 deletions
  1. +5
    -0
      __manifest__.py
  2. +3
    -1
      models/__init__.py
  3. +24
    -0
      models/accounting_deposit.py
  4. +24
    -0
      models/bank_deposit.py
  5. +20
    -1
      models/donation.py
  6. +45
    -0
      models/payment_batch.py
  7. +13
    -0
      report/report.xml
  8. +0
    -0
      report/report_bank_deposit.xml
  9. +7
    -1
      security/ir.model.access.csv
  10. +59
    -0
      views/accounting_deposit.xml
  11. +61
    -0
      views/bank_deposit.xml
  12. +32
    -9
      views/payment_batch.xml
  13. +3
    -1
      wizard/__init__.py
  14. +29
    -0
      wizard/create_accounting_deposit_wizard.py
  15. +29
    -0
      wizard/create_accounting_deposit_wizard.xml
  16. +38
    -0
      wizard/create_bank_deposit_wizard.py
  17. +29
    -0
      wizard/create_bank_deposit_wizard.xml

+ 5
- 0
__manifest__.py View File

@ -41,6 +41,8 @@
#'views/mail_mail.xml', #'views/mail_mail.xml',
'views/returnmail.xml', 'views/returnmail.xml',
'views/payment_batch.xml', 'views/payment_batch.xml',
'views/bank_deposit.xml',
'views/accounting_deposit.xml',
'views/website_sale.xml', 'views/website_sale.xml',
'views/aggregate.xml', 'views/aggregate.xml',
'views/duplicate.xml', 'views/duplicate.xml',
@ -48,10 +50,13 @@
'views/template_pa.xml', 'views/template_pa.xml',
'wizard/operation_duplicate_wizard.xml', 'wizard/operation_duplicate_wizard.xml',
'wizard/recurring_donation_wizard.xml', 'wizard/recurring_donation_wizard.xml',
'wizard/create_bank_deposit_wizard.xml',
'wizard/create_accounting_deposit_wizard.xml',
'report/report_donationtax.xml', 'report/report_donationtax.xml',
'report/report_donation_recurring.xml', 'report/report_donation_recurring.xml',
'report/report.xml', 'report/report.xml',
'report/report_donationthanks.xml', 'report/report_donationthanks.xml',
#'report/report_bank_deposit.xml',
'views/donation_tax_receipt.xml', 'views/donation_tax_receipt.xml',
'views/donation_thanks_template.xml', 'views/donation_thanks_template.xml',
'views/laposte_ref.xml', 'views/laposte_ref.xml',


+ 3
- 1
models/__init__.py View File

@ -25,4 +25,6 @@ from . import donation_recurring_template_letter
from . import donation_thanks_template from . import donation_thanks_template
from . import partner_import from . import partner_import
#from . import res_partner_bank #from . import res_partner_bank
from .import donation_print_email_history
from .import donation_print_email_history
from .import bank_deposit
from .import accounting_deposit

+ 24
- 0
models/accounting_deposit.py View File

@ -0,0 +1,24 @@
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError,Warning
from psycopg2 import sql, DatabaseError
from werkzeug import utils
class opendons_accounting_deposit(models.Model):
_name = 'opendons.accountingdeposit'
_description = 'manage accounting deposit'
company_id = fields.Many2one(
"res.company",
string="Company",
ondelete="cascade",
default=lambda self: self.env.company,
)
payment_batch_ids = fields.One2many(
'opendons_payment_batch',
'accountingdeposit_id',
string='Payment batchs',
readonly=True
)

+ 24
- 0
models/bank_deposit.py View File

@ -0,0 +1,24 @@
from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError,Warning
from psycopg2 import sql, DatabaseError
from werkzeug import utils
class opendons_bank_deposit(models.Model):
_name = 'opendons.bankdeposit'
_description = 'manage bank deposit'
company_id = fields.Many2one(
"res.company",
string="Company",
ondelete="cascade",
default=lambda self: self.env.company,
)
payment_batch_ids = fields.One2many(
'opendons_payment_batch',
'bankdeposit_id',
string='Payment batchs',
readonly=True
)

+ 20
- 1
models/donation.py View File

@ -122,17 +122,36 @@ class DonationDonation(models.Model):
states={"done": [("readonly", True)]} states={"done": [("readonly", True)]}
) )
bank_deposit_date=fields.Date('bank deposit date')
accounting_deposit_date=fields.Date('bank deposit date')
@api.model @api.model
def create(self, vals): def create(self, vals):
vals['tax_receipt_option']='annual' vals['tax_receipt_option']='annual'
res = super(DonationDonation, self).create(vals) res = super(DonationDonation, self).create(vals)
#si don hors lot de paiement, création auto du lot de paiement
if not res.payment_batch_id and res.state!='draft' :
vals={}
vals['payment_mode_id']=int(res.payment_mode_id)
batch=self.env['opendons_payment_batch'].create(vals)
batch.write({'donation_ids':[(4,int(res.id))]})
return res return res
def write(self, vals):
res = super(DonationDonation, self).write(vals)
#si don hors lot de paiement, création auto du lot de paiement
if not self.payment_batch_id and self.state!='draft' :
vals={}
vals['payment_mode_id']=int(self.payment_mode_id)
batch=self.env['opendons_payment_batch'].create(vals)
batch.write({'donation_ids':[(4,int(self.id))]})
@api.onchange("partner_id") @api.onchange("partner_id")


+ 45
- 0
models/payment_batch.py View File

@ -66,7 +66,52 @@ class opendons_payment_batch(models.Model):
string='donation', string='donation',
track_visibility='onchange') track_visibility='onchange')
deposited_in_bank=fields.Boolean('deposited in bank')
bank_deposit_date=fields.Datetime(related='bankdeposit_id.create_date')
accounting_deposit_date=fields.Datetime(related='accountingdeposit_id.create_date')
bankdeposit_id = fields.Many2one(
'opendons.bankdeposit',
String='Bank deposit',
index=True,
readonly=True,
track_visibility='onchange',
)
accountingdeposit_id = fields.Many2one(
'opendons.accountingdeposit',
String='Accounting deposit',
index=True,
readonly=True,
track_visibility='onchange',
)
state = fields.Selection([
('draft', 'Draft'),
('validated', 'Validated'),
('deposited_in_bank', 'Deposited in bank'),
('deposited_in_accounting', 'Deposited in accounting')
],
string='State',
readonly=True,
copy=False,
default='draft',
index=True,
track_visibility='onchange'
)
def validate(self):
for payment in self:
vals = {'state': 'validated'}
payment.write(vals)
return
def validated2draft(self):
'''from Done state to Cancel state'''
for payment in self:
payment.state = 'draft'
@api.model @api.model
def _default_currency(self): def _default_currency(self):


+ 13
- 0
report/report.xml View File

@ -43,4 +43,17 @@
<field name="binding_type">report</field> <field name="binding_type">report</field>
</record> </record>
<!-- <record id="report_bank_deposit" model="ir.actions.report">
<field name="name">Bank deposit report</field>
<field name="model">opendons.bankdeposit</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">opendons.report_bankdeposit</field>
<field name="report_file">opendons.report_bankdeposit</field>
<field name="print_report_name"
>'Remise_en_banque-'+(object.number or '').replace('/','')+'.pdf'</field>
<field name="binding_model_id" ref="model_opendons_bankdeposit" />
<field name="attachment_use" eval="True" />
<field name="binding_type">report</field>
</record> -->
</odoo> </odoo>

+ 0
- 0
report/report_bank_deposit.xml View File


+ 7
- 1
security/ir.model.access.csv View File

@ -50,4 +50,10 @@ access_opendons_print_donation_email_history,opendons_print_donation_email_histo
access_opendons_partnerdraft,opendons_partnerdraft,model_opendons_partnerdraft,donation.group_donation_manager,1,1,1,1 access_opendons_partnerdraft,opendons_partnerdraft,model_opendons_partnerdraft,donation.group_donation_manager,1,1,1,1
access_opendons_partnerdraftfile,opendons_partnerdraftfile,model_opendons_partnerdraftfile,donation.group_donation_manager,1,1,1,1 access_opendons_partnerdraftfile,opendons_partnerdraftfile,model_opendons_partnerdraftfile,donation.group_donation_manager,1,1,1,1
access_opendons_partnerdraft_file_mapping,opendons_partnerdraft_file_mapping,model_opendons_partnerdraftfile_mapping,donation.group_donation_manager,1,1,1,1
access_opendons_partnerdraft_file_mapping,opendons_partnerdraft_file_mapping,model_opendons_partnerdraftfile_mapping,donation.group_donation_manager,1,1,1,1
access_opendons_create_bank_deposit_wizard,opendons_create_bank_deposit_wizard,model_opendons_createbankdeposit,donation.group_donation_manager,1,1,1,1
access_opendons_create_accounting_deposit_wizard,opendons_create_accounting_deposit_wizard,model_opendons_createaccountingdeposit,donation.group_donation_manager,1,1,1,1
access_opendons_bank_deposit,opendons_bank_deposit,model_opendons_bankdeposit,donation.group_donation_manager,1,1,1,1
access_opendons_accounting_deposit,opendons_accounting_deposit,model_opendons_accountingdeposit,donation.group_donation_manager,1,1,1,1

+ 59
- 0
views/accounting_deposit.xml View File

@ -0,0 +1,59 @@
<odoo>
<data>
<record model="ir.ui.view" id="opendons.accounting_deposit_list">
<field name="name">opendons_accounting_deposit list</field>
<field name="model">opendons.accountingdeposit</field>
<field name="arch" type="xml">
<tree>
<field name="create_date"/>
<field name="create_uid"/>
<field name="payment_batch_ids"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="opendons.accounting_deposit_form">
<field name="name">opendons_payment_batch_accounting Form</field>
<field name="model">opendons.accountingdeposit</field>
<field name="arch" type="xml">
<form string="accounting_deposit_form">
<group name="accounting_deposit">
<field name="create_date"/>
<field name="create_uid"/>
<field name="payment_batch_ids">
<tree>
<field name="create_date"/>
<field name="create_uid"/>
<field name="payment_mode_id"/>
<field name="amount_total" string="Total"/>
<field name="payment_count" string="Payments count"/>
</tree>
</field>
</group>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="accounting_deposit_action">
<field name="name">accounting deposits</field>
<field name="res_model">opendons.accountingdeposit</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="accounting_deposit_menu" action="accounting_deposit_action"
parent="payment_batch_top_menu" sequence="30"/>
</data>
</odoo>

+ 61
- 0
views/bank_deposit.xml View File

@ -0,0 +1,61 @@
<odoo>
<data>
<record model="ir.ui.view" id="opendons.bank_deposit_list">
<field name="name">opendons_bank_deposit list</field>
<field name="model">opendons.bankdeposit</field>
<field name="arch" type="xml">
<tree>
<field name="create_date"/>
<field name="create_uid"/>
<field name="payment_batch_ids"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="opendons.bank_deposit_form">
<field name="name">opendons_payment_batch_bank Form</field>
<field name="model">opendons.bankdeposit</field>
<field name="arch" type="xml">
<header>
</header>
<sheet>
<form string="bank_deposit_form">
<group name="bank_deposit">
<field name="create_date"/>
<field name="create_uid"/>
<field name="payment_batch_ids">
<tree>
<field name="create_date"/>
<field name="create_uid"/>
<field name="payment_mode_id"/>
<field name="amount_total" string="Total"/>
<field name="payment_count" string="Payments count"/>
</tree>
</field>
</group>
</form>
</sheet>
</field>
</record>
<record model="ir.actions.act_window" id="bank_deposit_action">
<field name="name">Bank deposits</field>
<field name="res_model">opendons.bankdeposit</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="bank_deposit_menu" action="bank_deposit_action"
parent="payment_batch_top_menu" sequence="20"/>
</data>
</odoo>

+ 32
- 9
views/payment_batch.xml View File

@ -1,22 +1,18 @@
<odoo> <odoo>
<data> <data>
<!-- <template id="assets_backend" name="js assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/opendons/static/src/js/payment_batch.js">
</script>
</xpath>
</template> -->
<record model="ir.ui.view" id="opendons.payment_batch"> <record model="ir.ui.view" id="opendons.payment_batch">
<field name="name">opendons_payment_batch list</field> <field name="name">opendons_payment_batch list</field>
<field name="model">opendons_payment_batch</field> <field name="model">opendons_payment_batch</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree> <tree>
<field name="id"/>
<field name="state"/>
<field name="create_date"/> <field name="create_date"/>
<field name="create_uid"/> <field name="create_uid"/>
<!-- <field name="bank_deposit_date" string="bank deposit date" widget="badge" decoration-info="bank_deposit_date"/>
<field name="accounting_deposit_date" string="accounting deposit date" widget="badge" decoration-info="accounting_deposit_date"/> -->
<field name="payment_mode_id"/> <field name="payment_mode_id"/>
</tree> </tree>
@ -30,6 +26,14 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="payment_batch_form"> <form string="payment_batch_form">
<header> <header>
<button type="object" name="validate" string="Validate"
class="oe_highlight" states="draft"/>
<button type="object" name="validated2draft"
string="Back to Draft" states="validated"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,validated,deposited_in_bank,deposited_in_accounting"/>
</header> </header>
<sheet> <sheet>
<group name="payment_batch"> <group name="payment_batch">
@ -90,8 +94,24 @@
<field name="name">Payment batch</field> <field name="name">Payment batch</field>
<field name="res_model">opendons_payment_batch</field> <field name="res_model">opendons_payment_batch</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="context">{"search_default_not_deposited_in_bank":1}</field>
</record> </record>
<record id="opendons.payment_batch_search" model="ir.ui.view">
<field name="name">opendons_payment_batch.search</field>
<field name="model">opendons_payment_batch</field>
<field name="arch" type="xml">
<search>
<filter string="Deposited in bank" name="deposited_in_bank" domain="[('bankdeposit_id', '!=', False)]"/>
<filter string="Not deposited in bank" name="not_deposited_in_bank" domain="[('bankdeposit_id', '=', False)]"/>
<filter string="Deposited in accounting" name="deposited_in_accounting" domain="[('accountingdeposit_id', '!=', False)]"/>
<filter string="Not deposited in accounting" name="not_deposited_in_accounting" domain="[('accountingdeposit_id', '=', False),('bankdeposit_id', '!=', False)]"/>
</search>
</field>
</record>
<menuitem id="payment_batch_top_menu" sequence="16" <menuitem id="payment_batch_top_menu" sequence="16"
@ -105,6 +125,9 @@ parent="payment_batch_title_menu" sequence="10"/>
<menuitem id="payment_batch_account_payment_order" action="account_payment_order.account_payment_order_inbound_action" <menuitem id="payment_batch_account_payment_order" action="account_payment_order.account_payment_order_inbound_action"
parent="payment_batch_title_menu" sequence="20"/> parent="payment_batch_title_menu" sequence="20"/>
<!-- <menuitem id="payment_batch_bank_deposit" action="payment_batch_to_deposit_in_bank_action"
parent="payment_batch_title_menu" sequence="19"/> -->
</data> </data>
</odoo> </odoo>

+ 3
- 1
wizard/__init__.py View File

@ -1,2 +1,4 @@
from . import operation_duplicate_wizard from . import operation_duplicate_wizard
from . import recurring_donation_wizard
from . import recurring_donation_wizard
from . import create_bank_deposit_wizard
from . import create_accounting_deposit_wizard

+ 29
- 0
wizard/create_accounting_deposit_wizard.py View File

@ -0,0 +1,29 @@
from odoo import fields, models, _
from odoo.exceptions import UserError, ValidationError,Warning
class CreateaccountingDeposit(models.TransientModel):
_name = 'opendons.createaccountingdeposit'
_description = 'Create a accounting deposit form batchs selected'
def create_accounting_deposit(self):
active_ids = self._context.get('active_ids', []) or []
if active_ids:
payments=self.env['opendons_payment_batch'].browse(active_ids)
for p in payments:
if p.bank_deposit_date==False: raise Warning('the batch payment selected was not deposited in bank : operation cancelled')
if p.accounting_deposit_date: raise Warning('the batch payment selected was already deposited in bank : operation cancelled')
#create accounting deposit
vals={}
bd=self.env['opendons.accountingdeposit'].create(vals)
for p in payments:
#add payment to accounting deposit
bd.write({'payment_batch_ids':[(4,p.id)]})
#add accounting deposit to payment
p.accountingdeposit_id=bd.id
p.state='deposited_in_accounting'

+ 29
- 0
wizard/create_accounting_deposit_wizard.xml View File

@ -0,0 +1,29 @@
<odoo>
<record id="create_accounting_deposit_view" model="ir.ui.view">
<field name="name">create_accounting_deposit view</field>
<field name="model">opendons.createaccountingdeposit</field>
<field name="arch" type="xml">
<form>
<p>
Are you sure do you want to create a accounting deposit with selected payments ?
</p>
<footer>
<button name="create_accounting_deposit" string="Create a accounting deposit" type="object"/>
<button string="Cancel" class="btn btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_create_new_accounting_deposit" model="ir.actions.act_window">
<field name="name">Create an accounting deposit</field>
<field name="res_model">opendons.createaccountingdeposit</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="opendons.model_opendons_payment_batch"/>
</record>
</odoo>

+ 38
- 0
wizard/create_bank_deposit_wizard.py View File

@ -0,0 +1,38 @@
from odoo import fields, models, _
from odoo.exceptions import UserError, ValidationError,Warning
class CreateBankDeposit(models.TransientModel):
_name = 'opendons.createbankdeposit'
_description = 'Create a bank deposit form batchs selected'
def create_bank_deposit(self):
active_ids = self._context.get('active_ids', []) or []
if active_ids:
payments=self.env['opendons_payment_batch'].browse(active_ids)
for p in payments:
if p.state=='draft': raise Warning('the batch payment selected is not validated : operation cancelled')
if p.accounting_deposit_date: raise Warning('the batch payment selected was already deposited in accounting : operation cancelled')
if p.bank_deposit_date: raise Warning('the batch payment selected was already deposited in bank : operation cancelled')
#create bank deposit
vals={}
bd=self.env['opendons.bankdeposit'].create(vals)
for p in self.env['opendons_payment_batch'].browse(active_ids):
#add payment to bank deposit
bd.write({'payment_batch_ids':[(4,p.id)]})
#add bank deposit to payment
p.bankdeposit_id=bd.id
p.state='deposited_in_bank'
# #creation de l'opération sans les segments
# vals={}
# vals['name']='copy of ' + record.name
# vals['chanel']=record.chanel
# vals['user_id']=self._uid
# vals['state']='draft'
# dup_operation=super(opendons_operation, self).create(vals)

+ 29
- 0
wizard/create_bank_deposit_wizard.xml View File

@ -0,0 +1,29 @@
<odoo>
<record id="create_bank_deposit_view" model="ir.ui.view">
<field name="name">create_bank_deposit view</field>
<field name="model">opendons.createbankdeposit</field>
<field name="arch" type="xml">
<form>
<p>
Are you sure do you want to create a bank deposit with selected payments ?
</p>
<footer>
<button name="create_bank_deposit" string="Create a bank deposit" type="object"/>
<button string="Cancel" class="btn btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_create_new_bank_deposit" model="ir.actions.act_window">
<field name="name">Create a bank deposit</field>
<field name="res_model">opendons.createbankdeposit</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="opendons.model_opendons_payment_batch"/>
</record>
</odoo>

Loading…
Cancel
Save