Tower: unpublish om_account_daily_reports — remove source from 19.0 branch
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
from . import report_daybook
|
||||
from . import report_cashbook
|
||||
from . import report_bankbook
|
||||
@@ -1,183 +0,0 @@
|
||||
import time
|
||||
from odoo import api, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportBankBook(models.AbstractModel):
|
||||
_name = 'report.om_account_daily_reports.report_bankbook'
|
||||
_description = 'Bank Book'
|
||||
|
||||
def _get_account_move_entry(self, accounts, init_balance, sortby, display_account):
|
||||
"""
|
||||
:param:
|
||||
accounts: the record set of accounts
|
||||
init_balance: boolean value of initial_balance
|
||||
sortby: sorting by date or partner and journal
|
||||
display_account: type of account (receivable, payable and both)
|
||||
|
||||
Returns a dictionary of accounts with following key and value:
|
||||
{
|
||||
'code': account code,
|
||||
'name': account name,
|
||||
'debit': sum of total debit amount,
|
||||
'credit': sum of total credit amount,
|
||||
'balance': total balance,
|
||||
'amount_currency': sum of amount_currency,
|
||||
'move_lines': list of move lines
|
||||
}
|
||||
"""
|
||||
cr = self.env.cr
|
||||
MoveLine = self.env['account.move.line']
|
||||
move_lines = {x: [] for x in accounts.ids}
|
||||
|
||||
# Prepare initial SQL query and get the initial move lines
|
||||
if init_balance:
|
||||
init_tables, init_where_clause, init_where_params = MoveLine.with_context(
|
||||
date_from=self.env.context.get('date_from'),
|
||||
date_to=False,
|
||||
initial_bal=True
|
||||
)._query_get()
|
||||
|
||||
init_wheres = [""]
|
||||
if init_where_clause.strip():
|
||||
init_wheres.append(init_where_clause.strip())
|
||||
init_filters = " AND ".join(init_wheres)
|
||||
filters = init_filters.replace('account_move_line__move_id', 'm').replace('account_move_line', 'l')
|
||||
|
||||
sql = ("""
|
||||
SELECT 0 AS lid,
|
||||
l.account_id AS account_id,
|
||||
'' AS ldate, '' AS lcode, 0.0 AS amount_currency,
|
||||
'' AS lref, 'Initial Balance' AS lname,
|
||||
COALESCE(SUM(l.credit), 0.0) AS credit,
|
||||
COALESCE(SUM(l.debit), 0.0) AS debit,
|
||||
COALESCE(SUM(l.debit), 0) - COALESCE(SUM(l.credit), 0) AS balance,
|
||||
'' AS lpartner_id, '' AS move_name, '' AS currency_code,
|
||||
NULL AS currency_id, '' AS partner_name,
|
||||
'' AS mmove_id, '' AS invoice_id, '' AS invoice_type, '' AS invoice_number
|
||||
FROM account_move_line l
|
||||
LEFT JOIN account_move m ON (l.move_id = m.id)
|
||||
LEFT JOIN res_currency c ON (l.currency_id = c.id)
|
||||
LEFT JOIN res_partner p ON (l.partner_id = p.id)
|
||||
JOIN account_journal j ON (l.journal_id = j.id)
|
||||
JOIN account_account acc ON (l.account_id = acc.id)
|
||||
WHERE l.account_id IN %s """ + filters + 'GROUP BY l.account_id'
|
||||
)
|
||||
|
||||
params = (tuple(accounts.ids),) + tuple(init_where_params)
|
||||
cr.execute(sql, params)
|
||||
for row in cr.dictfetchall():
|
||||
move_lines[row.pop('account_id')].append(row)
|
||||
|
||||
sql_sort = 'l.date, l.move_id'
|
||||
if sortby == 'sort_journal_partner':
|
||||
sql_sort = 'j.code, p.name, l.move_id'
|
||||
|
||||
# Prepare SQL query based on selected parameters from wizard
|
||||
tables, where_clause, where_params = MoveLine._query_get()
|
||||
wheres = [""]
|
||||
if where_clause.strip():
|
||||
wheres.append(where_clause.strip())
|
||||
filters = " AND ".join(wheres).replace('account_move_line__move_id', 'm').replace('account_move_line', 'l')
|
||||
|
||||
if not accounts:
|
||||
journals = self.env['account.journal'].search([('type', '=', 'bank')])
|
||||
accounts = self.env['account.account']
|
||||
for journal in journals:
|
||||
for acc_out in journal.outbound_payment_method_line_ids:
|
||||
if acc_out.payment_account_id:
|
||||
accounts += acc_out.payment_account_id
|
||||
for acc_in in journal.inbound_payment_method_line_ids:
|
||||
if acc_in.payment_account_id:
|
||||
accounts += acc_in.payment_account_id
|
||||
|
||||
sql = ('''
|
||||
SELECT l.id AS lid, l.account_id AS account_id, l.date AS ldate, j.code AS lcode,
|
||||
l.currency_id, l.amount_currency, l.ref AS lref, l.name AS lname,
|
||||
COALESCE(l.debit, 0) AS debit, COALESCE(l.credit, 0) AS credit,
|
||||
COALESCE(SUM(l.debit), 0) - COALESCE(SUM(l.credit), 0) AS balance,
|
||||
m.name AS move_name, c.symbol AS currency_code, p.name AS partner_name
|
||||
FROM account_move_line l
|
||||
JOIN account_move m ON (l.move_id = m.id)
|
||||
LEFT JOIN res_currency c ON (l.currency_id = c.id)
|
||||
LEFT JOIN res_partner p ON (l.partner_id = p.id)
|
||||
JOIN account_journal j ON (l.journal_id = j.id)
|
||||
JOIN account_account acc ON (l.account_id = acc.id)
|
||||
WHERE l.account_id IN %s ''' + filters + '''
|
||||
GROUP BY l.id, l.account_id, l.date, j.code, l.currency_id, l.amount_currency,
|
||||
l.ref, l.name, m.name, c.symbol, p.name
|
||||
ORDER BY ''' + sql_sort
|
||||
)
|
||||
|
||||
params = (tuple(accounts.ids),) + tuple(where_params)
|
||||
cr.execute(sql, params)
|
||||
|
||||
for row in cr.dictfetchall():
|
||||
balance = 0
|
||||
for line in move_lines.get(row['account_id']):
|
||||
balance += line['debit'] - line['credit']
|
||||
row['balance'] += balance
|
||||
move_lines[row.pop('account_id')].append(row)
|
||||
|
||||
# Calculate the debit, credit and balance for accounts
|
||||
account_res = []
|
||||
for account in accounts:
|
||||
currency = account.currency_id or self.env.company.currency_id
|
||||
res = {fn: 0.0 for fn in ['credit', 'debit', 'balance']}
|
||||
res.update({'code': account.code, 'name': account.name, 'move_lines': move_lines[account.id]})
|
||||
|
||||
for line in res.get('move_lines'):
|
||||
res['debit'] += line['debit']
|
||||
res['credit'] += line['credit']
|
||||
res['balance'] = line['balance']
|
||||
|
||||
if display_account == 'all':
|
||||
account_res.append(res)
|
||||
elif display_account == 'movement' and res.get('move_lines'):
|
||||
account_res.append(res)
|
||||
elif display_account == 'not_zero' and not currency.is_zero(res['balance']):
|
||||
account_res.append(res)
|
||||
|
||||
return account_res
|
||||
|
||||
@api.model
|
||||
def _get_report_values(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model'):
|
||||
raise UserError(_("Form content is missing, this report cannot be printed."))
|
||||
|
||||
model = self.env.context.get('active_model')
|
||||
docs = self.env[model].browse(self.env.context.get('active_ids', []))
|
||||
init_balance = data['form'].get('initial_balance', True)
|
||||
display_account = data['form'].get('display_account')
|
||||
|
||||
sortby = data['form'].get('sortby', 'sort_date')
|
||||
codes = []
|
||||
|
||||
if data['form'].get('journal_ids', False):
|
||||
codes = [journal.code for journal in self.env['account.journal'].browse(data['form']['journal_ids'])]
|
||||
|
||||
accounts = self.env['account.account'].browse(data['form']['account_ids'])
|
||||
if not accounts:
|
||||
journals = self.env['account.journal'].search([('type', '=', 'bank')])
|
||||
accounts = self.env['account.account']
|
||||
for journal in journals:
|
||||
for acc_out in journal.outbound_payment_method_line_ids:
|
||||
if acc_out.payment_account_id:
|
||||
accounts += acc_out.payment_account_id
|
||||
for acc_in in journal.inbound_payment_method_line_ids:
|
||||
if acc_in.payment_account_id:
|
||||
accounts += acc_in.payment_account_id
|
||||
|
||||
record = self.with_context(data['form'].get('comparison_context', {}))._get_account_move_entry(
|
||||
accounts, init_balance, sortby, display_account
|
||||
)
|
||||
|
||||
return {
|
||||
'doc_ids': docids,
|
||||
'doc_model': model,
|
||||
'data': data['form'],
|
||||
'docs': docs,
|
||||
'time': time,
|
||||
'Accounts': record,
|
||||
'print_journal': codes,
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="report_bankbook">
|
||||
<t t-call="web.html_container">
|
||||
<t t-set="data_report_margin_top" t-value="12"/>
|
||||
<t t-set="data_report_header_spacing" t-value="9"/>
|
||||
<t t-set="data_report_dpi" t-value="110"/>
|
||||
<t t-call="web.internal_layout">
|
||||
<div class="page">
|
||||
<h2>Account Bank Book</h2>
|
||||
</div>
|
||||
<div class="row mt32">
|
||||
<div class="col-4">
|
||||
<strong>Journals:</strong>
|
||||
<p t-esc="', '.join([ lt or '' for lt in print_journal ])"/>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<strong>Start Date:</strong>
|
||||
<p t-esc="data['date_from']"/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
|
||||
<strong>End Date:</strong>
|
||||
<p t-esc="data['date_to']"/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div style="width:70%;">
|
||||
<strong>Sorted By:</strong>
|
||||
<p t-if="data['sortby'] == 'sort_date'">Date</p>
|
||||
<p t-if="data['sortby'] == 'sort_journal_partner'">Journal and Partner</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<strong>Target Moves:</strong>
|
||||
<p t-if="data['target_move'] == 'all'">All Entries</p>
|
||||
<p t-if="data['target_move'] == 'posted'">Posted Entries</p>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<table class="table table-sm table-reports">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Date</th>
|
||||
<th>JRNL</th>
|
||||
<th>Partner</th>
|
||||
<th>Ref</th>
|
||||
<th>Move</th>
|
||||
<th>Entry Label</th>
|
||||
<th>Debit</th>
|
||||
<th>Credit</th>
|
||||
<th>Balance</th>
|
||||
<th groups="base.group_multi_currency">Currency</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="Accounts" t-as="account">
|
||||
<tr style="font-weight: bold;">
|
||||
<td colspan="6">
|
||||
<span style="color: white;" t-esc="'..'"/>
|
||||
<span t-esc="account['code']"/>
|
||||
<span t-esc="account['name']"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['debit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['credit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['balance']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td groups="base.group_multi_currency"/>
|
||||
</tr>
|
||||
<tr t-foreach="account['move_lines']" t-as="line">
|
||||
<td>
|
||||
<span t-esc="line['ldate']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['lcode']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['partner_name']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-if="line['lref']" t-esc="line['lref']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['move_name']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['lname']"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['debit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['credit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['balance']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td t-if="line['amount_currency']" class="text-end"
|
||||
groups="base.group_multi_currency">
|
||||
<span t-esc="line['amount_currency'] if line['amount_currency'] > 0.00 else ''"/>
|
||||
<span t-esc="line['currency_code'] if line['amount_currency'] > 0.00 else ''"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
@@ -1,156 +0,0 @@
|
||||
import time
|
||||
from odoo import api, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportCashBook(models.AbstractModel):
|
||||
_name = 'report.om_account_daily_reports.report_cashbook'
|
||||
_description = 'Cash Book'
|
||||
|
||||
def _get_account_move_entry(self, accounts, init_balance, sortby, display_account):
|
||||
"""
|
||||
:param:
|
||||
accounts: the recordset of accounts
|
||||
init_balance: boolean value of initial_balance
|
||||
sortby: sorting by date or partner and journal
|
||||
display_account: type of account(receivable, payable and both)
|
||||
|
||||
Returns a dictionary of accounts with following key and value {
|
||||
'code': account code,
|
||||
'name': account name,
|
||||
'debit': sum of total debit amount,
|
||||
'credit': sum of total credit amount,
|
||||
'balance': total balance,
|
||||
'amount_currency': sum of amount_currency,
|
||||
'move_lines': list of move line
|
||||
}
|
||||
"""
|
||||
cr = self.env.cr
|
||||
MoveLine = self.env['account.move.line']
|
||||
move_lines = {x: [] for x in accounts.ids}
|
||||
|
||||
# Prepare initial sql query and Get the initial move lines
|
||||
if init_balance:
|
||||
init_tables, init_where_clause, init_where_params = MoveLine.with_context(date_from=self.env.context.get('date_from'), date_to=False,initial_bal=True)._query_get()
|
||||
init_wheres = [""]
|
||||
if init_where_clause.strip():
|
||||
init_wheres.append(init_where_clause.strip())
|
||||
init_filters = " AND ".join(init_wheres)
|
||||
filters = init_filters.replace('account_move_line__move_id', 'm').replace('account_move_line', 'l')
|
||||
sql = ("""
|
||||
SELECT 0 AS lid,
|
||||
l.account_id AS account_id, '' AS ldate, '' AS lcode,
|
||||
0.0 AS amount_currency,'' AS lref,'Initial Balance' AS lname,
|
||||
COALESCE(SUM(l.credit),0.0) AS credit,COALESCE(SUM(l.debit),0.0) AS debit,COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit),0) as balance,
|
||||
'' AS lpartner_id,'' AS move_name, '' AS currency_code,NULL AS currency_id,'' AS partner_name,
|
||||
'' AS mmove_id, '' AS invoice_id, '' AS invoice_type,'' AS invoice_number
|
||||
FROM account_move_line l
|
||||
LEFT JOIN account_move m ON (l.move_id = m.id)
|
||||
LEFT JOIN res_currency c ON (l.currency_id = c.id)
|
||||
LEFT JOIN res_partner p ON (l.partner_id = p.id)
|
||||
JOIN account_journal j ON (l.journal_id = j.id)
|
||||
JOIN account_account acc ON (l.account_id = acc.id)
|
||||
WHERE l.account_id IN %s""" + filters + 'GROUP BY l.account_id')
|
||||
params = (tuple(accounts.ids),) + tuple(init_where_params)
|
||||
cr.execute(sql, params)
|
||||
for row in cr.dictfetchall():
|
||||
move_lines[row.pop('account_id')].append(row)
|
||||
|
||||
sql_sort = 'l.date, l.move_id'
|
||||
if sortby == 'sort_journal_partner':
|
||||
sql_sort = 'j.code, p.name, l.move_id'
|
||||
|
||||
# Prepare sql query base on selected parameters from wizard
|
||||
tables, where_clause, where_params = MoveLine._query_get()
|
||||
wheres = [""]
|
||||
if where_clause.strip():
|
||||
wheres.append(where_clause.strip())
|
||||
filters = " AND ".join(wheres)
|
||||
filters = filters.replace('account_move_line__move_id', 'm').replace('account_move_line', 'l')
|
||||
if not accounts:
|
||||
journals = self.env['account.journal'].search([('type', '=', 'cash')])
|
||||
accounts = self.env['account.account']
|
||||
for journal in journals:
|
||||
for acc_out in journal.outbound_payment_method_line_ids:
|
||||
if acc_out.payment_account_id:
|
||||
accounts += acc_out.payment_account_id
|
||||
for acc_in in journal.inbound_payment_method_line_ids:
|
||||
if acc_in.payment_account_id:
|
||||
accounts += acc_in.payment_account_id
|
||||
|
||||
sql = ('''SELECT l.id AS lid, l.account_id AS account_id, l.date AS ldate, j.code AS lcode, l.currency_id, l.amount_currency, l.ref AS lref, l.name AS lname, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) AS balance,\
|
||||
m.name AS move_name, c.symbol AS currency_code, p.name AS partner_name\
|
||||
FROM account_move_line l\
|
||||
JOIN account_move m ON (l.move_id=m.id)\
|
||||
LEFT JOIN res_currency c ON (l.currency_id=c.id)\
|
||||
LEFT JOIN res_partner p ON (l.partner_id=p.id)\
|
||||
JOIN account_journal j ON (l.journal_id=j.id)\
|
||||
JOIN account_account acc ON (l.account_id = acc.id) \
|
||||
WHERE l.account_id IN %s ''' + filters + ''' GROUP BY l.id, l.account_id, l.date, j.code, l.currency_id, l.amount_currency, l.ref, l.name, m.name, c.symbol, p.name ORDER BY ''' + sql_sort)
|
||||
params = (tuple(accounts.ids),) + tuple(where_params)
|
||||
cr.execute(sql, params)
|
||||
|
||||
for row in cr.dictfetchall():
|
||||
balance = 0
|
||||
for line in move_lines.get(row['account_id']):
|
||||
balance += line['debit'] - line['credit']
|
||||
row['balance'] += balance
|
||||
move_lines[row.pop('account_id')].append(row)
|
||||
|
||||
# Calculate the debit, credit and balance for Accounts
|
||||
account_res = []
|
||||
for account in accounts:
|
||||
currency = account.currency_id and account.currency_id or self.env.company.currency_id
|
||||
res = dict((fn, 0.0) for fn in ['credit', 'debit', 'balance'])
|
||||
res['code'] = account.code
|
||||
res['name'] = account.name
|
||||
res['move_lines'] = move_lines[account.id]
|
||||
for line in res.get('move_lines'):
|
||||
res['debit'] += line['debit']
|
||||
res['credit'] += line['credit']
|
||||
res['balance'] = line['balance']
|
||||
if display_account == 'all':
|
||||
account_res.append(res)
|
||||
if display_account == 'movement' and res.get('move_lines'):
|
||||
account_res.append(res)
|
||||
if display_account == 'not_zero' and not currency.is_zero(res['balance']):
|
||||
account_res.append(res)
|
||||
return account_res
|
||||
|
||||
@api.model
|
||||
def _get_report_values(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model'):
|
||||
raise UserError(_("Form content is missing, this report cannot be printed."))
|
||||
model = self.env.context.get('active_model')
|
||||
docs = self.env[model].browse(self.env.context.get('active_ids', []))
|
||||
init_balance = data['form'].get('initial_balance', True)
|
||||
display_account = data['form'].get('display_account')
|
||||
|
||||
sortby = data['form'].get('sortby', 'sort_date')
|
||||
codes = []
|
||||
|
||||
if data['form'].get('journal_ids', False):
|
||||
codes = [journal.code for journal in
|
||||
self.env['account.journal'].browse(data['form']['journal_ids'])]
|
||||
account_ids = data['form']['account_ids']
|
||||
accounts = self.env['account.account'].browse(account_ids)
|
||||
if not accounts:
|
||||
journals = self.env['account.journal'].search([('type', '=', 'cash')])
|
||||
accounts = self.env['account.account']
|
||||
for journal in journals:
|
||||
for acc_out in journal.outbound_payment_method_line_ids:
|
||||
if acc_out.payment_account_id:
|
||||
accounts += acc_out.payment_account_id
|
||||
for acc_in in journal.inbound_payment_method_line_ids:
|
||||
if acc_in.payment_account_id:
|
||||
accounts += acc_in.payment_account_id
|
||||
record = self.with_context(data['form'].get('comparison_context', {}))._get_account_move_entry(accounts, init_balance, sortby, display_account)
|
||||
return {
|
||||
'doc_ids': docids,
|
||||
'doc_model': model,
|
||||
'data': data['form'],
|
||||
'docs': docs,
|
||||
'time': time,
|
||||
'Accounts': record,
|
||||
'print_journal': codes,
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="report_cashbook">
|
||||
<t t-call="web.html_container">
|
||||
<t t-set="data_report_margin_top" t-value="12"/>
|
||||
<t t-set="data_report_header_spacing" t-value="9"/>
|
||||
<t t-set="data_report_dpi" t-value="110"/>
|
||||
<t t-call="web.internal_layout">
|
||||
<div class="page">
|
||||
<h2>Account Cash Book</h2>
|
||||
</div>
|
||||
<div class="row mt32">
|
||||
<div class="col-4">
|
||||
<strong>Journals:</strong>
|
||||
<p t-esc="', '.join([ lt or '' for lt in print_journal ])"/>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<strong>Start Date:</strong>
|
||||
<p t-esc="data['date_from']"/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
|
||||
<strong>End Date:</strong>
|
||||
<p t-esc="data['date_to']"/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div style="width:70%;">
|
||||
<strong>Sorted By:</strong>
|
||||
<p t-if="data['sortby'] == 'sort_date'">Date</p>
|
||||
<p t-if="data['sortby'] == 'sort_journal_partner'">Journal and Partner</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<strong>Target Moves:</strong>
|
||||
<p t-if="data['target_move'] == 'all'">All Entries</p>
|
||||
<p t-if="data['target_move'] == 'posted'">Posted Entries</p>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<table class="table table-sm table-reports">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Date</th>
|
||||
<th>JRNL</th>
|
||||
<th>Partner</th>
|
||||
<th>Ref</th>
|
||||
<th>Move</th>
|
||||
<th>Entry Label</th>
|
||||
<th>Debit</th>
|
||||
<th>Credit</th>
|
||||
<th>Balance</th>
|
||||
<th groups="base.group_multi_currency">Currency</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="Accounts" t-as="account">
|
||||
<tr style="font-weight: bold;">
|
||||
<td colspan="6">
|
||||
<span style="color: white;" t-esc="'..'"/>
|
||||
<span t-esc="account['code']"/>
|
||||
<span t-esc="account['name']"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['debit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['credit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['balance']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td groups="base.group_multi_currency"/>
|
||||
</tr>
|
||||
<tr t-foreach="account['move_lines']" t-as="line">
|
||||
<td>
|
||||
<span t-esc="line['ldate']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['lcode']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['partner_name']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-if="line['lref']" t-esc="line['lref']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['move_name']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['lname']"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['debit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['credit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['balance']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>
|
||||
</td>
|
||||
<td t-if="line['amount_currency']" class="text-end"
|
||||
groups="base.group_multi_currency">
|
||||
<span t-esc="line['amount_currency'] if line['amount_currency'] > 0.00 else ''"/>
|
||||
<span t-esc="line['currency_code'] if line['amount_currency'] > 0.00 else ''"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
@@ -1,113 +0,0 @@
|
||||
import time
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import UserError
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
|
||||
class ReportDayBook(models.AbstractModel):
|
||||
_name = 'report.om_account_daily_reports.report_daybook'
|
||||
_description = 'Day Book'
|
||||
|
||||
def _get_account_move_entry(self, accounts, form_data, date):
|
||||
cr = self.env.cr
|
||||
MoveLine = self.env['account.move.line']
|
||||
init_wheres = [""]
|
||||
|
||||
init_tables, init_where_clause, init_where_params =MoveLine._query_get()
|
||||
if init_where_clause.strip():
|
||||
init_wheres.append(init_where_clause.strip())
|
||||
if form_data['target_move'] == 'posted':
|
||||
target_move = "AND m.state = 'posted'"
|
||||
else:
|
||||
target_move = ''
|
||||
|
||||
sql = ("""
|
||||
SELECT 0 AS lid,
|
||||
l.account_id AS account_id, l.date AS ldate, j.code AS lcode,
|
||||
l.amount_currency AS amount_currency,l.ref AS lref,l.name AS lname,
|
||||
COALESCE(SUM(l.credit),0.0) AS credit,COALESCE(l.debit,0) AS debit,COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit),0) as balance,
|
||||
m.name AS move_name,
|
||||
c.symbol AS currency_code,
|
||||
p.name AS lpartner_id,
|
||||
m.id AS mmove_id
|
||||
FROM
|
||||
account_move_line l
|
||||
LEFT JOIN account_move m ON (l.move_id = m.id)
|
||||
LEFT JOIN res_currency c ON (l.currency_id = c.id)
|
||||
LEFT JOIN res_partner p ON (l.partner_id = p.id)
|
||||
JOIN account_journal j ON (l.journal_id = j.id)
|
||||
JOIN account_account acc ON (l.account_id = acc.id)
|
||||
WHERE
|
||||
l.account_id IN %s
|
||||
AND l.journal_id IN %s """ + target_move + """
|
||||
AND l.date = %s
|
||||
GROUP BY
|
||||
l.id,
|
||||
l.account_id,
|
||||
l.date,
|
||||
m.name,
|
||||
m.id,
|
||||
p.name,
|
||||
c.symbol,
|
||||
j.code,
|
||||
l.ref
|
||||
ORDER BY
|
||||
l.date DESC
|
||||
""")
|
||||
|
||||
where_params = (tuple(accounts.ids), tuple(form_data['journal_ids']), date)
|
||||
cr.execute(sql, where_params)
|
||||
data = cr.dictfetchall()
|
||||
res = {}
|
||||
debit = credit = balance = 0.00
|
||||
for line in data:
|
||||
debit += line['debit']
|
||||
credit += line['credit']
|
||||
balance += line['balance']
|
||||
res['debit'] = debit
|
||||
res['credit'] = credit
|
||||
res['balance'] = balance
|
||||
res['lines'] = data
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _get_report_values(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model'):
|
||||
raise UserError(_("Form content is missing, this report cannot be printed."))
|
||||
model = self.env.context.get('active_model')
|
||||
docs = self.env[model].browse(self.env.context.get('active_ids', []))
|
||||
form_data = data['form']
|
||||
|
||||
date_from = fields.Date.from_string(form_data['date_from'])
|
||||
date_to = fields.Date.from_string(form_data['date_to'])
|
||||
codes = []
|
||||
|
||||
if data['form'].get('journal_ids', False):
|
||||
codes = [journal.code for journal in
|
||||
self.env['account.journal'].browse(data['form']['journal_ids'])]
|
||||
accounts = self.env['account.account'].search([])
|
||||
dates = []
|
||||
record = []
|
||||
days_total = date_to - date_from
|
||||
for day in range(days_total.days + 1):
|
||||
dates.append(date_from + timedelta(days=day))
|
||||
for date in dates:
|
||||
date_data = str(date)
|
||||
accounts_res = self.with_context(data['form'].get('comparison_context', {}))._get_account_move_entry(accounts, form_data, date_data)
|
||||
if accounts_res['lines']:
|
||||
record.append({
|
||||
'date': date,
|
||||
'debit': accounts_res['debit'],
|
||||
'credit': accounts_res['credit'],
|
||||
'balance': accounts_res['balance'],
|
||||
'move_lines': accounts_res['lines']
|
||||
})
|
||||
return {
|
||||
'doc_ids': docids,
|
||||
'doc_model': model,
|
||||
'data': data['form'],
|
||||
'docs': docs,
|
||||
'time': time,
|
||||
'Accounts': record,
|
||||
'print_journal': codes,
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="report_daybook">
|
||||
<t t-call="web.html_container">
|
||||
<t t-set="data_report_margin_top" t-value="12"/>
|
||||
<t t-set="data_report_header_spacing" t-value="9"/>
|
||||
<t t-set="data_report_dpi" t-value="110"/>
|
||||
<t t-call="web.internal_layout">
|
||||
<div class="page">
|
||||
<h2>Account Day Book</h2>
|
||||
|
||||
<div class="row mt32">
|
||||
<div class="col-4">
|
||||
<strong>Journals:</strong>
|
||||
<p t-esc="', '.join([ lt or '' for lt in print_journal ])"/>
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
<strong>Start Date:</strong>
|
||||
<p t-esc="data['date_from']"/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<strong>End Date:</strong>
|
||||
<p t-esc="data['date_to']"/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<strong>Target Moves:</strong>
|
||||
<p t-if="data['target_move'] == 'all'">All Entries</p>
|
||||
<p t-if="data['target_move'] == 'posted'">Posted Entries</p>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-sm table-reports">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>Date</th>
|
||||
<th>JRNL</th>
|
||||
<th>Partner</th>
|
||||
<th>Ref</th>
|
||||
<th>Move</th>
|
||||
<th>Entry Label</th>
|
||||
<th>Debit</th>
|
||||
<th>Credit</th>
|
||||
<th>Balance</th>
|
||||
<th groups="base.group_multi_currency">Currency</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="Accounts" t-as="account">
|
||||
<tr style="font-weight: bold;">
|
||||
<td colspan="6">
|
||||
<span style="color: white;" t-esc="'..'"/>
|
||||
<span t-esc="account['date']"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['debit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['credit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="account['balance']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
|
||||
</td>
|
||||
<td groups="base.group_multi_currency"/>
|
||||
</tr>
|
||||
<tr t-foreach="account['move_lines']" t-as="line">
|
||||
<td>
|
||||
<span t-esc="line['ldate']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['lcode']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['lpartner_id']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-if="line['lref']" t-esc="line['lref']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['move_name']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="line['lname']"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['debit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['credit']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<span t-esc="line['balance']"
|
||||
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
|
||||
</td>
|
||||
<td class="text-end" groups="base.group_multi_currency">
|
||||
<span t-esc="line['amount_currency'] if line['amount_currency'] and line['amount_currency'] > 0.00 else ''"/>
|
||||
<span t-esc="line['currency_code'] if line['amount_currency'] and line['amount_currency'] > 0.00 else ''"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="action_report_day_book" model="ir.actions.report">
|
||||
<field name="name">Day Book</field>
|
||||
<field name="model">account.daybook.report</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">om_account_daily_reports.report_daybook</field>
|
||||
<field name="report_file">om_account_daily_reports.report_daybook</field>
|
||||
</record>
|
||||
|
||||
<record id="action_report_cash_book" model="ir.actions.report">
|
||||
<field name="name">Cash Book</field>
|
||||
<field name="model">account.cashbook.report</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">om_account_daily_reports.report_cashbook</field>
|
||||
<field name="report_file">om_account_daily_reports.report_cashbook</field>
|
||||
</record>
|
||||
|
||||
<record id="action_report_bank_book" model="ir.actions.report">
|
||||
<field name="name">Bank Book</field>
|
||||
<field name="model">account.bankbook.report</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">om_account_daily_reports.report_bankbook</field>
|
||||
<field name="report_file">om_account_daily_reports.report_bankbook</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user