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

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

Subscriure's

Get notified when there's activity on this post

This question has been flagged
sale.order.formpartner_iddefault_getodoo10Odoo
1 Respondre
15282 Vistes
Avatar
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
Avatar
Descartar
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

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
Avatar
Descartar
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!

Registrar-se
Related Posts Respostes Vistes Activitat
Odoo - Click event customization in list view
odoo9.0 odoo10 Odoo
Avatar
0
d’ag. 17
3355
default_get() from sale.order.line Odoo 10
sequence sale.order.line default_get odoo10
Avatar
0
de nov. 18
6816
Selection Field in default_get
fields selection default_get odoo10
Avatar
1
de juny 18
4000
default_get : return several values ?
wizard default_get tree_view odoo10
Avatar
Avatar
1
de juny 17
5574
Validation Error while creating partial invoice from sales order in Odoo 10
odoo odoo10 odoo10.0 Odoo Odoo10.0
Avatar
Avatar
2
de gen. 18
5044
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