Skip to content

Commit

Permalink
[ADD] sustainability_product_label_print: add carbon on printed labels (
Browse files Browse the repository at this point in the history
#217)

## Related Issues

- closes #196
  • Loading branch information
jacopobacci authored Dec 12, 2024
1 parent 2d403e1 commit 0f27725
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
![LastCommit](https://img.shields.io/github/last-commit/sustainability-suite/sustainability-odoo?color=green)
[![Sustainability CI](https://github.com/sustainability-suite/sustainability-odoo/actions/workflows/ci.yaml/badge.svg)](https://github.com/sustainability-suite/sustainability-odoo/actions/workflows/ci.yaml)


# Sustainability Odoo v17

## License

This repository is licensed under [AGPL-3.0](LICENSE). Each module might be subject to a different license : see module manifest.


<!-- prettier-ignore-start -->
[//]: # (addons)

Expand All @@ -28,6 +26,7 @@ addon | version | maintainers | summary
[sustainability_hr_expense_report](sustainability_hr_expense_report/) | 17.0.1.0.0 | [![bonnetadam](https://github.com/bonnetadam.png?size=30px)](https://github.com/bonnetadam) | Provide CO2 accounting data for expense reports
[sustainability_mis_builder](sustainability_mis_builder/) | 17.0.1.0.0 | [![jguenat](https://github.com/jguenat.png?size=30px)](https://github.com/jguenat) | Provide CO2e accounting lines data for MIS builder reports
[sustainability_point_of_sale](sustainability_point_of_sale/) | 17.0.1.0.0 | [![jacopobacci](https://github.com/jacopobacci.png?size=30px)](https://github.com/jacopobacci) | Sustainability Point of Sale
[sustainability_product_label_print](sustainability_product_label_print/) | 17.0.1.0.0 | [![jacopobacci](https://github.com/jacopobacci.png?size=30px)](https://github.com/jacopobacci) | Sustainability Product Label Print
[sustainability_purchase](sustainability_purchase/) | 17.0.1.0.0 | [![jguenat](https://github.com/jguenat.png?size=30px)](https://github.com/jguenat) [![bonnetadam](https://github.com/bonnetadam.png?size=30px)](https://github.com/bonnetadam) [![jacopobacci](https://github.com/jacopobacci.png?size=30px)](https://github.com/jacopobacci) | Glue module for sustainability & purchase modules
[sustainability_website_sale](sustainability_website_sale/) | 17.0.1.0.0 | [![jacopobacci](https://github.com/jacopobacci.png?size=30px)](https://github.com/jacopobacci) | Sustainability eCommerce

Expand Down
1 change: 1 addition & 0 deletions sustainability/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ResConfigSettings(models.TransientModel):
module_sustainability_hr_expense_report = fields.Boolean()
module_sustainability_website_sale = fields.Boolean()
module_sustainability_point_of_sale = fields.Boolean()
module_sustainability_product_label_print = fields.Boolean()

@api.depends("company_id")
def _compute_available_modules(self):
Expand Down
3 changes: 3 additions & 0 deletions sustainability/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
>
<field name="module_sustainability_point_of_sale" />
</setting>
<setting string="Show CO2e in products printed labels" help="Display CO2e values in products printed labels">
<field name="module_sustainability_product_label_print" />
</setting>
</block>
<div class="col-6 p-4 center-content center co2_extra_modules" invisible="extra_module_names == False" style="margin-left: 3rem">
<h4>Use Sutainability module with more applications !</h4>
Expand Down
68 changes: 68 additions & 0 deletions sustainability_product_label_print/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
==================================
Sustainability Product Label Print
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:754180c8666c0d873b197614d943e56ad813c33c43db337eba5853989dda27cf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-sustainability--suite%2Fsustainability--odoo-lightgray.png?logo=github
:target: https://github.com/sustainability-suite/sustainability-odoo/tree/17.0/sustainability_product_label_print
:alt: sustainability-suite/sustainability-odoo

|badge1| |badge2| |badge3|

This module can be activated from Sustainability settings to add CO2e infos on printed product labels.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/sustainability-suite/sustainability-odoo/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/sustainability-suite/sustainability-odoo/issues/new?body=module:%20sustainability_product_label_print%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
~~~~~~~

* Open Net Sàrl

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

* Jacopo Bacci <https://github.com/jacopobacci>

Maintainers
~~~~~~~~~~~

.. |maintainer-jacopobacci| image:: https://github.com/jacopobacci.png?size=40px
:target: https://github.com/jacopobacci
:alt: jacopobacci

Current maintainer:

|maintainer-jacopobacci|

This module is part of the `sustainability-suite/sustainability-odoo <https://github.com/sustainability-suite/sustainability-odoo/tree/17.0/sustainability_product_label_print>`_ project on GitHub.

You are welcome to contribute.
18 changes: 18 additions & 0 deletions sustainability_product_label_print/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Sustainability Product Label Print",
"category": "Sales/Sales",
"version": "17.0.1.0.0",
"installable": True,
"application": False,
"auto_install": False,
"license": "LGPL-3",
"author": "Open Net Sàrl",
"maintainers": ["jacopobacci"],
"development_status": "Production/Stable",
"website": "https://www.open-net.ch",
"depends": ["sustainability"],
"data": [
"report/product_product_templates.xml",
],
"sequence": 1,
}
1 change: 1 addition & 0 deletions sustainability_product_label_print/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Jacopo Bacci <https://github.com/jacopobacci>
1 change: 1 addition & 0 deletions sustainability_product_label_print/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module can be activated from Sustainability settings to add CO2e infos on printed product labels.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<odoo>
<data>
<template id="report_simple_label2x7_inherit" inherit_id="product.report_simple_label2x7">
<xpath expr="//strong[hasclass('o_label_price')]" position="before">
<span class="me-2">
<span style="font-size: 1em;" t-out="'{:.2f}'.format(product.carbon_out_factor_id.carbon_value)" />
<span style="font-size: 0.8em;">kgCO2e</span>
</span>
</xpath>
</template>

<template id="report_simple_label4x7_inherit" inherit_id="product.report_simple_label4x7">
<xpath expr="//strong[hasclass('o_label_price_medium')]" position="before">
<span>
<span style="font-size: 0.8em;" t-out="'{:.2f}'.format(product.carbon_out_factor_id.carbon_value)" />
<span style="font-size: 0.6em;">kgCO2e</span>
</span>
</xpath>
</template>

<template id="report_simple_label4x12_inherit" inherit_id="product.report_simple_label4x12">
<xpath expr="//div[hasclass('o_label_price_medium')]//strong" position="before">
<span class="me-2">
<span style="font-size: 0.8em;" t-out="'{:.2f}'.format(product.carbon_out_factor_id.carbon_value)" />
<span style="font-size: 0.6em;">kgCO2e</span>
</span>
</xpath>
</template>

<template id="report_simple_label_dymo_inherit" inherit_id="product.report_simple_label_dymo">
<xpath expr="//strong[hasclass('o_label_price_small')]" position="before">
<span class="me-2">
<span style="font-size: 0.6em;" t-out="'{:.2f}'.format(product.carbon_out_factor_id.carbon_value)" />
<span style="font-size: 0.4em;">kgCO2e</span>
</span>
</xpath>
</template>
</data>
</odoo>

0 comments on commit 0f27725

Please sign in to comment.