Skip to content
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
92 changes: 92 additions & 0 deletions product_expiry_month/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
====================
Product Expiry Month
====================

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

.. |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%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/17.0/product_expiry_month
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-product_expiry_month
: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/product-attribute&target_branch=17.0
:alt: Try me on Runboat

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

This module adds a field to enter product expiration time in months,
which automatically converts to days.

Useful for products with long shelf lives where months are more
intuitive than days.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Open a product template
2. In the Inventory tab, enter expiration time in months
3. The system automatically calculates and sets the days field

Example:

- Enter 24 months → Sets 730 days
- Enter 6.5 months → Sets 198 days

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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/product-attribute/issues/new?body=module:%20product_expiry_month%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 Source Integrators

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

- Daniel Reis, Open Source Integrators dreis@opensourceintegrators.com

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/product-attribute <https://github.com/OCA/product-attribute/tree/17.0/product_expiry_month>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions product_expiry_month/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2026 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions product_expiry_month/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2026 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product Expiry Month",
"summary": "Add expiration time in months field with automatic conversion to days",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"category": "Product",
"website": "https://github.com/OCA/product-attribute",
"depends": ["product_expiry"],
"data": [
"data/system_parameter_data.xml",
"views/product_template_views.xml",
],
"installable": True,
"application": False,
}
7 changes: 7 additions & 0 deletions product_expiry_month/data/system_parameter_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="param_days_per_year" model="ir.config_parameter">
<field name="key">product_expiry_month.days_per_year</field>
<field name="value">365</field>
</record>
</odoo>
43 changes: 43 additions & 0 deletions product_expiry_month/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_expiry_month
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-27 08:26+0000\n"
"PO-Revision-Date: 2026-03-27 08:26+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: product_expiry_month
#: model_terms:ir.ui.view,arch_db:product_expiry_month.view_product_form_expiry_month
msgid "<span> months</span>"
msgstr "<span> meses</span>"

#. module: product_expiry_month
#: model:ir.model.fields,field_description:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,field_description:product_expiry_month.field_product_template__expiration_time_months
msgid "Expiration Time (Months)"
msgstr "Tiempo de caducidad (Meses)"

#. module: product_expiry_month
#: model:ir.model.fields,help:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,help:product_expiry_month.field_product_template__expiration_time_months
msgid ""
"Expiration time in months (can be fractional). Will be converted to days "
"using the system parameter 'product_expiry_month.days_per_year'."
msgstr ""
"Tiempo de caducidad en meses (puede ser fraccionario). Se convertirá a días "
"utilizando el parámetro del sistema 'product_expiry_month.days_per_year'."

#. module: product_expiry_month
#: model:ir.model,name:product_expiry_month.model_product_template
msgid "Product"
msgstr "Producto"
43 changes: 43 additions & 0 deletions product_expiry_month/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_expiry_month
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-27 08:26+0000\n"
"PO-Revision-Date: 2026-03-27 08:26+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: product_expiry_month
#: model_terms:ir.ui.view,arch_db:product_expiry_month.view_product_form_expiry_month
msgid "<span> months</span>"
msgstr "<span> mois</span>"

#. module: product_expiry_month
#: model:ir.model.fields,field_description:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,field_description:product_expiry_month.field_product_template__expiration_time_months
msgid "Expiration Time (Months)"
msgstr "Délai d'expiration (Mois)"

#. module: product_expiry_month
#: model:ir.model.fields,help:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,help:product_expiry_month.field_product_template__expiration_time_months
msgid ""
"Expiration time in months (can be fractional). Will be converted to days "
"using the system parameter 'product_expiry_month.days_per_year'."
msgstr ""
"Délai d'expiration en mois (peut être fractionnaire). Sera converti en jours "
"en utilisant le paramètre système 'product_expiry_month.days_per_year'."

