Odoo Help


Domain filter from another field

Pichchanok Nuchpan
on 8/10/16, 12:12 AM 417 views

Please Help me

in pos_config field i wanna show value only in pos_configs

thank for help .

class res_users(models.Model):
_name = 'res.users'
_inherit = 'res.users'
pos_configs = fields.Many2many('pos.config', string='POS(s)')
pos_config = fields.Many2one('pos.config', string="Default POS", domain=[()])
--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 8/10/16, 3:36 AM


You can try:

pos_config = fields.Many2one('pos.config', string="Default POS", domain="[('id', 'in', pos_configs[0][2])]")

And you can find the explanation here ..

*NB this will gives you an error when the pos_configs is empty; so you can make the pos_config invisible/readonly if the the pos_configs is empty or so ...

Hope this could helps

hi , please a have same issue but your solution isnt work with me

this is my class :

class AccountInvoice(models.Model):

_name = 'account.invoice'

_inherit = 'account.invoice'

town_id = fields.Many2one('account.town','Commune')

arrondissement_id = fields.Many2one('account.arrondissement','Arrondissement')

and this is my views :

<field name="name">Facture Client</field>

<field name="type">form</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_form" />

<field name="arch" type="xml">


<field name="fiscal_position" position="after">

<field name="prefecture_id" />

<field name="town_id" />

<field name="arrondissement_id" domain="[('town_id','in',town_id"/>

<field name="num_dossier"/>


class arrondissement contain the field town_id

pleaze help me

on 8/11/16, 5:40 AM


* First: you since it is a M2o relation you need to use '=' operatotr.

* Second it seems there is a syntax error. Try something like:

<field name="arrondissement_id" domain="[('town_id','=',town_id)]"/>

Ahmed M.Elmubarak
on 8/11/16, 7:36 AM
Pichchanok Nuchpan
On 8/11/16, 1:52 AM

wow it work

so many thank

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/10/16, 12:12 AM
Seen: 417 times
Last updated: 8/11/16, 1:52 AM