Skip to content
Merged
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 product_catalog_sale_rental/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===========================
Product Catalog Sale Rental
===========================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/license-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-nuobit%2Fodoo--addons-lightgray.png?logo=github
:target: https://github.com/nuobit/odoo-addons/tree/16.0/product_catalog_sale_rental
:alt: nuobit/odoo-addons

|badge1| |badge2| |badge3|

This module bridges ``product_catalog_sale`` with ``sale_rental`` so that
products added from the catalog on a rental order create proper rental lines.

Without this module, the catalog creates regular sale order lines missing
``rental_type``, ``rental_qty`` and dates. This module overrides
``_update_order_line_info`` to automatically set these fields using the
order's default start and end dates.

The catalog quantity represents the number of items to rent (``rental_qty``),
and ``product_uom_qty`` is computed as ``rental_qty × number_of_days``.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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

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

* NuoBiT Solutions SL

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

* `NuoBiT <https://www.nuobit.com>`__:

* Eric Antones <eantones@nuobit.com>

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

This module is part of the `nuobit/odoo-addons <https://github.com/nuobit/odoo-addons/tree/16.0/product_catalog_sale_rental>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions product_catalog_sale_rental/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions product_catalog_sale_rental/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2026 NuoBiT Solutions SL - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

{
"name": "Product Catalog Sale Rental",
"summary": "Bridge between product catalog and rental modules"
" to create proper rental lines from the catalog.",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Rental",
"author": "NuoBiT Solutions SL",
"website": "https://github.com/nuobit/odoo-addons",
"license": "AGPL-3",
"depends": [
"product_catalog_sale",
"sale_rental",
],
"data": [
"views/product_views.xml",
],
}
32 changes: 32 additions & 0 deletions product_catalog_sale_rental/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_catalog_sale_rental
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-24 00:00+0000\n"
"PO-Revision-Date: 2026-03-24 00:00+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: product_catalog_sale_rental
#: code:addons/product_catalog_sale_rental/models/sale_order.py:0
#, python-format
msgid ""
"Please set the start and end dates on the order before adding rental "
"products from the catalog."
msgstr ""
"Si us plau, establiu les dates d'inici i fi a la comanda abans d'afegir "
"productes de lloguer des del catàleg."

#. module: product_catalog_sale_rental
#: model_terms:ir.ui.view,arch_db:product_catalog_sale_rental.product_view_search_catalog
msgid "Rental Products"
msgstr "Productes de lloguer"
32 changes: 32 additions & 0 deletions product_catalog_sale_rental/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_catalog_sale_rental
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-24 00:00+0000\n"
"PO-Revision-Date: 2026-03-24 00:00+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: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: product_catalog_sale_rental
#: code:addons/product_catalog_sale_rental/models/sale_order.py:0
#, python-format
msgid ""
"Please set the start and end dates on the order before adding rental "
"products from the catalog."
msgstr ""
"Por favor, establezca las fechas de inicio y fin en el pedido antes de "
"añadir productos de alquiler desde el catálogo."

#. module: product_catalog_sale_rental
#: model_terms:ir.ui.view,arch_db:product_catalog_sale_rental.product_view_search_catalog
msgid "Rental Products"
msgstr "Productos de alquiler"
1 change: 1 addition & 0 deletions product_catalog_sale_rental/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
100 changes: 100 additions & 0 deletions product_catalog_sale_rental/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright 2026 NuoBiT Solutions SL - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import _, fields, models
from odoo.exceptions import UserError


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

def _is_rental_order(self):
self.ensure_one()
rental_type = self.env.ref(
"rental_base.rental_sale_type", raise_if_not_found=False
)
return bool(rental_type and self.type_id == rental_type)

def _get_action_add_from_catalog_extra_context(self):
ctx = super()._get_action_add_from_catalog_extra_context()
if self._is_rental_order():
ctx["search_default_rental_products"] = 1
return ctx

def _update_order_line_info(self, product_id, quantity, **kwargs):
product = self.env["product.product"].browse(product_id)
if not product.rented_product_id:
return super()._update_order_line_info(product_id, quantity, **kwargs)
if not self.default_start_date or not self.default_end_date:
raise UserError(
_(
"Please set the start and end dates on the order"
" before adding rental products from the catalog."
)
)
number_of_days = (self.default_end_date - self.default_start_date).days + 1
sol = self.order_line.filtered(lambda line: line.product_id.id == product_id)
if sol:
if quantity != 0:
sol.rental_qty = quantity
sol.product_uom_qty = quantity * number_of_days
elif self.state in ["draft", "sent"]:
price_unit = self.pricelist_id._get_product_price(
product=sol.product_id,
quantity=1.0,
currency=self.currency_id,
date=self.date_order,
**kwargs,
)
sol.unlink()
return price_unit
else:
sol.rental_qty = 0
sol.product_uom_qty = 0
elif quantity > 0:
sol = self.env["sale.order.line"].create(
{
"order_id": self.id,
"product_id": product_id,
"rental_type": "new_rental",
"rental_qty": quantity,
"start_date": self.default_start_date,
"end_date": self.default_end_date,
"product_uom_qty": quantity * number_of_days,
"sequence": (
(self.order_line and self.order_line[-1].sequence + 1) or 10
),
}
)
return sol.price_unit


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

start_date = fields.Date(readonly=False)
end_date = fields.Date(readonly=False)

def _get_product_catalog_lines_data(self, **kwargs):
if self and self[0].rental_type:
if len(self) == 1:
res = {
"quantity": self.rental_qty,
"price": self.price_unit,
"readOnly": self.order_id._is_readonly()
or (self.product_id.sale_line_warn == "block"),
}
if (
self.product_id.sale_line_warn != "no-message"
and self.product_id.sale_line_warn_msg
):
res["warning"] = self.product_id.sale_line_warn_msg
return res
elif self:
self.product_id.ensure_one()
return {
"readOnly": True,
"price": self[0].price_unit,
"quantity": sum(self.mapped("rental_qty")),
}
return super()._get_product_catalog_lines_data(**kwargs)
3 changes: 3 additions & 0 deletions product_catalog_sale_rental/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `NuoBiT <https://www.nuobit.com>`__:

* Eric Antones <eantones@nuobit.com>
10 changes: 10 additions & 0 deletions product_catalog_sale_rental/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This module bridges ``product_catalog_sale`` with ``sale_rental`` so that
products added from the catalog on a rental order create proper rental lines.

Without this module, the catalog creates regular sale order lines missing
``rental_type``, ``rental_qty`` and dates. This module overrides
``_update_order_line_info`` to automatically set these fields using the
order's default start and end dates.

The catalog quantity represents the number of items to rent (``rental_qty``),
and ``product_uom_qty`` is computed as ``rental_qty × number_of_days``.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading