Skip to Content
Menu
This question has been flagged
3 Replies
381 Views

Hi I need help.. I created gift card product in ,odoo 18 enterprise online version ,with free text attributes recepient email and custom message, these fields should enable customer to input recepient email and message that should be used to send automed email gift card. these input appear  in sales order line but i could not fetch them to store in model and later use them to send email using a new template or modify the email template that odoo automatically sends. I used automated action on loyality card model with executable code. this code did not give error while saving but stops the sales order confirmation step.

the following code is used to fetch those stored details

mail = line.product_custom_attribute_value_ids.filtered(lambda a: a.custom_product_template_attribute_value_id.name == 'Email').name

                message = line.product_custom_attribute_value_ids.filtered(lambda a: a.custom_product_template_attribute_value_id.name == 'Message').name 


this does not work

               

How could i fetch the values the customer inputs in free text attribute values. is there any alternative way to achieve this functionality.


Thanks in advance

Avatar
Discard
Best Answer

To fetch customer-inputted free text attributes in Odoo 18 from the sales order line, use the correct model relations. Your current code is trying to access name, but for free text attributes, the value is stored differently. Try this:

Corrected Code:

python

CopyEdit

email_attr = line.product_custom_attribute_value_ids.filtered( lambda a: a.custom_product_template_attribute_value_id.name == 'Email' ).custom_value message_attr = line.product_custom_attribute_value_ids.filtered( lambda a: a.custom_product_template_attribute_value_id.name == 'Message' ).custom_value

Why This Works:

  • custom_value stores the actual user input for free text attributes.
  • name is used for attribute names, not values.

Alternative Approach:

If you still have issues, you can store the values in a custom field in sale.order.line during order confirmation and later use them for the email template.

Avatar
Discard
Author Best Answer

need help in implementing few functionality in webshop 

1.The current eCommerce filter for the "color" attribute lists all 1500 colors, making it difficult for customers to filter products effectively. Instead of listing all colors, we need to group colors into 14 main colors and only display these in the filtering options. I tried changing the html script of shop page and the java script but did not work out for me. 

2. Gift card. The website should allow customer to input the message which should appear in the gift card email sent automatically and the template the customer selects should be in place of standard image in the email. Validity should be one year. I created a gift card product with multiple price varinats and template. I had issues updating the expiry date in automation rules and editing the email template

3. Return voucher: the gift card can be used for refund. However this gift card should be valid for three months and the orders placed using that specific gift voucher should not be returnable. 

I tried to do these using the automated actions and modifying html ,however could not achieve the functionality. So I am looking for some tips or support on this.

Avatar
Discard
Best Answer

In Odoo 18 Enterprise Online, free text attributes allow customers to input values such as recipient email and a custom message during a sale. However, the system does not automatically store these values in a structured way that enables further use, like triggering automated actions or sending emails.

To properly store and use the input data, consider the following approaches:

  1. Custom Fields on Sale Order Line – Extend the sale order line model (sale.order.line) to store the free text attribute values explicitly.
  2. Automated Action with Python Code – Ensure your automated action correctly retrieves attribute values from sale.order.line and links them to the required model.
  3. Odoo Studio or Custom Module – Use Odoo Studio or develop a module to capture and store these attributes properly within the database.
  4. Email Automation via Server Actions – Create a server action that retrieves the stored values and triggers email automation.

At Wan Buffer Services, we specialize in Odoo customization and can assist in implementing a structured workflow to capture and process customer inputs efficiently.

Avatar
Discard