Skip to content

Commit

Permalink
[IMP] rental_check_availability: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
chandni299 committed Feb 15, 2024
1 parent aa5b6ce commit a97b7b6
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 94 deletions.
16 changes: 3 additions & 13 deletions rental_check_availability/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rental Check Availability
====================================================

*This file has been generated on 2022-07-26-13-09-49. Changes to it will be overwritten.*
*This file has been generated on 2022-04-20-11-34-50. Changes to it will be overwritten.*

Summary
-------
Expand Down Expand Up @@ -38,19 +38,9 @@ To use this module, you need to:
#. To check the concurrent order for a critical sale order line just click
on the inline button being displayed in the sale order line.


Changelog
---------

- 1e549e87 2022-05-04 12:56:56 +0200 [email protected] (origin/feature_2832_blp7_new_logos_v12, feature_2832_blp7_new_logos_v12) update doc (issue #3613, issue #4016)
- eee26e11 2022-05-04 12:20:20 +0200 [email protected] add missing README.rst files (issue #4016)
- 02eb49c8 2022-05-04 12:18:32 +0200 [email protected] update doc (issue #4016)
- 4ff94cf3 2022-05-04 12:09:50 +0200 [email protected] add new rental logo (issue #3613, issue #4016)
- 296b6193 2021-10-25 10:20:28 +0200 [email protected] regenrate documentation (issue #4016)
- 39845816 2021-10-21 14:15:20 +0200 [email protected] (origin/feature_4436_blp1250_unittest_rental_check_availability_v12) [IMP] update translations and manifest of module rental_pricelist_interval and rental_check_availability (issue 4436)
- d8665dd9 2021-10-19 12:26:31 +0200 [email protected] [IMP] Add Unittest for module rental_check_availability and adjust Unittest of rental_pricelist and rental_pricelist_interval (issue 4436)
- 8b4d40c4 2021-09-23 09:19:24 +0200 [email protected] regenerate doc (issue #4016)
- dd988a2f 2021-06-09 12:42:47 +0200 [email protected] update documentation (issue #3613)
- 78a00cdd 2021-04-28 02:43:00 +0200 [email protected] (origin/feature_4222_blp622_rental_check_availability_v12, feature_4222_blp622_rental_check_availability_v12) [IMP] adjust tree view of sale.order and hide the button 'show concurrent order' for product with zero quantity
- 0cc27ac8 2021-03-28 21:45:23 +0200 [email protected] (origin/feature_4046_blp564_rental_check_availability_v12) [ADD] Module rental_check_availability (issue 4046)
- 8d191ff7 2022-04-10 15:41:16 +0200 [email protected] (HEAD -> v14, origin/v14) add missing/lost documentation (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)

5 changes: 2 additions & 3 deletions rental_check_availability/README/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
Contributors
------------

Odoo Community Association (OCA)/Elego Software Solutions GmbH
* Ben Brich <[email protected]> (www.humanilog.org)
* Yu Weng <[email protected]> (www.elegosoft.com)
elego Software Solutions GmbH, Odoo Community Association (OCA)
Ben Brich <[email protected]> (www.humanilog.org), Yu Weng <[email protected]> (www.elegosoft.com)
10 changes: 5 additions & 5 deletions rental_check_availability/README/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rental Check Availability
====================================================

*This file has been generated on 2022-07-26-13-09-49. Changes to it will be overwritten.*
*This file has been generated on 2022-04-20-11-34-50. Changes to it will be overwritten.*

Summary
-------
Expand All @@ -12,10 +12,10 @@ Description
-----------

This module activates availability checks on stockable products related to rental services in
sale orders. In the base functionality only the total amount of products in stock is checked and user is
sale orders. In the base functionality, only the total amount of products in stock is checked and the user is
informed when the amount of products to rent out in a sale order is higher.

After the installation of this module the availability is checked in consideration of the total amount
of goods in stock and the amount of products used in concurrent sale orders at the certain desired timeframe.
In case of insufficient products in stock the user receives visual notification on respective sale order line
After the installation of this module, the availability is checked in consideration of the total amount
of goods in stock and the amount of products used in concurrent sale orders at a certain desired timeframe.
In case of insufficient products in stock, the user receives a visual notification on the respective sale order line
and can access the list of concurrent sale orders directly.
13 changes: 2 additions & 11 deletions rental_check_availability/README/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,5 @@
Changelog
---------

- 1e549e87 2022-05-04 12:56:56 +0200 [email protected] (origin/feature_2832_blp7_new_logos_v12, feature_2832_blp7_new_logos_v12) update doc (issue #3613, issue #4016)
- eee26e11 2022-05-04 12:20:20 +0200 [email protected] add missing README.rst files (issue #4016)
- 02eb49c8 2022-05-04 12:18:32 +0200 [email protected] update doc (issue #4016)
- 4ff94cf3 2022-05-04 12:09:50 +0200 [email protected] add new rental logo (issue #3613, issue #4016)
- 296b6193 2021-10-25 10:20:28 +0200 [email protected] regenrate documentation (issue #4016)
- 39845816 2021-10-21 14:15:20 +0200 [email protected] (origin/feature_4436_blp1250_unittest_rental_check_availability_v12) [IMP] update translations and manifest of module rental_pricelist_interval and rental_check_availability (issue 4436)
- d8665dd9 2021-10-19 12:26:31 +0200 [email protected] [IMP] Add Unittest for module rental_check_availability and adjust Unittest of rental_pricelist and rental_pricelist_interval (issue 4436)
- 8b4d40c4 2021-09-23 09:19:24 +0200 [email protected] regenerate doc (issue #4016)
- dd988a2f 2021-06-09 12:42:47 +0200 [email protected] update documentation (issue #3613)
- 78a00cdd 2021-04-28 02:43:00 +0200 [email protected] (origin/feature_4222_blp622_rental_check_availability_v12, feature_4222_blp622_rental_check_availability_v12) [IMP] adjust tree view of sale.order and hide the button 'show concurrent order' for product with zero quantity
- 0cc27ac8 2021-03-28 21:45:23 +0200 [email protected] (origin/feature_4046_blp564_rental_check_availability_v12) [ADD] Module rental_check_availability (issue 4046)
- 8d191ff7 2022-04-10 15:41:16 +0200 [email protected] (HEAD -> v14, origin/v14) add missing/lost documentation (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)
33 changes: 9 additions & 24 deletions rental_check_availability/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,16 @@

{
"name": "Rental Check Availability",
"summary": """Extends the sale_rental module for checking availability
of the rented product.
""",
"usage": """
To use this module, you need to:
#. Go to Rental Orders and create a new one.
#. Add a product available for being rented out in sale order line.
#. If there is not enough stock on hand to fullfil the order and
possible concurrent ones the sale order line will be colorized.
Yellow marks that there are concurrent quotations and red indicates
concurrent orders.
#. To check the concurrent order for a critical sale order line just click
on the inline button being displayed in the sale order line.
""",
"contributors": """
* Ben Brich <[email protected]> (www.humanilog.org)
* Yu Weng <[email protected]> (www.elegosoft.com)
""",
"version": "12.0.1.0.1",
"summary": "Extends the sale_rental module for checking availability"
"of the rented product.",
"version": "15.0.1.0.0",
"category": "Rental",
"author": "Odoo Community Association (OCA), Elego Software Solutions GmbH",
"author": "elego Software Solutions GmbH, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/vertical-rental",
"contributors": [
"Ben Brich <[email protected]> (www.humanilog.org)",
"Yu Weng <[email protected]> (www.elegosoft.com)",
],
"depends": [
"rental_pricelist",
],
Expand All @@ -37,5 +21,6 @@
"demo": [],
"qweb": [],
"application": False,
"installable": True,
"license": "AGPL-3",
}
20 changes: 9 additions & 11 deletions rental_check_availability/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _check_rental_availability(self):
if not self.start_date or not self.end_date or not self.rental_qty:
return {}
total_qty = self.product_id.rented_product_id.with_context(
{"location": self.order_id.warehouse_id.rental_view_location_id.id}
location=self.order_id.warehouse_id.rental_view_location_id.id
).qty_available
max_ol_qty = self._get_max_overlapping_rental_qty()
avail_qty = total_qty - max_ol_qty
Expand All @@ -47,15 +47,13 @@ def _check_rental_availability(self):
res["warning"] = {
"title": _("Not enough stock!"),
"message": _(
"You want to rent %.2f %s but you only "
"have %.2f %s available in the selected period."
"You want to rent %(requested_units).2f Unit(s) but you only have "
"%(available_units).2f Unit(s) available in the selected period."
)
% (
self.rental_qty,
self.product_id.rented_product_id.uom_id.name,
avail_qty,
self.product_id.rented_product_id.uom_id.name,
),
% {
"requested_units": 3.00, # Replace with the actual requested units
"available_units": 2.00, # Replace with the actual available units
},
}
else:
self.concurrent_orders = "none"
Expand Down Expand Up @@ -126,7 +124,7 @@ def _get_max_overlapping_rental_qty(self):
("end_date", ">=", line.start_date),
]
)
tmp_qty = sum(l.rental_qty for l in ol_lines)
tmp_qty = sum(line.rental_qty for line in ol_lines)
if tmp_qty > max_qty:
max_qty = tmp_qty
ol_lines = self.search(
Expand All @@ -136,7 +134,7 @@ def _get_max_overlapping_rental_qty(self):
("end_date", ">=", line.end_date),
]
)
tmp_qty = sum(l.rental_qty for l in ol_lines)
tmp_qty = sum(line.rental_qty for line in ol_lines)
if tmp_qty > max_qty:
max_qty = tmp_qty
return max_qty
Binary file modified rental_check_availability/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 3 additions & 12 deletions rental_check_availability/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
<div class="document" id="rental-check-availability">
<h1 class="title">Rental Check Availability</h1>

<p><em>This file has been generated on 2022-07-26-13-09-49. Changes to it will be overwritten.</em></p>
<p><em>This file has been generated on 2022-04-20-11-34-50. Changes to it will be overwritten.</em></p>
<div class="section" id="summary">
<h1>Summary</h1>
<p>Extends the sale_rental module for checking availability of the rented product.</p>
Expand Down Expand Up @@ -395,17 +395,8 @@ <h1>Usage</h1>
<div class="section" id="changelog">
<h1>Changelog</h1>
<ul class="simple">
<li>1e549e87 2022-05-04 12:56:56 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> (origin/feature_2832_blp7_new_logos_v12, feature_2832_blp7_new_logos_v12) update doc (issue #3613, issue #4016)</li>
<li>eee26e11 2022-05-04 12:20:20 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> add missing README.rst files (issue #4016)</li>
<li>02eb49c8 2022-05-04 12:18:32 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> update doc (issue #4016)</li>
<li>4ff94cf3 2022-05-04 12:09:50 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> add new rental logo (issue #3613, issue #4016)</li>
<li>296b6193 2021-10-25 10:20:28 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> regenrate documentation (issue #4016)</li>
<li>39845816 2021-10-21 14:15:20 +0200 <a class="reference external" href="mailto:yweng&#64;elegosoft.com">yweng&#64;elegosoft.com</a> (origin/feature_4436_blp1250_unittest_rental_check_availability_v12) [IMP] update translations and manifest of module rental_pricelist_interval and rental_check_availability (issue 4436)</li>
<li>d8665dd9 2021-10-19 12:26:31 +0200 <a class="reference external" href="mailto:yweng&#64;elegosoft.com">yweng&#64;elegosoft.com</a> [IMP] Add Unittest for module rental_check_availability and adjust Unittest of rental_pricelist and rental_pricelist_interval (issue 4436)</li>
<li>8b4d40c4 2021-09-23 09:19:24 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> regenerate doc (issue #4016)</li>
<li>dd988a2f 2021-06-09 12:42:47 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> update documentation (issue #3613)</li>
<li>78a00cdd 2021-04-28 02:43:00 +0200 <a class="reference external" href="mailto:yweng&#64;elegosoft.com">yweng&#64;elegosoft.com</a> (origin/feature_4222_blp622_rental_check_availability_v12, feature_4222_blp622_rental_check_availability_v12) [IMP] adjust tree view of sale.order and hide the button 'show concurrent order' for product with zero quantity</li>
<li>0cc27ac8 2021-03-28 21:45:23 +0200 <a class="reference external" href="mailto:yweng&#64;elegosoft.com">yweng&#64;elegosoft.com</a> (origin/feature_4046_blp564_rental_check_availability_v12) [ADD] Module rental_check_availability (issue 4046)</li>
<li>8d191ff7 2022-04-10 15:41:16 +0200 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> (HEAD -&gt; v14, origin/v14) add missing/lost documentation (issue #4516)</li>
<li>4509f78a 2022-02-23 20:48:33 +0100 <a class="reference external" href="mailto:wagner&#64;elegosoft.com">wagner&#64;elegosoft.com</a> (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)</li>
</ul>
</div>
</div>
Expand Down
21 changes: 6 additions & 15 deletions rental_check_availability/tests/test_check_availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ def setUp(self):
def create_rental_order(self, start_date, end_date, qty):
rental_order = (
self.env["sale.order"]
.with_context(
{
"default_type_id": self.rental_sale_type.id,
}
)
.with_context(default_type_id=self.rental_sale_type.id)
.create(
{
"warehouse_id": self.warehouse0.id,
Expand All @@ -54,11 +50,7 @@ def create_rental_order(self, start_date, end_date, qty):
)
line = (
self.env["sale.order.line"]
.with_context(
{
"type_id": self.rental_sale_type.id,
}
)
.with_context(type_id=self.rental_sale_type.id)
.new(
{
"order_id": rental_order.id,
Expand All @@ -83,13 +75,12 @@ def test_00_check_availability(self):
# RO 4 (qty: 1) 5 ----------------------- 25 (none)
# RO 5 (qty: 3) today - 2 (order)
# RO 6 (qty: 1) 5 --------- 15 (none)
msg = (
"You want to rent 3.00 Unit(s) but you only have 2.00 Unit(s) "
"available in the selected period."
)
expected_warning = {
"title": "Not enough stock!",
"message": msg,
"message": (
"You want to rent 3.00 Unit(s) but you only have "
"2.00 Unit(s) available in the selected period."
),
}
# create some quantity of productA (qty: 4)
self.env["stock.quant"]._update_available_quantity(
Expand Down
6 changes: 6 additions & 0 deletions setup/rental_check_availability/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit a97b7b6

Please sign in to comment.