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

[17.0][MIG] account_ecotax_sale: Migration to 17.0 #481

Open
wants to merge 15 commits into
base: 17.0
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions account_avatax_sale_oca/views/sale_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
<field name="calculate_tax_on_save" invisible="1" />
<field name="tax_amount" invisible="1" />
</xpath>
<xpath expr="//field[@name='order_line']//tree" position="inside">
<xpath expr="//field[@name='order_line']/tree" position="inside">
<field name="tax_amt" groups="base.group_no_one" optional="hide" />
</xpath>
<xpath
expr="//field[@name='order_line']//form//field[@name='product_id']"
expr="//field[@name='order_line']/form//field[@name='product_id']"
position="after"
>
<field name="tax_amt" groups="base.group_no_one" optional="hide" />
Expand Down
90 changes: 90 additions & 0 deletions account_ecotax_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
======================
sale Ecotax Management
======================

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

.. |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%2Faccount--fiscal--rule-lightgray.png?logo=github
:target: https://github.com/OCA/account-fiscal-rule/tree/17.0/account_ecotax_sale
:alt: OCA/account-fiscal-rule
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-fiscal-rule-17-0/account-fiscal-rule-17-0-account_ecotax_sale
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-fiscal-rule&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module is an extension of the module *l10n_fr_ecotax* for sale
orders. Please refer to the README of the module *account_ecotax* for
more info about ecotax management.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-fiscal-rule/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/OCA/account-fiscal-rule/issues/new?body=module:%20account_ecotax_sale%0Aversion:%2017.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
-------

* Akretion

Contributors
------------

