-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
2,809 additions
and
2,418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 24 additions & 10 deletions
34
account_accountant_ux/models/account_journal_dashboard.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
from odoo import models, fields | ||
from odoo import fields, models | ||
from odoo.tools.misc import formatLang | ||
|
||
|
||
class AccountJournal(models.Model): | ||
_inherit = 'account.journal' | ||
_inherit = "account.journal" | ||
|
||
def _get_journal_dashboard_data_batched(self): | ||
res = super(AccountJournal, self)._get_journal_dashboard_data_batched() | ||
self._fill_journal_dashboard_general_balance(res) | ||
return res | ||
|
||
def _fill_journal_dashboard_general_balance(self, dashboard_data): | ||
journals = self.filtered(lambda journal: journal.type in ['bank', 'cash']) | ||
journals = self.filtered(lambda journal: journal.type in ["bank", "cash"]) | ||
for journal in journals: | ||
if journal.default_account_id: | ||
amount_field = 'aml.balance' if (not journal.currency_id or journal.currency_id == journal.company_id.currency_id) else 'aml.amount_currency' | ||
amount_field = ( | ||
"aml.balance" | ||
if (not journal.currency_id or journal.currency_id == journal.company_id.currency_id) | ||
else "aml.amount_currency" | ||
) | ||
query = """SELECT sum(%s) FROM account_move_line aml | ||
LEFT JOIN account_move move ON aml.move_id = move.id | ||
WHERE aml.account_id = %%s | ||
AND move.date <= %%s AND move.state = 'posted';""" % (amount_field,) | ||
self.env.cr.execute(query, (journal.default_account_id.id, fields.Date.context_today(self),)) | ||
self.env.cr.execute( | ||
query, | ||
( | ||
journal.default_account_id.id, | ||
fields.Date.context_today(self), | ||
), | ||
) | ||
query_results = self.env.cr.dictfetchall() | ||
if query_results and query_results[0].get('sum') is not None: | ||
account_sum = query_results[0].get('sum') | ||
if query_results and query_results[0].get("sum") is not None: | ||
account_sum = query_results[0].get("sum") | ||
currency = journal.currency_id or journal.company_id.currency_id | ||
dashboard_data[journal.id].update({ | ||
'account_balance_general': formatLang(self.env, currency.round(account_sum) + 0.0, currency_obj=currency) | ||
}) | ||
dashboard_data[journal.id].update( | ||
{ | ||
"account_balance_general": formatLang( | ||
self.env, currency.round(account_sum) + 0.0, currency_obj=currency | ||
) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
from odoo import models, fields | ||
from odoo import fields, models | ||
|
||
|
||
class AccountMovetLine(models.Model): | ||
_inherit = "account.move.line" | ||
|
||
_inherit = 'account.move.line' | ||
|
||
filter_amount = fields.Float(compute="_compute_filter_amout", search='_search_filter_amount') | ||
filter_amount = fields.Float(compute="_compute_filter_amout", search="_search_filter_amount") | ||
|
||
def _compute_filter_amout(self): | ||
self.filter_amount = False | ||
|
||
def _search_filter_amount(self, operator, value): | ||
res = [] | ||
if self.env.context.get('default_st_line_id'): | ||
statement_line = self.env['account.bank.statement.line'].browse(self.env.context.get('default_st_line_id')) | ||
if self.env.context.get("default_st_line_id"): | ||
statement_line = self.env["account.bank.statement.line"].browse(self.env.context.get("default_st_line_id")) | ||
|
||
primary_currency = statement_line.company_id.currency_id == statement_line.currency_id | ||
if primary_currency: | ||
amount = statement_line['amount'] | ||
amount_currency = statement_line['amount_currency'] | ||
amount = statement_line["amount"] | ||
amount_currency = statement_line["amount_currency"] | ||
else: | ||
amount = statement_line['amount_currency'] | ||
amount_currency = statement_line['amount'] | ||
|
||
if value != 0 and operator == '=': | ||
base_amount = ((100 - value)/100) * amount | ||
top_amount = ((100 + value)/100) * amount | ||
res.append(('amount_residual', '>', base_amount)) | ||
res.append(('amount_residual', '<', top_amount)) | ||
amount = statement_line["amount_currency"] | ||
amount_currency = statement_line["amount"] | ||
|
||
if value != 0 and operator == "=": | ||
base_amount = ((100 - value) / 100) * amount | ||
top_amount = ((100 + value) / 100) * amount | ||
res.append(("amount_residual", ">", base_amount)) | ||
res.append(("amount_residual", "<", top_amount)) | ||
else: | ||
amount = ((100 - value)/100) * amount | ||
amount_currency = ((100 - value)/100) * amount_currency | ||
amount = ((100 - value) / 100) * amount | ||
amount_currency = ((100 - value) / 100) * amount_currency | ||
|
||
if primary_currency: | ||
res.append(('amount_residual', operator, amount)) | ||
res.append(("amount_residual", operator, amount)) | ||
else: | ||
res.append(('amount_residual', operator, amount_currency)) | ||
res.append(("amount_residual", operator, amount_currency)) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.