Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Error when activating "Alerts by products or supplier"

Subscriure's

Get notified when there's activity on this post

This question has been flagged
errorv7customizationpurchase_order
1 Respondre
7102 Vistes
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)
Best Answer

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.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
How To: Add Internal Reference (code) on purchase orders Solved
v7 purchase_order
Avatar
Avatar
Avatar
Avatar
3
d’abr. 24
16476
Error creating a Purchase order
error purchase_order
Avatar
Avatar
2
d’ag. 19
3930
[8] error while try to duplicate purchase request
error purchase_order
Avatar
2
de juny 17
3967
Broken Pipe error when trying to view module's description
error v7
Avatar
0
de març 15
8673
What is "ValueError: No such external ID currently defined in the system: note.note_stage_01"?
error v7
Avatar
0
de març 15
4364
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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