Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
604 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
Unit rounded invoice (Swedish rounding) by currency | ||
======================================================= | ||
|
||
This module extende functionallity of module `Unit rounded invoice <https://github.com/OCA/account-invoicing/tree/8.0/account_invoice_rounding>`_. | ||
|
||
Add a parameter to give a unit for rounding such as CHF 0.05 for Swiss | ||
invoices | ||
|
||
In Settings -> Company -> Configurations you will find | ||
Currencies Rounding Rules | ||
Set currency rule for aech type of currency you need hadled. | ||
|
||
- `Swedish Round globally` | ||
|
||
To round your invoice total amount, this option will do the adjustment in | ||
the most important tax line of your invoice. | ||
|
||
- `Swedish Round by adding an invoice line` | ||
|
||
To round your invoice total amount, this option create a invoice line without | ||
taxes on it. This invoice line is tagged as `is_rounding` | ||
|
||
|
||
|
||
Usage | ||
===== | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/95/8.0 | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/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 | ||
`here <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_rounding_by_currency%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
Alessio Gerace <alessio.gerace@agilebg.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
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,23 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# Author: Alessio Gerace <alessio.gerace@agilebg.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from . import company | ||
from . import account | ||
from . import tests |
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,38 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# Author: Alessio Gerace <alessio.gerace@agilebg.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
{ | ||
'name': 'Unit rounded invoice by Currency', | ||
'version': '8.0.1.0.0', | ||
'category': 'Accounting', | ||
'author': "Agile Business Group,,Odoo Community Association (OCA)", | ||
'maintainer': 'Camptocamp', | ||
'website': 'http://www.agilebg.com/', | ||
'license': 'AGPL-3', | ||
'depends': ['account_invoice_rounding'], | ||
'data': [ | ||
'res_company.xml', | ||
'security/ir.model.access.csv', | ||
], | ||
"demo": ['demo/data.xml'], | ||
'installable': True, | ||
'auto_install': False, | ||
'application': False | ||
} |
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,61 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# Author: Alessio Gerace <alessio.gerace@agilebg.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from openerp import models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = "account.invoice" | ||
|
||
def _compute_swedish_rounding(self, cr, uid, invoice, context=None): | ||
""" | ||
Depending on the method defined, we add an invoice line or adapt the | ||
tax lines to have a rounded total amount on the invoice | ||
:param invoice: invoice browse record | ||
:return dict: updated values for _amount_all | ||
""" | ||
# avoid recusivity | ||
|
||
if 'swedish_write' in context: | ||
return {} | ||
rounding_rule_model = self.pool.get('company.rounding') | ||
company = invoice.company_id | ||
if invoice.currency_id.id != company.currency_id.id: | ||
ret_ids = rounding_rule_model.search( | ||
cr, uid, | ||
[ | ||
('company_id', '=', company.id), | ||
('currency_id', '=', invoice.currency_id.id), | ||
], | ||
context=context) | ||
if ret_ids: | ||
rule = rounding_rule_model.browse( | ||
cr, uid, ret_ids[0], context=context) | ||
company.tax_calculation_rounding_method = ( | ||
rule.tax_calculation_rounding_method) | ||
company.tax_calculation_rounding = ( | ||
rule.tax_calculation_rounding) | ||
company.tax_calculation_rounding_account_id = ( | ||
rule.tax_calculation_rounding_account_id) | ||
else: | ||
return {} | ||
|
||
return super(AccountInvoice, self)._compute_swedish_rounding( | ||
cr, uid, invoice, context=context) |
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,66 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (C) 2015 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# Author: Alessio Gerace <alessio.gerace@agilebg.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
from openerp import models, fields | ||
|
||
|
||
class RoundingByCurrency(models.Model): | ||
_name = 'company.rounding' | ||
|
||
company_id = fields.Many2one('res.company', 'Company', required=True) | ||
currency_id = fields.Many2one('res.currency', 'Currency', required=True) | ||
tax_calculation_rounding = fields.Float('Tax Rounding unit') | ||
tax_calculation_rounding_account_id = fields.Many2one( | ||
'account.account', | ||
'Tax Rounding Account', | ||
domain=[('type', '<>', 'view')] | ||
) | ||
tax_calculation_rounding_method = fields.Selection( | ||
[ | ||
('swedish_round_globally', 'Swedish Round globally'), | ||
('swedish_add_invoice_line', 'Swedish Round by adding a line'), | ||
], | ||
string='Tax Calculation Rounding Method', | ||
help="If you select 'Round per line' : for each tax, the tax " | ||
"amount will first be computed and rounded for each " | ||
"PO/SO/invoice line and then these rounded amounts will be " | ||
"summed, leading to the total amount for that tax. If you " | ||
"select 'Round globally': for each tax, the tax amount will " | ||
"be computed for each PO/SO/invoice line, then these amounts" | ||
" will be summed and eventually this total tax amount will " | ||
"be rounded. If you sell with tax included, you should " | ||
"choose 'Round per line' because you certainly want the sum " | ||
"of your tax-included line subtotals to be equal to the " | ||
"total amount with taxes." | ||
) | ||
|
||
_sql_constraints = [ | ||
('currency_id_uniq_per+company', 'unique (currency_id, company_id)', | ||
'Currency must be unique per Company!'), | ||
] | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = 'res.company' | ||
|
||
currency_rounding_rules = fields.One2many( | ||
'company.rounding', 'company_id', | ||
'Rounding Rule' | ||
) |
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,114 @@ | ||
<?xml version="1.0" ?> | ||
<openerp> | ||
<data noupdate="1"> | ||
|
||
<!-- | ||
<record forcecreate="True" id="decimal_payment" model="decimal.precision"> | ||
<field name="name">Account</field> | ||
<field name="digits">2</field> | ||
</record> | ||
--> | ||
|
||
<record id="tax_code_10" model="account.tax.code"> | ||
<field name="name">IVA a credito 10%</field> | ||
</record> | ||
|
||
<record id="tax_base_code_10" model="account.tax.code"> | ||
<field name="name">IVA a credito 10% (imponibile)</field> | ||
</record> | ||
|
||
<record id="tax_10" model="account.tax"> | ||
<field name="name">10% test</field> | ||
<field name="description">10</field> | ||
<field name="amount">0.10</field> | ||
<field name="base_code_id" ref="tax_base_code_10"></field> | ||
<field name="tax_code_id" ref="tax_code_10"></field> | ||
</record> | ||
|
||
<record id="base.main_company" model="res.company"> | ||
<field name="tax_calculation_rounding" eval="0.05"/> | ||
<field name="tax_calculation_rounding_method" eval="'swedish_round_globally'"/> | ||
</record> | ||
|
||
<record id="currency_rounding_rule" model="company.rounding"> | ||
<field name="currency_id" ref="base.CHF"/> | ||
<field name="company_id" ref="base.main_company"/> | ||
<field name="tax_calculation_rounding" eval="0.50"/> | ||
<field name="tax_calculation_rounding_method" eval="'swedish_round_globally'"/> | ||
</record> | ||
|
||
<!-- invoice 0 --> | ||
|
||
<record id="invtest_invoice_0" model="account.invoice"> | ||
<field name="journal_id" ref="account.bank_journal"/> | ||
<field name="currency_id" ref="base.EUR"/> | ||
<field name="user_id" ref="base.user_demo"/> | ||
<field name="company_id" ref="base.main_company"/> | ||
<field name="type">out_invoice</field> | ||
<field name="account_id" ref="account.a_pay"/> | ||
<field name="date_invoice" eval="'2015-10-07'"/> | ||
<field name="partner_id" ref="base.res_partner_12"/> | ||
</record> | ||
|
||
<record id="invtest_invoice_0_line_0" model="account.invoice.line"> | ||
<field name="invoice_id" ref="invtest_invoice_0"/> | ||
<field name="account_id" ref="account.a_sale"/> | ||
<field name="price_unit" eval="100.02" /> | ||
<field name="uos_id" ref="product.product_uom_unit"/> | ||
<field name="invoice_line_tax_id" eval="[(6,0,[ref('tax_10')])]"/> | ||
<field name="product_id" ref="product.product_product_3"/> | ||
<field name="quantity" eval="1.0" /> | ||
<field name="name">[PCSC234] PC Assemble SC234-2</field> | ||
</record> | ||
|
||
|
||
<!-- invoice 1 --> | ||
|
||
<record id="invtest_invoice_1" model="account.invoice"> | ||
<field name="journal_id" ref="account.bank_journal"/> | ||
<field name="currency_id" ref="base.EUR"/> | ||
<field name="user_id" ref="base.user_demo"/> | ||
<field name="company_id" ref="base.main_company"/> | ||
<field name="type">out_invoice</field> | ||
<field name="account_id" ref="account.a_pay"/> | ||
<field name="date_invoice" eval="'2015-10-07'"/> | ||
<field name="partner_id" ref="base.res_partner_12"/> | ||
</record> | ||
|
||
<record id="invtest_invoice_1_line_0" model="account.invoice.line"> | ||
<field name="invoice_id" ref="invtest_invoice_1"/> | ||
<field name="account_id" ref="account.a_sale"/> | ||
<field name="price_unit" eval="100.43" /> | ||
<field name="uos_id" ref="product.product_uom_unit"/> | ||
<field name="invoice_line_tax_id" eval="[(6,0,[ref('tax_10')])]"/> | ||
<field name="product_id" ref="product.product_product_3"/> | ||
<field name="quantity" eval="1.0" /> | ||
<field name="name">[PCSC234] PC Assemble SC234-2</field> | ||
</record> | ||
|
||
<!-- invoice 2 --> | ||
|
||
<record id="invtest_invoice_2" model="account.invoice"> | ||
<field name="journal_id" ref="account.bank_journal"/> | ||
<field name="currency_id" ref="base.CHF"/> | ||
<field name="user_id" ref="base.user_demo"/> | ||
<field name="company_id" ref="base.main_company"/> | ||
<field name="type">out_invoice</field> | ||
<field name="account_id" ref="account.a_pay"/> | ||
<field name="date_invoice" eval="'2015-10-07'"/> | ||
<field name="partner_id" ref="base.res_partner_12"/> | ||
</record> | ||
|
||
<record id="invtest_invoice_2_line_0" model="account.invoice.line"> | ||
<field name="invoice_id" ref="invtest_invoice_2"/> | ||
<field name="account_id" ref="account.a_sale"/> | ||
<field name="price_unit" eval="100.43" /> | ||
<field name="uos_id" ref="product.product_uom_unit"/> | ||
<field name="invoice_line_tax_id" eval="[(6,0,[ref('tax_10')])]"/> | ||
<field name="product_id" ref="product.product_product_3"/> | ||
<field name="quantity" eval="1.0" /> | ||
<field name="name">[PCSC234] PC Assemble SC234-2</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
Oops, something went wrong.