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
    • eLearning
    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
    • Información
    • 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 taberna
    • 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
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • 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
    Browse all Industries
  • 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
    • Services for 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

Related field wrong value with multi-company

Suscribirse

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

Se marcó esta pregunta
relatedstock_moverelated_fieldsmulti-companyodoo12
1 Responder
4914 Vistas
Avatar
Aïmane

Hello, 

I am on odoo 12.

I have two companies and different quantities for the same product.

I have a custom model with a field related to the product qty_available 

qty_available = fields.Float(related='product_id.qty_available', string="Qté Disponible")

The problem is that I got the quantity of both company in my view.

I've tried this option :
qty_available = fields.Float(related='product_id.qty_available', string="Qté Disponible", company_dependent=True)
Nothing changes.
The closest I can get to the issue is in the module stock, product.py, def _get_domain_locations(self):
The instruction line 205 

Warehouse.search([]).ids
It returns current company locations and the other company locations. 

I know that there is something related to the context but I can't figure out what, there is something I am missing concerning multi company, your help would be very appreciated :)

Most of my knowledge is coming from this article: https://www.cybrosys.com/blog/how-to-handle-multi-company-odoo-custom-module 


For the moment I've got around the issue using compute attribute just like that, its working fine but I am not fully satisfied, I want to understand :) Thank you in advance

qty_available = fields.Float(string="Qté Disponible", store=False, readonly=True, compute='_compute_qty_available')

def _compute_qty_available(self):
for line in self:
 
  line.qty_available = line.product_id.qty_available
0
Avatar
Descartar
Avatar
Begineer
Mejor respuesta

Hi, 

I hope you want to show the quantity of the product related to your specified company , so try this,

def _compute_qty_available(self):

    for line in self:

        In your case you can go with, your currently logged in users company //

        line.qty_available = line.product_id.with_context(force_company = self.env.user.company_id.id).qty_available

                                                                                or         
        you can give your own defined company  //

        company_id = your_company_id

        line.qty_available = line.product_id.with_context(force_company = company_id.id).qty_available


For your info,

line.qty_available = line.product_id.with_context(lot_id=line.prodlot_id and line.prodlot_id.id or False, location=each.src_location_id.id).qty_available

       Here lot is used for tracking purpose , for tracking the product quantity in the specific lot and in specific location

       you may use this if your product has tracking options enabled.


Hope it helps,

Thanks

1
Avatar
Descartar
¿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
How update One2many records regarding to another one related to same modue
one2many multiple related related_fields odoo12
Avatar
0
jun 19
4034
Can I stop calculating itself a related field if state != draft
related_fields odoo12
Avatar
0
oct 20
2765
Related field not saving
v8 related related_fields
Avatar
Avatar
Avatar
2
abr 24
9778
can we relate a field to a related field ? Resuelto
fields related related_fields
Avatar
1
mar 15
4159
Could not edit origin field in stock move. What happen if no related object for related field is found?
stock_move related_fields fields_related
Avatar
Avatar
1
mar 15
6457
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 de código abierto que cubren 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 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