Skip to main content

Posts

Showing posts with the label OpenERP

Implementation of free3of9 bar-code in Odoo/OpenERP

Following are the steps to implement free3of9 bar-code in Odoo/OpenERP. 1. Install fonts(.ttf) files on your server. a. You can download free3of9 bar-code files from here: http://www.barcodesinc.com/free-barcode-font/free3of9.zip b. Extract/unzip folder and copy extracted ' free3of9 ' folder in ' /usr/share/fonts/ ' folder only with .ttf files. 2. Odoo use two codes for 3of9 bar-code.  Standard39 for Normal 3of9 and Extended39 for Extended 3of9 or New 3of9 3. In Odoo you can use it as follow based on your .rml or .xml file a. For .rml file: <barCode code=" Standard39 " fontName="Times-Roman" fontSize="30" alignment="CENTER"> [[ o.name or '' ]] </barCode> b. For .xml file: <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % (' Standard39 ', o.name, 600, 100)" style="...

Odoo/OpenERP: Barcodes supported by Odoo

Following is the list/matrix of most popular bar-codes supported by Odoo. 1D Product 1D industrial 2D Code Name Bar-code Type Odoo Code Code Name Bar-code Type Odoo Code Code Name Bar-code Type Odoo Code UPC-A upca UPCA Code 39 code39 Standard39 QR Code qr QR UPC-E upce UPCE Code 39 (extended) code39 Extended39 EAN-8 ean8 EAN8 Code 93 code93 Standard93 EAN-13 ean13 EAN13 Code 93 (ex...

Odoo/OpenERP: Picking List printing blank barcode?

Are you facing a problem with bar-code in picking list. Is it displaying nothing? Reason is: Odoo uses reportlab to print barcode images and reason of showing blank barcode means reportlab fonts are missing. Follow following steps to install reportlab fonts: 1. Login to your server as root user. 2. Open terminal and go to location: '/usr/lib/python2.7/dist-packages/reportlab/' Check if 'fonts' directory is there? If not, create it. 3. Go to 'fonts' folder and Download Zip file from here: http://www.reportlab.com/ftp/pfbfer.zip i.e $ wget http://www.reportlab.com/ftp/pfbfer.zip extract it and delete pfbfer.zip  4. Restart your server. That's it. Thanks!!!!!!!! Enjoy Programming!!! :) Reference Links: https://github.com/odoo/odoo/issues/3234  

Odoo/OpenERP: Create multiple workflows in a single module

Today's post is about : How to create multiple workflows for multiple models in a single module. Few days back, I created a module custom_account with two models custom_expense and custom_payment. I created two different but almost similar workflows for both of them. When I installed the module, only latter one was working. What could be the reason? Problem was with Activity and Transition ids. I was using same ids in both the workflows. Check following: Old Code: custom_expense_workflow_view.xml         <!-- Activity -->                 <record id="act_draft" model="workflow.activity">             <field name="wkf_id" ref="custom_expense_workflow"/>             <field name="flow_start">True</field>             <field name="kind">dummy</field>           ...

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>         ...

Odoo/OpenERP : Module files sequence in __openerp__.py

This post is regarding, how to add module files in sequence in __openerp__.py 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': ' http://dirtyhandsphp.blogspot.in ',     '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 - survey.page.hr.user 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 - survey.page.hr.user 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: https://bugs.launchpad.net/openobject-server/+bug/944561

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 ( http://tutorialopenerp.wordpress.com/2014/04/23/one2one/ ) 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 = {             ...

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>       ...

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 = (datetime.today()).strftime(date_format) 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 :)

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 o r 127.0.0.1:8069 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>   ...

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, 'Na me already exists ', ['name'])]  Thanks!!!!!!!!!! Enjoy Programming :) Reference Link :  http://stackoverflow.com/questions...

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 Prog...

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 :  https://www.youtube.com/watch?v=eLf6lwJkVpk 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 :)