Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Artificial Intelligence
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Property Management
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Call function in domain odoo16

Subscriure's

Get notified when there's activity on this post

This question has been flagged
odooodoo16features
2 Respostes
4183 Vistes
Avatar
abc Electronics, Asmaa

I need to call function in domain odoo 16 
I know that calling function in domain depricated in odoo16
but how can i solve this problem?

I tried to use compute field but it does't work


@api.onchange('deliver_id.shipping_method')
def _on_change_shipping_method(self):
if self.deliver_id.Shipping_method:
cities=self.env['shipping.meth']['line_ids']['city_id'].search_read()
city_list={}
for rec in cities:
cit=self.deliver_id.Shipping_method.line_ids.city_id
for c in cit:
if rec['id'] == c.id:
city_list[c.id]=c.id
return city_list
@api.depends("deliver_id.Shipping_method")
def _compute_allowed_value_ids(self):
for record in self:
x= _on_change_shipping_method()
x=list(x.values())
record.allowed_value_ids=x
allowed_value_ids = fields.Many2one(
"city.city",
_compute="_compute_allowed_value_ids",required=False
)
city = fields.Many2one('city.city',string='City',domain="[('id', 'in', allowed_value_ids)]",)


0
Avatar
Descartar
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Asmaa,

I've checked the issue and here's what you can fix,

1) You need to remove '_' at beginning of compute parameter and write 'compute' instead as '_compute' is not a valid parameter.

2) The arguments used for onchange() decorator must be simple field names. If dotted names are used then it will be ignored by the decorator. Your onchange() decorator: ('deliver_id.shipping_method') will be ignored.

3) If your onchange method (in your case x) returns more than one value It throws an error, you cannot use them to write in Many2one as you can write only one value at a time in Many2one. 

So if your field 'allowed_value_ids' is not used in the view or anywhere else other than in the domain of field 'city', you can make the field type 
of field:'allowed_value_ids' as Many2many instead of Many2one.

Ex:- Suppose you have 3 cities, compute on your field 'allowed_value_ids' returns 2 cities, so it will write those two values in field 'allowed_value_ids' if it is a Many2many but not in Many2one. Now field 'city' will filter only those cities which are there in the field 'allowed_value_ids'. 

Hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Descartar
abc Electronics, Asmaa
Autor

allowed_value_ids field is Many2one not Many2many
How can i solve it?

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

You can call the domain using a external module from oca, web_domain_field add this module in the depends in manifest file

https://odoo-community.org/shop/web-domain-field-4368#attr=22677

Try to update the code like this , import json

@api.depends("deliver_id.Shipping_method")
def compute_allowed_value_ids(self):
    for record in self:
        val = self._on_change_shipping_method()
        x = list(val.values())
        record.allowed_value_ids = json.dumps(
                [('id', 'in',x)]
            )

Update the xml code like follows

<field name="city" domain="allowed_value_ids"/>


<field name="allowed_value_ids" invisible="1"/>


Regards

1
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
GST Applicability on Free Samples and Free Supplies | How to achieve the same in Odoo 16.0
odoo odoo16features
Avatar
Avatar
1
d’abr. 26
4455
haw to link purchase order with its payments?
odoo odoo16features
Avatar
Avatar
1
d’abr. 25
3049
Odoo App Solved
odoo odoo16features
Avatar
Avatar
1
de nov. 23
3797
Work Order Timer Losing Sync - Odoo.sh 16
odoo odoo16features
Avatar
0
de maig 24
3422
Data not save when refresh page odoo 16
odoo odoo16features
Avatar
0
de set. 23
3991
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now