Skip to main content


Showing posts from 2014

Ubuntu 14.04 : Add 1280 x 1024 screen resolution

Spent around 2 hours to set new resolution for Ubuntu 14.04 and when come to know the right way it took only 5 minutes. So, writing this post so that it can save someone else's time. Following are the steps to add 1280 x 1024 screen resolution in Ubuntu 14.04 1) Create /etc/X11/xorg.conf file with following content: Section "Monitor"     Identifier    "Monitor0"     Modeline "1280x1024_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync EndSection Section "Screen"     Identifier     "Screen0"     Device         "Card0"     Monitor        "Monitor0"     SubSection "Display"         Modes       "1280x1024_60.00"     EndSubSection EndSection Section "Device"     Identifier    "Card0"     Driver        "intel" EndSection  2) Restart Ubuntu That's it. Notes : a) To get Modeline u

Odoo/OpenERP : Populate one2many list using on_change method

Following is the method to update/populate simple field value using on_change method: return {'value' : {'field_name' : <field_value>}} Most of the OpenERP developers will be aware of it. What we will do if we have to add one2many list using on_change method? For example : I want to display list of leaves allotted, leaves taken and leaves pending of an employee. So on_change employee_id I want to show related updated leave list. leave_ids is one2many field in my main table. what we have to do is as follow: leave_ids = []        for record in records:     if record:         leave_ids.append([0,0, {'holiday_status_id':record,'max_leaves':records[record]['max_leaves'],'leaves_taken':records[record]['leaves_taken'],'remaining_leaves':records[record]['remaining_leaves']}]) return {'value' : {'leave_ids' : leave_ids}} Hopefully it will help someone. If you need more detail

Odoo/OpenERP: Create multiple sequence codes from single file

You can create multiple sequence codes from single sequence file. For example, if you want to create different employee codes for 'Regular Employee' and 'Trainee Employee' you can use single sequence file and achieve your results. As follow: If you don't know at all about sequences, how to create sequence in Odoo/OpenERP, Please click here . emp_code_sequence_view.xml <?xml version="1.0" encoding="utf-8"?> <openerp> <data>     <!-- Sequences for Regular Employee code -->     <record id="emp_code_sequence" model="ir.sequence.type">           <field name="name">Employee Code</field>         <field name="code">hr.employee</field>     </record>     <record id="seq_hr_employee" model="ir.sequence">         <field name="name">Employee Code</field>         <field name=&

Odoo/OpenERP : Module files sequence in

This post is regarding, how to add module files in sequence in file. If you are not adding files in proper sequence you will face an error. For example: Wrong sequence: {     'name': 'Employee Data Module',     'version': '1.0',     'category': 'Human Resources',     'description':"""Add details of employee""",     'author':'Shiv Shankar',     'website': ' ',     'images': [],     'depends':['base','mail', 'hr',],     'data':[         'view/employee_data_view.xml',         'workflow/employee_data_workflow_view.xml',         'security/user_groups.xml',         'security/ir_rule.xml',         'security/ir.model.access.csv'     ],     'installable':True,     'auto_install':False } In above data f

Oddo/OpenERP: Overwrite ACL permissions

To overwrite ACL permission in Odoo, you have to overwrite id of that ACL record. For example by default in Employee Appraisals module Human Resource/ Officer user group is given full permissions as follow. id - access_survey_page_hr_user name - model_id:id - survey.model_survey_page group_id:id - base.group_hr_user perm_read - 1 perm_write - 1 perm_create - 1 perm_unlink - 1 and later in your customized module you decide to revoke unlink permission for that user group you have to just keep exact id and change permissions section. ACL record will be as follow: id - access_survey_page_hr_user name - model_id:id - survey.model_survey_page group_id:id - base.group_hr_user perm_read - 1 perm_write - 1 perm_create - 1 perm_unlink - 0 Hopefully it will help someone. Thanks!!!!!!!!!!!!! Enjoy Programming :) Reference Link:

Odoo/OpenERP : Call function on button