#. module: product_expiry_month
#: model:ir.model,name:product_expiry_month.model_product_template
msgid "Product"
msgstr "Article"
40 changes: 40 additions & 0 deletions product_expiry_month/i18n/product_expiry_month.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_expiry_month
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-27 08:26+0000\n"
"PO-Revision-Date: 2026-03-27 08:26+0000\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: product_expiry_month
#: model_terms:ir.ui.view,arch_db:product_expiry_month.view_product_form_expiry_month
msgid "<span> months</span>"
msgstr ""

#. module: product_expiry_month
#: model:ir.model.fields,field_description:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,field_description:product_expiry_month.field_product_template__expiration_time_months
msgid "Expiration Time (Months)"
msgstr ""

#. module: product_expiry_month
#: model:ir.model.fields,help:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,help:product_expiry_month.field_product_template__expiration_time_months
msgid ""
"Expiration time in months (can be fractional). Will be converted to days "
"using the system parameter 'product_expiry_month.days_per_year'."
msgstr ""

#. module: product_expiry_month
#: model:ir.model,name:product_expiry_month.model_product_template
msgid "Product"
msgstr ""
43 changes: 43 additions & 0 deletions product_expiry_month/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_expiry_month
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-27 08:26+0000\n"
"PO-Revision-Date: 2026-03-27 08:26+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: product_expiry_month
#: model_terms:ir.ui.view,arch_db:product_expiry_month.view_product_form_expiry_month
msgid "<span> months</span>"
msgstr "<span> meses</span>"

#. module: product_expiry_month
#: model:ir.model.fields,field_description:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,field_description:product_expiry_month.field_product_template__expiration_time_months
msgid "Expiration Time (Months)"
msgstr "Tempo de Validade (Meses)"

#. module: product_expiry_month
#: model:ir.model.fields,help:product_expiry_month.field_product_product__expiration_time_months
#: model:ir.model.fields,help:product_expiry_month.field_product_template__expiration_time_months
msgid ""
"Expiration time in months (can be fractional). Will be converted to days "
"using the system parameter 'product_expiry_month.days_per_year'."
msgstr ""
"Tempo de validade em meses (pode ser fracionado). Será convertido em dias "
"usando o parâmetro do sistema 'product_expiry_month.days_per_year'."

#. module: product_expiry_month
#: model:ir.model,name:product_expiry_month.model_product_template
msgid "Product"
msgstr "Produto"
4 changes: 4 additions & 0 deletions product_expiry_month/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2026 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import product_template
43 changes: 43 additions & 0 deletions product_expiry_month/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2026 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

expiration_time_months = fields.Float(
string="Expiration Time (Months)",
compute="_compute_expiration_time_months",
inverse="_inverse_expiration_time_months",
store=True,
help="Expiration time in months (can be fractional). Will be converted "
"to days using the system parameter "
"'product_expiry_month.days_per_year'.",
)

@api.depends("expiration_time")
def _compute_expiration_time_months(self):
if self:
days_per_year = float(
self.env["ir.config_parameter"]
.sudo()
.get_param("product_expiry_month.days_per_year", "365")
)
for template in self:
template.expiration_time_months = (
template.expiration_time * 12 / days_per_year
)

def _inverse_expiration_time_months(self):
if self:
days_per_year = float(
self.env["ir.config_parameter"]
.sudo()
.get_param("product_expiry_month.days_per_year", "365")
)
for template in self:
template.expiration_time = round(
template.expiration_time_months * days_per_year / 12
)
3 changes: 3 additions & 0 deletions product_expiry_month/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions product_expiry_month/readme/CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change days per year in System Parameters: `product_expiry_month.days_per_year`
1 change: 1 addition & 0 deletions product_expiry_month/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Daniel Reis, Open Source Integrators <dreis@opensourceintegrators.com>
4 changes: 4 additions & 0 deletions product_expiry_month/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module adds a field to enter product expiration time in months,
which automatically converts to days.

Useful for products with long shelf lives where months are more intuitive than days.
7 changes: 7 additions & 0 deletions product_expiry_month/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1. Open a product template
2. In the Inventory tab, enter expiration time in months
3. The system automatically calculates and sets the days field

Example:
- Enter 24 months → Sets 730 days
- Enter 6.5 months → Sets 198 days
Loading
Loading