Browse Source

[IMP] Tax balance display all

pull/801/head
Mateu Griful 3 years ago
parent
commit
6c8f5655d9
  1. 14
      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

14
account_tax_balance/models/account_tax.py

@ -39,6 +39,7 @@ 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),
) )
def _account_tax_ids_with_moves(self): def _account_tax_ids_with_moves(self):
@ -69,7 +70,8 @@ class AccountTax(models.Model):
) )
) )
""" """
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()
self.env.cr.execute( self.env.cr.execute(
req, (company_id, from_date, to_date, company_id)) req, (company_id, from_date, to_date, company_id))
return [r[0] for r in self.env.cr.fetchall()] return [r[0] for r in self.env.cr.fetchall()]
@ -86,9 +88,14 @@ class AccountTax(models.Model):
@api.model @api.model
def _search_has_moves(self, operator, value): def _search_has_moves(self, operator, value):
from_date, to_date, company_id, target_move, display_all \
= self.get_context_values()
if self._is_unsupported_search_operator(operator) or not value: if self._is_unsupported_search_operator(operator) or not value:
raise ValueError(_("Unsupported search operator")) raise ValueError(_("Unsupported search operator"))
ids_with_moves = self._account_tax_ids_with_moves()
if display_all:
ids_with_moves = self.env['account.tax'].search([]).ids
else:
ids_with_moves = self._account_tax_ids_with_moves()
return [('id', 'in', ids_with_moves)] return [('id', 'in', ids_with_moves)]
def _compute_balance(self): def _compute_balance(self):
@ -161,7 +168,8 @@ class AccountTax(models.Model):
return domain return domain
def get_move_lines_domain(self, tax_or_base='tax', move_type=None): def get_move_lines_domain(self, tax_or_base='tax', move_type=None):
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)
type_list = self.get_target_type_list(move_type) type_list = self.get_target_type_list(move_type)
domain = self.get_move_line_partial_domain( domain = self.get_move_line_partial_domain(

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="Force display of 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):
@ -55,5 +59,6 @@ class WizardOpenTaxBalances(models.TransientModel):
'to_date': self.to_date, 'to_date': self.to_date,
'target_move': self.target_move, 'target_move': self.target_move,
'company_id': self.company_id.id, 'company_id': self.company_id.id,
'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