This question has been flagged
3 Replies
8644 Views

hi every one,

I have created  a table product_aaaaa_bbbb on openerp database, but i can't request data from the same table, i give an error like this:

warning -- Object Error Object product.aaaaa.bbbb doesn't exist

how i can insert/select data to/from my new table?

thx in advance.

Avatar
Discard

please add your code here then wl chk.......

Author

just i have create table within Postgres

Best Answer

Did you use the regular class to add a table? If not, then do so. It is no use to just create tables within Postgres assuming Odoo can reach them :) .

[EDIT]

class product_aaa_bbb(model.Models)

    _name = 'product.aaa.bbb'

<< ALL of your stuff here>>

 

This should create a table for product_aaa_bbb in your postgres database, which you can reach by using self.pool.get('product.aaa.bbb') from Odoo.

Avatar
Discard
Author

just i have create table within Postgres, any guide to how create it?

I edited my answer.

Best Answer

Hi,

Here I explain how to create a basic module in openerp .please follow the folder structure of modules ,this way you can create table and add datas inside the table.(model=postgres db,view-xml,python=controller....,This is the basic method )

 

init.py----------------------

import barcode_info

 

opeenrp.py----------------------

 

{
'name':'Barcode Generator',
'version':'0.0',
'author':'Libu',
'depends':['base'],
'update_xml' : ['barcode_view.xml'
                                ],
'installable':True,
'category':'General',
'description':'Barcode Geneartor Module',
'website':'',
'demo':[]
}

 

barcode_info.py-----------------

from osv import osv,fields


class barcode_info(osv.osv):
   
    _name='barcode.info'
    
    _columns={
            
             'barcode_id':fields.integer('Product code'),
             'barcode_ref':fields.integer('Reference #'),
             'barcode_price':fields.integer('weight/price'),
             'barcode_name':fields.integer('Barcode'),
             }
       
    def button_generate(self,cr,uid,ids,context=None):
        print " put your code here "
        return True
    
barcode_info()

 

barcode_view.xml----------------------

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        
        <record id="barcode_info_tree" model="ir.ui.view">
                <field name="name">barcode.information</field>
                <field name="model">barcode.info</field>
                <field name="arch" type="xml">
                    <tree string="Barcode">                                    
                        <field name="barcode_id"/>                
                        <field name="barcode_ref"/>
                        <field name="barcode_price"/>
                        <field name="barcode_name"/>
                        
                    </tree>
                </field>                
        </record>
    
        
                <record id="barcode_info_form" model="ir.ui.view">
                <field name="name">barcode.information</field>
                <field name="model">barcode.info</field>
                <field name="arch" type="xml">
                    <form string="Barcode Information">                                    
                        <field name="barcode_id"/>                
                        <field name="barcode_ref"/>
                        <field name="barcode_price"/>
                        <field name="barcode_name"/>
                        

                            <button name="button_generate" string="Generate"
                         class="oe_highlight" type="object"/>    
                             
                             </form>
                         
                     
                </field>                
        </record>
        
        
        <record id="barcode_id_action" model="ir.actions.act_window">
        <field name="name">Barcode Geneartor</field>
        <field name="res_model">barcode.info</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
        
        
        
        <menuitem id="menu_barcode_main" name="Barcode" />
        <menuitem id="menu_barcode_sub" name="Barcode Generation" parent="menu_barcode_main"/>
        <menuitem id="menu_barcode_sub1" name="Generate" parent="menu_barcode_sub" action="barcode_id_action"/>
        

                                </data>
        
            </openerp>

Avatar
Discard
Author

thank you Libu Koshy

Author Best Answer

i have a new module with name product_aaaa_bbbb

__init__.py

import product_aaaa_bbbb

__openerp__.py

{
    'name': 'product aaaa bbbb',
    'version': '0.1',
    'category': 'stock',
    'description': """This module is for .....""",
    'author': 'author',
    'website': 'http://www.site.com/',
    'depends': ['stock','product'],
    'init_xml': [],
    'update_xml': [],
    'demo_xml': [],
    'installable': True,
    'active': True,
}

product_aaaa_bbbb.py

from openerp.osv import osv, fields

class product_aaaa_bbbb(osv.osv):
    _name = "product.aaaa.bbbb"
    _description = "This table is for ......"
    _columns = {
        'location_id': fields.many2one('stock.location','Location',ondelete='no action',required=True,readonly=False),
        'product_id': fields.many2one('product.product','Product',ondelete='no action',required=True,readonly=False),
        'product_qty': fields.integer('Product Quantity',required=True,readonly=False)
    }
product_aaaa_bbbb()

but when request data from new table i get the same error:

warning -- Object Error Object product.aaaa.bbbb doesn't exist

Avatar
Discard