Sunday, 3 May 2015

Install Odesk Tracker in Ubuntu

Today, I tried to install Odesk Tracker on by Ubuntu machine but it was throwing a number of errors.

shiv@localhost:~$ sudo dpkg -i ~/Downloads/odeskteam_3.12.9_i386.deb 

(Reading database ... 294217 files and directories currently installed.)
Preparing to unpack .../odeskteam_3.12.9_i386.deb ...
Unpacking odeskteam (3.12.9) over (3.12.9) ...
dpkg: dependency problems prevent configuration of odeskteam:

 odeskteam depends on libphonon4 (>= 4:4.2.0).
odeskteam depends on phonon.

dpkg: error processing package odeskteam (--install):
 dependency problems - leaving unconfigured
Processing triggers for mime-support (3.54ubuntu1.1) ...
Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...
Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Errors were encountered while processing:
 odeskteam



Tried to install dependencies as well but no use. Same list of errors.

After lot of search and brainstorming I was not able to find any answer and contacted Odesk Support. After couple of hours they came up a solution which not at all working out. Finally found a very simple solution, the following chain of commands and it worked:

shiv@localhost:~$ sudo apt-get clean
shiv@
localhost:~$ sudo apt-get -f install
shiv@localhost:~$ sudo dpkg -i ~/Downloads/odeskteam_3.12.9_i386.deb

That's it.

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

Reference Link:

http://askubuntu.com/questions/314221/getting-errors-when-installing-packages


Friday, 24 April 2015

Simple example of datatables

Today's post is about use of datatables. Lot of examples are available on Internet. This example is just to explore it little more and explains how to read data from xml and display using datatables.

<?php

$file_url='blog.xml';
$file_content = file_get_contents($file_url);
$xml_string_arr=simplexml_load_string($file_content);

//Optional: Start of code if you want to add some attribute to xml
//code to add unique_id attribute
/*foreach( $xml_string_arr->xpath("entry") as $r ) {
    $attrs = $r->attributes();   
    if(!$attrs['unique_id'])
        $r->addAttribute('unique_id', $r->id);
}
$xml_string_arr->asXML($file_url);*/
//End of code if you want to add some attribute to xml



$json = json_encode($xml_string_arr);
$arr_new = json_decode($json,TRUE);

$required_content_arr = $arr_new['entry'];

?>
<!DOCTYPE html>
<html>
<head>
    <title>Task3</title>
    <link rel="stylesheet" href="DataTables/media/css/jquery.dataTables.css">
    <script src="DataTables/media/js/jquery.js"></script>
    <script src="DataTables/media/js/jquery.dataTables.js"></script>
</head>

<body>
  <table id="example" class="display" cellspacing="0" width="100%">
  </table>
</body>

</html>
<script language="javascript"> 
    $(document).ready(function() {
        var oTable = $('#example').dataTable({
            data: <?php echo json_encode($required_content_arr); ?>,
            columns: [
                { data: 'id' },
                { data: 'name' },
                { data: 'url' },
                { data: 'height' },               
            ]
        });
       
   
    } );   
   
</script>



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

Friday, 16 January 2015

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>
            <field name="name">draft</field>
        </record>          
       
        <record id="act_submit" model="workflow.activity">
            <field name="wkf_id" ref="custom_expense_workflow"/>
            <field name="kind">function</field>
            <field name="action">expense_submit()</field>
            <field name="name">submit</field>
        </record>    
       
        <!-- Transistion -->

        <record id="trans_draft_submit" model="workflow.transition">
            <field name="act_from" ref="act_draft"/>
            <field name="act_to" ref="act_submit"/>
            <field name="signal">signal_submit</field>                      
        </record>  
 
custom_payment_workflow_view.xml

        <!-- Activity -->
       
        <record id="act_draft" model="workflow.activity">
            <field name="wkf_id" ref="custom_payment_workflow"/>
            <field name="flow_start">True</field>
            <field name="kind">dummy</field>
            <field name="name">draft</field>
        </record>          
       
        <record id="act_submit" model="workflow.activity">
            <field name="wkf_id" ref="custom_payment_workflow"/>
            <field name="kind">function</field>
            <field name="action">expense_submit()</field>
            <field name="name">submit</field>
        </record>    
       
        <!-- Transistion -->

        <record id="trans_draft_submit" model="workflow.transition">
            <field name="act_from" ref="act_draft"/>
            <field name="act_to" ref="act_submit"/>
            <field name="signal">signal_submit</field>                      
        </record>      


So workflow.activity and workflow.transition were same. That was the catch.

New Code:


custom_expense_workflow_view.xml

         <!-- Activity -->
       
        <record id="expense_act_draft" model="workflow.activity">
            <field name="wkf_id" ref="custom_expense_workflow"/>
            <field name="flow_start">True</field>
            <field name="kind">dummy</field>
            <field name="name">draft</field>
        </record>          
       
        <record id="expense_act_submit" model="workflow.activity">
            <field name="wkf_id" ref="custom_expense_workflow"/>
            <field name="kind">function</field>
            <field name="action">expense_submit()</field>
            <field name="name">submit</field>
        </record>    
       
        <!-- Transistion -->

        <record id="expense_trans_draft_submit" model="workflow.transition">
            <field name="act_from" ref="expense_act_draft"/>
            <field name="act_to" ref="expense_act_submit"/>
            <field name="signal">signal_submit</field>                      
        </record>  
 
custom_payment_workflow_view.xml

        <!-- Activity -->
       
        <record id="payment_act_draft" model="workflow.activity">
            <field name="wkf_id" ref="custom_payment_workflow"/>
            <field name="flow_start">True</field>
            <field name="kind">dummy</field>
            <field name="name">draft</field>
        </record>          
       
        <record id="payment_act_submit" model="workflow.activity">
            <field name="wkf_id" ref="custom_payment_workflow"/>
            <field name="kind">function</field>
            <field name="action">expense_submit()</field>
            <field name="name">submit</field>
        </record>    
       
        <!-- Transistion -->

        <record id="payment_trans_draft_submit" model="workflow.transition">
            <field name="act_from" ref="payment_act_draft"/>
            <field name="act_to" ref="payment_act_submit"/>
            <field name="signal">signal_submit</field>                      
        </record>      

That's it.

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

Monday, 1 December 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 use following command:

cvt <h-resolution> <v-resolution>

e.g $ cvt 1280 1024

it will return : Modeline "1280x1024_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync

b) To get Device Driver use following command :

lshw -class display | grep "driver"

For intel graphic chip driver is intel only.



Sunday, 23 November 2014

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 on this. Please post your valuable comments.


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

Reference Link :

http://stackoverflow.com/questions/20954412/create-and-edit-items-of-a-one2many-field-through-on-change-method