Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
sale.order.formpartner_iddefault_getodoo10Odoo
1 Răspunde
15267 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
Sudhir Arya (ERP Harbor Consulting Services)
Cel mai bun răspuns

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
Imagine profil
Abandonează
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....!!

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

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Odoo - Click event customization in list view
odoo9.0 odoo10 Odoo
Imagine profil
0
aug. 17
3337
default_get() from sale.order.line Odoo 10
sequence sale.order.line default_get odoo10
Imagine profil
0
nov. 18
6815
Selection Field in default_get
fields selection default_get odoo10
Imagine profil
1
iun. 18
4000
default_get : return several values ?
wizard default_get tree_view odoo10
Imagine profil
Imagine profil
1
iun. 17
5569
Validation Error while creating partial invoice from sales order in Odoo 10
odoo odoo10 odoo10.0 Odoo Odoo10.0
Imagine profil
Imagine profil
2
ian. 18
5033
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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