init commit
commit
1b7ed7777f
|
@ -0,0 +1,7 @@
|
||||||
|
*.pyc
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
.DS_Store
|
||||||
|
.idea/
|
||||||
|
.run/
|
||||||
|
venv/
|
|
@ -0,0 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import models
|
||||||
|
from . import wizards
|
|
@ -0,0 +1,33 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
{
|
||||||
|
'name': "accounting_report",
|
||||||
|
|
||||||
|
'summary': """Accounting Report""",
|
||||||
|
|
||||||
|
'description': """
|
||||||
|
Accounting Report
|
||||||
|
""",
|
||||||
|
|
||||||
|
'author': "",
|
||||||
|
'website': "",
|
||||||
|
|
||||||
|
# Categories can be used to filter modules in modules listing
|
||||||
|
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
|
||||||
|
# for the full list
|
||||||
|
'category': 'Uncategorized',
|
||||||
|
'version': '0.1',
|
||||||
|
|
||||||
|
# any module necessary for this one to work correctly
|
||||||
|
'depends': ['base',
|
||||||
|
'account',
|
||||||
|
],
|
||||||
|
|
||||||
|
# always loaded
|
||||||
|
'data': [
|
||||||
|
'security/ir.model.access.csv',
|
||||||
|
|
||||||
|
'wizards/wz_ledger_bank_and_cash.xml',
|
||||||
|
'views/ledger_bank_and_cash.xml',
|
||||||
|
|
||||||
|
],
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
from . import ledger_bank_and_cash
|
|
@ -0,0 +1 @@
|
||||||
|
*.pyc
|
|
@ -0,0 +1,23 @@
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class LedgerBankAndCash(models.Model):
|
||||||
|
_name = 'ledger.bank.and.cash'
|
||||||
|
_description = 'Bank and Cash Report'
|
||||||
|
_order = 'account_id, date asc'
|
||||||
|
|
||||||
|
date = fields.Date()
|
||||||
|
account_id = fields.Many2one('account.account')
|
||||||
|
move_id = fields.Many2one('account.move')
|
||||||
|
source_no = fields.Char(related='move_id.name')
|
||||||
|
name = fields.Char(related='move_id.ref')
|
||||||
|
partner_id = fields.Many2one('res.partner')
|
||||||
|
currency_id = fields.Many2one('res.currency')
|
||||||
|
debit = fields.Monetary('Debit')
|
||||||
|
credit = fields.Monetary('Credit')
|
||||||
|
beginning_balance = fields.Monetary('Beginning Balance',)
|
||||||
|
account_code = fields.Char('Account Code', related='account_id.code')
|
||||||
|
account_name = fields.Char('Account Name', related='account_id.name')
|
||||||
|
balance = fields.Monetary('Balance',)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_lsbl_ledger_bank_and_cash,lsbl_ledger_bank_and_cash,model_ledger_bank_and_cash,base.group_user,1,1,1,1
|
||||||
|
access_wz_ledger_bank_and_cash,wz_ledger_bank_and_cash,model_wz_ledger_bank_and_cash,base.group_user,1,1,1,1
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="accounting_report_ledger_bank_and_cash_view_tree" model="ir.ui.view">
|
||||||
|
<field name="name">accounting.report.ledger.bank.and.cash.view.tree</field>
|
||||||
|
<field name="model">ledger.bank.and.cash</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree create="false" delete="false" edit="false">
|
||||||
|
<field name="date"/>
|
||||||
|
<field name="account_id" invisible='1'/>
|
||||||
|
<field name="account_code" string="Account No"/>
|
||||||
|
<field name="account_name" string="Account Name"/>
|
||||||
|
<field name="move_id" string="Nomor Dokumen"/>
|
||||||
|
<field name="name" string="Description"/>
|
||||||
|
<field name="partner_id" string="Partner"/>
|
||||||
|
<field name="currency_id"/>
|
||||||
|
<field name="beginning_balance"/>
|
||||||
|
<field name="debit"/>
|
||||||
|
<field name="credit"/>
|
||||||
|
<field name="balance"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_ledger_bank_and_cash" model="ir.actions.act_window">
|
||||||
|
<field name="name">Cash and Bank Book</field>
|
||||||
|
<field name="res_model">ledger.bank.and.cash</field>
|
||||||
|
<field name="view_mode">tree</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p>
|
||||||
|
Nothing Records
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
|
@ -0,0 +1 @@
|
||||||
|
from . import wz_ledger_bank_and_cash
|
|
@ -0,0 +1,72 @@
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
from datetime import date, datetime, timedelta
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
class WzLedgerBankAndCash(models.TransientModel):
|
||||||
|
_name = 'wz.ledger.bank.and.cash'
|
||||||
|
_description = 'Wizard Bank and Cash Report'
|
||||||
|
|
||||||
|
def default_user_type(self):
|
||||||
|
return self.env['account.account.type'].sudo().search([('name', '=', 'Bank and Cash')], limit=1)
|
||||||
|
|
||||||
|
date_from = fields.Date("From Date")
|
||||||
|
date_to = fields.Date("To Date")
|
||||||
|
account_ids = fields.Many2many('account.account', string='Account')
|
||||||
|
user_type_id = fields.Many2one('account.account.type', string='User Type', default=lambda self:self.default_user_type())
|
||||||
|
|
||||||
|
@api.constrains("date_from", "date_to")
|
||||||
|
def _check_filtered(self):
|
||||||
|
for rec in self:
|
||||||
|
if rec.date_from > rec.date_to:
|
||||||
|
raise ValidationError(_("Invalid Date ! End date should be greater than the start date"))
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
beginning_balance = 0
|
||||||
|
balance = 0
|
||||||
|
total_balance = 0
|
||||||
|
start = self.date_from
|
||||||
|
end = self.date_to
|
||||||
|
move_line = self.env['account.move.line'].search([('date', '>=', start), ('date', '<=', end),('account_id', 'in', self.account_ids.ids), ('move_id.state', '=', 'posted')])
|
||||||
|
bank_cash = self.env['ledger.bank.and.cash']
|
||||||
|
move_line2 = self.env['account.move.line'].search([('date', '<=', start), ('account_id', 'in', self.account_ids.ids), ('move_id.state', '=', 'posted')])
|
||||||
|
self.env.cr.execute("""
|
||||||
|
delete from ledger_bank_and_cash
|
||||||
|
""")
|
||||||
|
if move_line:
|
||||||
|
no = 1
|
||||||
|
mv_line_sorted = sorted(move_line, key=lambda x: x["date"])
|
||||||
|
for account in self.account_ids:
|
||||||
|
for rec in mv_line_sorted:
|
||||||
|
if rec.account_id.id == account.id:
|
||||||
|
beginning_balance = sum(move_line2.filtered(lambda x : x.account_id.id == rec.account_id.id).mapped('balance'))
|
||||||
|
if no == 1:
|
||||||
|
balance = beginning_balance + (rec.debit - rec.credit)
|
||||||
|
total_balance = balance
|
||||||
|
else:
|
||||||
|
total_balance += rec.balance
|
||||||
|
bank_cash.create({
|
||||||
|
'date': rec.date,
|
||||||
|
'account_id': rec.account_id.id,
|
||||||
|
'move_id': rec.move_id.id,
|
||||||
|
'partner_id': rec.partner_id.id,
|
||||||
|
'currency_id': rec.currency_id.id,
|
||||||
|
'beginning_balance': beginning_balance,
|
||||||
|
'balance': total_balance,
|
||||||
|
'debit': rec.debit,
|
||||||
|
'credit': rec.credit,
|
||||||
|
})
|
||||||
|
no += 1
|
||||||
|
no = 1
|
||||||
|
if bank_cash:
|
||||||
|
bank_cash.sorted(key=lambda r: (r.date, r.account_id))
|
||||||
|
return {
|
||||||
|
'name': _("Cash and Bank Book Period %s s/d %s" %(self.date_from.strftime("%d-%m-%Y"), self.date_to.strftime("%d-%m-%Y"))),
|
||||||
|
'view_mode': 'list',
|
||||||
|
'view_id': self.env.ref('accounting_report.accounting_report_ledger_bank_and_cash_view_tree').id,
|
||||||
|
'res_model': 'ledger.bank.and.cash',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'context': {
|
||||||
|
'group_by': ['account_id'],
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="wz_ledger_bank_and_cash_form" model="ir.ui.view">
|
||||||
|
<field name="name">wz.ledger.bank.and.cash.form</field>
|
||||||
|
<field name="model">wz.ledger.bank.and.cash</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="">
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="date_from" required="1"/>
|
||||||
|
<field name="date_to" required="1"/>
|
||||||
|
<field name="user_type_id" invisible="1"/>
|
||||||
|
<field name="account_ids" required="1" options="{'no_create' : True}" widget="many2many_tags" domain="[('user_type_id', '=', user_type_id)]"/>
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button string="Generate" name="generate" type="object" class="oe_highlight"/>
|
||||||
|
</footer>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_ledger_bank_and_cash_wizard" model="ir.actions.act_window">
|
||||||
|
<field name="name"> Ledger Detail Bank and Cash Report </field>
|
||||||
|
<field name="res_model">wz.ledger.bank.and.cash</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="report_custom_menu"
|
||||||
|
name="Custom Report"
|
||||||
|
parent="account.menu_finance_reports"
|
||||||
|
sequence="30"/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="wz_general_ledger_detail_bank_andCash_menu_act"
|
||||||
|
name="Cash and Bank"
|
||||||
|
parent="report_custom_menu"
|
||||||
|
action="action_ledger_bank_and_cash_wizard"
|
||||||
|
sequence="6"/>
|
||||||
|
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue