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

How to show default partner_id in wizard which is selected in sale order form but not saved yet?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
sale.order.formpartner_iddefault_getodoo10Odoo
1 Odpowiedz
15277 Widoki
Awatar
Pawan Kumar Sharma

Hello All,

I selected customer name in sales order form. And above the sale order line i added a button, for this button wizard is opened and getting information from customer. I want that in wizard customer name(partner_id) should be auto field when user open it. So, ho can i do that?

Wizard file code is:

class RentalPackWizard(models.TransientModel):

    _name = "rental.pack.wizard"

    _description = "Rental Pack Wizard"

"""@api.model

    def _get_default_partner(self):

        partner = self.env['res.partner'].search([()], limit=1)

        return partner"""

    ser6_partner_id = fields.Many2one('res.partner', string='Customer')# , default=_get_default_partner)


Also Attached image for problem

 

0
Awatar
Odrzuć
Awatar
Sudhir Arya (ERP Harbor Consulting Services)
Najlepsza odpowiedź

Hi Pawan,

You can access the sales order record as active_ids from self._context and then access the partner.

@api.model
def _get_default_partner(self):
ctx = self._context
if ctx.get('active_model') == 'sale.order':
return self.env['sale.order'].browse(ctx.get('active_ids')[0]).partner_id.id

Hope this solve your problem.

Sudhir Arya
ERP Harbor Consulting Services
skype: sudhir@erpharbor.com  website: http://www.erpharbor.com
7
Awatar
Odrzuć
Pawan Kumar Sharma
Autor

Hello @Sudhir, i tried your method but i don't get default customer, also after choosing customer and save wizard then it shows error for "Product Unit of Measure - product.uom". So, i ho to get default customer on wizard.

Thanks for your reply..

Sudhir Arya (ERP Harbor Consulting Services)

Would you please share your module or code?

Pawan Kumar Sharma
Autor

Hii @Sudhir, Here is my python code:

class RentalPackWizard(models.TransientModel):

_name = "rental.pack.wizard"

_description = "Rental Pack Wizard"

@api.model

def _get_default_service6(self):

service = self.env['product.product'].search([('type_service', '=', 'd')], limit=1)

return service

@api.model

def _get_default_partner(self):

ctx = self._context

if ctx.get('active_mode') == 'sale.order':

return self.env['sale.order'].ctx.get('active_ids')[0].partner_id.id

check_ser6 = fields.Boolean(string='Include In sales order')

product_id_ser6 = fields.Many2one('product.product', string='Service', default=_get_default_partner)

ser6_partner_id = fields.Many2one('res.partner', string="Customer")

ser6_price = fields.Float('Price')

ser6_weight = fields.Many2one('est.weight', string='Weight')

ser6_actual_weight = fields.Float("Actual Weight(Kg)")

@api.multi

def action_rentalpack_add(self):

rec = self._context.get('active_ids', [])

print "REntal", rec, self.product_id_rental.categ_id

g1 = []

if rec:

hydro_treat = {'product_id': self.product_id_ser6.id,

'category_id': self.product_id_ser6.categ_id.id,

'product_uom': self.product_id_ser6.uom_id.id,

# 'product_uom': 1,

'order_id': rec[0],

'price_unit': self.ser6_price

if self.check_ser6 is True:

sale_order_line6 = self.env['sale.order.line'].create(hydro_treat)

xml code:

<page string="Hydrolysis Treatment">

<group string="Hydrolysis Treatment" col="4" colspan="4">

<field name="check_ser6" context="{'default_partner_id':partner_id}"/>

<field name="product_id_ser6" readonly="1"/>

<field name="ser6_partner_id"/>

<field name="ser6_weight"/>

<field name="ser6_actual_weight"/>

<field name="ser6_price"/>

</group>

</page>

Sudhir Arya (ERP Harbor Consulting Services)

Hi Pawan,

It was my mistake. I did typo mistake in the code.

if ctx.get('active_mode') == 'sale.order'

Here, it should be active_model and not active_mode.

I have corrected the code. Please try that and give feedback.

Pawan Kumar Sharma
Autor

Hello Sudhir i still getting error: "File "/opt/odoo10/odoo/odoo/addons/rental/rental_pack.py", line 401, in _get_default_partner

return self.env['sale.order'].ctx.get('active_ids')[0].partner_id.id

AttributeError: 'sale.order' object has no attribute 'ctx'"

for - if ctx.get('active_model') == 'sale.order':

Sudhir Arya (ERP Harbor Consulting Services)

Updated the code in answer. This should work now.

Pawan Kumar Sharma
Autor

Thanks Sudhir it's work. i added "change_default=True" in field after-that it works.

Sudhir Arya (ERP Harbor Consulting Services)

Glad to know that its working fine now.

Pawan Kumar Sharma
Autor

Hello Sudhir, when click on "OK" button on wizard then it show error "[object with reference: Product Unit of Measure - product.uom] " for this method. When i make method disable value return. So, how to solve this?

Pawan Kumar Sharma
Autor

Now, done. Thank's Sudhir....!!

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ść
Odoo - Click event customization in list view
odoo9.0 odoo10 Odoo
Awatar
0
sie 17
3346
default_get() from sale.order.line Odoo 10
sequence sale.order.line default_get odoo10
Awatar
0
lis 18
6816
Selection Field in default_get
fields selection default_get odoo10
Awatar
1
cze 18
4000
default_get : return several values ?
wizard default_get tree_view odoo10
Awatar
Awatar
1
cze 17
5573
Validation Error while creating partial invoice from sales order in Odoo 10
odoo odoo10 odoo10.0 Odoo Odoo10.0
Awatar
Awatar
2
sty 18
5034
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