mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
@@ -6,16 +6,16 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Account Check Deposit',
|
||||
'version': '12.0.1.0.1',
|
||||
'name': 'Account Deposit in Bank',
|
||||
'version': '12.0.2.0.1',
|
||||
'category': 'Accounting',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Manage deposit of checks to the bank',
|
||||
'summary': 'Manage deposit of checks, cash, etc. to the bank',
|
||||
'author': "Odoo Community Association (OCA),"
|
||||
"Akretion,"
|
||||
"Tecnativa",
|
||||
'website': 'https://github.com/OCA/account-financial-tools'
|
||||
'account_check_deposit',
|
||||
"Tecnativa,"
|
||||
"GRAP",
|
||||
'website': 'https://github.com/OCA/account-financial-tools',
|
||||
'depends': [
|
||||
'account',
|
||||
],
|
||||
@@ -25,6 +25,7 @@
|
||||
'security/check_deposit_security.xml',
|
||||
'data/sequence.xml',
|
||||
'views/account_deposit_view.xml',
|
||||
'views/account_journal_view.xml',
|
||||
'views/account_move_line_view.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'report/report.xml',
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# Copyright (C) 2019-Today: GTRAP (<http://www.grap.coop/>)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
def migrate(env, version):
|
||||
if not version:
|
||||
return
|
||||
|
||||
# Update values for journal that can be deposited
|
||||
env.execute("""
|
||||
UPDATE account_journal
|
||||
SET can_be_deposited = true,
|
||||
deposit_debit_account_id = default_debit_account_id
|
||||
WHERE type = 'bank'
|
||||
AND bank_account_id IS NULL
|
||||
;""")
|
||||
|
||||
env.execute("""
|
||||
UPDATE account_journal
|
||||
SET can_receive_deposit = true
|
||||
WHERE type = 'bank'
|
||||
AND bank_account_id IS NOT NULL
|
||||
;""")
|
||||
@@ -1,4 +1,5 @@
|
||||
from . import account_deposit
|
||||
from . import account_journal
|
||||
from . import account_move_line
|
||||
from . import res_company
|
||||
from . import res_config_settings
|
||||
|
||||
@@ -18,6 +18,7 @@ class AccountCheckDeposit(models.Model):
|
||||
|
||||
@api.depends(
|
||||
'company_id', 'currency_id', 'check_payment_ids.debit',
|
||||
'check_payment_ids.credit',
|
||||
'check_payment_ids.amount_currency',
|
||||
'move_id.line_ids.reconciled')
|
||||
def _compute_check_deposit(self):
|
||||
@@ -33,11 +34,9 @@ class AccountCheckDeposit(models.Model):
|
||||
if currency_none_same_company_id:
|
||||
total += line.amount_currency
|
||||
else:
|
||||
total += line.debit
|
||||
total += line.debit - line.credit
|
||||
if deposit.move_id:
|
||||
for line in deposit.move_id.line_ids:
|
||||
if line.debit > 0 and line.reconciled:
|
||||
reconcile = True
|
||||
reconcile = all(deposit.mapped('move_id.line_ids.reconciled'))
|
||||
deposit.total_amount = total
|
||||
deposit.is_reconcile = reconcile
|
||||
deposit.currency_none_same_company_id =\
|
||||
@@ -46,7 +45,7 @@ class AccountCheckDeposit(models.Model):
|
||||
|
||||
name = fields.Char(string='Name', size=64, readonly=True, default='/')
|
||||
check_payment_ids = fields.One2many(
|
||||
'account.move.line', 'check_deposit_id', string='Check Payments',
|
||||
'account.move.line', 'check_deposit_id', string='Payments',
|
||||
states={'done': [('readonly', '=', True)]})
|
||||
deposit_date = fields.Date(
|
||||
string='Deposit Date', required=True,
|
||||
@@ -54,10 +53,10 @@ class AccountCheckDeposit(models.Model):
|
||||
default=fields.Date.context_today)
|
||||
journal_id = fields.Many2one(
|
||||
'account.journal', string='Journal',
|
||||
domain=[('type', '=', 'bank'), ('bank_account_id', '=', False)],
|
||||
domain=[('can_be_deposited', '=', True)],
|
||||
required=True, states={'done': [('readonly', '=', True)]})
|
||||
journal_default_account_id = fields.Many2one(
|
||||
'account.account', related='journal_id.default_debit_account_id',
|
||||
'account.account', related='journal_id.deposit_debit_account_id',
|
||||
string='Default Debit Account of the Journal')
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency', string='Currency', required=True,
|
||||
@@ -74,8 +73,8 @@ class AccountCheckDeposit(models.Model):
|
||||
'account.move', string='Journal Entry', readonly=True)
|
||||
bank_journal_id = fields.Many2one(
|
||||
'account.journal', string='Bank Account', required=True,
|
||||
domain="[('company_id', '=', company_id), ('type', '=', 'bank'), "
|
||||
"('bank_account_id', '!=', False)]",
|
||||
domain="[('company_id', '=', company_id),"
|
||||
"('can_receive_deposit', '=', True)]",
|
||||
states={'done': [('readonly', '=', True)]})
|
||||
line_ids = fields.One2many(
|
||||
'account.move.line', related='move_id.line_ids',
|
||||
@@ -90,7 +89,7 @@ class AccountCheckDeposit(models.Model):
|
||||
digits=dp.get_precision('Account'))
|
||||
check_count = fields.Integer(
|
||||
compute='_compute_check_deposit', readonly=True, store=True,
|
||||
string="Number of Checks")
|
||||
string="Number of Deposit Lines")
|
||||
is_reconcile = fields.Boolean(
|
||||
compute='_compute_check_deposit', readonly=True, store=True,
|
||||
string="Reconcile")
|
||||
@@ -103,20 +102,20 @@ class AccountCheckDeposit(models.Model):
|
||||
for line in deposit.check_payment_ids:
|
||||
if line.currency_id:
|
||||
raise ValidationError(
|
||||
_("The check with amount %s and reference '%s' "
|
||||
_("The line with amount %s and reference '%s' "
|
||||
"is in currency %s but the deposit is in "
|
||||
"currency %s.") % (
|
||||
line.debit, line.ref or '',
|
||||
line.debit or line.credit, line.ref or '',
|
||||
line.currency_id.name,
|
||||
deposit_currency.name))
|
||||
else:
|
||||
for line in deposit.check_payment_ids:
|
||||
if line.currency_id != deposit_currency:
|
||||
raise ValidationError(
|
||||
_("The check with amount %s and reference '%s' "
|
||||
_("The line with amount %s and reference '%s' "
|
||||
"is in currency %s but the deposit is in "
|
||||
"currency %s.") % (
|
||||
line.debit, line.ref or '',
|
||||
line.debit or line.credit, line.ref or '',
|
||||
line.currency_id.name,
|
||||
deposit_currency.name))
|
||||
|
||||
@@ -160,17 +159,19 @@ class AccountCheckDeposit(models.Model):
|
||||
move_vals = {
|
||||
'journal_id': journal_id,
|
||||
'date': deposit.deposit_date,
|
||||
'ref': _('Check Deposit %s') % deposit.name,
|
||||
'ref': _('%(journal_name)s Deposit %(deposit_name)s') % {
|
||||
'journal_name': deposit.journal_id.name,
|
||||
'deposit_name': deposit.name,
|
||||
},
|
||||
}
|
||||
return move_vals
|
||||
|
||||
@api.model
|
||||
def _prepare_move_line_vals(self, line):
|
||||
assert (line.debit > 0), 'Debit must have a value'
|
||||
return {
|
||||
'name': _('Check Deposit - Ref. Check %s') % line.ref,
|
||||
'name': _('Deposit - Ref. %s') % line.ref,
|
||||
'credit': line.debit,
|
||||
'debit': 0.0,
|
||||
'debit': line.credit,
|
||||
'account_id': line.account_id.id,
|
||||
'partner_id': line.partner_id.id,
|
||||
'currency_id': line.currency_id.id or False,
|
||||
@@ -179,11 +180,11 @@ class AccountCheckDeposit(models.Model):
|
||||
|
||||
@api.model
|
||||
def _prepare_counterpart_move_lines_vals(
|
||||
self, deposit, total_debit, total_amount_currency):
|
||||
self, deposit, total_amount, total_amount_currency):
|
||||
company = deposit.company_id
|
||||
if not company.check_deposit_offsetting_account:
|
||||
raise UserError(_(
|
||||
"You must configure the 'Check Deposit Offsetting Account' "
|
||||
"You must configure the 'Deposit Offsetting Account' "
|
||||
"on the Accounting Settings page"))
|
||||
if company.check_deposit_offsetting_account == 'bank_account':
|
||||
if not deposit.bank_journal_id.default_debit_account_id:
|
||||
@@ -194,13 +195,16 @@ class AccountCheckDeposit(models.Model):
|
||||
elif company.check_deposit_offsetting_account == 'transfer_account':
|
||||
if not company.check_deposit_transfer_account_id:
|
||||
raise UserError(_(
|
||||
"Missing 'Check Deposit Offsetting Account' on the "
|
||||
"Missing 'Deposit Offsetting Account' on the "
|
||||
"company '%s'.") % company.name)
|
||||
account_id = company.check_deposit_transfer_account_id.id
|
||||
return {
|
||||
'name': _('Check Deposit %s') % deposit.name,
|
||||
'debit': total_debit,
|
||||
'credit': 0.0,
|
||||
'name': _('%(journal_name)s Deposit %(deposit_name)s') % {
|
||||
'journal_name': deposit.journal_id.name,
|
||||
'deposit_name': deposit.name,
|
||||
},
|
||||
'debit': (total_amount > 0) and total_amount or 0.0,
|
||||
'credit': (total_amount < 0) and - total_amount or 0.0,
|
||||
'account_id': account_id,
|
||||
'partner_id': False,
|
||||
'currency_id': deposit.currency_none_same_company_id.id or False,
|
||||
@@ -213,11 +217,11 @@ class AccountCheckDeposit(models.Model):
|
||||
for deposit in self:
|
||||
move_vals = self._prepare_account_move_vals(deposit)
|
||||
move = am_obj.create(move_vals)
|
||||
total_debit = 0.0
|
||||
total_amount = 0.0
|
||||
total_amount_currency = 0.0
|
||||
to_reconcile_lines = []
|
||||
for line in deposit.check_payment_ids:
|
||||
total_debit += line.debit
|
||||
total_amount += line.debit - line.credit
|
||||
total_amount_currency += line.amount_currency
|
||||
line_vals = self._prepare_move_line_vals(line)
|
||||
line_vals['move_id'] = move.id
|
||||
@@ -227,7 +231,7 @@ class AccountCheckDeposit(models.Model):
|
||||
|
||||
# Create counter-part
|
||||
counter_vals = self._prepare_counterpart_move_lines_vals(
|
||||
deposit, total_debit, total_amount_currency)
|
||||
deposit, total_amount, total_amount_currency)
|
||||
counter_vals['move_id'] = move.id
|
||||
move_line_obj.create(counter_vals)
|
||||
if deposit.company_id.check_deposit_post_move:
|
||||
|
||||
27
account_check_deposit/models/account_journal.py
Normal file
27
account_check_deposit/models/account_journal.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2019-Today: GTRAP (<http://www.grap.coop/>)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = 'account.journal'
|
||||
|
||||
can_be_deposited = fields.Boolean(string="Can be Deposited")
|
||||
|
||||
can_receive_deposit = fields.Boolean(string="Can Receive Deposit")
|
||||
|
||||
deposit_debit_account_id = fields.Many2one(
|
||||
comodel_name="account.account",
|
||||
domain="[('deprecated', '=', False)]",
|
||||
string="Debit Account for Deposit")
|
||||
|
||||
@api.onchange('can_be_deposited', 'default_debit_account_id')
|
||||
def _onchange_default_debit_account_id(self):
|
||||
# Prefill deposit account with debit account by default
|
||||
for journal in self.filtered(lambda x: (
|
||||
not x.deposit_debit_account_id and x.can_be_deposited)):
|
||||
journal.deposit_debit_account_id =\
|
||||
journal.default_debit_account_id.id
|
||||
@@ -1,5 +1,6 @@
|
||||
This module allows you to easily manage check deposits : you can select all
|
||||
the checks you received and create a global deposit for the selected checks.
|
||||
This module allows you to easily manage deposits : you can select all
|
||||
the payment lines you received and create a global deposit for the selected
|
||||
payments lines.
|
||||
This module supports multi-currency ; each deposit has a currency and all the
|
||||
checks of the deposit must have the same currency (so, if you have checks in
|
||||
EUR and checks in USD, you must create 2 deposits: one in EUR and one in USD).
|
||||
lines of the deposit must have the same currency (so, if you have payments in
|
||||
EUR and payments in USD, you must create 2 deposits: one in EUR and one in USD).
|
||||
|
||||
12
account_check_deposit/readme/ROADMAP.rst
Normal file
12
account_check_deposit/readme/ROADMAP.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
* Add an option on journals that can be deposited ``grouped_move_line``
|
||||
to generate an account move with a single main line, that reconciles
|
||||
all the lines.
|
||||
|
||||
* Move the configuration ``check_deposit_offsetting_account`` and
|
||||
``check_deposit_transfer_account_id`` from ``res.company`` to the
|
||||
``account.journal`` that can be deposited.
|
||||
Make required the ``bank_journal_id`` field, only in the ``bank_account``
|
||||
option and not in the ``transfer_account`` option.
|
||||
|
||||
* Rename fields that belong ``check`` as this module allow to make deposit
|
||||
of checks, cash, etc...
|
||||
@@ -12,30 +12,40 @@
|
||||
|
||||
<t t-call="web.html_container">
|
||||
<t t-foreach="docs" t-as="o">
|
||||
<t t-call="web.internal_layout">
|
||||
<t t-call="web.external_layout">
|
||||
|
||||
<div class="page">
|
||||
|
||||
<h1>Check Deposit n°<span t-field="o.name"/></h1>
|
||||
<h2>Deposit n°<span t-field="o.name"/></h2>
|
||||
|
||||
<h3>Bank:</h3>
|
||||
<p><span t-field="o.bank_journal_id.bank_account_id.bank_id.name"/><br/>
|
||||
<span t-field="o.bank_journal_id.bank_account_id.bank_id.street"/><br/>
|
||||
<span t-field="o.bank_journal_id.bank_account_id.bank_id.zip"/> <span t-field="o.bank_journal_id.bank_account_id.bank_id.city"/></p>
|
||||
<div id="informations" class="row mt32 mb32">
|
||||
<div class="col-auto mw-100 mb-2" t-if="o.bank_journal_id.bank_account_id" name="bank_journal_id">
|
||||
<strong>Bank:</strong>
|
||||
<p class="m-0">
|
||||
<span t-field="o.bank_journal_id.bank_account_id.bank_id.name"/><br/>
|
||||
<span t-field="o.bank_journal_id.bank_account_id.bank_id.street"/><br/>
|
||||
<span t-field="o.bank_journal_id.bank_account_id.bank_id.zip"/> <span t-field="o.bank_journal_id.bank_account_id.bank_id.city"/>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-auto mw-100 mb-2" t-if="o.bank_journal_id.bank_account_id" name="acc_number">
|
||||
<strong>Account Number:</strong>
|
||||
<p class="m-0" t-field="o.bank_journal_id.bank_account_id.acc_number"/>
|
||||
</div>
|
||||
<div class="col-auto mw-100 mb-2" name="currency_id">
|
||||
<strong>Currency:</strong>
|
||||
<p class="m-0" t-field="o.currency_id.name"/>
|
||||
</div>
|
||||
<div class="col-auto mw-100 mb-2" name="deposit_date">
|
||||
<strong>Transfer Date:</strong>
|
||||
<p class="m-0" t-field="o.deposit_date"/>
|
||||
</div>
|
||||
<div class="col-auto mw-100 mb-2" name="check_count">
|
||||
<strong>Lines:</strong>
|
||||
<p class="m-0" t-field="o.check_count"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Beneficiary:</h3>
|
||||
<div t-field="o.company_id.partner_id"
|
||||
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true}'/>
|
||||
|
||||
<p><b>Bank Account Number to Credit:</b> <span t-field="o.bank_journal_id.bank_account_id.acc_number"/></p>
|
||||
|
||||
<p><b>Check Currency:</b> <span t-field="o.currency_id.name"/></p>
|
||||
|
||||
<p><b>Transfer Date:</b> <span t-field="o.deposit_date"/></p>
|
||||
|
||||
<p><b>Number of checks:</b> <span t-field="o.check_count"/></p>
|
||||
|
||||
<h3>List of checks:</h3>
|
||||
<h3>Details:</h3>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
@@ -56,8 +66,14 @@
|
||||
<td><span t-field="move_line.partner_id.name"/></td>
|
||||
<td>
|
||||
<t t-if="o.currency_id == o.company_id.currency_id">
|
||||
<span t-field="move_line.debit"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
|
||||
<t t-if="move_line.debit > 0">
|
||||
<span t-field="move_line.debit"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
|
||||
</t>
|
||||
<t t-if="move_line.credit > 0">
|
||||
(<span t-field="move_line.credit"
|
||||
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>)
|
||||
</t>
|
||||
</t>
|
||||
<t t-if="o.currency_id != o.company_id.currency_id">
|
||||
<span t-field="move_line.amount_currency"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<label string="Check Deposit" for="name"/>
|
||||
<label string="Bank Deposit" for="name"/>
|
||||
<h1>
|
||||
<field name="name"/>
|
||||
</h1>
|
||||
@@ -40,7 +40,7 @@
|
||||
<field name="journal_id"
|
||||
widget="selection"/>
|
||||
<field name="journal_default_account_id"
|
||||
invisible="1"/>
|
||||
invisible="1"/>
|
||||
<field name="currency_id"
|
||||
groups="base.group_multi_currency"/>
|
||||
<field name="bank_journal_id" widget="selection"/>
|
||||
@@ -54,13 +54,13 @@
|
||||
<field name="total_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="move_id"/>
|
||||
<field name="is_reconcile"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="Check Payments" name="check_payments">
|
||||
<group string="Bank Payments" name="check_payments">
|
||||
<field name="check_payment_ids" nolabel="1"
|
||||
widget="many2many"
|
||||
domain="[('reconciled', '=', False),
|
||||
('debit', '>', 0),
|
||||
('check_deposit_id', '=', False),
|
||||
('currency_id', '=', currency_none_same_company_id),
|
||||
('account_id', '=', journal_default_account_id)]"
|
||||
@@ -113,7 +113,7 @@
|
||||
<field name="model">account.check.deposit</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name" string="Checks Deposit"/>
|
||||
<field name="name" string="Bank Deposit"/>
|
||||
<filter name="draft" string="Draft"
|
||||
domain="[('state', '=', 'draft')]"/>
|
||||
<filter name="done" string="Done"
|
||||
@@ -133,7 +133,7 @@
|
||||
</record>
|
||||
|
||||
<record id="action_check_deposit_tree" model="ir.actions.act_window">
|
||||
<field name="name">Checks Deposits</field>
|
||||
<field name="name">Bank Deposits</field>
|
||||
<field name="res_model">account.check.deposit</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
23
account_check_deposit/views/account_journal_view.xml
Normal file
23
account_check_deposit/views/account_journal_view.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2019-Today GRAP (http://www.grap.coop/)
|
||||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<record id="account_journal_form" model="ir.ui.view">
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="type" position="after">
|
||||
<field name="can_receive_deposit" attrs="{'invisible': [('type', '!=', 'bank')]}"/>
|
||||
<field name="can_be_deposited" attrs="{'invisible': [('type', 'not in', ['bank', 'cash'])]}"/>
|
||||
<field name="deposit_debit_account_id" attrs="{
|
||||
'invisible': [('can_be_deposited', '=', False)],
|
||||
'required': [('can_be_deposited', '=', True)]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user