-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] warranty: Add waranty feature for sale order
-Created new model waranty feture for sale order -Create delete functionality for sale.order.line -Create wizard for show to product which is sale.order.line and show the year end_date
- Loading branch information
Showing
22 changed files
with
265 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
<menuitem id="action_installment_config_settings" name="Installment"> | ||
<menuitem id="action_installment_config_settings" name="Installment"/> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "Product Warranty", | ||
"version": "1.0", | ||
"license": "LGPL-3", | ||
"depends": ["base","stock","sale_management"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"wizard/add_warranty_button_action.xml", | ||
"views/inherit_product_template.xml", | ||
"views/add_warranty_button.xml", | ||
"views/waranty_configuration_views.xml", | ||
"views/warranty_configuration.xml", | ||
], | ||
"installable": True, | ||
"application": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from . import product_warranty | ||
from . import product_template | ||
from . import warranty_configuration | ||
from . import sale_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from odoo import models, fields, api | ||
|
||
class ProductTemplate(models.Model): | ||
_inherit = 'product.template' | ||
|
||
|
||
is_warranty_available = fields.Boolean() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from odoo import models, fields, api | ||
|
||
|
||
class ProductWarranty(models.Model): | ||
_name='product.warranty' | ||
|
||
name = fields.Char('Title') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from odoo import models | ||
from datetime import timedelta | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
def add_warranty_wizard_button(self): | ||
products = self.order_line | ||
for product in products: | ||
if product.product_template_id.is_warranty_available: | ||
return { | ||
'type': 'ir.actions.act_window', | ||
'name': 'Add Warranty', | ||
'res_model': 'add.warranty', | ||
'view_mode': 'form', | ||
'view_id': self.env.ref('warranty.view_warranty_form').id, | ||
'target': 'new', | ||
} | ||
else: | ||
raise UserError('This product does not have a warranty.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from odoo import models, fields, api | ||
|
||
|
||
class WarrantyConfiguration(models.Model): | ||
_name='warranty.configuration' | ||
|
||
name = fields.Char() | ||
product_id = fields.Many2one('product.template',string="product") | ||
period = fields.Integer('Period') | ||
percentage = fields.Float() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
warranty.access_product_warranty,access_product_warranty,model_product_warranty,base.group_user,1,1,1,1 | ||
warranty.access_warranty_configuration,access_warranty_configuration,warranty.model_warranty_configuration,base.group_user,1,1,1,1 | ||
warranty.access_add_warranty,access_add_warranty,warranty.model_add_warranty,base.group_user,1,1,1,1 | ||
warranty.access_add_warranty_line,access_add_warranty_line,warranty.model_add_warranty_line,base.group_user,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<odoo> | ||
<record id="add_emi_view" model="ir.ui.view"> | ||
<field name="name">add.warranty</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div//button[@name='action_open_discount_wizard']" position="before"> | ||
<button string="Add Warranty" | ||
name="add_warranty_wizard_button" | ||
type="object" | ||
class="btn btn-primary"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
Oops, something went wrong.