This question has been flagged
6 Replies
8841 Views

I want to have a custom view where  I have only the states from my country. I've tried everything I found but I can't get it working.

<record model="ir.ui.view" id="res_country_state_sifranti_tree_view">
	<field name="name">Šifranti občin</field>
	<field name="model">res.country.state</field>
	<field name="arch" type="xml">
		<tree>
			<field name="code"/>
			<field name="name"/>
			<field name="country_id" domain="[('country_id','=','201')]"/>
			<!-- and the domain="[('id','=','201')]" -->
		</tree>
	</field>
</record>

and in the action

<record model="ir.actions.act_window.view" id="res_country_state_sifranti_action_tree">
	<field name="sequence" eval="1"/>
	<field name="view_mode">tree</field>
        <field name="domain">[('country_id', '=', '201')]</field>
	<field name="view_id" ref="res_country_state_sifranti_tree_view"/>
	<field name="act_window_id" ref="res_country_state_sifranti_action_window"/>
</record>

Only this two options didn't cause errors. But the only thing I accomplished is that I get an empty view.

How should I show only those records that have the country_id 201?


Avatar
Discard

'201' is not equal 201

Author

Tried that one to... didn't work.

You use domain only in action.

Author

I don't understand what you want to say. Maybe you could use more than one sentence. :)

Make sure the related field having set to store="true", if the field is persist in database then it will work fine smoothly like other fields.

Best Answer

Example (standard base action modified, Poland filtering):

        <record id="base.action_country_state" model="ir.actions.act_window">
            <field name="name">Fed. States</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">res.country.state</field>
            <field name="view_type">form</field>
            <field name="res_model">res.country.state</field>
            <field name="view_id" ref="base.view_country_state_tree"/>
            <field name="domain">[('country_id', '=', 178)]</field>
        </record>

PS. Do you have defined any res.country.state for Slovakia?

Avatar
Discard
Author

Thanks it works... I thought I tried this... looks like I Fed something up. HAHA... Slovakia. I have filled the records with a data xml for Slovenian states.

I apologize to Slovenia :), in my database 201 = Slovakia