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

[14.0] Add Missing Changes from v12 #51

Open
wants to merge 5 commits into
base: 14.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
26 changes: 22 additions & 4 deletions rental_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@
"version": "14.0.1.0.1",
"category": "Rental",
"summary": "Manage Rental of Products",
"usage": """
Create a rentable product and its rental service.
* Go to Rentals > Configuration > Settings.
* Please activate the checkbox for using 'Product Variants'.
* Go to Rentals > Products > Products.
* Create a new storable product.
* Activate the checkbox 'Can be Rented'.
* Go to page 'Sales & Purchase'.
* Create the rental service and configure its name and price.

Create a rental order:
* Go to Rentals > Customer > Rental Quotations.
* Create a new order and choose the type 'Rental Order'.
* Add the rental service as an order line.
* Set the quantity to rent out one or several storable rentable products.
* Choose start and end date.
* Confirm the order.
* Check out the two deliveries, one for outgoing and one for incoming delivery.

Please also see the usage section of sale_rental module.
""",
"author": "elego Software Solutions GmbH, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/vertical-rental",
"depends": [
"account",
"product_analytic",
"sale",
"sale_order_type",
"sale_rental",
"sale_start_end_dates",
"sale_stock",
"sales_team",
],
"data": [
"security/ir.model.access.csv",
"security/rental_security.xml",
"data/ir_sequence_data.xml",
"data/order_type_data.xml",
"data/product_uom_data.xml",
Expand Down
6 changes: 6 additions & 0 deletions rental_base/data/product_uom_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
<field ref="uom.uom_categ_wtime" name="category_id" />
<field name="factor" eval="0.033" />
</record>
<record id="product_uom_week" model="uom.uom">
<field name="name">Week(s)</field>
<field name="uom_type">bigger</field>
<field ref="uom.uom_categ_wtime" name="category_id" />
<field name="factor" eval="0.143" />
</record>
</odoo>
26 changes: 26 additions & 0 deletions rental_base/models/sale.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Part of rental-vertical See LICENSE file for full copyright and licensing details.

import datetime
from math import ceil

from odoo import _, api, exceptions, fields, models
from odoo.exceptions import ValidationError
Expand Down Expand Up @@ -174,6 +175,27 @@ def _check_sale_line_rental(self):
)
)

# use this field to show the widget radio for field rental
order_type = fields.Selection(
string="Order Type",
selection=[("normal", "Normal"), ("rental", "Rental")],
compute="_compute_order_type",
inverse="_inverse_order_type",
)

@api.depends("rental")
def _compute_order_type(self):
for rec in self:
rec.order_type = "rental" if rec.rental else "normal"

def _inverse_order_type(self):
for rec in self:
rec.rental = rec.order_type == "rental"

@api.onchange("order_type")
def _onchange_order_type(self):
self.rental = self.order_type == "rental"

def _prepare_invoice_line(self, **optional_values):
self.ensure_one()
res = super()._prepare_invoice_line(**optional_values)
Expand All @@ -184,10 +206,12 @@ def _prepare_invoice_line(self, **optional_values):
@api.model
def _get_time_uom(self):
uom_month = self.env.ref("rental_base.product_uom_month")
uom_week = self.env.ref("rental_base.product_uom_week")
uom_day = self.env.ref("uom.product_uom_day")
uom_hour = self.env.ref("uom.product_uom_hour")
return {
"month": uom_month,
"week": uom_week,
"day": uom_day,
"hour": uom_hour,
}
Expand All @@ -205,6 +229,8 @@ def _get_number_of_time_unit(self):
# https://www.checkyourmath.com/convert/time/days_months.php
number = ((self.end_date - self.start_date).days + 1) / 30.4167
number = float_round(number, precision_rounding=1)
elif self.product_uom.id == time_uoms["week"].id:
number = ceil(((self.end_date - self.start_date).days + 1) / 7)
return number

