Skip to content

Commit

Permalink
[MIG] rental_base : Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adasatorres committed Sep 28, 2024
1 parent d880da6 commit 9a6827f
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 250 deletions.
85 changes: 75 additions & 10 deletions rental_base/README.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
===========
Rental Base
====================================================
===========

*This file has been generated on 2022-05-04-12-21-41. Changes to it will be overwritten.*
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3aa33913fc209f65f5d921f23e1f593e9e994d0753b589e5de2d93d567558aac
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Summary
-------
.. |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_base
: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_base
: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

Manage Rental of Products

Description
-----------
|badge1| |badge2| |badge3| |badge4| |badge5|

Base Module for Rental Management

This module provides a new menu for rental management.
It is based on the sale_rental module that currently can be found in sale-workflow repository.

**Table of contents**

.. contents::
:local:

Usage
-----
=====

Create a rentable product and its rental service.
* Go to Rentals > Configuration > Settings.
Expand All @@ -41,10 +62,54 @@ Create a rental order:
Please also see the usage section of sale_rental module.

Changelog
---------
=========

- 8d191ff7 2022-04-10 15:41:16 +0200 [email protected] add missing/lost documentation (issue #4516)
- 39ff8efc 2022-03-14 15:15:31 +0100 [email protected] [IMP] rental_tour correction, (issue#4516)
- ac980b89 2022-02-28 17:36:28 +0100 [email protected] [FIX][IMP] correct code, (issue#4516)
- 4509f78a 2022-02-23 20:48:33 +0100 [email protected] (origin/feature_4516_add_files_ported_from_v12_v14, feature_4516_add_files_ported_from_v12_v14) add files ported to v14 by cpatel and khanhbui (issue #4516)

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_base%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
~~~~~~~

* elego Software Solutions GmbH

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

* elego Software Solutions GmbH

* `Binhex <http://www.binhex.cloud>`_:

* Adasat Torres de León <[email protected]>
* Zuzanna Elzbieta Szalaty Szalaty <[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/vertical-rental <https://github.com/OCA/vertical-rental/tree/16.0/rental_base>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
7 changes: 4 additions & 3 deletions rental_base/README/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* elego Software Solutions GmbH

Contributors
------------
* `Binhex <http://www.binhex.cloud>`_:

elego Software Solutions GmbH, Odoo Community Association (OCA)
* Adasat Torres de León <[email protected]>
* Zuzanna Elzbieta Szalaty Szalaty <[email protected]>
13 changes: 0 additions & 13 deletions rental_base/README/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
Rental Base
====================================================

*This file has been generated on 2022-05-04-12-21-41. Changes to it will be overwritten.*

Summary
-------

Manage Rental of Products

Description
-----------

Base Module for Rental Management

This module provides a new menu for rental management.
Expand Down
4 changes: 0 additions & 4 deletions rental_base/README/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

Changelog
---------

- 8d191ff7 2022-04-10 15:41:16 +0200 [email protected] add missing/lost documentation (issue #4516)
- 39ff8efc 2022-03-14 15:15:31 +0100 [email protected] [IMP] rental_tour correction, (issue#4516)
- ac980b89 2022-02-28 17:36:28 +0100 [email protected] [FIX][IMP] correct code, (issue#4516)
Expand Down
4 changes: 0 additions & 4 deletions rental_base/README/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

Usage
-----

Create a rentable product and its rental service.
* Go to Rentals > Configuration > Settings.
* Please activate the checkbox for using 'Product Variants'.
Expand Down
1 change: 0 additions & 1 deletion rental_base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Part of rental-vertical See LICENSE file for full copyright and licensing details.
from . import models
from . import tests
from . import wizard
2 changes: 1 addition & 1 deletion rental_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "Rental Base",
"version": "14.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Rental",
"summary": "Manage Rental of Products",
"author": "elego Software Solutions GmbH, Odoo Community Association (OCA)",
Expand Down
6 changes: 6 additions & 0 deletions rental_base/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ class ProductTemplate(models.Model):
_inherit = "product.template"

rental = fields.Boolean("Can be Rent")


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

rental = fields.Boolean("Can be Rent")
75 changes: 40 additions & 35 deletions rental_base/models/sale.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Part of rental-vertical See LICENSE file for full copyright and licensing details.

import datetime

from odoo import _, api, exceptions, fields, models
Expand All @@ -11,14 +10,12 @@ class SaleOrder(models.Model):
_inherit = "sale.order"

default_start_date = fields.Date(
string="Default Start Date",
compute="_compute_default_start_date",
readonly=False,
store=True,
)

default_end_date = fields.Date(
string="Default End Date",
compute="_compute_default_end_date",
readonly=False,
store=True,
Expand Down Expand Up @@ -106,49 +103,54 @@ def _check_sale_line_rental(self):
if not line.extension_rental_id:
raise ValidationError(
_(
'Missing "Rental to Extend" on the sale order line '
"with rental service %s."
'Missing "Rental to Extend" on the sale order line'
" with rental service %(name)s."
)
% line.product_id.name
% {"name": line.product_id.name}
)

if line.rental_qty != line.extension_rental_id.rental_qty:
raise ValidationError(
_(
"On the sale order line with rental service %s, "
"you are trying to extend a rental with a rental "
"quantity (%s) that is different from the quantity "
"of the original rental (%s). This is not supported."
)
% (
line.product_id.name,
line.rental_qty,
line.extension_rental_id.rental_qty,
"On the sale order line with"
" rental service %(name)s"
" ,you are trying to extend a "
"rental with a rental "
"quantity (%(rental_qty)s) "
"that is different from the quantity "
"of the original rental "
"(%(ext_rental_qty)s). "
"This is not supported."
)
% {
"name": line.product_id.name,
"rental_qty": line.rental_qty,
"ext_rental_qty": line.extension_rental_id.rental_qty,
}
)
if line.rental_type in ("new_rental", "rental_extension"):
if not line.product_id.rented_product_id:
raise ValidationError(
_(
'On the "new rental" sale order line with product '
'"%s", we should have a rental service product!'
'"%(name)s", we should have a rental service product!'
)
% (line.product_id.name)
% {"name": line.product_id.name}
)
elif line.sell_rental_id:
if line.product_uom_qty != line.sell_rental_id.rental_qty:
raise ValidationError(
_(
"On the sale order line with product %s "
"On the sale order line with product %(name)s "
"you are trying to sell a rented product with a "
"quantity (%s) that is different from the rented "
"quantity (%s). This is not supported."
)
% (
line.product_id.name,
line.product_uom_qty,
line.sell_rental_id.rental_qty,
"quantity (%(qty)s) that is different from the rented "
"quantity (%(sell_rental_qty)s). This is not supported."
)
% {
"name": line.product_id.name,
"qty": line.product_uom_qty,
"sell_rental_qty": line.sell_rental_id.rental_qty,
}
)

def _prepare_invoice_line(self, **optional_values):
Expand Down Expand Up @@ -218,10 +220,10 @@ def update_start_end_date(self, date_start, date_end):
]:
raise exceptions.UserError(
_(
"Outgoing shipment is in state %s. You cannot change \
the start date anymore."
"Outgoing shipment is in state %(state)s."
" You cannot change the start date anymore."
)
% rental.out_move_id.state
% {"state": rental.out_move_id.state}
)
rental.out_move_id.date = datetime_start
if rentals and date_end:
Expand All @@ -235,10 +237,10 @@ def update_start_end_date(self, date_start, date_end):
]:
raise exceptions.UserError(
_(
"Incoming shipment is in state %s. You cannot change \
the end date anymore."
"Incoming shipment is in state %s."
" You cannot change the end date anymore."
)
% rental.in_move_id.state
% {"state": rental.in_move_id.state}
)
rental.in_move_id.date = datetime_end

Expand Down Expand Up @@ -293,14 +295,17 @@ def write(self, values):
if messages:
messages.append(
_(
"\nOrder: %s\n"
"Line with product: '%s'\n\n"
"\nOrder: %(order)s\n"
"Line with product: '%(product)s'\n\n"
"Please use instead the button 'Update Times' "
"in the order to correctly update the order "
"line's times, its timeline entry, contract and "
"its stock moves and pickings as required."
)
% (sol.order_id.name, sol.product_id.display_name)
% {
"order": sol.order_id.name,
"product": sol.product_id.display_name,
}
)
raise exceptions.UserError("\n".join(messages))
return super(SaleOrderLine, self).write(values)
return super().write(values)
Loading

0 comments on commit 9a6827f

Please sign in to comment.