Friday, 18 July 2014

Odoo/ OpenERP Common Errors

From last one month started working on OpenERP. While customizing code daily facing one or the other issue. So thought of keeping all of them at one place with solutions for future use and may be can help someone else as well :

1) AttributeError: 'NoneType' object has no attribute '_columns'

Solution : Problem is with your __openerp__.py file. Check depends attribute.

Reference Links :
http://stackoverflow.com/questions/10565288/attributeerror-nonetype-object-has-no-attribute-columns
http://forum.openerp.com/forum/topic24199.html

2) Openerp : new module is not showing into module list?

Solution : If you have developed a new module and it's in the addons folder but still not showing in the module list than follow following steps :

a) Restart OpenERP server by using command :

./openerp-server --addons-path=XXXX/XXXXXXX/addons/ (path of addons directory)

b) Go to the browser and open

localhost:8069 or 127.0.0.1:8069

c) Login into OpenERP; Go to Settings menu; Users; Select your user, edit it and check the check-box of 'Technical Features', save it and reload the web page.

d) Again Go to Settings, you will find two more options under Modules section

  • Update Modules List
  • Apply Scheduled Upgrades

Click on 'Update Modules list' option. Update modules.

e) Now search your module using 'Installed Modules' option.

That's it.

Reference Links :

3) Model XXX is declared but cannot be added/loaded

Solution : Problem is with xxx model entry in ir_model table.

a) Login to PostgeSQL database using psql or pgAdmin III

b) Run following commands :

Delete from ir_model_constraint where model=(Select id from ir_model where name='xxx');

Delete from ir_model where name='xxx';

Hopefully this will fix your problem.

Reference Links :
http://openerp-community.2306076.n4.nabble.com/Openerp-community-Openerp-table-cleanup-td4642465.html

4) KeyError: 22

Solution: Most of the times this error is due to the wrong way of returning values from function. For more information, please check following reference link:

Reference Link:
http://stackoverflow.com/questions/15102388/how-add-a-function-in-openerp-7/15132719

Many more to come.....

Saturday, 5 July 2014

Odoo/ OpenERP: Customize one2many relational field

I was working on one2many relational field to integration one functionality. Worked on python code and then wrote an xml file for the same. Restarted my server. It showed me the row with headers and 'Add an item' button. When clicked on that it opened a pop-up to provide inputs. It shows all the fields with in sequence of it's own.


Q1. I need input fields in other sequence or don't need all fields.

A.   In xml you would have wrote code like this :

<field name="dirtyhandsphp" widget="one2many_list" colspan="4" nolabel="1">
<tree string="Details">
             <field name="field1" />
             <field name="field2" />
                     ---------------------------------------------
             <field name="designation" />
        </tree>                                                    
</field>

Add form section inside and mention all the fields you needed, as follow :

<field name="dirtyhandsphp" widget="one2many_list" colspan="4" nolabel="1">
<tree string="Details">
             <field name="field1" />
             <field name="field2" />
                     ---------------------------------------------
             <field name="designation" />
        </tree>
        <form string="Details" editable="bottom">
             <field name="field1" />
             <field name="field2" />
                     ---------------------------------------------
             <field name="designation" />
        </form>                                            
</field>

Q2. Fields are few so want to edit at the same place. No separate pop-up.

A. Add editable attribute to tree tag as follow

<tree string="Details" editable="bottom">

or

<tree string="Details" editable="top">


Thanks!!!!!!!! Enjoy Programming:)


Friday, 4 July 2014

Odoo/OpenERP: Custom unique name constraint with ignore case

#custom unique name constraint with ignore case

def _check_unique_insesitive(self, cr, uid, ids, context=None):

        list_ids = self.search(cr, uid , [], context=context)

        lst = [list_id.name.lower() for list_id in self.browse(cr, uid, list_ids, context=context) if list_id.name and list_id.id not in ids]

        for self_obj in self.browse(cr, uid, ids, context=context):
            if self_obj.name and self_obj.name.lower() in lst:
                return False
            return True


Use as following in your class :

_constraints = [(_check_unique_insesitive, <error_message>, ['<field_name>'])] 

e.g : _constraints = [(_check_unique_insesitive, 'Name already exists', ['name'])] 


Thanks!!!!!!!!!! Enjoy Programming :)


Reference Link : http://stackoverflow.com/questions/13263507/openerp-unique-constraint

Wednesday, 2 July 2014

Odoo/OpenERP Warning : invalid module names, ignored

Create a new module and new class. After adding 2 variables in class, I tried to restart OpenERP server with following command :

Command : $./openerp-server -u <module_name> -d <db_name>

Example : $./openerp-server -u my_training -d training

Server got started but showed me following warning message on console :

Warning :  invalid module names, ignored

Checked code and followed all necessary steps to check each and everything but was not getting any clue. After some time found a link and ran following command on console :

Command : $./openerp-server -u base -i <module_name> -d <db_name>

Example : $./openerp-server -u base -i my_training -d training

It worked. What this command will do is; it will install all the base modules and update your new module as well.

I feel like this solution is good but not the best. If someone else is having better one please don't hesitate to post as comments.

Thanks!!!!!! Enjoy Programming :)

Reference Link : https://www.odoo.com/forum/Help-1/question/is-Update-Module-List-from-command-line-possible-54578

Gmail: Download blocked file

Hi, today we are going to learn, how to download blocked file in gmail. Sometimes you see following message in gmail: and you can...