def update_start_end_date(self, date_start, date_end):
Expand Down
10 changes: 10 additions & 0 deletions rental_base/security/rental_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<odoo>
<record id="group_rental_menu" model="res.groups">
<field name="name">See Rental Menu</field>
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>
</odoo>
1 change: 1 addition & 0 deletions rental_base/tests/stock_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def setUp(self):
self.uom_hour = self.env.ref("uom.product_uom_hour")
self.uom_day = self.env.ref("uom.product_uom_day")
self.uom_month = self.env.ref("rental_base.product_uom_month")
self.uom_week = self.env.ref("rental_base.product_uom_week")
self.uom_unit = self.env.ref("uom.product_uom_unit")
self.uom_kgm = self.env.ref("uom.product_uom_kgm")
self.warehouse0 = self.env.ref("stock.warehouse0")
Expand Down
26 changes: 25 additions & 1 deletion rental_base/views/menu_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,84 +74,97 @@
name="Rentals"
id="menu_rental_root"
sequence="5"
groups="group_rental_menu"
web_icon="rental_base,static/description/icon.png"
/>

<menuitem
name="Customers"
id="menu_top_customer"
groups="base.group_user"
parent="menu_rental_root"
sequence="10"
/>
<menuitem
name="Customers"
id="menu_customers"
groups="base.group_user"
parent="menu_top_customer"
action="account.res_partner_action_customer"
sequence="0"
/>
<menuitem
name="Quotations"
id="menu_customer_quotations"
groups="sales_team.group_sale_salesman"
parent="menu_top_customer"
sequence="5"
/>
<menuitem
name="Rental Quotations"
id="menu_rental_quotations"
groups="sales_team.group_sale_salesman"
parent="menu_customer_quotations"
action="action_rental_quotations"
sequence="5"
/>
<menuitem
name="Orders"
id="menu_customer_orders"
groups="sales_team.group_sale_salesman"
parent="menu_top_customer"
sequence="10"
/>
<menuitem
name="Rental Orders"
id="menu_rental_orders"
groups="sales_team.group_sale_salesman"
parent="menu_customer_orders"
action="action_rental_orders"
sequence="5"
/>
<menuitem
name="Delivery"
id="menu_customer_delivery"
groups="stock.group_stock_user"
parent="menu_top_customer"
sequence="15"
/>
<menuitem
name="Outgoing Deliveries"
id="menu_customer_delivery_outgoing"
groups="stock.group_stock_user"
parent="menu_customer_delivery"
action="stock_picking_action_picking_type_out"
sequence="5"
/>
<menuitem
name="Incoming Deliveries"
id="menu_customer_delivery_incoming"
groups="stock.group_stock_user"
parent="menu_customer_delivery"
action="stock_picking_action_picking_type_in"
sequence="10"
/>
<menuitem
name="Invoices"
id="menu_customer_invoices"
groups="account.group_account_user"
parent="menu_top_customer"
sequence="20"
/>
<menuitem
name="Customer Invoices"
id="menu_customer_invoices2"
groups="account.group_account_user"
parent="menu_customer_invoices"
action="account.action_move_out_invoice_type"
sequence="20"
/>
<menuitem
name="Customer Credit Notes"
id="menu_customer_credit_notes"
groups="account.group_account_user"
parent="menu_customer_invoices"
action="account.action_move_out_refund_type"
sequence="25"
Expand All @@ -161,52 +174,60 @@
<menuitem
name="Vendors"
id="menu_top_vendor"
groups="base.group_user"
parent="menu_rental_root"
sequence="15"
/>
<menuitem
name="Vendors"
id="menu_vendors"
groups="base.group_user"
parent="menu_top_vendor"
action="account.res_partner_action_supplier"
sequence="0"
/>
<menuitem
name="Delivery"
id="menu_vendor_delivery"
groups="stock.group_stock_user"
parent="menu_top_vendor"
sequence="15"
/>
<menuitem
name="Incoming Deliveries"
id="menu_vendor_delivery_incoming"
groups="stock.group_stock_user"
parent="menu_vendor_delivery"
action="stock_picking_action_picking_type_in"
sequence="5"
/>
<menuitem
name="Outgoing Deliveries"
id="menu_vendor_delivery_outgoing"
groups="stock.group_stock_user"
parent="menu_vendor_delivery"
action="stock_picking_action_picking_type_out"
sequence="10"
/>
<menuitem
name="Invoices"
id="menu_vendor_invoices"
groups="account.group_account_user"
parent="menu_top_vendor"
sequence="20"
/>
<menuitem
name="Vendor Bills"
id="menu_vendor_bills"
groups="account.group_account_user"
parent="menu_vendor_invoices"
action="account.action_move_in_invoice_type"
sequence="5"
/>
<menuitem
name="Vendor Credit Notes"
id="menu_vendor_credit_notes"
groups="account.group_account_user"
parent="menu_vendor_invoices"
action="account.action_move_in_refund_type"
sequence="10"
Expand All @@ -216,6 +237,7 @@
<menuitem
name="Products"
id="menu_master_data"
groups="base.group_user"
parent="menu_rental_root"
sequence="20"
/>
Expand All @@ -231,20 +253,22 @@
<menuitem
name="Configuration"
id="menu_config"
groups="sales_team.group_sale_manager"
parent="menu_rental_root"
sequence="30"
groups="sales_team.group_sale_manager"
/>
<menuitem
name="Settings"
id="menu_settings"
groups="sales_team.group_sale_manager"
parent="menu_config"
action="rental_base.action_rental_configuration"
sequence="0"
/>
<menuitem
name="Products"
id="menu_config_products"
groups="sales_team.group_sale_manager"
parent="menu_config"
sequence="20"
/>
Expand Down
5 changes: 5 additions & 0 deletions rental_base/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<label for="rental" />
</div>
</xpath>
<xpath expr="//page[@name='sales']" position="attributes">
<attribute
name="attrs"
>{'invisible': [('sale_ok','=',False), ('rental','=',False)]}</attribute>
</xpath>
</field>
</record>

