ai*
This commit is contained in:
1
ai_website_sale_slides/models/__init__.py
Normal file
1
ai_website_sale_slides/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import slide_channel
|
||||
24
ai_website_sale_slides/models/slide_channel.py
Normal file
24
ai_website_sale_slides/models/slide_channel.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models
|
||||
|
||||
|
||||
class SlideChannel(models.Model):
|
||||
_inherit = 'slide.channel'
|
||||
|
||||
def _ai_get_preview_metadata(self):
|
||||
"""Extend preview metadata with linked product prices."""
|
||||
metadata = super()._ai_get_preview_metadata()
|
||||
channels_with_product = self.filtered('product_id')
|
||||
if not channels_with_product:
|
||||
return metadata
|
||||
|
||||
product_id_by_channel_id = {
|
||||
channel.id: channel.product_id.id
|
||||
for channel in channels_with_product
|
||||
}
|
||||
combo_info = (
|
||||
channels_with_product.mapped('product_id').sudo()._resolve_product_combination_info()
|
||||
)
|
||||
for entry in metadata:
|
||||
entry.update(combo_info.get(product_id_by_channel_id.get(entry['id']), {}))
|
||||
return metadata
|
||||
Reference in New Issue
Block a user