diff --git a/add_product_warranty/__init__.py b/add_product_warranty/__init__.py new file mode 100644 index 00000000000..9b4296142f4 --- /dev/null +++ b/add_product_warranty/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/add_product_warranty/__manifest__.py b/add_product_warranty/__manifest__.py new file mode 100644 index 00000000000..7027e537bb5 --- /dev/null +++ b/add_product_warranty/__manifest__.py @@ -0,0 +1,19 @@ +{ + "name": "Add Warranty Product", + "description": """ + The Module helps to add warranty to our product + """, + "version": "1.0", + "depends": ["product", "sale_management"], + "data": [ + "security/ir.model.access.csv", + "views/product_warranty.xml", + "views/warranty_menus.xml", + "views/product_template.xml", + "views/sale_order_button.xml", + "wizard/add_warranty_wizard.xml", + ], + "auto-install": True, + "application": False, + "license": "LGPL-3", +} diff --git a/add_product_warranty/models/__init__.py b/add_product_warranty/models/__init__.py new file mode 100644 index 00000000000..26348eaacdf --- /dev/null +++ b/add_product_warranty/models/__init__.py @@ -0,0 +1,3 @@ +from . import product_warranty +from . import product_template +from . import sale_order_unlink diff --git a/add_product_warranty/models/product_template.py b/add_product_warranty/models/product_template.py new file mode 100644 index 00000000000..b47f510d0f1 --- /dev/null +++ b/add_product_warranty/models/product_template.py @@ -0,0 +1,7 @@ +from odoo import fields, models + + +class productTemplate(models.Model): + _inherit = "product.template" + + is_warranty_available = fields.Boolean(string="Is Warranty Available") diff --git a/add_product_warranty/models/product_warranty.py b/add_product_warranty/models/product_warranty.py new file mode 100644 index 00000000000..5b5da5b3d77 --- /dev/null +++ b/add_product_warranty/models/product_warranty.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class productWarranty(models.Model): + _name = "product.warranty" + _description = "Product Warranty" + + name = fields.Char(string="Name", required=True) + percentage = fields.Float(string="Percentage", required=True) + validity_year = fields.Integer(string="Validity Year") diff --git a/add_product_warranty/models/sale_order_unlink.py b/add_product_warranty/models/sale_order_unlink.py new file mode 100644 index 00000000000..170550981c4 --- /dev/null +++ b/add_product_warranty/models/sale_order_unlink.py @@ -0,0 +1,19 @@ +from odoo import fields, models + + +class salesOrderLine(models.Model): + _inherit = "sale.order.line" + + linked_sale_order_line_id = fields.Many2one( + "sale.order.line", string="Linked Product Line" + ) + + def unlink(self): + for line in self: + linked_warranty_lines = self.search( + [("linked_sale_order_line_id", "=", line.id)] + ) + + linked_warranty_lines.unlink() + + return super().unlink() diff --git a/add_product_warranty/security/ir.model.access.csv b/add_product_warranty/security/ir.model.access.csv new file mode 100644 index 00000000000..4073da91b52 --- /dev/null +++ b/add_product_warranty/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +add_product_warranty.access_product_warranty,access_product_warranty,add_product_warranty.model_product_warranty,base.group_user,1,1,1,1 +add_product_warranty.access_warranty_wizard,access_warranty_wizard,add_product_warranty.model_warranty_wizard,base.group_user,1,1,1,1 +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 diff --git a/add_product_warranty/views/product_template.xml b/add_product_warranty/views/product_template.xml new file mode 100644 index 00000000000..554f5ffff76 --- /dev/null +++ b/add_product_warranty/views/product_template.xml @@ -0,0 +1,15 @@ + + + + product.template.inherit.form + product.template + + + + + + + + + + diff --git a/add_product_warranty/views/product_warranty.xml b/add_product_warranty/views/product_warranty.xml new file mode 100644 index 00000000000..51a372de0bd --- /dev/null +++ b/add_product_warranty/views/product_warranty.xml @@ -0,0 +1,20 @@ + + + + Warranty Configuration + product.warranty + list,form + + + + product.warranty.list + product.warranty + + + + + + + + + diff --git a/add_product_warranty/views/sale_order_button.xml b/add_product_warranty/views/sale_order_button.xml new file mode 100644 index 00000000000..d0b854643c8 --- /dev/null +++ b/add_product_warranty/views/sale_order_button.xml @@ -0,0 +1,14 @@ + + + + sale.order.button.wizard + sale.order + + + +