Skip to content

Commit

Permalink
[IMP] Add amount residual currency in _search_filter_amount
Browse files Browse the repository at this point in the history
  • Loading branch information
maq-adhoc committed Nov 1, 2023
1 parent 63085de commit 5bed1b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 14 additions & 5 deletions account_accountant_ux/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
from odoo import models, fields
from odoo import models, fields, osv


class AccountMovetLine(models.Model):

_inherit = 'account.move.line'

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'):
amount = self.env['account.bank.statement.line'].browse(self.env.context.get('default_st_line_id'))['amount']
statement_line = self.env['account.bank.statement.line'].browse(self.env.context.get('default_st_line_id'))
amount = statement_line['amount']
amount_currency = statement_line['amount_currency']
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))
base_amount_currency = ((100 - value)/100) * amount_currency
top_amount_currency = ((100 + value)/100) * amount_currency
res += osv.expression.OR([
[('amount_residual', '>', base_amount),('amount_residual', '<', top_amount)],
[('amount_residual_currency', '>', base_amount_currency),('amount_residual_currency', '<', top_amount_currency)]
])
else:
amount = ((100 - value)/100) * amount
amount_currency = ((100 - value)/100) * amount_currency
res.append('|')
res.append(('amount_residual', operator, amount))
res.append(('amount_residual_currency', operator, amount_currency))
return res
3 changes: 2 additions & 1 deletion account_accountant_ux/models/bank_rec_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def _compute_amls_widget(self):
super()._compute_amls_widget()
amls_widget = wizard.amls_widget
amls_widget['context']['default_st_line_id'] = wizard.st_line_id.id
amls_widget['context']['search_default_same_amount'] = True
#amls_widget['context']['search_default_same_amount'] = True
amls_widget['context']['search_default_close_amount'] = True
wizard.amls_widget = amls_widget

def collect_global_info_data(self, journal_id):
Expand Down

0 comments on commit 5bed1b9

Please sign in to comment.