Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
161 มุมมอง

I am using Odoo.sh in Version 18.0, I added some custom fields to my sale order view and have them printed in the pdf order. Now I would like to have them included in the order templates to have them precompiled and be able to make just little modifications to it, so I don't have to copy/paste the text all the time. I added the fields to the template view and changed the fields in the order view in a way, that they are dependent on the fields of the template (screenshots below). So far that works good, if I make a template and write stuff in that fields, the text is inserted in the orders, but now my problem: If I make some modification in the order to the text, it overwrites the text in the template as well, so everytime I create a new order, the modificated text will be shown, not the original one from the template. How can I make sure, that if I use the template and make changes to the text, that it only affects this specific order and does not overwrite the template?

Thanks for any help.





อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Based on your configuration, this is behaving as intended.

The Related Field Definition (zu deutsch Bezugsfeld) is meant to define a direct 'link' between two fields on different models to have exactly the same value in both (das, was wir gemeinhin als 'durchschleifen' bezeichnen).

What you need is the Compute field (zu deutsch Berechnen), in order to only set the value of x_studio_teil_1 upon selecting/changing a Sale Order Template.

Something like this should do:

for record in self:
    record['x_studio_teil_1'] = record.sale_order_template_id.x_studio_teil_1


For this to work you need to set the Dependencies field (Abhängigkeiten) to 

sale_order_template_id

in order to have Odoo know, under what circumstance to change the value.

Finally, since by default, a field with a compute function is Readonly, you may want to untick that checkbox then (Nur Lesen) so you can also override the value in the Sale Order.


This will, whenever you change the Sale Order Template on a Sale Order, reset the Value to the one from the selected Template.

If you prefer the value to remain the same if set once, change the compute method to something like this:

for record in self:
    record['x_studio_teil_1'] = record.sale_order_template_id.x_studio_teil_1 if not record.x_studio_teil_1 else record.x_studio_teil_1
อวตาร
ละทิ้ง
ผู้เขียน

Thanks for your help, the first part works fine, it does not even change the text when the template is modified. The second option was not exactly what I wanted, it would not even have changed the text if I would used another template, it would always stay the same. But the first one works, so thanks for that.

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 15
11914
1
ต.ค. 22
5977
1
มี.ค. 25
1135
1
มี.ค. 22
9316
1
ต.ค. 25
3282