Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

[Odoo 12] How to perform a search on a One2many field through a wizard?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
wizardone2manysearch12.0
2 Odpowiedzi
15998 Widoki
Awatar
Willem Datema

Hello all,

I am trying to perform a filter/search through a wizard for a One2manyfield. The One2manyfield connects to the model stock.picking. I created a TransientModel in which a user can pick a Sale Order and the wizard should return a form with a filtered one2many field. The form will then only show the pickings which have the Sale Order that the user selected as Origin. The TransientModel looks like this:

class SearchPacking(models.TransientModel):
    _name = 'search.packing'
_description = 'Search a packing'

sale_order_id = fields.Many2one('sale.order',string="Sale Order")

def search_filtered_packing(self):
return {
'type':'ir.actions.act_window',
'view_type':'form',
'view_mode':'form',
'src_model':'search.packing',
'res_model':'pickpack.packview',
'target':'new',
'res_id':self.env.context.get('active_id'),
'domain':[('origin','=',self.sale_order_id)]
}


The model pickpack.packview is a model that shows all the pickings with picking type "Pack" in a batch. It has a one2many field that looks like this:

class PackView(models.Model):
    // OTHER DEFINITIONS ​   ​    ​   ​     ​   ​    ​   ​
    pickings = fields.One2many('stock.picking','packviews',string='Operations to pack',readonly=False,store=True, compute='_compute_operations_to_pack')
@api.one
@api.depends('batch_id')
def _compute_operations_to_pack(self):
self.ensure_one()
res = self.env['stock.picking']
for picking in res.search([('batch_id','=',self.batch_id.id),('picking_type_id.name','=','Pack')]):
res += picking
self.pickings = res

What happens now if I click the button in the wizard that calls search_filtered_packing (after selecting a Sales Order) is that I just get the same model back, without any filters. 
The One2Many field is searchable on Sales Order in the tree view. Can anyone see what is going wrong here?


Thanks in advance.

0
Awatar
Odrzuć
Awatar
Ryan Tran
Najlepsza odpowiedź

Hi,

There are some problems in your solution:

  • If you really mean to compute the One2many field, you should not define it with the inverse_name. By doing this, there are no real connection between these 2 models, and you cannot store this o2m field. If the relation already exist between 2 model with the m2o relation defined in the corresponding model, then you can only apply domain to decide what to be shown.

  • You cannot domain a form view, but you can domain a field shown as tree in the form view, if you return correct value to domain that field in particular.

Then the solution now is depends on what you want to achieve:

  • You can add a sale_order_origin to stock.picking form view to apply domain dynamically to the related one2many field, with an onchange function.

  • If you want to use the wizard, then from that wizard, you select the reference Sale Order, then assign the result recordset to an m2m field on the wizard, and then finally write those m2m ids to the o2m field in stock.picking.

I think you would want to domain what to be picked base on the Sale Order (delivery operation) rather than automatically creating o2m record from the wizard. Then returning domain for a selected field using onchange function is your best friend. Try :

return {'domain':{'picking_ids': [('origin', '=', self.sale_order_id.name)]}}
1
Awatar
Odrzuć
Awatar
faOtools
Najlepsza odpowiedź

You return a form view and, moreover, you return res_id in your method. So, you say to Odoo - 'show me a form of this object in a new window'. The param domain is applied to tree, kanban, calendar views: so to any where there are a few items.

A few other comments:

  • How might origin (char) be equal to sale_order_id (recordset)?

  • What for do you need 'src_model'?

Thus, you should re-develop your action to return, for example a list. Something like:

@api.multi
def search_filtered_packing(self):
self.ensure_one()
return {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'pickpack.packview',
'type': 'ir.actions.act_window',
'domain':[('origin', '=', self.sale_order_id.name)],
}
0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
How to open wizard from "Add a line" link of One2many field?
wizard one2many
Awatar
Awatar
1
cze 24
443
Smart search of phone numbers. Rozwiązane
search 12.0
Awatar
Awatar
2
gru 20
5671
Read values from one2many relation
one2many search
Awatar
Awatar
1
lis 18
3540
One2many through wizard, (without errors, but no add to the record)
wizard one2many
Awatar
Awatar
1
lut 16
5755
One2many field on wizard opens by itself
wizard one2many print
Awatar
Awatar
1
wrz 23
2875
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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