-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '11.0' into 11.0-add-di
- Loading branch information
Showing
18 changed files
with
246 additions
and
33 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
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 @@ | ||
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,24 @@ | ||
# © 2019 Mackilem Van der Laan, Trustcode | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ # pylint: disable=C8101,C8103 | ||
'name': "Define Taxes as Python Code - Pass extra variables", | ||
'summary': "Allows to use python code to define taxes", | ||
'description': """Allows to use python code to define taxes - | ||
Define extra variables to calculate taxes in Brazil""", | ||
'author': "Trustcode", | ||
'website': "http://www.trustcode.com.br", | ||
'category': 'account', | ||
'version': '11.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'contributors': [ | ||
'Mackilem Van der Laan <mack.vdl@gmail.com>', | ||
], | ||
'depends': [ | ||
'br_account', | ||
'account_tax_python' | ||
], | ||
'data': [ | ||
'data/account_tax_data.xml' | ||
], | ||
} |
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,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="tax_pis_paulistana" model="account.tax"> | ||
<field name="description">PIS 1.05 Saída Paulistana</field> | ||
<field name="name">PIS 1.05 Saída Paulistana</field> | ||
<field name="domain">pis</field> | ||
<field name="type_tax_use">sale</field> | ||
<field name="amount_type">code</field> | ||
<field name="amount">0</field> | ||
<field eval="0" name="price_include"/> | ||
<field name="python_compute"> | ||
result = 0.0 | ||
if invoice_amount and invoice_amount > 215.15: | ||
result = round(base_amount * -0.0065, 3) | ||
</field> | ||
<field name="python_applicable">result = True</field> | ||
</record> | ||
|
||
<record id="tax_cofins_paulistana" model="account.tax"> | ||
<field name="description">COFINS 1.05 Saída Paulistana</field> | ||
<field name="name">COFINS 1.05 Saída Paulistana</field> | ||
<field name="domain">cofins</field> | ||
<field name="type_tax_use">sale</field> | ||
<field name="amount_type">code</field> | ||
<field name="amount">0</field> | ||
<field eval="0" name="price_include"/> | ||
<field name="python_compute"> | ||
result = 0.0 | ||
if invoice_amount and invoice_amount > 215.15: | ||
result = round(base_amount * -0.03, 3) | ||
</field> | ||
<field name="python_applicable">result = True</field> | ||
</record> | ||
|
||
<record id="tax_csll_paulistana" model="account.tax"> | ||
<field name="description">CSLL 1.05 Saída Paulistana</field> | ||
<field name="name">CSLL 1.05 Saída Paulistana</field> | ||
<field name="domain">csll</field> | ||
<field name="type_tax_use">sale</field> | ||
<field name="amount_type">code</field> | ||
<field name="amount">0</field> | ||
<field eval="0" name="price_include"/> | ||
<field name="python_compute"> | ||
result = 0.0 | ||
if invoice_amount and invoice_amount > 215.15: | ||
result = round(base_amount * -0.01, 3) | ||
</field> | ||
<field name="python_applicable">result = True</field> | ||
</record> | ||
|
||
<record id="tax_irrf_paulistana" model="account.tax"> | ||
<field name="description">IRRF 1.05 Saída Paulistana</field> | ||
<field name="name">IRRF 1.05 Saída Paulistana</field> | ||
<field name="domain">irrf</field> | ||
<field name="type_tax_use">sale</field> | ||
<field name="amount_type">code</field> | ||
<field name="amount">0</field> | ||
<field eval="0" name="price_include"/> | ||
<field name="python_compute"> | ||
result = 0.0 | ||
if invoice_amount and invoice_amount > 666.66: | ||
result = round(base_amount * -0.015, 3) | ||
</field> | ||
<field name="python_applicable">result = True</field> | ||
</record> | ||
|
||
</odoo> |
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,2 @@ | ||
from . import account_invoice | ||
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,15 @@ | ||
# © 2019 Mackilem Van der Laan, Trustcode | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountInvoiceLine(models.Model): | ||
_inherit = 'account.invoice.line' | ||
|
||
def _prepare_tax_context(self): | ||
res = super(AccountInvoiceLine, self)._prepare_tax_context() | ||
amount = (self.invoice_id.amount_total | ||
+ self.quantity * self.price_unit) | ||
res['invoice_amount'] = amount | ||
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,30 @@ | ||
# © 2019 Mackilem Van der Laan, Trustcode | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
|
||
class AccountTax(models.Model): | ||
_inherit = 'account.tax' | ||
|
||
def _compute_amount(self, base_amount, price_unit, quantity=1.0, | ||
product=None, partner=None): | ||
self.ensure_one() | ||
if self.amount_type == 'code': | ||
company = self.env.user.company_id | ||
invoice_amount = self._context.get('invoice_amount', 0) | ||
localdict = { | ||
'invoice_amount': invoice_amount, | ||
'base_amount': base_amount, | ||
'price_unit': price_unit, | ||
'quantity': quantity, | ||
'product': product, | ||
'partner': partner, | ||
'company': company, | ||
'context': self._context, | ||
} | ||
safe_eval(self.python_compute, localdict, mode="exec", nocopy=True) | ||
return localdict['result'] | ||
return super(AccountTax, self)._compute_amount( | ||
base_amount, price_unit, quantity, product, partner) |
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
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
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
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
Oops, something went wrong.