Browse Source

[IMP] Add option to display all TAX

pull/769/head
Mateu Griful 4 years ago
parent
commit
aa5601b057
  1. 11
      account_tax_balance/models/account_tax.py
  2. 5
      account_tax_balance/wizard/open_tax_balances.py
  3. 1
      account_tax_balance/wizard/open_tax_balances_view.xml

11
account_tax_balance/models/account_tax.py

@ -39,13 +39,19 @@ class AccountTax(models.Model):
context.get('to_date', fields.Date.context_today(self)),
context.get('company_id', self.env.user.company_id.id),
context.get('target_move', 'posted'),
context.get('display_all', False),
)
@api.model
def _search_has_moves(self, operator, value):
assert isinstance(value, bool), "Not implemented"
assert operator == "=", "Not implemented"
ids_with_moves = self.search([]).filtered(lambda t: t.has_moves == value)
from_date, to_date, company_id, target_move, display_all \
= self.get_context_values()
if display_all:
ids_with_moves = self.env['account.tax'].search([])
else:
ids_with_moves = self.search([]).filtered(lambda t: t.has_moves == value)
return [('id', 'in', ids_with_moves.ids)]
def _compute_regular_and_refund(self, total):
@ -141,7 +147,8 @@ class AccountTax(models.Model):
return total_balance
def get_move_lines_query(self, tax_or_base="tax"):
from_date, to_date, company_id, target_move = self.get_context_values()
from_date, to_date, company_id, target_move, display_all \
= self.get_context_values()
state_list = self.get_target_state_list(target_move)
base_query = self.get_move_lines_base_query()
_where = ""

5
account_tax_balance/wizard/open_tax_balances.py

@ -18,6 +18,10 @@ class WizardOpenTaxBalances(models.TransientModel):
('posted', 'All Posted Entries'),
('all', 'All Entries'),
], 'Target Moves', required=True, default='posted')
display_all = fields.Boolean(
string="Display all tax accounts",
default=False
)
@api.onchange('date_range_id')
def onchange_date_range_id(self):
@ -56,5 +60,6 @@ class WizardOpenTaxBalances(models.TransientModel):
'target_move': self.target_move,
'company_id': self.company_id.id,
'search_default_filter_has_moves': True,
'display_all': self.display_all,
}
return vals

1
account_tax_balance/wizard/open_tax_balances_view.xml

@ -13,6 +13,7 @@
<field name="from_date"></field>
<field name="to_date"></field>
<field name="target_move"></field>
<field name="display_all"></field>
</group>
<footer>
<button string="Open Taxes" name="open_taxes" type="object" class="oe_highlight"/>

Loading…
Cancel
Save