Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Problem with many2one field in models which inerit res.partner

Odoberať

Get notified when there's activity on this post

This question has been flagged
many2oneinherit
2 Replies
17242 Zobrazenia
Avatar
ghofrane

Hi all,

I want to add new field (many2one) in form view of res.partner but i got ERROR DataError: invalid input syntax for integer: "default" LINE 1: ...om.id FROM "travel_room" WHERE travel_room.id IN ('default')... :


in my model i create partner.py :

from osv import osv,fields

class partner(osv.osv):

_inherit = 'res.partner'
_columns = {
    'hotel' : fields.boolean('Hotel'),
    'type' : fields.many2one('travel.room', 'type de la chambre', change_default=True, select=True, track_visibility='always', ondelete="cascade"),
}

partner()


and my partner_view.xml :

<openerp> <data> <record model="ir.ui.view" id="partner_hotel_form_view">

    <field name="name">partner.hotel.name</field>
    <field name="model">res.partner</field>  
    <field name="inherit_id" ref="base.view_partner_form" />    
    <field name="arch" type="xml">
   <data>
   <field name="supplier" position="after">
    <field name="hotel" />
   </field>
       <field name="customer" position="after">
    <field name="type" />
   </field>
   </data>
    </field>        
</record>

</data> </openerp>


and here my class travel_room :

class travel_room(osv.osv):

_name = 'travel.room'

_columns = {
    'product_id' : fields.many2one('product.product', 'Type de la chambre', required=True, change_default=True, select=True, track_visibility='always', ondelete="cascade"),
    'name' : fields.related('product_id', 'name', type='char', size=128, string='Product Name'),
    'room_desc' : fields.many2one('product.category', 'Descripcion', required=True, ondelete='cascade'),
    'cost_price' : fields.float('Prix de revient', digits=(6,3), help="Prix de revient"),
    'sale_price' : fields.float('Prix d\'achat', digits=(6,3), help="Prix d'achat"),
}
_defaults = {
}

travel_room()

any one can help me Please! Thank you

1
Avatar
Zrušiť
Brett Lehrer

Any reason for the blank _defaults dictionary? What version are you running? You could run the server with the command line option --log-sql to expand on what that full statement is.

ghofrane
Autor

Hi Brett, i'm using version 7 of openerp , I removed the blank _defaults dictionary and I got same error : 2013-05-16 09:14:46,340 6896 ERROR test openerp.sql_db: bad query: SELECT travel_room."product_id",travel_room."sale_price",travel_room."cost_price",travel_room."room_desc",travel_room.id FROM "travel_room" WHERE travel_room.id IN ('default') ORDER BY id Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130331_231656-py2.7.egg/openerp/sql_db.py", line 22

Avatar
Brett Lehrer
Best Answer

The problem is that the field 'type' already exists in res.partner. Not normally a big deal, but it's also given default values from the base module, which means that if you inherit res.partner and define 'type' differently but don't change the _defaults dictionary to stop inserting 'contact' or 'default', this error will occur.

Just change the name of your 'type' field to something like 'hotel_type' - it's more explicit and pythonic anyway, but also fixes your problem. Also cleaned up the view a bit for organization so that the hotel_type is hidden when 'hotel' is False.

partner.py: from openerp.osv import osv,fields

class partner(osv.Model):
    _inherit = 'res.partner'
    _columns = {
        'hotel': fields.boolean('Hotel'),
        'hotel_type': fields.many2one('travel.room', 'type de la chambre', change_default=True, select=True, ondelete='cascade'),
    }
partner()

partner_view.xml:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="partner_hotel_form_view">
    <field name="name">partner.hotel.name</field>
    <field name="model">res.partner</field>  
    <field name="inherit_id" ref="base.view_partner_form" />
    <field name="arch" type="xml">
        <data>
            <xpath expr="//group/field[@name='supplier']" position="after">
                <field name="hotel" />
                <field name="hotel_type" attrs="{'invisible': [('hotel','=',False)]}"/>
            </xpath>
        </data>
    </field>
</record>
</data>
</openerp>
0
Avatar
Zrušiť
ghofrane
Autor

Thank you very much Brett for your answer but when i add or change any field in partner.py i see this ERROR! 2013-05-16 14:40:46,119 16911 ERROR test openerp.netsvc: column res_partner.hotel_type does not exist LINE 1: ..._partner."debit_limit",res_partner."signup_token",res_partne... it's from yestreday :( Please have you a solution for this Error ?

ghofrane
Autor

Even when i add any other field in my partner.py i get the same Error, i can't understand why ?!

Brett Lehrer

Have you reloaded your module? Changing the field after it's initialized means it needs to be reloaded. Or if that doesn't work, try on a fresh database to see what happens.

ghofrane
Autor

with a fresh database it work! Brett Please can you tell me if there is a possibility to clean the database after i delete any field from .py file ? because every time i delete a field and i check the database with pgadmin3 i see the column named with the that field and with the word _moved1 or _moved_2 ... for example type_moved1 !

ghofrane
Autor

and Thank you very much again :))

Brett Lehrer

I don't think it's possible to automatically do that, since it tends to just ignore unused columns rather than drop them completely. It's fine to leave them in as you're developing and testing, just make a new database and import data once you're ready to move to production. If you really want to drop a column, you'd have to do it manually in pgAdmin through the menus or with this SQL statement format: "ALTER TABLE my_table DROP my_obsolete_field;"

ghofrane
Autor

Thank you Brett for your quick and good answer :)

Avatar
ghofrane
Autor Best Answer

Hi Brett, i'm using version 7 of openerp , I removed the blank _defaults dictionary and I got same error : 2013-05-16 09:14:46,340 6896 ERROR test openerp.sql_db: bad query: SELECT travel_room."product_id",travel_room."sale_price",travel_room."cost_price",travel_room."room_desc",travel_room.id FROM "travel_room" WHERE travel_room.id IN ('default') ORDER BY id Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20130331_231656-py2.7.egg/openerp/sql_db.py", line 226, in execute res = self._obj.execute(query, params) DataError: invalid input syntax for integer: "default" LINE 1: ...om.id FROM "travel_room" WHERE travel_room.id IN ('default')...

Please can anyoune help me! i just want to know if it's possible to add field.many2one('my.model') in class which inherit res.partner knowing that 'my.model' contain field.many2one('product.product'). i(m using version 7 of openerp

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
many2one field in inherited class ?
many2one inherit
Avatar
0
mar 15
4815
value not pass from many2one field to form
many2one
Avatar
Avatar
Avatar
Avatar
3
sep 25
2445
Display values of dropdown in a many2one field Solved
many2one
Avatar
Avatar
2
feb 25
7084
How to do Prototpye inherit in odoo
inherit
Avatar
Avatar
Avatar
Avatar
Avatar
4
mar 24
4614
Inheritance for account.financial.report model?
inherit
Avatar
Avatar
1
okt 23
6581
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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