diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/website_sale/models/product_attribute.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website_sale/models/product_attribute.py')
| -rw-r--r-- | addons/website_sale/models/product_attribute.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/website_sale/models/product_attribute.py b/addons/website_sale/models/product_attribute.py new file mode 100644 index 00000000..67bbe3a8 --- /dev/null +++ b/addons/website_sale/models/product_attribute.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from collections import OrderedDict + +from odoo import models + + +class ProductTemplateAttributeLine(models.Model): + _inherit = 'product.template.attribute.line' + + def _prepare_single_value_for_display(self): + """On the product page group together the attribute lines that concern + the same attribute and that have only one value each. + + Indeed those are considered informative values, they do not generate + choice for the user, so they are displayed below the configurator. + + The returned attributes are ordered as they appear in `self`, so based + on the order of the attribute lines. + """ + single_value_lines = self.filtered(lambda ptal: len(ptal.value_ids) == 1) + single_value_attributes = OrderedDict([(pa, self.env['product.template.attribute.line']) for pa in single_value_lines.attribute_id]) + for ptal in single_value_lines: + single_value_attributes[ptal.attribute_id] |= ptal + return single_value_attributes |
