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