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
    • Validacions
    • 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ó
    • Gestió immobiliària
    • 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

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
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

Setup filter in Sales Order "Add An Item" search view

Subscriure's

Get notified when there's activity on this post

This question has been flagged
sale.orderproduct.product
1 Respondre
11669 Vistes
Avatar
Jae Landers

I am trying to setup a filter that will base itself off of the "Customer" field (partner_id) when creating or modifying a Sales Order. I am very new to OpenERP, so please pardon any obvious mistakes.

I made the following line in the search view to create the filter:

<filter string="Customers Items" domain="[('x_whereused','=',sale.view_order_form.partner_id)]" name="own_area_items"/>

x_whereused is a custom field I made in product.template which indicates which customers use what parts. I want the Add an Item - Search More view to have the above filter compare the partner_id in the newly made Sales Order with my custom field (x_whereused) and display if it matches. I get the following error currently when applying the filter.
 

"TypeError: context is undefined

http://_________/web/js.web.assets_backend/7b7a275:3778"

Thanks very much for any assistance on this!

1
Avatar
Descartar
john5000

Hi Kyle, you should change your "answer" below to a comment to my answer. Click the "Convert as comment" to do that. You may have to also copy-paste it as a comment to my answer. Also, click the grey circled checkmark on my answer to "accept" it.

john5000

And I'm checking out how to answer your further question...

Jae Landers
Autor

Thanks! I'm definitely going to try that out. One question I have is in the case that I wanted the user to be able (if they wanted) to go through the other listings that are not matching the x_whereused field (say the item is not in the list and the sales man wants to check for something not necessarily associated with that customer), would they be able to do this with the above code in place? Please excuse me if I'm mis-understanding, but from what I can tell, the code you gave will filter the results regardless of filters being applied in the search window itself. My idea came up from observing the "My" filter in th Draft Quotations view, that shows your own drafts, and then if you remove it, it shows everyone's. Thanks and Happy New Year!

john5000

Hello. I follow what you are asking for. Unfortunately I've not found out how to do that. The domain puts a filter there, which is not shown to the user. Normally you use default_search_(field) to set a default that is shown as a search filter to the user. But that is not made for doing a lookup on a many2one within a form. So, at this point it is probably best to work out the other parts of your system and then come back to this when you have a better understanding of the various capabilities.

Jae Landers
Autor

Well, been a long time coming but I finally ended up revisiting this and got your code implemented in a module. I decided to ditch the optional part of seeing another customers parts as that can be done in the product menu, doesn't need to done in the sales order. The final code I ended up using is: sale.view.order.form.inherit sale.order <xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="attributes"> [('whereused','=',parent.partner_id)]

Avatar
john5000
Best Answer

You can't use "sale.view_order_form.partner_id" in your filter, as the search view will not be able to understand it.

Also the filter needs to be part of the product lookup with in the sales order form.

Here is how you can add a filter to the products listing in a sales order:

And in your case the partner_id will be used as the id to filter with. 

Add the following to the product_id field view defintion:

   domain="[('x_whereused', '=', parent.partner_id)]"

You will find an example of the xpath section for doing this in the file "sale_stock_view.xml" (under the "sales" addon folder)
Look for the following section, which is the xpath section that needs to be modified:

<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="replace" 
    <field name="product_id
        domain="[('x_whereused', '=', parent.partner_id)]"             <-- Add this
        context=... (etc.)
        ...    />
</xpath>

You should of course put this this in your own addon that is used to override the exiting logic (hopefully you are doing that).

But if you just want to see it in action quickly, you can add that line above to the "sale_stock_view.xml" file, then under Settings->Apps find the "Sales Management" and do "Upgrade".

Now when you create an order and click on the product field it will be filtered by the partner_id.  Of course, you can change that domain= to filter by other criteria also. 

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
Where to find the possible and available models the ORM API provides? Solved
sale.order product.product api.model
Avatar
Avatar
3
d’oct. 17
7994
Display field only for one company on list view Solved
sale.order
Avatar
Avatar
1
de maig 25
1764
Sale order Balance
sale.order
Avatar
Avatar
Avatar
2
de nov. 24
2822
Mark a sales order as fully invoiced despite Order amount and invoiced amount do not match () Solved
sale.order
Avatar
Avatar
Avatar
Avatar
Avatar
4
de febr. 24
13453
sale / delivery Solved
sale.order
Avatar
Avatar
1
de gen. 24
2222
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 ภาษาไทย 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