account_check_deposit: Don't force 'name' of account.move

Add print button (feature up-ported from v10)
Add option to post moves (feature up-ported from v10)
Sequence now takes into account the deposit date
Customize the filename of the report
Update README with v12 labels
This commit is contained in:
Alexis de Lattre
2019-03-02 13:16:06 +01:00
committed by Thomas Binsfeld (ACSONE)
parent 5cfb5bbb66
commit 800db2b5b0
9 changed files with 37 additions and 22 deletions

View File

@@ -16,7 +16,6 @@ class AccountCheckDeposit(models.Model):
_description = "Account Check Deposit"
_order = 'deposit_date desc'
@api.multi
@api.depends(
'company_id', 'currency_id', 'check_payment_ids.debit',
'check_payment_ids.amount_currency',
@@ -59,12 +58,12 @@ class AccountCheckDeposit(models.Model):
required=True, states={'done': [('readonly', '=', True)]})
journal_default_account_id = fields.Many2one(
'account.account', related='journal_id.default_debit_account_id',
string='Default Debit Account of the Journal', readonly=True)
string='Default Debit Account of the Journal')
currency_id = fields.Many2one(
'res.currency', string='Currency', required=True,
states={'done': [('readonly', '=', True)]})
currency_none_same_company_id = fields.Many2one(
'res.currency', compute='_compute_check_deposit',
'res.currency', compute='_compute_check_deposit', store=True,
string='Currency (False if same as company)')
state = fields.Selection(
[
@@ -84,20 +83,18 @@ class AccountCheckDeposit(models.Model):
company_id = fields.Many2one(
'res.company', string='Company', required=True,
states={'done': [('readonly', '=', True)]},
default=lambda self: self.env['res.company']._company_default_get(
'account.check.deposit'))
default=lambda self: self.env['res.company']._company_default_get())
total_amount = fields.Float(
compute='_compute_check_deposit',
string="Total Amount", readonly=True,
string="Total Amount", readonly=True, store=True,
digits=dp.get_precision('Account'))
check_count = fields.Integer(
compute='_compute_check_deposit', readonly=True,
compute='_compute_check_deposit', readonly=True, store=True,
string="Number of Checks")
is_reconcile = fields.Boolean(
compute='_compute_check_deposit', readonly=True,
compute='_compute_check_deposit', readonly=True, store=True,
string="Reconcile")
@api.multi
@api.constrains('currency_id', 'check_payment_ids', 'company_id')
def _check_deposit(self):
for deposit in self:
@@ -123,7 +120,6 @@ class AccountCheckDeposit(models.Model):
line.currency_id.name,
deposit_currency.name))
@api.multi
def unlink(self):
for deposit in self:
if deposit.state == 'done':
@@ -133,7 +129,6 @@ class AccountCheckDeposit(models.Model):
% deposit.name)
return super(AccountCheckDeposit, self).unlink()
@api.multi
def backtodraft(self):
for deposit in self:
if deposit.move_id:
@@ -150,6 +145,7 @@ class AccountCheckDeposit(models.Model):
def create(self, vals):
if vals.get('name', '/') == '/':
vals['name'] = self.env['ir.sequence'].\
with_context(ir_sequence_date=vals.get('deposit_date')).\
next_by_code('account.check.deposit')
return super(AccountCheckDeposit, self).create(vals)
@@ -164,8 +160,7 @@ class AccountCheckDeposit(models.Model):
move_vals = {
'journal_id': journal_id,
'date': deposit.deposit_date,
'name': _('Check Deposit %s') % deposit.name,
'ref': deposit.name,
'ref': _('Check Deposit %s') % deposit.name,
}
return move_vals
@@ -199,7 +194,7 @@ class AccountCheckDeposit(models.Model):
elif company.check_deposit_offsetting_account == 'transfer_account':
if not company.check_deposit_transfer_account_id:
raise UserError(_(
"Missing 'Account for Check Deposits' on the "
"Missing 'Check Deposit Offsetting Account' on the "
"company '%s'.") % company.name)
account_id = company.check_deposit_transfer_account_id.id
return {
@@ -212,7 +207,6 @@ class AccountCheckDeposit(models.Model):
'amount_currency': total_amount_currency,
}
@api.multi
def validate_deposit(self):
am_obj = self.env['account.move']
move_line_obj = self.env['account.move.line']
@@ -236,6 +230,8 @@ class AccountCheckDeposit(models.Model):
deposit, total_debit, total_amount_currency)
counter_vals['move_id'] = move.id
move_line_obj.create(counter_vals)
if deposit.company_id.check_deposit_post_move:
move.post()
deposit.write({'state': 'done', 'move_id': move.id})
for reconcile_lines in to_reconcile_lines:
@@ -261,3 +257,9 @@ class AccountCheckDeposit(models.Model):
self.currency_id = self.journal_id.currency_id
else:
self.currency_id = self.journal_id.company_id.currency_id
def get_report(self):
report = self.env.ref(
'account_check_deposit.report_account_check_deposit')
action = report.report_action(self)
return action