Expand Down
7 changes: 6 additions & 1 deletion rental_base/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,12 @@
<xpath expr="//group[@id='further_rental_info']" position="inside">
<!-- Group: Rental Settings -->
<group id="rental_settings" string="Rental Settings" colspan="4">
<field name="rental" />
<field name="rental" invisible="1" />
<field
name="order_type"
widget="radio"
options="{'horizontal': True}"
/>
<field
name="rental_type"
attrs="{'invisible': [('rental', '=', False)],
Expand Down
32 changes: 31 additions & 1 deletion rental_offday/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,39 @@

{
"name": "Rental Off-Day",
"summary": "Manage off-days in rentals on daily basis",
"version": "14.0.1.0.0",
"category": "Rental",
"summary": "Manage off-days in rentals on daily basis",
"usage": """
The off-days can only be used for products rentable in days.

Create a rentable product and its rental service for daily rentals:
* Go to Rentals > Configuration > Settings.
* Please activate the checkbox for using 'Product Variants'.
* Go to Rentals > Products > Products.
* Create a new storable product.
* Active the checkbox 'Can be Rented'.
* Go to page 'Rental Price'.
* Activate the boolean fields for daily rental.
* Add a usual price for one day.
* Save the product, which creates the related rental service.
* Add bulk prices as desired, e.g. one day costs 300 €, 7 days 290 €, 21 days 250 €, and so on.
* Adjust its stock in location 'Rental In'.

Create a rental order:
* Go to Rentals > Customer > Rental Quotations.
* Create a new order and choose the type 'Rental Order'.
* Add the rental service as an order line.
* Set the quantity to rent out one or several storable rentable products.
* Choose start and end date, e.g. for 3 weeks.
* On the order line you will see a page 'Off-Days' at the bottom.
* Choose the type 'Weekend' in order to create 'Fixed Off-Days'
and you get a list with all saturdays and sundays within the rental period.
* Add some additional off-days as needed.
* The number of off-days reduces the rental quantity
and is therefore not included in price calculation.
* Confirm the order.
""",
"author": "elego Software Solutions GmbH, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/vertical-rental",
"depends": [
Expand Down
Loading
Loading