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 l10n fr ecotaxe product #450

Closed
Closed
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
80 changes: 80 additions & 0 deletions l10n_fr_ecotaxe_product/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
==========================================
France Custom Ecotaxe - Manage on Products
==========================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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--france-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-france/tree/15.0/l10n_fr_ecotaxe_product
:alt: OCA/l10n-france
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-france-15-0/l10n-france-15-0-l10n_fr_ecotaxe_product
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/121/15.0
:alt: Try me on Runbot

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

This module extends "France Custom Ecotaxe" by allowing ecotaxes to be managed
on products instead of templates.

**Table of contents**

.. contents::
:local:

Usage
=====

Usage is similar to module "France Custom Ecotaxe", with the exception that
ecotaxes are managed on products instead of templates.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-france/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 <https://github.com/OCA/l10n-france/issues/new?body=module:%20l10n_fr_ecotaxe_product%0Aversion:%2015.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
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Silvio Gregorini <[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-france <https://github.com/OCA/l10n-france/tree/15.0/l10n_fr_ecotaxe_product>`_ 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 l10n_fr_ecotaxe_product/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions l10n_fr_ecotaxe_product/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Camptocamp
# @author Silvio Gregorini <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "France Custom Ecotaxe - Manage on Products",
"summary": "Move Ecotax management from templates to products",
"version": "16.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-france",
"category": "Localization/Account Taxes",
"license": "AGPL-3",
"depends": ["l10n_fr_ecotaxe"],
"installable": True,
}
46 changes: 46 additions & 0 deletions l10n_fr_ecotaxe_product/i18n/l10n_fr_ecotaxe_product.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_fr_ecotaxe_product
#
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_product
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_product.field_product_product__ecotaxe_amount
msgid "Ecotaxe Amount"
msgstr ""

#. module: l10n_fr_ecotaxe_product
#: model:ir.model.fields,help:l10n_fr_ecotaxe_product.field_product_product__ecotaxe_amount
msgid "Ecotaxe Amount computed form Classification"
msgstr ""

#. module: l10n_fr_ecotaxe_product
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_product.field_product_product__ecotaxe_classification_id
msgid "Ecotaxe Classification"
msgstr ""

#. module: l10n_fr_ecotaxe_product
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_product.field_product_product__manual_fixed_ecotaxe
msgid "Manual Fixed Ecotaxe"
msgstr ""

#. module: l10n_fr_ecotaxe_product
#: model:ir.model.fields,help:l10n_fr_ecotaxe_product.field_product_product__manual_fixed_ecotaxe
msgid ""
"Manual Fixed ecotaxe.\n"
"Allow to subtite default Ecotaxe Classification\n"
msgstr ""

#. module: l10n_fr_ecotaxe_product
#: model:ir.model,name:l10n_fr_ecotaxe_product.model_product_product
msgid "Product"
msgstr ""
5 changes: 5 additions & 0 deletions l10n_fr_ecotaxe_product/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2021 Camptocamp
# @author Silvio Gregorini <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import product_product
69 changes: 69 additions & 0 deletions l10n_fr_ecotaxe_product/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2021 Camptocamp
# @author Silvio Gregorini <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

ecotaxe_classification_id = fields.Many2one(
"account.ecotaxe.classification",
string="Ecotaxe Classification",
)
ecotaxe_amount = fields.Float(
compute="_compute_ecotaxe",
help="Ecotaxe Amount computed form Classification",
store=True,
)
manual_fixed_ecotaxe = fields.Float(
help="Manual Fixed ecotaxe.\n"
"Allow to subtite default Ecotaxe Classification\n"
)

@api.model_create_multi
def create(self, vals_list):
prods = super().create(vals_list)
prods._post_create_set_ecotax_classification()
return prods

def _post_create_set_ecotax_classification(self):
for prod in self:
tmpl = prod.product_tmpl_id
# Case 1:
# * newly created product has an ecotax classification
# * the template has no classification
# * the product is the template's only variant
# => copy ecotax from product to template
if (
prod.ecotaxe_classification_id
and not tmpl.ecotaxe_classification_id
and tmpl.product_variant_ids == prod
):
tmpl.ecotaxe_classification_id = prod.ecotaxe_classification_id
# Case 2:
# * newly created product has no ecotax classification
# * the template has ecotax classification
# => copy ecotax from template to product
elif not prod.ecotaxe_classification_id and tmpl.ecotaxe_classification_id:
prod.ecotaxe_classification_id = tmpl.ecotaxe_classification_id

@api.depends(
"ecotaxe_classification_id",
"ecotaxe_classification_id.ecotaxe_type",
"ecotaxe_classification_id.ecotaxe_coef",
"manual_fixed_ecotaxe",
"weight",
"product_tmpl_id.ecotaxe_amount",
)
def _compute_ecotaxe(self):
for prod in self:
ecotax_cls = prod.ecotaxe_classification_id
if ecotax_cls.ecotaxe_type == "weight_based":
amt = ecotax_cls.ecotaxe_coef * (prod.weight or 0.0)
elif prod.manual_fixed_ecotaxe:
amt = prod.manual_fixed_ecotaxe
else:
amt = ecotax_cls.default_fixed_ecotaxe
prod.ecotaxe_amount = amt
1 change: 1 addition & 0 deletions l10n_fr_ecotaxe_product/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Silvio Gregorini <[email protected]>
2 changes: 2 additions & 0 deletions l10n_fr_ecotaxe_product/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends "France Custom Ecotaxe" by allowing ecotaxes to be managed
on products instead of templates.
2 changes: 2 additions & 0 deletions l10n_fr_ecotaxe_product/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Usage is similar to module "France Custom Ecotaxe", with the exception that
ecotaxes are managed on products instead of templates.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading