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

Error when activating "Alerts by products or supplier"

Suscribirse

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

Se marcó esta pregunta
errorv7customizationpurchase_order
1 Responder
7112 Vistas
Avatar
Anabela Damas

Hi,

I made some customization to OpenErp to when in Purchase Orders(PO) if I choose a Sale Order (SO) the Purchase Order Lines will get the information from Sales Order Lines. My code:

mymodule.py

class purchase_order(osv.osv):
    _columns = {
       'asd_pquotation_id': fields.many2one('sale.order','Sale Quotation', domain=[('state','in',('draft','sent'))]),
    }
    _defaults = {
        'state': 'draft',
        'asd_pquotation_id': lambda self, cr, uid, context: context.get('asd_pquotation_id', False),
    }
    def onchange_sales_order(self, cr, uid, ids, asd_pquotation_id, partner_id, pricelist_id):
        domain = []
        value = []
        if asd_pquotation_id:
            so = self.pool.get('sale.order').browse(cr,uid,asd_pquotation_id)
            for sol in so.order_line:
                vals = self.pool.get('purchase.order.line').onchange_product_id(cr, uid, ids, pricelist_id, sol.product_id.id, sol.product_uom_qty, sol.product_uom.id, partner_id)
                vals['value'].update({
                    'product_id': sol.product_id.id,
                    'state':'draft',
                    'move_ids':[],
                    'invoiced':0,
                    'invoice_lines':[]
                    })
                value.append(vals['value'])
                domain.append(vals['domain']) 
        return {'value': {'order_line': value}, 'domain': {'order_line': domain}}
purchase_order()

class sale_order(osv.osv):
    _inherit = "sale.order"
    _name = "sale.order"
    _columns = {
        'vi_contact_by': fields.selection([ ('by1','Email'), ('by2','Fax'), ('by3','Phone'), ('by4','Meeting'), ], 'Contacted by'),
        'asd_squotation': fields.one2many('purchase.order','asd_pquotation_id', 'Purchase Quotation'),
    }
sale_order()

mymoule_view.xml

   <record id="purchase_order_form_change" model="ir.ui.view">
        <field name="name">purchase.order.form.change</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_form"/>
        <field name="arch" type="xml">
        <xpath expr="/form/sheet/group/group/field[@name='company_id']" position="after">
            <field name="asd_pquotation_id" on_change="onchange_sales_order(asd_pquotation_id,partner_id,pricelist_id)"/>
        </xpath>
        </field>
    </record>

Everything was working until I check the checkbox in Settins-> Purchases the box from:

Alerts by products or supplier

So if I check this, when I try to choose a SO in the form of PO I get this error:

2013-04-15 17:11:06,423 13876 ERROR nova2 openerp.osv.osv: Uncaught exception
Traceback (most recent call last):
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 123, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 179, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 166, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/openerp-7.0/openerp/addons/infinitechoices/infinitechoices.py", line 74, in onchange_sales_order
    domain.append(vals['domain'])
KeyError: 'domain'
2013-04-15 17:11:06,424 13876 ERROR nova2 openerp.netsvc: domain
Traceback (most recent call last):
  File "/opt/openerp-7.0/openerp/netsvc.py", line 289, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp-7.0/openerp/service/web_services.py", line 614, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 169, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 123, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 179, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 166, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/openerp-7.0/openerp/addons/infinitechoices/infinitechoices.py", line 74, in onchange_sales_order
    domain.append(vals['domain'])
KeyError: 'domain'

Someone know how to fix this? Thanks

0
Avatar
Descartar
Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Mejor respuesta

I have made some changes in code. So replace your code by this:

def onchange_sales_order(self, cr, uid, ids, asd_pquotation_id, partner_id, pricelist_id):
    domain = []
    value = []
    warning_message = False
    if asd_pquotation_id:
        so = self.pool.get('sale.order').browse(cr,uid,asd_pquotation_id)
        for sol in so.order_line:
            vals = self.pool.get('purchase.order.line').onchange_product_id(cr, uid, ids, pricelist_id, sol.product_id.id, sol.product_uom_qty, sol.product_uom.id, partner_id)
            vals['value'].update({
              'product_id': sol.product_id.id,
              'state':'draft',
              'move_ids':[],
              'invoiced':0,
              'invoice_lines':[]
            })
            value.append(vals['value'])
            if vals.get('domain', False):
                domain.append(vals['domain'])
            if vals.get('warning', False):
                if not warning_message:
                    warning_message = ""
                warning_message += sol.product_id.default_code + " : " + vals['warning']['message'] + " \n\n "
    res = {'value': {'order_line': value}, 'domain': {'order_line': domain}, 'warning': {'title': 'Warning!', 'message': warning_message}}
    if warning_message:
        res.update({'warning': {'title': 'Warning!', 'message': warning_message}})
    return res

I have modified warning message also because we cannot return multiple warnings.

3
Avatar
Descartar
Anabela Damas
Autor

I get this when I go to Purchases -> Quotation ->Create : "Error: QWeb2 - template['CrashManager.warning']: Runtime Error: TypeError: Cannot read property 'data' of undefined"

Sudhir Arya (ERP Harbor Consulting Services)

Its working for me. I am not facing such error.

Anabela Damas
Autor

Still the same error nothing change.

¿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 To: Add Internal Reference (code) on purchase orders Resuelto
v7 purchase_order
Avatar
Avatar
Avatar
Avatar
3
abr 24
16509
Error creating a Purchase order
error purchase_order
Avatar
Avatar
2
ago 19
3951
[8] error while try to duplicate purchase request
error purchase_order
Avatar
2
jun 17
3979
Broken Pipe error when trying to view module's description
error v7
Avatar
0
mar 15
8686
What is "ValueError: No such external ID currently defined in the system: note.note_stage_01"?
error v7
Avatar
0
mar 15
4388
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