- Mourad EL HADJ MIMOUNE <[email protected]>
- Florian DA COSTA <[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.

.. |maintainer-mourad-ehm| image:: https://github.com/mourad-ehm.png?size=40px
:target: https://github.com/mourad-ehm
:alt: mourad-ehm
.. |maintainer-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px
:target: https://github.com/florian-dacosta
:alt: florian-dacosta

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mourad-ehm| |maintainer-florian-dacosta|

This module is part of the `OCA/account-fiscal-rule <https://github.com/OCA/account-fiscal-rule/tree/17.0/account_ecotax_sale>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_ecotax_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions account_ecotax_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# © 2014-2023 Akretion (http://www.akretion.com)
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "sale Ecotax Management",
"summary": "Sale Ecotaxe",
"version": "17.0.1.0.0",
"maintainers": ["mourad-ehm", "florian-dacosta"],
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-fiscal-rule",
"category": "Localization/Account Taxes",
"license": "AGPL-3",
"depends": ["account_ecotax", "sale"],
"data": [
"views/sale_view.xml",
"security/ir.model.access.csv",
],
"installable": True,
}
39 changes: 39 additions & 0 deletions account_ecotax_sale/i18n/account_ecotaxe_sale.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_fr_ecotaxe_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order__amount_ecotaxe
msgid "Included Ecotaxe"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__subtotal_ecotaxe
msgid "Subtotal Ecotaxe"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__unit_ecotaxe_amount
msgid "ecotaxe Unit."
msgstr ""
42 changes: 42 additions & 0 deletions account_ecotax_sale/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_fr_ecotaxe_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-01 13:01+0000\n"
"PO-Revision-Date: 2022-03-01 13:01+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order__amount_ecotaxe
msgid "Included Ecotaxe"
msgstr "Ecotaxe Incluse"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order
msgid "Sales Order"
msgstr "Bon de commande"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr "Ligne de bons de commande"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__subtotal_ecotaxe
msgid "Subtotal Ecotaxe"
msgstr "Sous-total Ecotaxe"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__unit_ecotaxe_amount
msgid "ecotaxe Unit."
msgstr "Ecotaxe par Unité"
3 changes: 3 additions & 0 deletions account_ecotax_sale/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import sale_order_line_ecotax
from . import sale_order_line
from . import sale_order
24 changes: 24 additions & 0 deletions account_ecotax_sale/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# © 2015 -2023 Akretion (http://www.akretion.com)
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

amount_ecotax = fields.Float(
digits="Ecotaxe",
string="Included Ecotaxe",
store=True,
compute="_compute_ecotax",
)

@api.depends("order_line.subtotal_ecotax")
def _compute_ecotax(self):
for order in self:
val_ecotax = 0.0
for line in order.order_line:
val_ecotax += line.subtotal_ecotax
order.amount_ecotax = val_ecotax
106 changes: 106 additions & 0 deletions account_ecotax_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# © 2015 -2023 Akretion (http://www.akretion.com)
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import Command, api, fields, models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

ecotax_line_ids = fields.One2many(
"sale.order.line.ecotax",
"sale_order_line_id",
compute="_compute_ecotax_line_ids",
store=True,
readonly=False,
string="Ecotax Lines",
copy=True,
)
subtotal_ecotax = fields.Float(
string="Ecotax", digits="Ecotax", store=True, compute="_compute_ecotax"
)
ecotax_amount_unit = fields.Float(
digits="Ecotax",
string="Ecotax Unit",
store=True,
compute="_compute_ecotax",
)

def _get_ecotax_amounts(self):
self.ensure_one()
unit = sum(self.ecotax_line_ids.mapped("amount_unit"))
subtotal_ecotax = sum(self.ecotax_line_ids.mapped("amount_total"))
return unit, subtotal_ecotax

@api.depends(
"currency_id",
"product_uom_qty",
"ecotax_line_ids",
"ecotax_line_ids.amount_unit",
"ecotax_line_ids.amount_total",
)
def _compute_ecotax(self):
for line in self:
amount_unit, subtotal = line._get_ecotax_amounts()
line.subtotal_ecotax = subtotal
line.ecotax_amount_unit = amount_unit

def _get_new_vals_list(self):
self.ensure_one()
new_vals_list = [
Command.create(
{
"classification_id": ecotaxline_prod.classification_id.id,
"force_amount_unit": ecotaxline_prod.force_amount,
}
)
for ecotaxline_prod in self.product_id.all_ecotax_line_product_ids
]
return new_vals_list

@api.depends("product_id")
def _compute_ecotax_line_ids(self):
"""Unlink and recreate ecotax_lines when modifying the product_id."""
for line in self:
delete_vals_list = [
Command.delete(taxline.id) for taxline in line.ecotax_line_ids
]
new_vals_list = line._get_new_vals_list()
update = new_vals_list + delete_vals_list
line.ecotax_line_ids = update

def edit_ecotax_lines(self):
view = {

Check warning on line 74 in account_ecotax_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax_sale/models/sale_order_line.py#L74

Added line #L74 was not covered by tests
"name": ("Ecotax classification"),
"view_type": "form",
"view_mode": "form",
"res_model": "sale.order.line",
"view_id": self.env.ref(
"account_ecotax_sale.view_sale_line_ecotax_form"
).id,
"type": "ir.actions.act_window",
"target": "new",
"res_id": self.id,
}
return view

Check warning on line 86 in account_ecotax_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax_sale/models/sale_order_line.py#L86

Added line #L86 was not covered by tests

def _prepare_invoice_line(self, **optional_values):
"""Create equivalente ecotax_line_ids for account move line
from sale order line ecotax_line_ids .
"""
res = super()._prepare_invoice_line(**optional_values)
ecotax_cls_vals = []

Check warning on line 93 in account_ecotax_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax_sale/models/sale_order_line.py#L92-L93

Added lines #L92 - L93 were not covered by tests
for ecotaxline in self.ecotax_line_ids:
ecotax_cls_vals.append(

Check warning on line 95 in account_ecotax_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax_sale/models/sale_order_line.py#L95

Added line #L95 was not covered by tests
(
0,
0,
{
"classification_id": ecotaxline.classification_id.id,
"force_amount_unit": ecotaxline.force_amount_unit,
},
)
)
res["ecotax_line_ids"] = ecotax_cls_vals
return res

Check warning on line 106 in account_ecotax_sale/models/sale_order_line.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax_sale/models/sale_order_line.py#L105-L106

Added lines #L105 - L106 were not covered by tests
28 changes: 28 additions & 0 deletions account_ecotax_sale/models/sale_order_line_ecotax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# © 2014-2023 Akretion (http://www.akretion.com)
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class SaleOrderLineEcotaxe(models.Model):
_name = "sale.order.line.ecotax"
_inherit = "ecotax.line.mixin"
_description = "Sale order line ecotax"

sale_order_line_id = fields.Many2one(
comodel_name="sale.order.line",
string="Sale Line",
required=True,
readonly=True,
index=True,
auto_join=True,
ondelete="cascade",
)
product_id = fields.Many2one(
"product.product", related="sale_order_line_id.product_id", readonly=True
)
quantity = fields.Float(related="sale_order_line_id.product_uom_qty", readonly=True)
currency_id = fields.Many2one(
related="sale_order_line_id.currency_id", readonly=True
)
3 changes: 3 additions & 0 deletions account_ecotax_sale/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions account_ecotax_sale/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Mourad EL HADJ MIMOUNE \<[email protected]\>
- Florian DA COSTA \<[email protected]\>
3 changes: 3 additions & 0 deletions account_ecotax_sale/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module is an extension of the module *l10n_fr_ecotax* for sale
orders. Please refer to the README of the module *account_ecotax* for
more info about ecotax management.
4 changes: 4 additions & 0 deletions account_ecotax_sale/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_ecotax_line_product_sale_readonly,ecotax.line.product readonly,account_ecotax.model_ecotax_line_product,sales_team.group_sale_salesman,1,0,0,0
access_account_move_line_ecotax_readonly_sale_user,account.move.line.ecotax readonly sale user,account_ecotax.model_account_move_line_ecotax,sales_team.group_sale_salesman,1,0,0,0
ir_model_access_sale_order_line_ecotax_group_sale_salesman,Read Full acess to model_sale_order_line_ecotax to group sale_salesman,model_sale_order_line_ecotax,sales_team.group_sale_salesman,1,1,1,1
Binary file added account_ecotax_sale/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading