Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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 add quantity stock for all locations for each product in view tree openerp

Suscribirse

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

Se marcó esta pregunta
1 Responder
8492 Vistas
Avatar
oussama

Hi

how to add quantity of  stock for all locations in  any product to view tree 

Thanks

 

0
Avatar
Descartar
Avatar
Ivan
Mejor respuesta

Oussama, when you say 'add' is to include it in the tree view or to increase the quantity?  If you need to include the quantity field (there are 2 quantity fields) you just need to include it in the product's tree view.  The fields name are qty_available and virtual_available.  The virtual_available includes all potential (not completed) movements while qty_available includes only completed movements.  If you didn't specify anything else you get the total (in - out) movement into all locations that are attached to Warehouses' Stock location including their children.  In principle this is the stock that the company holds.  Any location that are considered company's stock should be within the Warehouse's Stock location structure.

 

If you want to increase the quantity, you need to do it through export-import of stock.move.  Each product and location pairs are increased using one stock.move record.

0
Avatar
Descartar
oussama
Autor

Thanks john, My question is how to include quantity of product for all location (for example i have location "A" with qty_available 30 and lacation "B" with qty_available 50 , I want to display in the view tree of model product.product the qty_available for location "A" and qty_available for location "B" for each product. thanks a lot

Ivan

Oussama, what I can think on top of my head is to create a function field which returns the data that you want. Unfortunately I don't think it can be made into a tabulized layout (cross-tab query if you understand it). A very simple implementation is a function field of type text that will return the name of locations with qty_available and the qty_available. I would imagine that this would need quite a bit of processing power and time, though.

OdooBot
Thanks John
I created this function but it not working
def get_stock_locations(self, cr, uid, ids, field_names=None, arg=None, context=None):
        res={}
        if not ids: return result
        location_obj = self.pool.get('stock.location')
        count = location_obj.search(cr, uid, [('usage', '=', 'internal'),('company_id', '=', 'sousse1')], context=context)
        for id in count:
            for record in location_obj.browse(cr, uid, id, context=context):
                res[record.a] = {'sousse1' : 0.0}
                res[record.a]['sousse1'] =  record.stock_real
        return res
'sousse1': fields.function(get_stock_locations, type='float', string='Sousse1'),
Thanks a lots

2014-11-03 12:11 GMT+01:00 John Doe <niecw@mail.odoo.com>:

Oussama, what I can think on top of my head is to create a function field which returns the data that you want. Unfortunately I don't think it can be made into a tabulized layout (cross-tab query if you understand it). A very simple implementation is a function field of type text that will return the name of locations with qty_available and the qty_available. I would imagine that this would need quite a bit of processing power and time, though.

--
John Doe
Sent by Odoo Inc. using Odoo about Forum Post False

Ivan

You need to elaborate what do you mean by not working. The code that you have crafted will show the monetary value (not quantity) of the stock in the last internal location in company_id that is equal to 'sousse1'. Now, do you have company which ID is 'sousse1' (I doubt it because company_ids are integer)? Do you have any location which belong to that company? Do you have any product in that location?

OdooBot
Hi Jhon
Yes i have a company name is 'sousse1' (company_id is a field many2one) and i have a location in this company .
Thanks

2014-11-04 17:00 GMT+01:00 John Doe <niecw@mail.odoo.com>:

You need to elaborate what do you mean by not working. The code that you have crafted will show the monetary value (not quantity) of the stock in the last internal location in company_id that is equal to 'sousse1'. Now, do you have company which ID is 'sousse1' (I doubt it because company_ids are integer)? Do you have any location which belong to that company? Do you have any product in that location?

--
John Doe
Sent by Odoo Inc. using Odoo about Forum Post False

Ivan

It's a bit unusual to search by a specific company. In a single-company situation, it does not matter if you filter by company or not. In a multi-company situation, filtering by a specific company instead of the company the user is currently in may lead into cross-company data inconsistency (a transaction that is made with data from various companies). It is more usual to filter by the company the user is currently logged into. To do so, you can use the following domain: [('usage', '=', 'internal'),('company_id', 'child_of', user.company_id.id)]. But, again your code will show the monetary value (not quantity) of the stock in the last internal location in the company that the user is logged into. If you want to show the total of the monetary value in all locations, you need to aggregate record.stock_real. So use res[record.a] += record.stock_real. Put the res[record.a] = {'sousse1' : 0.0} outside the for loop but assign a 0.0 instead. If you want to show the quantity per location, as I've mentioned before you need to text field instead of float. Then you can construct a string with the location's name and value. If you want to show the quantity instead of monetary value, use product.product's qty_available. You need to browse the product several times with different context. Read the get_product_available method in stock/product.py to understand the working of qty_available. (get_product_available is the method called to calculate qty_available).

OdooBot
Hi Jhon

In my situation i have  a multi company and i want to display only the quantity stock of company "sousse1"



Thanks


2014-11-05 1:46 GMT+01:00 John Doe <niecw@mail.odoo.com>:

It's a bit unusual to search by a specific company. In a single-company situation, it does not matter if you filter by company or not. In a multi-company situation, filtering by a specific company instead of the company the user is currently in may lead into cross-company data inconsistency (a transaction that is made with data from various companies). It is more usual to filter by the company the user is currently logged into. To do so, you can use the following domain: [('usage', '=', 'internal'),('company_id', 'child_of', user.company_id.id)]. But, again your code will show the monetary value (not quantity) of the stock in the last internal location in the company that the user is logged into. If you want to show the total of the monetary value in all locations, you need to aggregate record.stock_real. So use res[record.a] += record.stock_real. Put the res[record.a] = {'sousse1' : 0.0} outside the for loop but assign a 0.0 instead. If you want to show the quantity per location, as I've mentioned before you need to text field instead of float. Then you can construct a string with the location's name and value. If you want to show the quantity instead of monetary value, use product.product's qty_available. You need to browse the product several times with different context. Read the get_product_available method in stock/product.py to understand the working of qty_available. (get_product_available is the method called to calculate qty_available).

--
John Doe
Sent by Odoo Inc. using Odoo about Forum Post False

Ivan

Then you can try to use ['company_id.name', '=', 'sousse1'] instead. There are 2 catches. Catch No. 1, it will search by Company's name, so if the Company's name changed, the filter will fail. It is better to use XML ID, however the implementation will be quite different. Catch No. 2, if the user logs into a company that does not have access to 'sousse1', then the view may not be displayed at all due to permission error.

OdooBot
First in my situation the company can not changed the name because it is a static setting  ,second i want to display the quantity of stock only for admin user .
Thanks a lots.

2014-11-07 7:18 GMT+01:00 John Doe <niecw@mail.odoo.com>:

Then you can try to use ['company_id.name', '=', 'sousse1'] instead. There are 2 catches. Catch No. 1, it will search by Company's name, so if the Company's name changed, the filter will fail. It is better to use XML ID, however the implementation will be quite different. Catch No. 2, if the user logs into a company that does not have access to 'sousse1', then the view may not be displayed at all due to permission error.

--
John Doe
Sent by Odoo Inc. using Odoo about Forum Post False

Ivan

Well those would be good restrictions to have. If you want to display the quantity only to admin, you can create a group (with proper XMLID) and make that field visible only to that group. And make sure that only admin belongs to that group. Note that although admin may have access to all company, at any point in time the admin user need to log in to a company. If the company admin user logs into does not have access to sousse1 company, the user still may get an error.

OdooBot
Hi Jhon
I don't have a problem with the permission of user, my question is how to display the quantity of  stock in  company "sousse1"  for  the tree view of the product,
So i use a simple code to get the quantity from the model stock.location.but it not worked.


class product_product(osv.osv):
    _inherit = 'product.product'

def get_stock_location(self, cr, uid, ids, name, args, context=None):
        result = {}
        if not ids: return result       
        location_obj = self.pool.get('stock.location')
        count = location_obj.search(cr, uid, [('usage', '=', 'internal'),('company_id.name','=','sousse1')], context=context)   
        result={'stock_real':0}
        for record in location_obj.browse(cr,uid,count):   
            result[record.id]['stock_real']= record.stock_real    
        return result

_columns={'sousse1' : fields.function(get_stock_location, type='float', method=True, string='sousse1')}
Thanks.

2014-11-07 11:38 GMT+01:00 John Doe <niecw@mail.odoo.com>:

Well those would be good restrictions to have. If you want to display the quantity only to admin, you can create a group (with proper XMLID) and make that field visible only to that group. And make sure that only admin belongs to that group. Note that although admin may have access to all company, at any point in time the admin user need to log in to a company. If the company admin user logs into does not have access to sousse1 company, the user still may get an error.

--
John Doe
Sent by Odoo Inc. using Odoo about Forum Post False

Ivan

Sorry Oussama, if you cannot elaborate further than "it not worked", I'm afraid I can't help you further.

OdooBot
Thank you very mush Jhon for your help.

2014-11-08 3:54 GMT+01:00 John Doe <niecw@mail.odoo.com>:

Sorry Oussama, if you cannot elaborate further than "it not worked", I'm afraid I can't help you further.

--
John Doe
Sent by Odoo Inc. using Odoo about Forum Post False

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

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

Registrarse
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar totalmente integrado.

Sitio web hecho con

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