Skip to content

Commit

Permalink
Merge PR #58 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Feb 15, 2022
2 parents f28e48d + 85ab16b commit 5adcc62
Showing 1 changed file with 31 additions and 1 deletion.
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):
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

0 comments on commit 5adcc62

Please sign in to comment.