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
    • 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 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

odoo 10 - set lead times per product, per customer

Suscribirse

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

Se marcó esta pregunta
lead_time10.0
1 Responder
2993 Vistas
Avatar
Dominic Pain

My client has a requirement to set lead times on products, on a per customer basis. For instance:

The product is a search report on coal mining activity in the vicinity of a property. The standard lead time is 5 days.

Customer A asks for a search report on coal mining activity around a property. We really like Customer A, so we have decided that they will have that report within 3 working days. The customer specific lead time should be set to -2 ( 2 days less than standard)

Customer B asks for a search report on coal mining activity around a property. They always pay their bills late, though, so we have secretly decided that they're at the back of the queue - they will have that report within 7 working days. The customer specific lead time should be set to 2 (2 days more than standard)

What I want to do is to add an extra tab to the res.partner view, called Lead Times, and have the product list (including variants) display in a table there. Each row will have 

<tr>
    <td>product name</td>     <td><input type="text" value="a number"></td>
<tr>

This is where I've got to so far:

The model (models/customer.py)

# encoding=utf8
from odoo import fields, api, models
import logging
logging.basicConfig(level=logging.DEBUG)
from datetime import datetime, timedelta
 

class Customer(models.Model):
    _name = 'lead_times'
    partner_id = fields.Many2one('res.partner')
    product_id = fields.Many2one('product.product')
    lead_time = fields.Integer('lead_time')

class MsukPartner(models.Model):
    _inherit = 'res.partner'
    lead_times = fields.Many2one(compute='_get_lead_times', store=False)
    def _get_lead_times(self):
        lead_time_rows = self.env['lead_times'].search([('partner_id', '=', 780)])
        return lead_time_rows

That has produced a table which looks like this:.

miningsearchesuk=# \d lead_times
                                      Table "public.lead_times"
   Column    |            Type             |                        Modifiers                        
-------------+-----------------------------+---------------------------------------------------------
 id          | integer                     | not null default nextval('lead_times_id_seq'::regclass)
 create_uid  | integer                     | 
 product_id  | integer                     | 
 write_uid   | integer                     | 
 write_date  | timestamp without time zone | 
 create_date | timestamp without time zone | 
 partner_id  | integer                     | 
 lead_time   | integer                     | 
Indexes:
    "lead_times_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "lead_times_create_uid_fkey" FOREIGN KEY (create_uid) REFERENCES res_users(id) ON DELETE SET NULL
    "lead_times_partner_id_fkey" FOREIGN KEY (partner_id) REFERENCES res_partner(id) ON DELETE SET NULL
    "lead_times_product_id_fkey" FOREIGN KEY (product_id) REFERENCES product_product(id) ON DELETE SET NULL
    "lead_times_write_uid_fkey" FOREIGN KEY (write_uid) REFERENCES res_users(id) ON DELETE SET NULL

miningsearchesuk=#


The view (views/res_partner_views.xml)

<odoo>
    <record id="view_partner_msuk_form" model="ir.ui.view">
        <field name="name">res.partner.msuk.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
            <notebook position="inside">
                <page string="Lead Times">
                    <group>
                        <field name="lead_times" />
                        <!--<field name="product_id" />-->
                    </group>
                </page>
            </notebook>
        </field>
    </record>
</odoo>

__init__.py

# -*- encoding: utf-8 -*-

from . import project
from . import product
from . import sale
from . import crm
from . import project_category
from . import product
from . import customer

What I see on screen:


(screenshot deleted as it was causing a 400 error from the forum, I think)


I've created a lead_time entry manually, and set a breakpoint just before _get_lead_times in customer.py. Here's the output:

> /home/miningsearchesuk/src/python/project_template/models/customer.py(21)_get_lead_times()
-> lead_time_rows = self.env['lead_times'].search([('partner_id', '=', 780)])
(Pdb) list
 16
 17         lead_times = fields.Many2one(compute='_get_lead_times', store=False)
 18
 19         def _get_lead_times(self):
 20             import pdb; pdb.set_trace()
 21  ->         lead_time_rows = self.env['lead_times'].search([('partner_id', '=', 780)])
 22             return lead_time_rows
 23
[EOF]
(Pdb) lead_time_rows
*** NameError: name 'lead_time_rows' is not defined
(Pdb) n

> /home/miningsearchesuk/src/python/project_template/models/customer.py(22)_get_lead_times()
-> return lead_time_rows
(Pdb) lead_time_rows
lead_times(1,)
(Pdb) pp lead_time_rows.read([])
[{'__last_update': '2018-07-18 09:53:01',
  'create_date': False,
  'create_uid': False,
  'display_name': u'lead_times,1',
  'id': 1,
  'lead_time': 5,
  'partner_id': (780, u'3MS Construction Ltd'),
  'product_id': (16, u'Further Site Investigation'),
  'write_date': False,
  'write_uid': False}]
(Pdb)

Can anyone give me any hints as to what to do next? How do I get my lead_time_rows to appear as I want?

Thanks

0
Avatar
Descartar
Avatar
vishalratani
Mejor respuesta

Hello Dominic,

I see that you have put in a lot of efforts on the lines of managing lead times per customer so am not sure if you would like my approach. But have you thought of this like I do:

There is a requested date and a commitment date on the quotation/ Sale order. requested date is something your customer is asking for and commitment date is coming from your system's lead times. Now you have to manage the gaps between the two dates and you would know the customer on your quotation.

Thanks

Vishal

0
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
changing the delivery lead time unit
lead_time
Avatar
Avatar
1
jul 25
942
Can't reconcile bank statement line
10.0
Avatar
Avatar
Avatar
Avatar
4
abr 20
10245
how to use field from same model Resuelto
10.0
Avatar
Avatar
1
nov 19
4819
How to post a change log message for relational One2many fields? Resuelto
10.0
Avatar
Avatar
3
oct 19
8806
How to fix: "odoo.addons.base.ir.ir_qweb.assetsbundle: This error occured while compiling the bundle 'web.assets_frontend' containing:"?
10.0
Avatar
Avatar
2
feb 18
15434
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