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

Problem creating many2many relationship with product.template

Subscriure's

Get notified when there's activity on this post

This question has been flagged
2 Respostes
7516 Vistes
Avatar
Nathan Beck

I am trying to create a module that allows me to assign products to categories determined by external websites (for example Amazon and eBay categories). Each external category can have many products in it, and each product can be in many categories, one for each external site. Everything works until I try to create a many2many relationship between my external_categories and product.template.

My external_categories class looks a lot like the category class in product, it's name is: _name = "external_categories.category"

The class I am trying to create the many2many relationship in is:

class product_template(osv.osv):
    _inherit = "product.template"
    _columns = {
        'ext_cat_prod_ids': fields.many2many('external_categories.category', 'ext_cat_prod_rel', 'prod_id', 'ext_cat_id', 'External Categories'),
    }

product_template()

I know that I am inheriting product.template, and in the XML sample below I am using the model product.product. I have tried every combination of the two (product.template and product.product) in both locations without luck.

I am trying to add a tab to the product page on the front end. In this tab I will be able to add the product to multiple categories, my XML is:

<record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">6</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="External Categories">
                        <group name="properties">
                            <group>
                                <field name="ext_cat_prod_ids" colspan="2" widget="many2many_tags"/>
                            </group>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>

When I try to install the module I get an error, this is from the log:

2014-07-27 19:33:46,736 1396 ERROR newVeroTemp openerp.osv.orm: Can't find field 'ext_cat_prod_ids' in the following view parts composing the view of object model 'product.product':
 * product.normal.form.inherit

Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model
2014-07-27 19:33:46,736 1396 ERROR newVeroTemp openerp.addons.base.ir.ir_ui_view: Can't render view  for model: product.product
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_ui_view.py", line 126, in _check_render_view
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\stock\product.py", line 441, in fields_view_get
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 2278, in fields_view_get
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 1955, in __view_look_dom_arch
except_orm: ('View error', u"Can't find field 'ext_cat_prod_ids' in the following view parts composing the view of object model 'product.product':\n * product.normal.form.inherit\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model")
2014-07-27 19:33:46,740 1396 ERROR newVeroTemp openerp.tools.convert: Parse error in file:///C:/Program Files (x86)/OpenERP 7.0-20140622-231040/Server/server/openerp/addons/external_categories/external_categories.xml:142: 
<record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">6</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="External Categories">
                        <group name="properties">
                            <group>
                                <field name="ext_cat_prod_ids" colspan="2" widget="many2many_tags"/>
                            </group>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>
Traceback (most recent call last):
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\convert.py", line 852, in parse
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\convert.py", line 819, in _tag_record
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_model.py", line 971, in _update
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_ui_view.py", line 103, in create
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 4551, in create
  File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\orm.py", line 1562, in _validate
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2014-07-27 19:33:46,740 1396 ERROR newVeroTemp openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

Thank you in advance for any help our guidence you can provide in the use of many2many relationships.

 

-1
Avatar
Descartar
Avatar
Nathan Beck
Autor Best Answer

Thank you Jagdish Panchal. I tried your code. Unfortunately, I still get basically the same error: Can't find field 'ext_cat_prod_ids' in the following view parts composing the view of object model 'product.product'

-- UPDATE, PROBLEM SOLVED --

I updated Odoo from 7 to 8 and everything works fine now with the code exactly as it was before (in the original questions). It must be something wrong with Odoo 7 that was causing the problem.

0
Avatar
Descartar
Jagdish Panchal

I have update ans please try it.

Avatar
Jagdish Panchal
Best Answer

Hi,

Try below code

Py file

class product_product(osv.osv):
    _inherit = "product.product"
    _columns = {
        'ext_cat_prod_ids': fields.many2many('external_categories.category', 'ext_cat_prod_rel', 'prod_id', 'ext_cat_id', 'External Categories'),
    }

product_product()

xml file

<record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit</field>
            <field name="model">product.product</field>
            <field name="priority">6</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="External Categories">
                        <group name="properties">
                            <group>
                                <field name="ext_cat_prod_ids" colspan="2" widget="many2many_tags"/>
                            </group>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>

 

 

 

0
Avatar
Descartar
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
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