| 1 |
|
| 2 |
|
| 3 |
from collections import OrderedDict |
| 4 |
|
| 5 |
from odoo import models |
| 6 |
|
| 7 |
|
| 8 |
class ProductTemplateAttributeLine(models.Model): |
| 9 |
_inherit = 'product.template.attribute.line' |
| 10 |
|
| 11 |
def _prepare_single_value_for_display(self): |
| 12 |
"""On the product page group together the attribute lines that concern |
| 13 |
the same attribute and that have only one value each. |
| 14 |
|
| 15 |
Indeed those are considered informative values, they do not generate |
| 16 |
choice for the user, so they are displayed below the configurator. |
| 17 |
|
| 18 |
The returned attributes are ordered as they appear in `self`, so based |
| 19 |
on the order of the attribute lines. |
| 20 |
""" |
| 21 |
single_value_lines = self.filtered( |
| 22 |
lambda ptal: len(ptal.value_ids) == 1 and ptal.attribute_id.display_type != 'multi' |
| 23 |
) |
| 24 |
single_value_attributes = OrderedDict([(pa, self.env['product.template.attribute.line']) for pa in single_value_lines.attribute_id]) |
| 25 |
for ptal in single_value_lines: |
| 26 |
single_value_attributes[ptal.attribute_id] |= ptal |
| 27 |
return single_value_attributes |