تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
4338 أدوات العرض

I want to print the product_id and the name in my invoice if one differs from each other, if not only the product_id should be printed.

I added these two lines in my report, but it is not working :-( ....

<td t-if="l.name != l.product_id"><span t-field="l.product_id"/><br></br><div style="font-size:smaller; text-indent:10px"><span t-field="l.name"/></div></td>

<td t-if="l.name == l.product_id"><span t-field="l.product_id"/></td>


The Log files warns me: "Comparing apples and oranges" - but I don't know what that means!




الصورة الرمزية
إهمال

Thanks for the advice - the condition is working now.  But unfortunately it's not what I want. Like Ray mentioned not with products with description and not with products with different variants/attributes. How can I include this in my condition?

My intention is: if the user manually fills in or overwrites the text in field "description", both fields (name and product_id) should be printed on the invoice. Maybe my approach is wrong?

Are you trying to handle the case where users remove the product information and overwrite instead of just appending? Perhaps you need an additional field for them, and not let them change description?

الكاتب

Yes, that is what I'm trying. I thought it was easier than adding a custom field, but that's apparently not the case. I will add a field. Thanks for the help Ray!

أفضل إجابة

Hi,

In your condition, you're comparing a string (text)  with a Record ( Product ).
Try:

<td t-if="l.name != l.product_id.name"><span t-field="l.product_id"/><br></br><div style="font-size:smaller; text-indent:10px"><span t-field="l.name"/></div></td>

<td t-if="l.name == l.product_id.name"><span t-field="l.product_id"/></td>

الصورة الرمزية
إهمال
أفضل إجابة

You are comparing a PRODUCT with a TEXT field.

You can compare the Product NAME with the Description (name) field, but they will only match for products without an Internal Reference and Description for Customers as the Description field concatenates the Internal Reference to the start and the Description for Customers to the end.

<td t-if="l.name == l.product_id.name">
الصورة الرمزية
إهمال