View File

@@ -5,7 +5,7 @@
# @author: Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields
from odoo import fields, models
class ResCompany(models.Model):
@@ -19,3 +19,5 @@ class ResCompany(models.Model):
'account.account', string='Transfer Account for Check Deposits',
ondelete='restrict', copy=False,
domain=[('reconcile', '=', True), ('deprecated', '=', False)])
check_deposit_post_move = fields.Boolean(
string='Post Move for Check Deposits')

View File

@@ -16,3 +16,6 @@ class ResConfigSettings(models.TransientModel):
related='company_id.check_deposit_transfer_account_id',
readonly=False,
)
check_deposit_post_move = fields.Boolean(
related='company_id.check_deposit_post_move', readonly=False,
)

View File

@@ -1,10 +1,10 @@
When you receive a check that pays a customer invoice, you can go to that
invoice and click on the button *Register Payment* and select the
*Check Received* journal as *Payment Method*.
*Check Received* journal as *Payment Journal*.
When you want to deposit checks to the bank, go to the menu
*Accounting > Adviser > Check Deposit*, create a new check deposit and set the
*Invoicing > Accounting > Check Deposit*, create a new check deposit and set the
journal *Checks Received* and select the bank account on which you want to
credit the checks. Then click on *Add an item* to select the checks you want to
credit the checks. Then click on *Add a line* to select the checks you want to
deposit at the bank. Eventually, validate the deposit and print the report
(you probably want to customize this report).

View File

@@ -14,6 +14,7 @@
report_type="qweb-pdf"
name="account_check_deposit.report_checkdeposit"
file="account_check_deposit.report_checkdeposit"
print_report_name="'check_deposit-%s%s' % (object.name, object.state == 'draft' and '-draft' or '')"
/>
</odoo>

View File

@@ -11,7 +11,6 @@
<record id="check_deposit_rule" model="ir.rule">
<field name="name">Check Deposit multi-company</field>
<field name="model_id" ref="model_account_check_deposit"/>
<field name="global" eval="True"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>

View File

@@ -1,2 +1 @@
from . import test_check_deposit

View File

@@ -22,6 +22,7 @@
states="done"
string="Back to Draft"
type="object"/>
<button name="get_report" string="Print" type="object"/>
<field name="state"
widget="statusbar"
statusbar_visible="draft,done"/>

View File

@@ -23,7 +23,7 @@
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box" attrs="{'invisible': ['|', ('has_chart_of_accounts', '=', False), ('check_deposit_offsetting_account', '!=', 'transfer_account')]}">
<div class="col-xs-12 col-md-6 o_setting_box" attrs="{'invisible': ['|', ('has_chart_of_accounts', '=', False), ('check_deposit_offsetting_account', '!=', 'transfer_account')]}" id="account_check_deposit_transfer_account_id">
<div class="o_setting_left_pane"/>
<div class="o_setting_right_pane">
<label for="check_deposit_transfer_account_id"/>
@@ -32,6 +32,14 @@
/>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box" id="account_check_deposit_post_move">
<div class="o_setting_left_pane">
<field name="check_deposit_post_move" />
</div>
<div class="o_setting_right_pane">
<label for="check_deposit_post_move"/>
</div>
</div>
</div>
</xpath>
</field>