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][ADD] rental_variant #36

Open
wants to merge 1 commit into
base: 16.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
95 changes: 95 additions & 0 deletions rental_variant/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
==============
Rental Variant
==============

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

.. |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%2Fvertical--rental-lightgray.png?logo=github
:target: https://github.com/OCA/vertical-rental/tree/16.0/rental_variant
:alt: OCA/vertical-rental
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/vertical-rental-16-0/vertical-rental-16-0-rental_variant
: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/vertical-rental&target_branch=16.0
:alt: Try me on Runboat

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

This module allows to rent variant products.

**Table of contents**

.. contents::
:local:

Usage
=====

* From a physical or consumable product template, create its rental twin (as service) by "Copy For Rental" button
* The attributes and values between the physical and rental service templates are synchronize by a cron and a button "Update Attributes values".
* In a Sale Order, select the service variant to rent, the rental configuration is in a popup on the line.
* In case of dynamical product creation mode on attributes, if the physical product does not exist, it will be created.


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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/vertical-rental/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/vertical-rental/issues/new?body=module:%20rental_variant%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
~~~~~~~

* Akretion
*
* Groupe Voltaire SAS

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

* Kévin Roche <[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-Kev-Roche| image:: https://github.com/Kev-Roche.png?size=40px
:target: https://github.com/Kev-Roche
:alt: Kev-Roche

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

|maintainer-Kev-Roche|

This module is part of the `OCA/vertical-rental <https://github.com/OCA/vertical-rental/tree/16.0/rental_variant>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions rental_variant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
24 changes: 24 additions & 0 deletions rental_variant/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>

{
"name": "Rental Variant",
"version": "16.0.1.0.0",
"category": "Rental",
"website": "https://github.com/OCA/vertical-rental",
"author": "Akretion, Odoo Community Association (OCA), , Groupe Voltaire SAS",
"maintainers": ["Kev-Roche"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"sale_rental",
],
"data": [
"security/ir.model.access.csv",
"data/data.xml",
"views/product_template.xml",
"views/sale_order.xml",
"wizard/sale_rental_wizard.xml",
],
}
15 changes: 15 additions & 0 deletions rental_variant/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="ir_cron_update_rental_attributes_values" model="ir.cron">
<field name="name">Update Rental Attributes Values</field>
<field name="active" eval="True" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">5</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model_id" ref="product.model_product_template" />
<field name="state">code</field>
<field name="code">model.cron_update_rental_attributes_values()</field>
</record>
</odoo>
205 changes: 205 additions & 0 deletions rental_variant/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rental_variant
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-14 14:59+0000\n"
"PO-Revision-Date: 2023-12-14 16:04+0100\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: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.4.1\n"

#. module: rental_variant
#: model_terms:ir.ui.view,arch_db:rental_variant.sale_rental_line_wizard_view
msgid "Confirm"
msgstr "Confirmer"

#. module: rental_variant
#: model_terms:ir.ui.view,arch_db:rental_variant.product_template_only_form_view
msgid "Copy For Rental"
msgstr "Copier Pour location"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__create_uid
msgid "Created by"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__create_date
msgid "Created on"
msgstr ""

#. module: rental_variant
#: model_terms:ir.ui.view,arch_db:rental_variant.sale_rental_line_wizard_view
msgid "Discard"
msgstr "Annuler"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__display_name
msgid "Display Name"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__end_date
msgid "End Date"
msgstr "Date de fin"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__id
msgid "ID"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_order_line__is_rental
msgid "Is Rental Variant Exist"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard____last_update
msgid "Last Modified on"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__write_uid
msgid "Last Updated by"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__write_date
msgid "Last Updated on"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields.selection,name:rental_variant.selection__sale_rental_line_wizard__rental_type__new_rental
msgid "New Rental"
msgstr "Nouvelle location"

#. module: rental_variant
#. odoo-python
#: code:addons/rental_variant/models/sale_order.py:0
#, python-format
msgid "Physical rent product can not be found / created."
msgstr "Le produit physique à loué ne peut être trouvé / créé."

#. module: rental_variant
#: model:ir.model,name:rental_variant.model_product_template
msgid "Product"
msgstr "Article"

#. module: rental_variant
#: model:ir.model,name:rental_variant.model_product_product
msgid "Product Variant"
msgstr "Variante de produit"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_product_product__rental_product_tmpl_id
#: model:ir.model.fields,field_description:rental_variant.field_product_template__rental_product_tmpl_id
msgid "Related Rental Product Template"
msgstr "Modèle de location associé"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_order_line__rental_id
msgid "Rental"
msgstr "Location"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_product_product__rental_attributes_values_need_update
#: model:ir.model.fields,field_description:rental_variant.field_product_template__rental_attributes_values_need_update
msgid "Rental Attributes Values Need Update"
msgstr "Valeurs d'attributs à Mettre à Jour"

#. module: rental_variant
#: model_terms:ir.ui.view,arch_db:rental_variant.view_order_form
msgid "Rental Config."
msgstr "Location Config."

#. module: rental_variant
#: model:ir.model.fields.selection,name:rental_variant.selection__sale_rental_line_wizard__rental_type__rental_extension
msgid "Rental Extension"
msgstr "Exension de location"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__rental_line_id
msgid "Rental Line"
msgstr ""

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_product_product__rental_product_id
msgid "Rental Product"
msgstr "Produit Loué"

#. module: rental_variant
#: model_terms:ir.ui.view,arch_db:rental_variant.product_template_only_form_view
msgid "Rental Product Template"
msgstr "Modèle de location"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__rental_qty
msgid "Rental Qty"
msgstr "Qté à louer"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__rental_type
msgid "Rental Type"
msgstr "Type de location"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__extension_rental_id
msgid "Rental to Extend"
msgstr "Location à étendre"

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__sell_rental_id
msgid "Rental to Sell"
msgstr "Location à vendre"

#. module: rental_variant
#: model_terms:ir.ui.view,arch_db:rental_variant.sale_rental_line_wizard_view
msgid "Rented Product Qty"
msgstr "Qté produit loué"

#. module: rental_variant
#: model:ir.model,name:rental_variant.model_sale_rental_line_wizard
msgid "Sale Rental Line Wizard"
msgstr ""

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

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

#. module: rental_variant
#: model:ir.model.fields,field_description:rental_variant.field_sale_rental_line_wizard__start_date
msgid "Start Date"
msgstr "Date de début"

#. module: rental_variant
#: model_terms:ir.ui.view,arch_db:rental_variant.product_template_only_form_view
msgid "Update Attributes values"
msgstr ""

#. module: rental_variant
#: model:ir.actions.server,name:rental_variant.ir_cron_update_rental_attributes_values_ir_actions_server
#: model:ir.cron,cron_name:rental_variant.ir_cron_update_rental_attributes_values
msgid "Update Rental Attributes Values"
msgstr "MAJ valeurs d'attributs de location"

#. module: rental_variant
#. odoo-python
#: code:addons/rental_variant/models/product_template.py:0
#, python-format
msgid "[RENT] %s"
msgstr "[LOC] %s"
3 changes: 3 additions & 0 deletions rental_variant/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import product_product
from . import product_template
from . import sale_order
35 changes: 35 additions & 0 deletions rental_variant/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>

from odoo import fields, models


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

rental_product_id = fields.Many2one(
"product.product",
)

def get_rented_product_id(self):
if len(self.rented_product_tmpl_id.product_variant_ids) == 1:
return self.rented_product_tmpl_id.product_variant_ids
product = self.rented_product_tmpl_id.product_variant_ids.filtered_domain(
[
(
"product_template_attribute_value_ids",
"=",
self.product_template_attribute_value_ids.ids,
)
]
)
if product:
if len(product) == 1:
return product
else:
return product.filtered(
lambda x, self: len(self.product_template_attribute_value_ids)
== len(x.product_template_attribute_value_ids)
)
else:
return None
Loading
Loading