İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
3646 Görünümler

In the Sales, there's a s Send By Email button. In the template of the email, there's a field 'object'. Where does this come from? I checked action_quotation_send but there's no object params passed. This is the email template it automatically referenced to the field 'object'


<record id="mail_template_sale_confirmation" model="mail.template">

<field name="name">Sales: Order Confirmation</field>

<field name="model_id" ref="sale.model_sale_order"/>

<field name="subject">{{ object\.company_id\.name\ \}\}\ \{\{\ \(object\.get_portal_last_transaction\(\)\.state\ ==\ \&\#39;pending\&\#39;\)\ and\ \&\#39;Pending\ Order\&\#39;\ or\ \&\#39;Order\&\#39;\ \}\}\ \(Ref\ \{\{\ object\.name\ or\ \&\#39;n/a\&\#39;\ \}\}\)\</field\>

\ \ \ \ \ \ \ \ \ \ \ \ \<field\ name=\"email_from\"\>\{\{\ \(object\.user_id\.email_formatted\ or\ user\.email_formatted\)\ \}\}\</field\>

\ \ \ \ \ \ \ \ \ \ \ \ \<field\ name=\"partner_to\"\>\{\{\ object.partner_id.id }}</field>

<field name="description">Sent to customers on order confirmation</field>

<field name="body_html" type="html">

</field>

</record>


Avatar
Vazgeç
En İyi Yanıt

Hi,

In the provided email template, the object variable is used to reference the current record (sale order) that the email is associated with. In Odoo email templates, the object variable is automatically made available and corresponds to the record for which the email is being sent. In this case, the email template is associated with the Sale Order model (sale.model_sale_order), so object represents an instance of a sale order.

Here's how the object variable is used in the email template you provided:

Subject Line:
The subject field in the email template is using the object variable to include dynamic information in the email subject. For example, it references object.name to include the sale order's name in the subject. 
Sender's Email:
The email_from field in the email template is used to specify the sender's email address. It uses object.user_id.email_formatted to get the email address of the user associated with the sale order. If the user's email is not available, it falls back to the email of the user variable.

Recipient's Email:
The partner_to field in the email template specifies the recipient's email address. It uses object.partner_id.id to get the ID of the partner associated with the sale order.

In summary, the object variable in the email template refers to the sale order record for which the email is being sent, and it allows you to dynamically include information from that sale order in the email subject, sender's email address, and recipient's email address.
To know more about email templates you can refer our blog:-How to create email template in odoo 16


Hope it helps

Avatar
Vazgeç
En İyi Yanıt

Hi,

The "object" field you mentioned in the email template is typically used to dynamically display information about the document being sent, such as the quotation, sale order, or any other relevant document.

it represents the actual record or document itself, specifically the instance of the document that you are sending via email.

hope this will help you

thanks

Avatar
Vazgeç
Üretici

yes i understand that but where is it passed? I need to add and modify the data passed on that "object" field

İlgili Gönderiler Cevaplar Görünümler Aktivite
8
Tem 24
23118
1
Oca 24
3899
1
Ara 23
1850
1
Nis 23
2761
1
Eyl 21
3851