Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Cervecería
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y soporte técnico
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Explorar todos los sectores
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Servicios para partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
sale.order.formpartner_iddefault_getodoo10Odoo
1 Responder
15278 Vistas
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)
Mejor respuesta

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....!!

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo - Click event customization in list view
odoo9.0 odoo10 Odoo
Avatar
0
ago 17
3349
default_get() from sale.order.line Odoo 10
sequence sale.order.line default_get odoo10
Avatar
0
nov 18
6816
Selection Field in default_get
fields selection default_get odoo10
Avatar
1
jun 18
4000
default_get : return several values ?
wizard default_get tree_view odoo10
Avatar
Avatar
1
jun 17
5573
Validation Error while creating partial invoice from sales order in Odoo 10
odoo odoo10 odoo10.0 Odoo Odoo10.0
Avatar
Avatar
2
ene 18
5042
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones empresariales de código abierto que cubre todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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