Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
4148 Переглядів

Hi all,
i'm trying to display one custom field on sale.order view only if customer (partner) country_id is equal to 97. 

This is the code I used - it's not working. Can someone please help. https://ibb.co/wJqDTj1






    

Аватар
Відмінити
Найкраща відповідь

Hi Matija,
Instead of giving the attr in the xpath tag, give it for the field.

Create a related char field in sale.order. Then give condition for the field based on that.

in python,

customer_country_ code= fields.Char(string='Nationality',related='partner_id.country_id.code')

Then in your xml inside the xpath give
   

Hope this helps

Аватар
Відмінити
Автор

Akshay - this is the method I'm gonna implement - works good. Thank you!

Найкраща відповідь

Hello Matija,

You need to give attrs into field.Kindly refer below example.

Аватар
Відмінити

<field name='amount_untaxed' position='after'>
<field name='custom_untaxed' attrs="{'invisible':[('partner_id.country_id.id','!=','97')]}"
</field>

Автор

Thank you - that should do the trick, but there is one more question: How to get partner country id - this is the error I get at the moment

Invalid composed field o.partner_id.country_id.id in attrs.invisible ({'invisible':[('o.partner_id.country_id.id','!=','97')]})

I tried with o.partner_id.country_id.id but it's not working, do you know how to get it?

are you inheriting report xml file of sale order?

Автор

Yes, look here https://ibb.co/LSj0tGL

Related Posts Відповіді Переглядів Дія
0
лист. 17
5975
customer_lead V16 Вирішено
1
жовт. 23
1528
10
січ. 24
17566
1
бер. 15
3914
1
бер. 15
3702