summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/account_general_ledger.py58
-rw-r--r--indoteknik_custom/models/account_report_general_ledger.py2
2 files changed, 46 insertions, 14 deletions
diff --git a/indoteknik_custom/models/account_general_ledger.py b/indoteknik_custom/models/account_general_ledger.py
index 6f73544c..4fccf0b0 100644
--- a/indoteknik_custom/models/account_general_ledger.py
+++ b/indoteknik_custom/models/account_general_ledger.py
@@ -1,12 +1,51 @@
+# -*- coding: utf-8 -*-
+######################################################################################
+#
+# Cybrosys Technologies Pvt. Ltd.
+#
+# Copyright (C) 2020-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
+# Author: Cybrosys Technologies (odoo@cybrosys.com)
+#
+# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
+# It is forbidden to publish, distribute, sublicense, or sell copies of the Software
+# or modified copies of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+########################################################################################
+
import time
from odoo import api, models, _
from odoo.exceptions import UserError
class ReportGeneralLedger(models.AbstractModel):
- _inherit = 'report.account.report_generalledger'
-
- def _get_account_move_entry_posted_custom(self, accounts, init_balance, sortby, display_account):
+ _name = 'report.account.report_generalledger'
+
+ def _get_account_move_entry_custom(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}
@@ -31,7 +70,6 @@ class ReportGeneralLedger(models.AbstractModel):
LEFT JOIN account_move i ON (m.id =i.id)\
JOIN account_journal j ON (l.journal_id=j.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():
@@ -73,7 +111,7 @@ class ReportGeneralLedger(models.AbstractModel):
account_res = []
for account in accounts:
currency = account.currency_id and account.currency_id or account.company_id.currency_id
- res = dict((fn, 0.0) for fn in ['credit', 'debit', 'balance'])
+ res = dict((fn, 0.0) for fn in ['credit', 'debit', 'balance', 'balance_month'])
res['code'] = account.code
res['name'] = account.name
res['company_id'] = account.company_id.id
@@ -81,14 +119,13 @@ class ReportGeneralLedger(models.AbstractModel):
for line in res.get('move_lines'):
res['debit'] += line['debit']
res['credit'] += line['credit']
- res['balance'] = res['balance']
+ 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
@@ -107,12 +144,7 @@ class ReportGeneralLedger(models.AbstractModel):
codes = [journal.code for journal in self.env['account.journal'].search([('id', 'in', data['form']['journal_ids'])])]
accounts = docs if model == 'account.account' else self.env['account.account'].search([])
- date_from = data['form'].get('date_from', False)
- date_to = data['form'].get('date_to', False)
- accounts_res = self.with_context(data['form'].get('used_context', {}))._get_account_move_entry_posted_custom(accounts, init_balance, sortby, display_account, date_from, date_to)
- for account in accounts_res:
- debit_sum = sum(line['debit'] for line in account['move_lines'])
-
+ accounts_res = self.with_context(data['form'].get('used_context',{}))._get_account_move_entry_custom(accounts, init_balance, sortby, display_account)
return {
'doc_ids': docids,
'doc_model': model,
diff --git a/indoteknik_custom/models/account_report_general_ledger.py b/indoteknik_custom/models/account_report_general_ledger.py
index 6457b914..11881f39 100644
--- a/indoteknik_custom/models/account_report_general_ledger.py
+++ b/indoteknik_custom/models/account_report_general_ledger.py
@@ -82,7 +82,7 @@ class AccountReportGeneralLedger(models.TransientModel):
init_balance = vals['initial_balance']
date_from = options['form'].get('date_from', False)
date_to = options['form'].get('date_to', False)
- report_obj = env_obj.with_context(data['form'].get('used_context', {}))._get_account_move_entry_posted_custom(
+ report_obj = env_obj.with_context(data['form'].get('used_context', {}))._get_account_move_entry_custom(
accounts, init_balance, sortby, display_account)
sheet = workbook.add_worksheet()
format1 = workbook.add_format({'font_size': 16, 'align': 'center', 'bg_color': '#D3D3D3', 'bold': True})