Skip to content
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

[16.0][MIG] eng_l10n_br_account_tax_engine_disable: Migration to 16.0 #39

Draft
wants to merge 6 commits into
base: 16.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions eng_l10n_br_account_tax_engine_disable/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
======================================
Eng L10n Br Account Tax Engine Disable
======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f0bb8b159a1e78a6fd684dc4f877f8a2813368ac81d8eb03982d0cd1265fb6bb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-Engenere%2Fengenere--addons-lightgray.png?logo=github
:target: https://github.com/Engenere/engenere-addons/tree/16.0/eng_l10n_br_account_tax_engine_disable
:alt: Engenere/engenere-addons

|badge1| |badge2| |badge3|



**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/Engenere/engenere-addons/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/Engenere/engenere-addons/issues/new?body=module:%20eng_l10n_br_account_tax_engine_disable%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Engenere

Maintainers
-----------

This module is part of the `Engenere/engenere-addons <https://github.com/Engenere/engenere-addons/tree/16.0/eng_l10n_br_account_tax_engine_disable>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions eng_l10n_br_account_tax_engine_disable/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions eng_l10n_br_account_tax_engine_disable/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Engenere.one
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Eng L10n Br Account Tax Engine Disable",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Engenere",
"website": "https://github.com/Engenere/engenere-addons",
"depends": [
"l10n_br_account",
],
"data": [
"views/l10n_br_fiscal_document.xml",
],
"demo": [],
}
3 changes: 3 additions & 0 deletions eng_l10n_br_account_tax_engine_disable/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import l10n_br_fiscal_document_line_mixin_methods
from . import account_move
from . import l10n_br_fiscal_document
33 changes: 33 additions & 0 deletions eng_l10n_br_account_tax_engine_disable/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 Engenere.one
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class AccountMove(models.Model):
_inherit = "account.move"

@api.model
def _compute_taxes_mapped(self, base_line):
balance_taxes_res = super()._compute_taxes_mapped(base_line)

Check warning on line 12 in eng_l10n_br_account_tax_engine_disable/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/account_move.py#L12

Added line #L12 was not covered by tests

if self.fiscal_tax_engine_disabled:
# então força a base manual e os valores dos impostos:
for tax_item in balance_taxes_res["taxes"]:
if isinstance(tax_item["fiscal_tax_id"], models.NewId):
tax_domain = (

Check warning on line 18 in eng_l10n_br_account_tax_engine_disable/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/account_move.py#L18

Added line #L18 was not covered by tests
self.env["l10n_br_fiscal.tax"]
.browse(tax_item["fiscal_tax_id"].origin)
.tax_domain
)
elif isinstance(tax_item["fiscal_tax_id"], int):
tax_domain = (

Check warning on line 24 in eng_l10n_br_account_tax_engine_disable/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/account_move.py#L24

Added line #L24 was not covered by tests
self.env["l10n_br_fiscal.tax"]
.browse(tax_item["fiscal_tax_id"])
.tax_domain
)
else:
continue
tax_item["base"] = getattr(base_line, f"{tax_domain}_base")
tax_item["amount"] = getattr(base_line, f"{tax_domain}_value")
return balance_taxes_res

Check warning on line 33 in eng_l10n_br_account_tax_engine_disable/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/account_move.py#L30-L33

Added lines #L30 - L33 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024 Engenere.one
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class L10nBrFiscalDocument(models.Model):
_inherit = "l10n_br_fiscal.document"

fiscal_tax_engine_disabled = fields.Boolean(default=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2024 Engenere.one
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class FiscalDocumentLineMixinMethods(models.AbstractModel):
_inherit = "l10n_br_fiscal.document.line.mixin.methods"

def _remove_all_fiscal_tax_ids(self):
if self._is_fiscal_tax_engine_disabled():
return
super()._remove_all_fiscal_tax_ids()

Check warning on line 13 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L12-L13

Added lines #L12 - L13 were not covered by tests

def _prepare_tax_fields(self, compute_result):
if self._is_fiscal_tax_engine_disabled():
return {}
return super()._prepare_tax_fields(compute_result)

Check warning on line 18 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L17-L18

Added lines #L17 - L18 were not covered by tests

def _process_fiscal_mapping(self, mapping_result):
if self._is_fiscal_tax_engine_disabled():
return
super()._process_fiscal_mapping(mapping_result)

Check warning on line 23 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L22-L23

Added lines #L22 - L23 were not covered by tests

def _is_fiscal_tax_engine_disabled(self):
# When the mixin is used for instance
# in a PO line or SO line, there is no document_id
# and we consider the document is not fiscal_tax_engine_disabled
return (

Check warning on line 29 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L29

Added line #L29 was not covered by tests
hasattr(self, "document_id") and self.document_id.fiscal_tax_engine_disabled
)

def _update_fiscal_taxes(self):
res = super()._update_fiscal_taxes()

Check warning on line 34 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L34

Added line #L34 was not covered by tests
if self._is_fiscal_tax_engine_disabled():
self._update_fiscal_taxes_when_disabled()
return res

Check warning on line 37 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L36-L37

Added lines #L36 - L37 were not covered by tests

def _update_fiscal_taxes_when_disabled(self):
tax_groups = self.env["l10n_br_fiscal.tax.group"].search([])

Check warning on line 40 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L40

Added line #L40 was not covered by tests

for line in self:
amount_tax_included = 0
amount_tax_not_included = 0
amount_tax_withholding = 0

Check warning on line 45 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L43-L45

Added lines #L43 - L45 were not covered by tests
for group in tax_groups:
tax_domain_value = group.tax_domain + "_value"

Check warning on line 47 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L47

Added line #L47 was not covered by tests

if hasattr(line, tax_domain_value):
tax_value = getattr(line, tax_domain_value)

Check warning on line 50 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L50

Added line #L50 was not covered by tests
if group.tax_include:
amount_tax_included += tax_value

Check warning on line 52 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L52

Added line #L52 was not covered by tests
else:
amount_tax_not_included += tax_value

Check warning on line 54 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L54

Added line #L54 was not covered by tests
if group.tax_withholding:
amount_tax_withholding += tax_value

Check warning on line 56 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L56

Added line #L56 was not covered by tests

to_update = {

Check warning on line 58 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L58

Added line #L58 was not covered by tests
"amount_tax_included": amount_tax_included,
"amount_tax_not_included": amount_tax_not_included,
"amount_tax_withholding": amount_tax_withholding,
}
line.write(to_update)

Check warning on line 63 in eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py

View check run for this annotation

Codecov / codecov/patch

eng_l10n_br_account_tax_engine_disable/models/l10n_br_fiscal_document_line_mixin_methods.py#L63

Added line #L63 was not covered by tests
3 changes: 3 additions & 0 deletions eng_l10n_br_account_tax_engine_disable/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Empty file.
Loading