Skip to content

Commit 1e3097a

Browse files
author
kuay-odoo
committed
[ADD] add_product_warranty: add warranty availability flow for products
This commit introduces a complete feature for managing warranty products within the Sales application: - Added a Is Warranty Available boolean field on product templates to indicate warranty eligibility. - Moved warranty configuration under the 'Configuration' menu in the Sales app for better accessibility and UX alignment. - Introduced a wizard for adding warranty products to sale orders, dynamically computing prices and descriptions based on selected lines. - Implemented automatic deletion of warranty wizard lines when the product is removed from the wizard to maintain data integrity. This feature improves the workflow for managing extended warranties, providing a seamless integration in Sales for both users and system operations.
1 parent 630e34e commit 1e3097a

15 files changed

+248
-0
lines changed

add_product_warranty/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import wizard

add_product_warranty/__manifest__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Add Warranty Product",
3+
"description": """
4+
The Module helps to add warranty to our product
5+
""",
6+
"version": "1.0",
7+
"depends": ["product", "sale_management"],
8+
"data": [
9+
"security/ir.model.access.csv",
10+
"views/product_warranty.xml",
11+
"views/warranty_menus.xml",
12+
"views/product_template.xml",
13+
"views/sale_order_button.xml",
14+
"wizard/add_warranty_wizard.xml",
15+
],
16+
"auto-install": True,
17+
"application": False,
18+
"license": "LGPL-3",
19+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import product_warranty
2+
from . import product_template
3+
from . import sale_order_unlink
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from odoo import fields, models
2+
3+
4+
class productTemplate(models.Model):
5+
_inherit = "product.template"
6+
7+
is_warranty_available = fields.Boolean(string="Is Warranty Available")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from odoo import fields, models
2+
3+
4+
class productWarranty(models.Model):
5+
_name = "product.warranty"
6+
_description = "Product Warranty"
7+
8+
name = fields.Char(string="Name", required=True)
9+
percentage = fields.Float(string="Percentage", required=True)
10+
validity_year = fields.Integer(string="Validity Year")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from odoo import fields, models
2+
3+
4+
class salesOrderLine(models.Model):
5+
_inherit = "sale.order.line"
6+
7+
linked_sale_order_line_id = fields.Many2one(
8+
"sale.order.line", string="Linked Product Line"
9+
)
10+
11+
def unlink(self):
12+
for line in self:
13+
linked_warranty_lines = self.search(
14+
[("linked_sale_order_line_id", "=", line.id)]
15+
)
16+
17+
linked_warranty_lines.unlink()
18+
19+
return super(salesOrderLine, self).unlink()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
add_product_warranty.access_product_warranty,access_product_warranty,add_product_warranty.model_product_warranty,base.group_user,1,1,1,1
3+
add_product_warranty.access_warranty_wizard,access_warranty_wizard,add_product_warranty.model_warranty_wizard,base.group_user,1,1,1,1
4+
add_product_warranty.access_warranty_wizard_line,access_warranty_wizard_line,add_product_warranty.model_warranty_wizard_line,base.group_user,1,1,1,1
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="product_template_inherit_form" model="ir.ui.view">
4+
<field name="name">product.template.inherit.form</field>
5+
<field name="model">product.template</field>
6+
<field name="inherit_id" ref="product.product_template_form_view" />
7+
<field name="arch" type="xml">
8+
<xpath expr="//page[@name='sales']/group[@name='sale']" position="inside">
9+
<group string="Product Warranty" name="product_warranty">
10+
<field name="is_warranty_available" />
11+
</group>
12+
</xpath>
13+
</field>
14+
</record>
15+
</odoo>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="warranty_config_action" model="ir.actions.act_window">
4+
<field name="name">Warranty Configuration</field>
5+
<field name="res_model">product.warranty</field>
6+
<field name="view_mode">list,form</field>
7+
</record>
8+
9+
<record id="warranty_list_view" model="ir.ui.view">
10+
<field name="name">product.warranty.list </field>
11+
<field name="model">product.warranty</field>
12+
<field name="arch" type="xml">
13+
<list create="1">
14+
<field name="name" />
15+
<field name="percentage" />
16+
<field name="validity_year" />
17+
</list>
18+
</field>
19+
</record>
20+
</odoo>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="sale_order_button_wizard" model="ir.ui.view">
4+
<field name="name">sale.order.button.wizard</field>
5+
<field name="model">sale.order</field>
6+
<field name="inherit_id" ref="sale.view_order_form" />
7+
<field name="arch" type="xml">
8+
<xpath expr="//div[@name='so_button_below_order_lines']" position="inside">
9+
<button string="Add Warranty" type="action"
10+
name="%(add_product_warranty.action_add_warranty)d" class="btn btn-primary" />
11+
</xpath>
12+
</field>
13+
</record>
14+
</odoo>

0 commit comments

Comments
 (0)