|
|
@ -86,24 +86,24 @@ class AccountTax(models.Model): |
|
|
|
def _compute_balance(self): |
|
|
|
for tax in self: |
|
|
|
tax.balance_regular = tax.compute_balance( |
|
|
|
tax_or_base="tax", move_type="regular" |
|
|
|
tax_or_base="tax", financial_type="regular" |
|
|
|
) |
|
|
|
tax.base_balance_regular = tax.compute_balance( |
|
|
|
tax_or_base="base", move_type="regular" |
|
|
|
tax_or_base="base", financial_type="regular" |
|
|
|
) |
|
|
|
tax.balance_refund = tax.compute_balance( |
|
|
|
tax_or_base="tax", move_type="refund" |
|
|
|
tax_or_base="tax", financial_type="refund" |
|
|
|
) |
|
|
|
tax.base_balance_refund = tax.compute_balance( |
|
|
|
tax_or_base="base", move_type="refund" |
|
|
|
tax_or_base="base", financial_type="refund" |
|
|
|
) |
|
|
|
tax.balance = tax.balance_regular + tax.balance_refund |
|
|
|
tax.base_balance = tax.base_balance_regular + tax.base_balance_refund |
|
|
|
|
|
|
|
def get_target_type_list(self, move_type=None): |
|
|
|
if move_type == "refund": |
|
|
|
def get_target_type_list(self, financial_type=None): |
|
|
|
if financial_type == "refund": |
|
|
|
return ["receivable_refund", "payable_refund"] |
|
|
|
elif move_type == "regular": |
|
|
|
elif financial_type == "regular": |
|
|
|
return ["receivable", "payable", "liquidity", "other"] |
|
|
|
return [] |
|
|
|
|
|
|
@ -123,10 +123,10 @@ class AccountTax(models.Model): |
|
|
|
("company_id", "in", company_ids), |
|
|
|
] |
|
|
|
|
|
|
|
def compute_balance(self, tax_or_base="tax", move_type=None): |
|
|
|
def compute_balance(self, tax_or_base="tax", financial_type=None): |
|
|
|
self.ensure_one() |
|
|
|
domain = self.get_move_lines_domain( |
|
|
|
tax_or_base=tax_or_base, move_type=move_type |
|
|
|
tax_or_base=tax_or_base, financial_type=financial_type |
|
|
|
) |
|
|
|
# balance is debit - credit whereas on tax return you want to see what |
|
|
|
# vat has to be paid so: |
|
|
@ -144,7 +144,7 @@ class AccountTax(models.Model): |
|
|
|
("tax_exigible", "=", True), |
|
|
|
] |
|
|
|
if type_list: |
|
|
|
domain.append(("move_id.move_type", "in", type_list)) |
|
|
|
domain.append(("move_id.financial_type", "in", type_list)) |
|
|
|
return domain |
|
|
|
|
|
|
|
def get_base_balance_domain(self, state_list, type_list): |
|
|
@ -154,13 +154,13 @@ class AccountTax(models.Model): |
|
|
|
("tax_exigible", "=", True), |
|
|
|
] |
|
|
|
if type_list: |
|
|
|
domain.append(("move_id.move_type", "in", type_list)) |
|
|
|
domain.append(("move_id.financial_type", "in", type_list)) |
|
|
|
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", financial_type=None): |
|
|
|
from_date, to_date, company_ids, target_move = self.get_context_values() |
|
|
|
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(financial_type) |
|
|
|
domain = self.get_move_line_partial_domain(from_date, to_date, company_ids) |
|
|
|
balance_domain = [] |
|
|
|
if tax_or_base == "tax": |
|
|
@ -170,12 +170,12 @@ class AccountTax(models.Model): |
|
|
|
domain.extend(balance_domain) |
|
|
|
return domain |
|
|
|
|
|
|
|
def get_lines_action(self, tax_or_base="tax", move_type=None): |
|
|
|
def get_lines_action(self, tax_or_base="tax", financial_type=None): |
|
|
|
domain = self.get_move_lines_domain( |
|
|
|
tax_or_base=tax_or_base, move_type=move_type |
|
|
|
tax_or_base=tax_or_base, financial_type=financial_type |
|
|
|
) |
|
|
|
action = self.env.ref("account.action_account_moves_all_tree") |
|
|
|
vals = action.read()[0] |
|
|
|
vals = action.sudo().read()[0] |
|
|
|
vals["context"] = {} |
|
|
|
vals["domain"] = domain |
|
|
|
return vals |
|
|
@ -190,16 +190,16 @@ class AccountTax(models.Model): |
|
|
|
|
|
|
|
def view_tax_regular_lines(self): |
|
|
|
self.ensure_one() |
|
|
|
return self.get_lines_action(tax_or_base="tax", move_type="regular") |
|
|
|
return self.get_lines_action(tax_or_base="tax", financial_type="regular") |
|
|
|
|
|
|
|
def view_base_regular_lines(self): |
|
|
|
self.ensure_one() |
|
|
|
return self.get_lines_action(tax_or_base="base", move_type="regular") |
|
|
|
return self.get_lines_action(tax_or_base="base", financial_type="regular") |
|
|
|
|
|
|
|
def view_tax_refund_lines(self): |
|
|
|
self.ensure_one() |
|
|
|
return self.get_lines_action(tax_or_base="tax", move_type="refund") |
|
|
|
return self.get_lines_action(tax_or_base="tax", financial_type="refund") |
|
|
|
|
|
|
|
def view_base_refund_lines(self): |
|
|
|
self.ensure_one() |
|
|
|
return self.get_lines_action(tax_or_base="base", move_type="refund") |
|
|
|
return self.get_lines_action(tax_or_base="base", financial_type="refund") |