odoo/tutorials#1274
Created by Aditi Pawar (adpaw)
Blocked
- Merge method
- Review
-
CI
- ci/style: (runtime 4s)
- ci/tutorial: (runtime 127s)
- label
- odoo-dev:19.0-rental-deposit-adpaw
- head
- 98619120af85b95ad0f860ad87dbe7785e3ac613
| odoo/tutorials | |
|---|---|
| 19.0 | #1274 missing r+ |
| master |
[ADD] rental_deposit: adding deposit to rental products.
Introduced a new custom module that adds deposit configuration on rental products and automatically manages deposit lines on sale orders and the webshop. This allows businesses to enforce a refundable deposit whenever a rental product is added, both from the backend and the frontend.
WHY this change is being made:
Currently, when a customer rents a product there is no built-in way to collect or track a deposit amount tied to that rental. Salespersons had to manually add deposit lines every time, which is error-prone and inconsistent. This module automates that process and ensures deposit lines are always present, correctly priced, and protected from accidental edits or deletions.
Technical decisions taken:
1. Added require_deposit (Boolean) and 'deposit_amount' on 'product.template' to allow per-product deposit configuration under the Rental Prices tab.
2. Extended 'res.company' with 'deposit_product_id' and exposed it via 'res.config.settings' using 'related=' to set a global deposit product that gets added as the order line product.
3. Overrode create on sale.order.line with @api.model_create_multi to auto-add a deposit line whenever a qualifying rental product is added.
4. Implemented write and @api.ondelete overrides to keep deposit line quantity in sync and remove it when the rental line is deleted.
5. Used context keys skip_deposit_write_check and skip_deposit_delete_check to allow internal updates while blocking direct user edits on deposit lines.
6. Inherited the webshop product template to display the deposit amount and added a JS widget (RentalDepositWidget) to update the displayed amount dynamically when the quantity selector is changed by the customer.