Browse Source

[IMP] Add option to display all TAX

pull/769/head
Mateu Griful 3 years ago
parent
commit
aa5601b057
  1. 9
      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

9
account_tax_balance/models/account_tax.py

@ -39,12 +39,18 @@ class AccountTax(models.Model):
context.get('to_date', fields.Date.context_today(self)), context.get('to_date', fields.Date.context_today(self)),
context.get('company_id', self.env.user.company_id.id), context.get('company_id', self.env.user.company_id.id),
context.get('target_move', 'posted'), context.get('target_move', 'posted'),
context.get('display_all', False),
) )
@api.model @api.model
def _search_has_moves(self, operator, value): def _search_has_moves(self, operator, value):
assert isinstance(value, bool), "Not implemented" assert isinstance(value, bool), "Not implemented"
assert operator == "=", "Not implemented" assert operator == "=", "Not implemented"
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) ids_with_moves = self.search([]).filtered(lambda t: t.has_moves == value)
return [('id', 'in', ids_with_moves.ids)] return [('id', 'in', ids_with_moves.ids)]
@ -141,7 +147,8 @@ class AccountTax(models.Model):
return total_balance return total_balance
def get_move_lines_query(self, tax_or_base="tax"): 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) state_list = self.get_target_state_list(target_move)
base_query = self.get_move_lines_base_query() base_query = self.get_move_lines_base_query()
_where = "" _where = ""

5
account_tax_balance/wizard/open_tax_balances.py

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

1
account_tax_balance/wizard/open_tax_balances_view.xml

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

Loading…
Cancel
Save