There are three ways to add functionality on button in OpenERP/Odoo: 1. Call function directly on button: You can directly call the function defined in model/class using type="object" attribute. i.e <button string="Check availability" name="check_username_availability" type="object" class="oe_highlight" /> In this case you have to define ' check_username_availablilty' function in model. 2. Using Workflow: Workflow is the most used functionality in OpenERP/Odoo to process flow of the activity. Default type of button is workflow i.e type="workflow" .  Workflow itself is an vital topic so can't talk much about this here. <button string="Accept" name="signal_accept" type="workflow" class="oe_highlight" /> 3. Using action: You have to user type="action" if you want to call any action defined in the .xml file. For example if you want to open

Odoo/OpenERP: one2one relational field example

one2one relational field is deprecated in OpenERP version>5 but you can achieve the same using many2one relational field. You can achieve it in following two ways : 1) using many2one field in both the objects ( ) 2)  using inheritance by deligation You can easily find the first solution with little search over internet so let's start with 2nd solution. Scenario :  I want to create a one2one relation between two objects of openerp hr.employee and hr.employee.medical.details What I should do  i. Add _inherits section in hr_employee class ii. Add field medical_detail_id in hr_employee class class hr_employee(osv.osv):     _name = 'hr.employee'     _inherits = {' hr.employee.medical.details ': "medical_detail_id"}     _inherit = 'hr.employee'         _columns = {              'emp_code':fields.char('Employee Code', si

Odoo/OpenERP: Generate Employee Code

Employee code can be generated in following three simple steps: 1. Create a sequence file emp_code_sequence_view.xml <?xml version="1.0" encoding="utf-8"?> <openerp>     <data>         <!-- Sequences for employee code -->         <record id="emp_code_sequence" model="ir.sequence.type">             <field name="name">Employee Code</field>             <field name="code">hr.employee</field>         </record>         <record id="seq_hr_employee" model="ir.sequence">             <field name="name">Employee Code</field>             <field name="code">hr.employee</field>            <field name="prefix">EMP</field>             <field name="padding">5</field>             <field name="company_id" eval="False"/>      

Odoo/OpenERP : _rec_name and name_get()

_rec_name = ‘name’ (by default)  where ‘name’ is field of the model. If ‘name’ field is not there then you have to assign any other filed name to this ‘_rec_name’ variable from columns. Note : If ‘name’ field is there in your columns then there is no need to specify '_rec_name'. Let’s try to dig more using an example. Case I: If you are having hr.employee module with name field and you are using it as reference in other module, say hr.employee.detail to provide other employee details then you will use it as: 'employee_id' : fields.many2one('hr.employee', 'Employee') and it will show you the employee name in selection list. But, In a company, more than one employee can share the same name. So name field can’t be used to differentiate them from each other. But, employee code will be unique for each employee. In such cases, we will take a column field like ‘emp_code’ and will assign it to ‘_rec_name’ _rec_name = ‘emp_code’ So that i

Odoo/ OpenERP: Calculate difference between two dates

from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta date_format = '%Y-%m-%d' joining_date = '2013-08-23' current_date = ( d1 = datetime.strptime(joining_date, date_format).date() d2 = datetime.strptime(current_date, date_format).date() r = relativedelta(d2,d1) print r.years print r.months print r.days Thanks!!!!!!!!! Enjoy Programming :)

File upload not working on PHP Server

Few days back, our team faced a new issue in file upload on server. It was restricting user to upload file size over 8KB while the following parameters were already set : php_value file_uploads  On php_value upload_max_filesize 200M php_value memory_limit  512M php_value post_max_size 200M php_value max_execution_time 1000 php_value max_input_time 300 but still file uploading was not working. Searched over internet and found that above problem was due to LimitRequestBody Directive of Apache. This parameter Restricts the total size of the HTTP request body sent from the client. "The LimitRequestBody directive allows the user to set a limit on the allowed size of an HTTP request message body within the context in which the directive is given (server, per-directory, per-file or per-location). If the client request exceeds that limit, the server will return an error response instead of servicing the request. The size of a normal request message body will vary greatly de

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 file. Check depends attribute. Reference Links : 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 o r c) Login into OpenERP; Go t

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

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 =, uid , [], context=context)         lst = [ for list_id in self.browse(cr, uid, list_ids, context=context) if and not in ids]         for self_obj in self.browse(cr, uid, ids, context=context):             if and 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, 'Na me already exists ', ['name'])]  Thanks!!!!!!!!!! Enjoy Programming :) Reference Link :

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 :) Referen

Creately for Diagramming

In IT world, day-to-day activities, we have to work with projects and provide some wireframes, flowcharts and other graphical diagrams to internal (seniors) and external clients. There are a lot of tools available to create all these diagrams. Few days back, from one of my senior I come to know about Creately, an online fast tool to create wireframes, flowcharts, graphical diagrams etc. You can draw almost everything using Creately. It’s really user friendly. You will create your diagram; do changes; save it there. You can export it in form of Image, PDF or SVG file. You can start using it with Google account from here: Or directly from their website: I love it the way it works. You can use Free or Paid account. In case you are using free account you have to share your diagrams publicly. That’s the only and the biggest disadvantage they are having. Thanks!!!!!!!! Enjoy Programming J

Use Google as external email service

Undoubtedly, Gmail has become a very important part of each and everyday's life. Through Google Apps, they have given freedom to use Gmail for business purpose as well. Google Apps is having feature to feel like you are sending emails through your own servers, instead of Google server. You can use email id's like , etc..  and on backend emails are sent through Gmail. Let's see how we can handle this whole thing : 1. To set up an external email, first of all, you should have domain name and it's control panel. 2. Go to link :  and setup your Google Apps account. 3. Login to your control panel and navigate to Mail Manager. Point DNS Server’s MX records to Google Apps. Add following MX entries : ASPMX.L.GOOGLE.COM with priority 1 ALT1.ASPMX.L.GOOGLE.COM with priority 5 ALT2.ASPMX.L.GOOGLE.COM with priority 5 ASPMX2.GOOGLEMAIL.COM with priority 10 ASPMX3.GOOGLEMAIL.COM with

Important links for bloggers

Add Google+ badge to blog/website. How To Create Feed URL With FeedBurner? How to reduce Blogger's feed size below FeedBurner's 512K limit? Add Live Traffic Feed to your blog/website How to Backup & Restore WordPress Thanks!!! Enjoy Programming :)

Add custom field in Odoo/OpenERP

Today, I decided to write a tutorial on topic 'Add custom field in OpenERP' and one video was exact the same i was suppose to write. So thought of sharing that only instead of reinventing the wheel. Please check here : If you found any problem in accessing the video or if you are not able to understand the steps from it, Please post you comments. Thanks!!!!!!!! Enjoy Programming :)

Odoo/OpenERP opererp-server file

Since few days, working with OpenERP backend section. I did some coding changes in Python but was not able to restart OpenERP service due to commented and wrong python file openerp-server . File was at following location of my server : /etc/init.d/openerp-server Checked over internet and didn't find any relevant answer which could have solved my problem. After spending few hours i corrected my file that's running successfully now. Please check attached file here . Download Hopefully it will someone else's issue as well. Thanks!!!!!!!!!!! Enjoy Programming :)

CakePHP TinyMCE Validation Problem

In development world, daily we face lot of problems, some are big while some are minor. Sometimes it takes a lot of time to fix small one than bigger ones. Similar to this, today I faced a small issue with TinyMCE in CakePHP. It was to set an attribute and to figure it out itself took couple of hours of mine. Then I decided to share it with my readers, thinking that it may save those couple of hours of someone else at some point of time. Problem : TinyMCE notempty validation was not working fine and it was showing following message on console. An invalid form control with name='page [description]' is not focusable Solution :  Set required attribute to be false in view file. For example : <div>                 <div class="umstyle3"><?php echo __('Page Description');?></div>                 <div class="umstyle4" ><?php echo $this->Form->input("description" ,array('rows&#

Aptana IDE

Recently, I attended GDG meet in Chandigarh and 2nd time heard about Aptana IDE. So decided to download and use the same. Downloaded Aptana Studio 3.4.2 from here , installed and run it on my machine. First screen would look like this. Aptana Studio 3.4.0 is an open source Web development IDE being used by lot of developers across world. This powerful tool is having features like intellisense, integrated debugger and good version control system that gives you the precision control to create the applications you need without wasting time or running multiple programs simultaneously. Aptana Studio 3.4.0 makes it easy to develop, test, debug and publish your applications within a single environment. If you code in PHP, Python , HTML, CSS, Ruby, Javascript or other languages, Aptana is what you need for top-quality results. If you need to move back and forth between Windows and Mac OS, Aptana makes it happen. If you have used Netbeans or Eclipse before in development, t

Magento : Admin backend 404 not found

Have you imported database to new server and you are not able to access Magento admin panel? and it's showing you 404 not found error? If yes, try to run following commands from phpmyadmin. SET FOREIGN_KEY_CHECKS=0; UPDATE core_store SET store_id = 0 WHERE code='admin'; UPDATE core_store_group SET group_id = 0 WHERE name='Default'; UPDATE core_website SET website_id = 0 WHERE code='admin'; UPDATE customer_group SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN'; SET FOREIGN_KEY_CHECKS=1; It worked for me. Hopefully, this will work for you guys as well. The reason for this error is that store_id and website_id for admin should be set to 0 (zero) . But, when you import database to new server, somehow these values are not set to 0. Thanks!!!!!!!! Enjoy Programming :) Reference Links : 

Magento : Disable 'Merchant Email Receipt'

After order has been placed, if customers are getting an email with subject : ‘Merchant Email Receipt’ having   following   content **Please DO NOT REPLY to this message. E-mail if you have any questions. ========= SECURITY STATEMENT ========== It is not recommended that you ship product(s) or otherwise grant services relying solely upon this e-mail receipt. ========= GENERAL INFORMATION ========= Merchant : XXXXXXXXXXXX (1356037) Date/Time : 21-Apr-2014 13:43:26 PDT ========= ORDER INFORMATION ========= Invoice : none Description : Test transaction for ValidateCustomerPaymentProfile. Amount : 0.01 (USD) Payment Method : MasterCard Type : Authorization Only etc.... and you don’t want to send these type of emails to your customers? If yes, then here is the solution. Go to Magento Admin panel -> System -> Configuration -> Sales -> Payment Methods -> -> Email Customer Set to no and save th

Magento : Admin login not working in Chrome

Workaround #1 : Before Installation Use when you set up magento in localhost. I prefer this one because no need to make any changes in code. Workaround #2 : After Installation 1. Go to app\code\core\Mage\Core\Model\Session\Abstract\Varien.php file 2. Go to line number 85 and replace // session cookie params $cookieParams = array(             'lifetime' => $cookie->getLifetime(),             'path'     => $cookie->getPath(),             'domain'   => $cookie->getConfigDomain(),             'secure'   => $cookie->isSecure(),             'httponly' => $cookie->getHttponly() ); code snippet with // session cookie params $cookieParams = array(             'lifetime' => $cookie->getLifetime(),             'path'     => $cookie->getPath() ); Clear browser cache and try again. Hopefully it will work for you as well. Thanks!!!!!!!! Enjoy Programming :)

Magento AW Followupemail extension : Show multiple products in email template.

As I discussed in my previous post , due to well-written documentation it was very easy to integrate AW Followupemail extension. I implemented the basic functionality using newsletter templates and it is working very fine. But, there was a confusion in Product Review follow-up email, in case there will be having more than one products in cart. I mean to say I have to loop through the cart items. Let’s do it. 1) Go to Admin Section -> Newsletter->Newsletter Templates 2) Create a Newsletter template with name ‘AW Product Feedback’ and copy following code in Template Content section. <h1>Dear {{var customer_name}}!</h1> <p> You have bought these products on {{var order.updated_at|formatDateTime:F j, Y}}</p> <p>The order contains the following items:</p> <table border="1" cellspacing="1" cellpadding="5" width="100%">     <tbody>         <tr>              &