Skip to content

Commit 275224e

Browse files
committed
[ADD] warranty_configuration: added new model for apply warranty while so
Started developing module name warranty_configuration which enable user to apply warranty order lines in sales order based on defined warraty period and amount. Developed models, view, inherited views and inherited models to add menu in sales app for warranty configuration. Added is warranty available checkbox on product page in sales tab. added add warranty button in sales order form as well.
1 parent 4538aa3 commit 275224e

13 files changed

+159
-0
lines changed

warranty_configuration/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Warranty Configuration",
3+
"version": "1.0",
4+
"depends": ["base", "sale_management", "stock"],
5+
"author": "djip-odoo",
6+
"description": """
7+
Part of technical training
8+
Creating Warranty Configuration module for assignment 1
9+
""",
10+
"data": [
11+
"security/ir.model.access.csv",
12+
"wizards/so_add_warranty_wizard.xml",
13+
14+
"views/sales_management_menu.xml",
15+
"views/warranty_configuration_views.xml",
16+
"views/product_views.xml",
17+
"views/so_add_warranty_button_view.xml",
18+
],
19+
"installable": True,
20+
"application": False,
21+
"license": "LGPL-3",
22+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from . import warranty_configuration
2+
from . import product_template
3+
from . import sale_order
4+
from . import sale_order_line
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+
warranty = fields.Boolean(string="Is Warranty Available ?", default=False)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from odoo import models, api, fields
2+
3+
class SaleOrder(models.Model):
4+
_inherit = "sale.order"
5+
6+
def action_open_warranty_wizard(self):
7+
print("-" * 100)
8+
# Properly define the return dictionary for the wizard action
9+
return {
10+
'type': 'ir.actions.act_window',
11+
'name': 'Add Warranty',
12+
'res_model': 'warranty.configuration', # Your wizard model
13+
'view_mode': 'form',
14+
'view_id': self.env.ref('warranty_configuration.view_add_warranty_wizard').id, # Adjust the module/view XML ID
15+
'target': 'new',
16+
'context': {
17+
'default_product_ids': self.order_line.ids, # Adjust based on the wizard's logic
18+
},
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from odoo import models,api,fields
2+
3+
class SaleOrderLine(models.Model):
4+
_inherit = "sale.order.line"
5+
6+
@api.model_create_multi
7+
def create(self, vals_list):
8+
print(vals_list)
9+
return []
10+
11+
def action_add_warranty(self):
12+
print("-*- " * 100)
13+
print("hello from warranty !")
14+
print("-*- " * 100)
15+
16+
return []
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from odoo import fields, models
2+
3+
4+
class WarrantyConfiguration(models.Model):
5+
_name = "warranty.configuration"
6+
_description = "warranty order line for selected products !"
7+
8+
name = fields.Char(
9+
required=True,
10+
string="Name",
11+
)
12+
product_id = fields.Many2one("product.product", string="Product")
13+
year = fields.Integer(default=0, required=True)
14+
percentage = fields.Float(default=0.0, digits=(5, 2), required=True)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
warranty_configuration.access_warranty_configuration,access_warranty_configuration,warranty_configuration.model_warranty_configuration,base.group_user,1,1,1,1
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<odoo>
2+
<record id="inherited_product_template_form_view_warranty_configuration" model="ir.ui.view">
3+
<field name="name">product.template.form.warranty.configuration</field>
4+
<field name="model">product.template</field>
5+
<field name="inherit_id" ref="product.product_template_form_view" />
6+
<field name="arch" type="xml">
7+
<xpath expr="//group[@name='description']" position="after">
8+
<group name="warranty_info" string="Warranty Configuration">
9+
<field name="warranty" colspan="2"/>
10+
</group>
11+
</xpath>
12+
</field>
13+
</record>
14+
</odoo>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<odoo>
2+
<record id="action_sale_config_warranty_configuration" model="ir.actions.act_window">
3+
<field name="name">Warranty Configuration</field>
4+
<field name="res_model">warranty.configuration</field>
5+
<field name="view_mode">list</field>
6+
</record>
7+
8+
<menuitem
9+
id="menu_warranty_configuration_config"
10+
name="Warranty Configuration"
11+
parent="sale.menu_sale_config"
12+
action="action_sale_config_warranty_configuration"
13+
/>
14+
</odoo>

0 commit comments

Comments
 (0)