-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] warranty_configuration: wizard view and action updated
Solved all error faced yesterday and completed wizard view properly. Configured it such that it adding order line. updated views as well as Transient models. Added new field in sale order line model to assign functionality such that it product get removed from order line than its warranty product also get removed. Demo data added for warranty configuration State button file path uncommented from estate_account solved error occured for agent and manger group. Image not displayed other than admin issue solved in website page of properties.
- Loading branch information
Showing
15 changed files
with
144 additions
and
75 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
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,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="product_warranty_basic" model="product.product"> | ||
<field name="name">Basic Warranty Service</field> | ||
<field name="type">service</field> | ||
<field name="default_code">WARRANTY_BASIC</field> | ||
<field name="list_price">50.0</field> | ||
<field name="standard_price">30.0</field> | ||
<field name="categ_id" ref="product.product_category_1" /> | ||
</record> | ||
|
||
<record id="product_warranty_premium" model="product.product"> | ||
<field name="name">Premium Warranty Service</field> | ||
<field name="type">service</field> | ||
<field name="default_code">WARRANTY_PREMIUM</field> | ||
<field name="list_price">100.0</field> | ||
<field name="standard_price">70.0</field> | ||
<field name="categ_id" ref="product.product_category_1" /> | ||
</record> | ||
|
||
<record id="product_warranty_extended" model="product.product"> | ||
<field name="name">Extended Warranty Service</field> | ||
<field name="type">service</field> | ||
<field name="default_code">WARRANTY_EXTENDED</field> | ||
<field name="list_price">150.0</field> | ||
<field name="standard_price">100.0</field> | ||
<field name="categ_id" ref="product.product_category_1" /> | ||
</record> | ||
</odoo> |
23 changes: 23 additions & 0 deletions
23
warranty_configuration/demo/warranty_configuration_demo.xml
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="warranty_configuration_product1" model="warranty.configuration"> | ||
<field name="name">Warranty - 1 year</field> | ||
<field name="product_id" ref="warranty_configuration.product_warranty_basic" /> | ||
<field name="year">1</field> | ||
<field name="percentage">10.0</field> | ||
</record> | ||
|
||
<record id="warranty_configuration_product2" model="warranty.configuration"> | ||
<field name="name">Warranty - 2 year</field> | ||
<field name="product_id" ref="warranty_configuration.product_warranty_premium" /> | ||
<field name="year">2</field> | ||
<field name="percentage">15.0</field> | ||
</record> | ||
|
||
<record id="warranty_configuration_product3" model="warranty.configuration"> | ||
<field name="name">Warranty - 3 year</field> | ||
<field name="product_id" ref="warranty_configuration.product_warranty_extended" /> | ||
<field name="year">3</field> | ||
<field name="percentage">20.0</field> | ||
</record> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from . import warranty_configuration | ||
from . import product_template | ||
from . import sale_order | ||
from . import sale_order_line |
This file was deleted.
Oops, something went wrong.
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,7 +1,12 @@ | ||
from odoo import models,api,fields | ||
from odoo import models, fields, api | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
_inherit = "sale.order.line" | ||
|
||
# warranty_id = | ||
|
||
parent_sale_order_line_id = fields.Many2one( | ||
comodel_name="sale.order.line", | ||
readonly=True, | ||
ondelete="cascade", | ||
string="parent sale order line id", | ||
) |
2 changes: 1 addition & 1 deletion
2
...ion/views/so_add_warranty_button_view.xml → ..._configuration/views/sale_order_views.xml
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,59 +1,54 @@ | ||
from odoo import models, fields, api, Command | ||
from odoo import models, fields, api | ||
|
||
|
||
class AddWarrantyWizard(models.TransientModel): | ||
_name = "add.warranty.wizard" | ||
_description = "Wizard to Add Warranty" | ||
|
||
order_id = fields.Many2one("sale.order", string="Sale Order") | ||
product_ids = fields.Many2many("product.product") | ||
|
||
warranty_lines_ids = fields.One2many( | ||
comodel_name="add.warranty.line.wizard", | ||
inverse_name="wizard_id", | ||
store=True, | ||
inverse_name="warranty_id", | ||
string="Warranty Lines", | ||
) | ||
|
||
def action_add_warranty(self): | ||
print("-*- " * 100) | ||
|
||
new_order_line_list = [] | ||
# Iterate through the warranty lines in the wizard | ||
for record in self: | ||
print(record.order_id) | ||
warranty_product_ids = record.warranty_lines_ids.mapped("product_id.id") | ||
print("Warranty product IDs:", warranty_product_ids) | ||
|
||
# # Iterate over order lines to find matching products | ||
# for ol in record.order_id.order_line: | ||
# new_order_line_list.append(ol) | ||
# print( | ||
# f"Checking Order Line Product: {ol.product_id.id} in Warranty Lines" | ||
# ) | ||
|
||
# if ol.product_id.id in warranty_product_ids: | ||
# print(f"Match found: {ol}") | ||
|
||
print(new_order_line_list) | ||
print("hello from warranty !") | ||
print("-*- " * 100) | ||
|
||
return new_order_line_list | ||
|
||
@api.model | ||
def default_get(self, fields): | ||
res = super(AddWarrantyWizard, self).default_get(fields) | ||
order_id = self.env.context.get("active_id") | ||
sale_order = self.env["sale.order"].browse(order_id) | ||
|
||
warranty_products = sale_order.order_line.mapped("product_id").filtered( | ||
lambda p: p.warranty | ||
) | ||
sale_order = self.env["sale.order"].browse(order_id) | ||
|
||
warranty_line_vals = [] | ||
for product in warranty_products: | ||
warranty_line_vals.append(Command.create({"product_id": product.id})) | ||
print(warranty_products) | ||
res["product_ids"] = [Command.set(warranty_products)] | ||
res["warranty_lines_ids"] = [ | ||
[ | ||
0, | ||
0, | ||
{ | ||
"sale_order_line_id": line.id, | ||
}, | ||
] | ||
for line in sale_order.order_line.filtered( | ||
lambda x: x.product_template_id.warranty | ||
) | ||
] | ||
res["order_id"] = order_id | ||
|
||
return res | ||
|
||
def action_add_warranty(self): | ||
new_order_line_list = [ | ||
{ | ||
"order_id": line.sale_order_line_id.order_id.id, | ||
"name": str(line.warranty_config_id.name) + "/" + str(line.end_date), | ||
"price_unit": line.sale_order_line_id.price_subtotal | ||
* (line.warranty_config_id.percentage / 100), | ||
"product_id": line.warranty_config_id.product_id.id, | ||
"parent_sale_order_line_id": line.sale_order_line_id.id, | ||
"sequence": line.sale_order_line_id.sequence, | ||
} | ||
for line in self.warranty_lines_ids.filtered( | ||
lambda x: x.warranty_config_id.name | ||
) | ||
] | ||
self.env["sale.order.line"].create(new_order_line_list) |
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