Skip to content

Commit d34419e

Browse files
[ADD] website_sale_insurance_caser
TT58928
1 parent ddf2a55 commit d34419e

20 files changed

Lines changed: 1231 additions & 0 deletions
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
============================
2+
Website Sale Insurance Caser
3+
============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:PLACEHOLDER
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--spain-lightgray.png?logo=github
20+
:target: https://github.com/OCA/l10n-spain/tree/18.0/website_sale_insurance_caser
21+
:alt: OCA/l10n-spain
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/l10n-spain-18-0/l10n-spain-18-0-website_sale_insurance_caser
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-spain&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Integrates Caser insurance into Odoo eCommerce, allowing customers to
32+
purchase insurance for their products directly from the online store.
33+
34+
This module extends **sale_insurance_caser** by adding:
35+
36+
- Checkbox on product page to add insurance
37+
- Interactive modal at checkout offering insurance for uncovered
38+
products
39+
- Visual badges identifying insurance lines in the cart
40+
- Automatic synchronization between cart and insurance lines
41+
42+
**Table of contents**
43+
44+
.. contents::
45+
:local:
46+
47+
Configuration
48+
=============
49+
50+
1. **Configure the base module** ``sale_insurance_caser``:
51+
52+
- Define price ranges (``caser.price.range``)
53+
- Configure insurance products
54+
- Set up Caser API credentials
55+
56+
2. **Enable insurance on eCommerce products**:
57+
58+
- Go to *Inventory > Products > Products*
59+
- Open a product you want to offer with insurance
60+
- In the **Sales** tab, check the **Caser Insurance in eCommerce**
61+
checkbox
62+
63+
Usage
64+
=====
65+
66+
**On the product page:**
67+
68+
1. Products with insurance enabled show a checkbox: *"Add Caser
69+
insurance protection (+5.50€)"*
70+
2. Insurance price is displayed dynamically based on product price
71+
3. When checkbox is marked and product added to cart, insurance line is
72+
created automatically
73+
74+
**In the shopping cart:**
75+
76+
4. Insurance lines appear as separate items with a blue *"Insurance"*
77+
badge
78+
5. Insurance quantity matches the insured product quantity
79+
80+
**At checkout (payment page):**
81+
82+
6. A modal *"Protect Your Products"* appears automatically if there are
83+
uninsured products
84+
7. The modal displays:
85+
86+
- Product image and name
87+
- Insurance price per unit and total
88+
- Toggle switches to select which products to insure
89+
90+
8. Upon confirmation, page reloads with new insurance lines added
91+
92+
Bug Tracker
93+
===========
94+
95+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-spain/issues>`_.
96+
In case of trouble, please check there if your issue has already been reported.
97+
If you spotted it first, help us to smash it by providing a detailed and welcomed
98+
`feedback <https://github.com/OCA/l10n-spain/issues/new?body=module:%20website_sale_insurance_caser%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
99+
100+
Do not contact contributors directly about support or help with technical issues.
101+
102+
Credits
103+
=======
104+
105+
Authors
106+
-------
107+
108+
* Tecnativa
109+
110+
Contributors
111+
------------
112+
113+
- `Tecnativa <https://www.tecnativa.com>`__:
114+
115+
- Juan Carlos Oñate
116+
117+
Maintainers
118+
-----------
119+
120+
This module is maintained by the OCA.
121+
122+
.. image:: https://odoo-community.org/logo.png
123+
:alt: Odoo Community Association
124+
:target: https://odoo-community.org
125+
126+
OCA, or the Odoo Community Association, is a nonprofit organization whose
127+
mission is to support the collaborative development of Odoo features and
128+
promote its widespread use.
129+
130+
.. |maintainer-juancarlosonate-tecnativa| image:: https://github.com/juancarlosonate-tecnativa.png?size=40px
131+
:target: https://github.com/juancarlosonate-tecnativa
132+
:alt: juancarlosonate-tecnativa
133+
134+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
135+
136+
|maintainer-juancarlosonate-tecnativa|
137+
138+
This module is part of the `OCA/l10n-spain <https://github.com/OCA/l10n-spain/tree/18.0/website_sale_insurance_caser>`_ project on GitHub.
139+
140+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import controllers
2+
from . import models
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 Juan Carlos Oñate - Tecnativa <juancarlos.onate@tecnativa.com>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
{
4+
"name": "Website Sale Insurance Caser",
5+
"summary": "Add Caser insurance to eCommerce products",
6+
"version": "18.0.1.0.0",
7+
"category": "Website/Website",
8+
"author": "Tecnativa, Odoo Community Association (OCA)",
9+
"maintainers": ["juancarlosonate-tecnativa"],
10+
"website": "https://github.com/OCA/l10n-spain",
11+
"license": "AGPL-3",
12+
"installable": True,
13+
"depends": [
14+
"sale_insurance_caser",
15+
"website_sale",
16+
],
17+
"data": [
18+
"views/product_template_views.xml",
19+
"views/templates.xml",
20+
],
21+
"assets": {
22+
"web.assets_frontend": [
23+
"website_sale_insurance_caser/static/src/js/website_sale_insurance_caser.esm.js",
24+
"website_sale_insurance_caser/static/src/js/checkout_insurance.esm.js",
25+
],
26+
},
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright 2025 Juan Carlos Oñate - Tecnativa <juancarlos.onate@tecnativa.com>
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3+
4+
from odoo import http
5+
from odoo.http import request
6+
7+
8+
class WebsaleCaserInsuranceController(http.Controller):
9+
@http.route(
10+
"/shop/caser_insurance/get_uninsured_products",
11+
type="json",
12+
auth="public",
13+
website=True,
14+
)
15+
def get_uninsured_products(self):
16+
order = request.website.sale_get_order()
17+
if not order:
18+
return {"products": []}
19+
uninsured = []
20+
for line in order.order_line:
21+
if (
22+
line.product_id.product_tmpl_id.caser_insurance_ecommerce
23+
and not line.caser_insure_quantity
24+
and not line.is_caser_insurance
25+
):
26+
price_range = request.env["caser.price.range"].search(
27+
[
28+
("min_price", "<=", line.price_reduce_taxinc),
29+
("max_price", ">=", line.price_reduce_taxinc),
30+
],
31+
limit=1,
32+
)
33+
uninsured.append(
34+
{
35+
"line_id": line.id,
36+
"product_name": line.product_id.display_name,
37+
"quantity": int(line.product_uom_qty),
38+
"price": line.price_reduce_taxinc,
39+
"insurance_price": price_range.product_id.list_price
40+
if price_range
41+
else 0,
42+
"image_url": (
43+
f"/web/image/product.product/"
44+
f"{line.product_id.id}/image_128"
45+
),
46+
}
47+
)
48+
return {"products": uninsured}
49+
50+
@http.route(
51+
"/shop/caser_insurance/update_insurance",
52+
type="json",
53+
auth="public",
54+
website=True,
55+
)
56+
def update_insurance(self, line_insurances):
57+
order = request.website.sale_get_order()
58+
if not order:
59+
return {"success": False}
60+
for line_id, insure_qty in line_insurances.items():
61+
int_line_id = int(line_id)
62+
line = order.order_line.filtered(lambda rec, lid=int_line_id: rec.id == lid)
63+
if line:
64+
line.caser_insure_quantity = int(insure_qty)
65+
return {"success": True}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * website_sale_insurance_caser
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 18.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-12-11 12:10+0000\n"
10+
"PO-Revision-Date: 2025-12-11 12:10+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: website_sale_insurance_caser
19+
#: model_terms:ir.ui.view,arch_db:website_sale_insurance_caser.product_caser_insurance_checkbox
20+
msgid "<i class=\"fa fa-shield text-primary\"/> Add Caser insurance protection"
21+
msgstr "<i class=\"fa fa-shield text-primary\"/> Añadir protección del seguro Caser"
22+
23+
#. module: website_sale_insurance_caser
24+
#: model_terms:ir.ui.view,arch_db:website_sale_insurance_caser.caser_insurance_checkout_modal
25+
msgid "<i class=\"fa fa-shield\"/> Add Selected Insurance"
26+
msgstr "<i class=\"fa fa-shield\"/> Añadir seguro seleccionado"
27+
28+
#. module: website_sale_insurance_caser
29+
#: model_terms:ir.ui.view,arch_db:website_sale_insurance_caser.caser_insurance_checkout_modal
30+
msgid "<i class=\"fa fa-shield\"/> Protect Your Products"
31+
msgstr "<i class=\"fa fa-shield\"/> Protege tus productos"
32+
33+
#. module: website_sale_insurance_caser
34+
#: model_terms:ir.ui.view,arch_db:website_sale_insurance_caser.cart_lines_caser_insurance
35+
#: model_terms:ir.ui.view,arch_db:website_sale_insurance_caser.checkout_caser_insurance
36+
msgid ""
37+
"<span class=\"badge bg-info ms-2\">\n"
38+
" <i class=\"fa fa-shield\"/> Insurance\n"
39+
" </span>"
40+
msgstr ""
41+
"<span class=\"badge bg-info ms-2\">\n"
42+
" <i class=\"fa fa-shield\"/> Seguro\n"
43+
" </span>"
44+
45+
#. module: website_sale_insurance_caser
46+
#: model:ir.model.fields,field_description:website_sale_insurance_caser.field_product_product__caser_insurance_ecommerce
47+
#: model:ir.model.fields,field_description:website_sale_insurance_caser.field_product_template__caser_insurance_ecommerce
48+
msgid "Caser Insurance in eCommerce"
49+
msgstr "Seguro Caser en comercio electrónico"
50+
51+
#. module: website_sale_insurance_caser
52+
#: model:ir.model.fields,help:website_sale_insurance_caser.field_product_product__caser_insurance_ecommerce
53+
#: model:ir.model.fields,help:website_sale_insurance_caser.field_product_template__caser_insurance_ecommerce
54+
msgid ""
55+
"If enabled, Caser insurance will be automatically added to cart when this "
56+
"product is purchased through the website."
57+
msgstr ""
58+
"Si está habilitado, el seguro Caser se añadirá automáticamente al carrito "
59+
"cuando este producto se compre a través de la web."
60+
61+
#. module: website_sale_insurance_caser
62+
#: model:ir.model.fields,field_description:website_sale_insurance_caser.field_product_product__caser_insurance_price_display
63+
#: model:ir.model.fields,field_description:website_sale_insurance_caser.field_product_template__caser_insurance_price_display
64+
msgid "Insurance Price Display"
65+
msgstr "Visualización del precio del seguro"
66+
67+
#. module: website_sale_insurance_caser
68+
#: model_terms:ir.ui.view,arch_db:website_sale_insurance_caser.caser_insurance_checkout_modal
69+
msgid "No, thanks"
70+
msgstr "No, gracias"
71+
72+
#. module: website_sale_insurance_caser
73+
#: model:ir.model,name:website_sale_insurance_caser.model_product_template
74+
msgid "Product"
75+
msgstr "Producto"
76+
77+
#. module: website_sale_insurance_caser
78+
#: model:ir.model,name:website_sale_insurance_caser.model_sale_order
79+
msgid "Sales Order"
80+
msgstr "Pedido de venta"
81+
82+
#. module: website_sale_insurance_caser
83+
#: model_terms:ir.ui.view,arch_db:website_sale_insurance_caser.caser_insurance_checkout_modal
84+
msgid ""
85+
"The following products can be protected with Caser insurance. Would you like"
86+
" to add coverage?"
87+
msgstr ""
88+
"Los siguientes productos se pueden proteger con el seguro Caser. ¿Desea "
89+
"añadir cobertura?"

0 commit comments

Comments
 (0)