-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADD l10n_it_vat_registries_split_payment #570
Merged
+256
−7
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
# 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': '10.0.1.0.0', | ||
'version': '10.0.1.1.0', | ||
'category': 'Localization/Italy', | ||
'summary': 'Split Payment', | ||
'author': 'Abstract, Agile Business Group, ' | ||
'Odoo Community Association (OCA)', | ||
'website': 'http://www.abstract.it', | ||
'website': 'https://github.com/OCA/l10n-italy', | ||
'license': 'AGPL-3', | ||
'depends': ['account'], | ||
'data': [ | ||
|
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,19 @@ | ||
# -*- 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)]) | ||
tax.is_split_payment = any( | ||
fp_line.position_id.split_payment for fp_line in fp_lines | ||
) |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# 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). | ||
|
||
|
@@ -16,13 +16,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([ | ||
|
@@ -69,6 +77,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, | ||
|
@@ -81,7 +90,7 @@ def test_invoice(self): | |
'quantity': 1, | ||
'price_unit': 100, | ||
'invoice_line_tax_ids': [(6, 0, { | ||
self.tax22.id | ||
self.tax22sp.id | ||
})] | ||
})] | ||
}) | ||
|
@@ -116,7 +125,7 @@ def test_invoice(self): | |
'quantity': 1, | ||
'price_unit': 100, | ||
'invoice_line_tax_ids': [(6, 0, { | ||
self.tax22.id | ||
self.tax22sp.id | ||
})] | ||
})] | ||
}) | ||
|
@@ -151,7 +160,7 @@ def test_invoice(self): | |
'quantity': 1, | ||
'price_unit': 100, | ||
'invoice_line_tax_ids': [(6, 0, { | ||
self.tax22.id | ||
self.tax22sp.id | ||
})] | ||
})] | ||
}) | ||
|
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 <[email protected]> | ||
|
||
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). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you can place your own copyright |
||
|
||
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 <[email protected]> |
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)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bump module version