Skip to content

Commit

Permalink
check module added
Browse files Browse the repository at this point in the history
  • Loading branch information
doganaltunbay committed Jan 31, 2020
1 parent b31871c commit 44409e5
Show file tree
Hide file tree
Showing 36 changed files with 3,185 additions and 0 deletions.
Binary file added account_check/ANALISIS CHEQUES.ods
Binary file not shown.
6 changes: 6 additions & 0 deletions account_check/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import models
from . import wizard
36 changes: 36 additions & 0 deletions account_check/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
'name': 'Account Check Management',
'version': '12.0.1.0.0',
'category': 'Accounting',
'summary': 'Accounting, Payment, Check, Third, Issue',
'website': 'www.codequarters.com',
'author': 'CODEQUARTERS',
'license': 'AGPL-3',
'images': [
],
'depends': [
'account',
'account_payment_fix',
# TODO we should move field amount_company_currency to
# account_payment_fix so that we dont need to depend on
# account_payment_group
],
'data': [
'data/account_payment_method_data.xml',
'data/ir_actions_server_data.xml',
'wizard/account_check_action_wizard_view.xml',
'wizard/print_pre_numbered_checks_view.xml',
'views/res_config_settings_view.xml',
'views/account_payment_view.xml',
'views/account_check_view.xml',
'views/account_journal_dashboard_view.xml',
'views/account_journal_view.xml',
'views/account_checkbook_view.xml',
'views/account_chart_template_view.xml',
'security/ir.model.access.csv',
'security/account_check_security.xml',
],
'installable': True,
'auto_install': False,
'application': True,
}
26 changes: 26 additions & 0 deletions account_check/data/account_payment_method_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">

<record id="account_payment_method_received_third_check" model="account.payment.method">
<field name="name">Received Third Check</field>
<field name="code">received_third_check</field>
<field name="payment_type">inbound</field>
</record>

<record id="account_payment_method_delivered_third_check" model="account.payment.method">
<field name="name">Delivered Third Check</field>
<field name="code">delivered_third_check</field>
<field name="payment_type">outbound</field>
</record>

<record id="account_payment_method_issue_check" model="account.payment.method">
<field name="name">Issue Check</field>
<field name="code">issue_check</field>
<field name="payment_type">outbound</field>
</record>

<function model="account.journal" name="_enable_issue_check_on_bank_journals"/>

</data>
</odoo>
14 changes: 14 additions & 0 deletions account_check/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import account_journal
from . import account_invoice
from . import account_checkbook
from . import account_check
from . import account_payment
from . import res_company
from . import account_chart_template
from . import account_bank_statement_line
from . import res_config_settings
59 changes: 59 additions & 0 deletions account_check/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api, _
from odoo.exceptions import ValidationError
import logging
_logger = logging.getLogger(__name__)


class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"

@api.multi
def button_cancel_reconciliation(self):
""" Delete operation of checks that are debited from statement
"""
for st_line in self.filtered('move_name'):
if st_line.journal_entry_ids.filtered(
lambda x:
x.payment_id.payment_reference == st_line.move_name):
check_operation = self.env['account.check.operation'].search(
[('origin', '=',
'account.bank.statement.line,%s' % st_line.id)])
check_operation.check_id._del_operation(st_line)
return super(
AccountBankStatementLine, self).button_cancel_reconciliation()

def process_reconciliation(
self, counterpart_aml_dicts=None, payment_aml_rec=None,
new_aml_dicts=None):
"""
Si el move line de contrapartida es un cheque entregado, entonces
registramos el debito desde el extracto en el cheque
TODO: por ahora si se cancela la linea de extracto no borramos el
debito, habria que ver si queremos hacer eso modificando la funcion de
arriba directamente
"""

check = False
if counterpart_aml_dicts:
for line in counterpart_aml_dicts:
move_line = line.get('move_line')
check = move_line and move_line.payment_id.check_id or False
moves = super(AccountBankStatementLine, self).process_reconciliation(
counterpart_aml_dicts=counterpart_aml_dicts,
payment_aml_rec=payment_aml_rec, new_aml_dicts=new_aml_dicts)
if check and check.state == 'handed':
if check.journal_id != self.statement_id.journal_id:
raise ValidationError(_(
'To record the debit of a check from the statement,'
' the check and extract journal must be the same.' )
)
if len(moves) != 1:
raise ValidationError(_(
'To record the debit of a check from the extract '
'there should only be one counterpart line.'))
check._add_operation('debited', self, date=self.date)
return moves
85 changes: 85 additions & 0 deletions account_check/models/account_chart_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import models, api, fields
import logging
_logger = logging.getLogger(__name__)


class AccountChartTemplate(models.Model):
_inherit = 'account.chart.template'

rejected_check_account_id = fields.Many2one(
'account.account.template',
'Rejected Check Account',
help='Rejection Checks account, for eg. "Rejected Checks"',
# domain=[('type', 'in', ['other'])],
)
deferred_check_account_id = fields.Many2one(
'account.account.template',
'Deferred Check Account',
help='Deferred Checks account, for eg. "Deferred Checks"',
# domain=[('type', 'in', ['other'])],
)
holding_check_account_id = fields.Many2one(
'account.account.template',
'Holding Check Account',
help='Holding Checks account for third checks, '
'for eg. "Holding Checks"',
# domain=[('type', 'in', ['other'])],
)

@api.multi
def _load_template(
self, company, code_digits=None,
account_ref=None, taxes_ref=None):
account_ref, taxes_ref = super(
AccountChartTemplate, self)._load_template(
company,
code_digits=code_digits,
account_ref=account_ref,
taxes_ref=taxes_ref)
for field in [
'rejected_check_account_id',
'deferred_check_account_id',
'holding_check_account_id']:
account_field = self[field]
# TODO we should send it in the context and overwrite with
# lower hierichy values
if account_field:
company[field] = account_ref[account_field.id]
return account_ref, taxes_ref

@api.multi
def _create_bank_journals(self, company, acc_template_ref):
"""
Bank - Cash journals are created with this method
Inherit this function in order to add checks to cash and bank
journals. This is because usually will be installed before chart loaded
and they will be disable by default
"""

res = super(
AccountChartTemplate, self)._create_bank_journals(
company, acc_template_ref)

# creamos diario para cheques de terceros
received_third_check = self.env.ref(
'account_check.account_payment_method_received_third_check')
delivered_third_check = self.env.ref(
'account_check.account_payment_method_delivered_third_check')
self.env['account.journal'].create({
'name': 'Cheques de Terceros',
'type': 'cash',
'company_id': company.id,
'inbound_payment_method_ids': [
(4, received_third_check.id, None)],
'outbound_payment_method_ids': [
(4, delivered_third_check.id, None)],
})

self.env['account.journal'].with_context(
force_company_id=company.id)._enable_issue_check_on_bank_journals()
return res
Loading

0 comments on commit 44409e5

Please sign in to comment.