mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 23:32:06 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,2 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from . import website_sale_comparison
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import product_attribute
|
||||
from . import product_attribute_category
|
||||
from . import product_product
|
||||
from . import product_template_attribute_line
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductAttribute(models.Model):
|
||||
_inherit = 'product.attribute'
|
||||
|
||||
category_id = fields.Many2one(
|
||||
comodel_name='product.attribute.category',
|
||||
string="eCommerce Category",
|
||||
index=True,
|
||||
help="Set a category to regroup similar attributes under the same section in the Comparison"
|
||||
" page of eCommerce.",
|
||||
)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductAttributeCategory(models.Model):
|
||||
_name = 'product.attribute.category'
|
||||
_description = "Product Attribute Category"
|
||||
_order = 'sequence, id'
|
||||
|
||||
name = fields.Char("Category Name", required=True, translate=True)
|
||||
sequence = fields.Integer("Sequence", default=10, index=True)
|
||||
|
||||
attribute_ids = fields.One2many('product.attribute', 'category_id', string="Related Attributes", domain="[('category_id', '=', False)]")
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def _prepare_categories_for_display(self):
|
||||
"""On the comparison page group on the same line the values of each
|
||||
product that concern the same attributes, and then group those
|
||||
attributes per category.
|
||||
|
||||
The returned categories are ordered following their default order.
|
||||
|
||||
:return: OrderedDict [{
|
||||
product.attribute.category: OrderedDict [{
|
||||
product.attribute: OrderedDict [{
|
||||
product: [product.template.attribute.value]
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
"""
|
||||
attributes = self.product_tmpl_id.valid_product_template_attribute_line_ids.attribute_id.sorted()
|
||||
categories = OrderedDict([(cat, OrderedDict()) for cat in attributes.category_id.sorted()])
|
||||
if any(not pa.category_id for pa in attributes):
|
||||
# category_id is not required and the mapped does not return empty
|
||||
categories[self.env['product.attribute.category']] = OrderedDict()
|
||||
for pa in attributes:
|
||||
categories[pa.category_id][pa] = OrderedDict([(
|
||||
product,
|
||||
product.product_template_attribute_value_ids.filtered(
|
||||
lambda ptav: ptav.attribute_id == pa
|
||||
) or # If no_variant, show all possible values
|
||||
product.attribute_line_ids.filtered(lambda ptal: ptal.attribute_id == pa).value_ids
|
||||
) for product in self])
|
||||
return categories
|
||||
|
||||
def _get_image_1024_url(self):
|
||||
""" Returns the local url of the product main image.
|
||||
Note: self.ensure_one()
|
||||
:rtype: str
|
||||
"""
|
||||
self.ensure_one()
|
||||
return self.env['website'].image_url(self, 'image_1024')
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# 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_categories_for_display(self):
|
||||
"""On the product page group together the attribute lines that concern
|
||||
attributes that are in the same category.
|
||||
|
||||
The returned categories are ordered following their default order.
|
||||
|
||||
:return: OrderedDict [{
|
||||
product.attribute.category: [product.template.attribute.line]
|
||||
}]
|
||||
"""
|
||||
attributes = self.attribute_id
|
||||
categories = OrderedDict([(cat, self.env['product.template.attribute.line']) for cat in attributes.category_id.sorted()])
|
||||
if any(not pa.category_id for pa in attributes):
|
||||
# category_id is not required and the mapped does not return empty
|
||||
categories[self.env['product.attribute.category']] = self.env['product.template.attribute.line']
|
||||
for ptal in self:
|
||||
categories[ptal.attribute_id.category_id] |= ptal
|
||||
return categories
|
||||
|
||||
def _prepare_categories_for_display_in_specs_table(self):
|
||||
"""
|
||||
Prepare attribute categories for display in a specs table.
|
||||
|
||||
Filters out attribute lines that have a single value and whose value is
|
||||
marked as custom, then call _prepare_categories_for_display to group
|
||||
the remaining attribute lines by category.
|
||||
|
||||
:return: OrderedDict [{
|
||||
product.attribute.category: [product.template.attribute.line]
|
||||
}]
|
||||
"""
|
||||
filtered_self = self - self.filtered(
|
||||
lambda ptal: len(ptal.value_ids) == 1 and ptal.value_ids.is_custom
|
||||
)
|
||||
return filtered_self._prepare_categories_for_display()
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductAttributeCategory(models.Model):
|
||||
_name = "product.attribute.category"
|
||||
_description = "Product Attribute Category"
|
||||
_order = 'sequence, id'
|
||||
|
||||
name = fields.Char("Category Name", required=True, translate=True)
|
||||
sequence = fields.Integer("Sequence", default=10, index=True)
|
||||
|
||||
attribute_ids = fields.One2many('product.attribute', 'category_id', string="Related Attributes", domain="[('category_id', '=', False)]")
|
||||
|
||||
|
||||
class ProductAttribute(models.Model):
|
||||
_inherit = 'product.attribute'
|
||||
_order = 'category_id, sequence, id'
|
||||
|
||||
category_id = fields.Many2one('product.attribute.category', string="Category", index=True,
|
||||
help="Set a category to regroup similar attributes under "
|
||||
"the same section in the Comparison page of eCommerce")
|
||||
|
||||
|
||||
class ProductTemplateAttributeLine(models.Model):
|
||||
_inherit = 'product.template.attribute.line'
|
||||
|
||||
def _prepare_categories_for_display(self):
|
||||
"""On the product page group together the attribute lines that concern
|
||||
attributes that are in the same category.
|
||||
|
||||
The returned categories are ordered following their default order.
|
||||
|
||||
:return: OrderedDict [{
|
||||
product.attribute.category: [product.template.attribute.line]
|
||||
}]
|
||||
"""
|
||||
attributes = self.attribute_id
|
||||
categories = OrderedDict([(cat, self.env['product.template.attribute.line']) for cat in attributes.category_id.sorted()])
|
||||
if any(not pa.category_id for pa in attributes):
|
||||
# category_id is not required and the mapped does not return empty
|
||||
categories[self.env['product.attribute.category']] = self.env['product.template.attribute.line']
|
||||
for ptal in self:
|
||||
categories[ptal.attribute_id.category_id] |= ptal
|
||||
return categories
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def _prepare_categories_for_display(self):
|
||||
"""On the comparison page group on the same line the values of each
|
||||
product that concern the same attributes, and then group those
|
||||
attributes per category.
|
||||
|
||||
The returned categories are ordered following their default order.
|
||||
|
||||
:return: OrderedDict [{
|
||||
product.attribute.category: OrderedDict [{
|
||||
product.attribute: OrderedDict [{
|
||||
product: [product.template.attribute.value]
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
"""
|
||||
attributes = self.product_tmpl_id.valid_product_template_attribute_line_ids.attribute_id.sorted()
|
||||
categories = OrderedDict([(cat, OrderedDict()) for cat in attributes.category_id.sorted()])
|
||||
if any(not pa.category_id for pa in attributes):
|
||||
# category_id is not required and the mapped does not return empty
|
||||
categories[self.env['product.attribute.category']] = OrderedDict()
|
||||
for pa in attributes:
|
||||
categories[pa.category_id][pa] = OrderedDict([(
|
||||
product,
|
||||
product.attribute_line_ids.filtered(lambda ptal: ptal.attribute_id == pa).value_ids
|
||||
) for product in self])
|
||||
return categories
|
||||
Loading…
Add table
Add a link
Reference in a new issue