Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

The goal is to hide the states_id field in the res.partner form expect for countries which do have states.

So the idea is to make the field invisible when the country is not in the list of countries with states. I don't know if there are such a country apart from USA.

Also I don't know if I should compare country_id with "United States" or 235. Anyway here is the codeI unsuccessfully tried:

    <record model="ir.ui.view" id="view_partner_form">
        <field name="name">partner.axima</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
        <xpath expr="//field[@name='state_id']" position="attributes">
                    <attribute name="invisible">country_id not in [235, "United States"]</attribute>
        </xpath>
        </field>
        </record>

But it fails with the following message :

openerp.tools.safe_eval: Cannot eval 'country_id not in [235, "United States"]'
Traceback (most recent call last):
 File "/home/mathieu/src/OpenERP/server/openerp/tools/safe_eval.py", line 284, in safe_eval
 return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
 File "", line 1, in <module>
 NameError: name 'country_id' is not defined

Is it possible to achieve what I'm trying to do?

Awatar
Odrzuć

@Mathieu Stumpf same question posted twice already answered in the previous post http://help.openerp.com/question/50576/how-do-you-hide-state_id-for-countries-without-states/

Powiązane posty Odpowiedzi Widoki Czynność
4
mar 24
11164
2
sty 25
904
5
maj 21
28536
2
mar 15
3864
2
maj 19
5017