Skip to content

Commit

Permalink
[ADD] account tax and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Nov 16, 2018
1 parent e229264 commit 70cabf4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
4 changes: 2 additions & 2 deletions l10n_it_split_payment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2015 Davide Corio <[email protected]>
# Copyright 2015-2016 Lorenzo Battistini - Agile Business Group
# Copyright 2015-2018 Lorenzo Battistini - Agile Business Group
# Copyright 2016 Alessio Gerace - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Split Payment',
'version': '11.0.1.0.0',
'version': '11.0.1.1.0',
'category': 'Localization/Italy',
'summary': 'Split Payment',
'author': 'Abstract, Agile Business Group, '
Expand Down
1 change: 1 addition & 0 deletions l10n_it_split_payment/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

from . import account
from . import config
from . import account_tax
18 changes: 18 additions & 0 deletions l10n_it_split_payment/models/account_tax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, fields, api


class AccountTax(models.Model):
_inherit = 'account.tax'
is_split_payment = fields.Boolean(
"Is split payment", compute="_compute_is_split_payment")

@api.multi
def _compute_is_split_payment(self):
for tax in self:
fp_lines = self.env['account.fiscal.position.tax'].search(
[('tax_dest_id', '=', tax.id)])
tax.is_split_payment = any(
fp_line.position_id.split_payment for fp_line in fp_lines
)
17 changes: 13 additions & 4 deletions l10n_it_split_payment/tests/test_splitpayment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2015 Davide Corio <[email protected]>
# Copyright 2015-2016 Lorenzo Battistini - Agile Business Group
# Copyright 2015-2018 Lorenzo Battistini - Agile Business Group
# Copyright 2016 Alessio Gerace - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand All @@ -15,13 +15,21 @@ def setUp(self):
self.term_model = self.env['account.payment.term']
self.inv_line_model = self.env['account.invoice.line']
self.fp_model = self.env['account.fiscal.position']
self.tax22sp = self.tax_model.create({
'name': '22% SP',
'amount': 22,
})
self.tax22 = self.tax_model.create({
'name': '22%',
'amount': 22,
})
self.sp_fp = self.fp_model.create({
'name': 'Split payment',
'split_payment': True,
'tax_ids': [(0, 0, {
'tax_src_id': self.tax22.id,
'tax_dest_id': self.tax22sp.id
})]
})
self.company = self.env.ref('base.main_company')
self.company.sp_account_id = self.env['account.account'].search([
Expand Down Expand Up @@ -68,6 +76,7 @@ def setUp(self):
limit=1).date_invoice

def test_invoice(self):
self.assertTrue(self.tax22sp.is_split_payment)
invoice = self.invoice_model.create({
'date_invoice': self.recent_date,
'partner_id': self.env.ref('base.res_partner_3').id,
Expand All @@ -80,7 +89,7 @@ def test_invoice(self):
'quantity': 1,
'price_unit': 100,
'invoice_line_tax_ids': [(6, 0, {
self.tax22.id
self.tax22sp.id
})]
})]
})
Expand Down Expand Up @@ -115,7 +124,7 @@ def test_invoice(self):
'quantity': 1,
'price_unit': 100,
'invoice_line_tax_ids': [(6, 0, {
self.tax22.id
self.tax22sp.id
})]
})]
})
Expand Down Expand Up @@ -150,7 +159,7 @@ def test_invoice(self):
'quantity': 1,
'price_unit': 100,
'invoice_line_tax_ids': [(6, 0, {
self.tax22.id
self.tax22sp.id
})]
})]
})
Expand Down

0 comments on commit 70cabf4

Please sign in to comment.