跳至内容
菜单
此问题已终结

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 indented.

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
形象
丢弃
相关帖文 回复 查看 活动
1
3月 15
11905
1
10月 22
5966
1
3月 25
1131
1
3月 22
9309
1
10月 25
3265