-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD l10n_it_vat_registries_split_payment to fix the following case:
- Configure Split Payment fiscal position and tax - Make a customer invoice with SP - Print VAT register Split Payment VAT must not appear as deductible VAT
- Loading branch information
Showing
13 changed files
with
255 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
|
||
from . import account | ||
from . import config | ||
from . import account_tax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# 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)]) | ||
for fp_line in fp_lines: | ||
if fp_line.position_id.split_payment: | ||
tax.is_split_payment = True | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
============================== | ||
VAT registries + Split Payment | ||
============================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github | ||
:target: https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_vat_registries_split_payment | ||
:alt: OCA/l10n-italy | ||
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/122/10.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| | ||
|
||
Bridge module to make VAT registries module work along with Split Payment module | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Agile Business Group | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/10.0/l10n_it_vat_registries_split_payment>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Lorenzo Battistini | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "VAT registries + Split Payment", | ||
"summary": "Bridge module to make VAT registries work with Split Payment", | ||
"version": "10.0.1.0.0", | ||
"development_status": "Beta", | ||
"category": "Hidden", | ||
"website": "https://github.com/OCA/l10n-italy/", | ||
"author": "Agile Business Group, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"auto_install": True, | ||
"depends": [ | ||
"l10n_it_vat_registries", | ||
"l10n_it_split_payment" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import account_tax |
16 changes: 16 additions & 0 deletions
16
l10n_it_vat_registries_split_payment/models/account_tax.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountTax(models.Model): | ||
_inherit = 'account.tax' | ||
|
||
def _compute_totals_tax(self, data): | ||
res = super(AccountTax, self)._compute_totals_tax(data) | ||
if self.is_split_payment: | ||
# res is (tax_name, base, tax, deductible, undeductible) | ||
# so, in case of SP, SP VAT must not appear as deductible | ||
return (res[0], res[1], res[2], 0.0, res[4]) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Bridge module to make VAT registries module work along with Split Payment module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import test_sp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from odoo.addons.account.tests.account_test_users import AccountTestUsers | ||
|
||
|
||
class TestSP(AccountTestUsers): | ||
|
||
def setUp(self): | ||
super(TestSP, self).setUp() | ||
self.tax_model = self.env['account.tax'] | ||
self.invoice_model = self.env['account.invoice'] | ||
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([ | ||
( | ||
'user_type_id', '=', | ||
self.env.ref('account.data_account_type_current_assets').id | ||
) | ||
], limit=1) | ||
account_user_type = self.env.ref( | ||
'account.data_account_type_receivable') | ||
self.a_recv = self.account_model.sudo(self.account_manager.id).create( | ||
dict( | ||
code="cust_acc", | ||
name="customer account", | ||
user_type_id=account_user_type.id, | ||
reconcile=True, | ||
)) | ||
self.a_sale = self.env['account.account'].search([ | ||
( | ||
'user_type_id', '=', | ||
self.env.ref('account.data_account_type_revenue').id) | ||
], limit=1) | ||
self.sales_journal = self.env['account.journal'].search( | ||
[('type', '=', 'sale')])[0] | ||
# Set invoice date to recent date in the system | ||
# This solves problems with account_invoice_sequential_dates | ||
self.recent_date = self.invoice_model.search( | ||
[('date_invoice', '!=', False)], order='date_invoice desc', | ||
limit=1).date_invoice | ||
|
||
def test_invoice(self): | ||
invoice = self.invoice_model.create({ | ||
'date_invoice': self.recent_date, | ||
'partner_id': self.env.ref('base.res_partner_3').id, | ||
'journal_id': self.sales_journal.id, | ||
'account_id': self.a_recv.id, | ||
'fiscal_position_id': self.sp_fp.id, | ||
'invoice_line_ids': [(0, 0, { | ||
'name': 'service', | ||
'account_id': self.a_sale.id, | ||
'quantity': 1, | ||
'price_unit': 100, | ||
'invoice_line_tax_ids': [(6, 0, { | ||
self.tax22sp.id | ||
})] | ||
})] | ||
}) | ||
invoice.action_invoice_open() | ||
invoice2 = self.invoice_model.create({ | ||
'date_invoice': self.recent_date, | ||
'partner_id': self.env.ref('base.res_partner_3').id, | ||
'journal_id': self.sales_journal.id, | ||
'account_id': self.a_recv.id, | ||
'fiscal_position_id': self.sp_fp.id, | ||
'invoice_line_ids': [(0, 0, { | ||
'name': 'service', | ||
'account_id': self.a_sale.id, | ||
'quantity': 1, | ||
'price_unit': 100, | ||
'invoice_line_tax_ids': [(6, 0, { | ||
self.tax22.id | ||
})] | ||
})] | ||
}) | ||
invoice2.action_invoice_open() | ||
data = { | ||
'from_date': self.recent_date, | ||
'to_date': self.recent_date, | ||
} | ||
totals_sp = self.tax22sp._compute_totals_tax(data) | ||
totals = self.tax22._compute_totals_tax(data) | ||
self.assertEqual(totals_sp, (u'22% SP', 100.0, 22.0, 0.0, 0)) | ||
self.assertEqual(totals, (u'22%', 100.0, 22.0, 22.0, 0)) |