Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] product_configurator_sale (Custom Values on Reconfigure) #58

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion product_configurator_sale/wizard/product_configurator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models


class ProductConfiguratorSale(models.TransientModel):
Expand Down Expand Up @@ -52,3 +52,33 @@ def action_config_done(self):
else:
self.order_id.write({"order_line": [(0, 0, values)]})
return

@api.model
def create(self, vals):
if self.env.context.get("default_order_line_id", False):
patrickrwilson marked this conversation as resolved.
Show resolved Hide resolved
sale_line = self.env["sale.order.line"].browse(
self.env.context["default_order_line_id"]
)
if sale_line.custom_value_ids:
vals["custom_value_ids"] = self._get_custom_values(
sale_line.config_session_id
)
res = super(ProductConfiguratorSale, self).create(vals)
return res

def _get_custom_values(self, session):
custom_values = [(5,)] + [
(
0,
0,
{
"attribute_id": value_custom.attribute_id.id,
"value": value_custom.value,
"attachment_ids": [
(4, attach.id) for attach in value_custom.attachment_ids
],
},
)
for value_custom in session.custom_value_ids
]
return custom_values