Skip to Content
Menu
This question has been flagged
1 Reply
8771 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=[()])
Avatar
Discard
Author

wow it work


so many thank

Best Answer

Hi,

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

Avatar
Discard

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">

<data>

<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"/>

</field>

class arrondissement contain the field town_id

pleaze help me

Hi,

* 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)]"/>