Thursday, May 29, 2014

Download youtube videos without any plugin or application

This is very simple technique to download the youtube videos without any software support or plugin in browser.

step 1: copy the url of video.
ex: https://www.youtube.com/watch?v=ulE2CbvCCG0
step 2: Omit the part 'https://www.' from url and  add 'ss' instead of it in url.
ie, ssyoutube.com/watch?v=ulE2CbvCCG0
step 3: Reload the browser.

Friday, May 23, 2014

Barcode in RML Reports

Barcode in rml report:
<barCode code="code128" quiet="9" fontName="Times-Roman" barWidth="2.00" fontSize="350" alignment="CENTER">[[ o.reg_no ]]</barCode>

Wednesday, May 21, 2014

Install VirtualBox in Ubuntu

To install virtualbox in ubuntu:
sudo apt-get install virtualbox-ose

Install nautilus-open-terminal in Ubuntu

To get 'Open in Terminal' in right button option in Ubuntu, need to install nautilus-open-terminal.

command:
sudo apt-get install nautilus-open-terminal

Tuesday, May 20, 2014

Generate random numbers in Python

Python random module helps to generate random numbers.
We can generate this in three ways
  • randint(a, b)
  • uniform(a, b)
  • random()
randint(a, b) : returns a random integer number in the range [a, b]
uniform(a, b) : returns a floating point number in the range [a, b]
random() : returns a floating point number in the range [0, 1]

>>> import random
>>> a = random.randint(1,99)
>>> a
77
>>> b = random.uniform(1,999)
>>> b
766.6455229055509
>>> c = random.random()
>>> c
0.6372421095384033
>>>

Convert PDF to JPEG Python

Convert pdf file to image file using 'PythonMagick' in Python. PythonMagick provides object oriented bindings for the ImageMagick Library. You can dowload PythonMagick

Ex:
>>> import PythonMagick
>>> pdf = 'Invoices.pdf'
>>> p = PythonMagick.Image()
>>> p.density('600')
>>> p.read(pdf)
>>> p.write('test_image.jpg')
>>>

Date in Python and its Conversion

Current date in Python using 'time' module

>>> import time
>>> time.strftime("format")
Ex:
>>> import time
>>> time.strftime("%d-%m-%Y")
'20-05-2014'
>>> time.strftime("%d-%m-%Y %H:%M:%S")
'20-05-2014 12:17:51'
Current date in Python using 'datetime' module

>>> import datetime
>>> now = datetime.datetime.now()
>>> now
datetime.datetime(2014, 5, 20, 12, 19, 16, 547221)
>>> now.year
2014
>>> now.month
5
>>> now.day
20
>>> now.hour
12
>>> now.minute
19
>>> now.second
16
>>> now.microsecond
547221
>>>
Change date format using time module

syntax:
time.strftime('required format', time.strptime('date data', 'source format'))
Ex:
>>> import time
>>> d1 = time.strftime('%d-%m-%Y', time.strptime('2014-05-10', '%Y-%m-%d'))
>>> d1
'10-05-2014'
>>>
Convert date to datetime using datetime module

Ex:
>>> from datetime import datetime
>>> d1 = datetime.strftime(datetime.strptime('2014-05-10', '%Y-%m-%d'), "%Y-%m-%d 00:00:00")
>>> d1
'2014-05-10 00:00:00'
>>> d2 = datetime.strftime(datetime.strptime('2014-05-10', '%Y-%m-%d'), "%Y-%m-%d 23:59:59")
>>> d2
'2014-05-10 23:59:59'
>>> d1, d2
('2014-05-10 00:00:00', '2014-05-10 23:59:59')
>>>

Monday, May 19, 2014

Generate random password in Python

To generate random password in Python

import string
import random
from random import sample

def create_password(self):
        """
        create a random password
        """
        rand = string.ascii_letters + string.digits
        length = 8
        passwd = ''.join(sample(rand, length))
        return passwd

Ex:
>>> import string
>>> import random
>>> from random import sample
>>> rand = string.ascii_letters + string.digits
>>> length = 8
>>> passwd = ''.join(sample(rand, length))
>>> passwd
'8fK6ZR0q'
>>>

Add spaces between lines in RML reports OpenERP

In OpenERP, the rml repots generates will omit the white spaces between lines. So in order to maintain the white spaces between lines needs to modify the base code in openerp report module or modify the rml syntax.

Solution 1:

=== modified file 'openerp/report/render/rml2pdf/trml2pdf.py'
--- openerp/report/render/rml2pdf/trml2pdf.py    2012-07-16 07:52:17 +0000
+++ openerp/report/render/rml2pdf/trml2pdf.py    2012-07-19 10:16:33 +0000
@@ -743,6 +743,8 @@
                 style.__dict__.update(extra_style)
             result = []
             for i in self._textual(node).split('\n'):
+                if len(i.strip()) == 0:
+                    i = '<font color="white"> </font>'
                 result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
             return result
         elif node.tag=='barCode':

Solution 2:

Replace <para></para> with <xpre></xpre> in rml file.

ex:
<xpre style="terp_default_9">[[ format(o.note or '') ]]</xpre>

Number of days between two dates/ date differences in Python

To find the number of days between two given dates or to find the difference between two dates in Python. This function generally needs in many case in most of the program.

from datetime import datetime

def days_between(d1, d2):
    d1 = datetime.strptime(d1, "%Y-%m-%d")
    d2 = datetime.strptime(d2, "%Y-%m-%d")
    return abs((d2 - d1).days)

Example:

>>> from datetime import datetime
>>> d1 = '2014-05-10'
>>> d2 = '2014-05-05'
>>> d1 = datetime.strptime(d1, "%Y-%m-%d")
>>> d2 = datetime.strptime(d2, "%Y-%m-%d")
>>> no_of_days = abs((d2 - d1).days)
>>> no_of_days
5 

Remove duplicates from a list in Python

The python built in function 'set()' helps to remove the duplicates from a list.

consider an example:
>>> list1 = [1, 2, 3, 1, 2, 5, 6, 7, 8]
>>> list1
[1, 2, 3, 1, 2, 5, 6, 7, 8]
>>> set(list1)
set([1, 2, 3, 5, 6, 7, 8])
>>> list(set(list1))
[1, 2, 3, 5, 6, 7, 8]
>>>

Page Number in RML Report

To show the page number in rml report:

<drawString x="4.5cm" y="27.35cm"><pageCount/></drawString>

To show the page number in such a format 'page 1 of 3' :
<drawString x="9.5cm" y="0.2cm"> Page: <pageNumber/> of </drawString>
<drawString x="10.6cm" y="0.2cm"><pageCount/></drawString>

Tuesday, April 29, 2014

Install Magento theme using Magento Connect Manager 1.8

These are the steps to be followed to install theme in Magento 1.8 using Magento Connect Manager.

  1. Go to Magento Admin Panel.  System -> Magento Connect -> Magento Connect Manager.
  2. Here you will get an Login area.
  3. Click on 'Magento connect' hyperlink.
  4. Click on 'Themes' menu and select the category of theme you want.
  5. Select the theme and go for install option.
  6. Select the magento connect 1.0 or 2.0 and check the 'extension license agreement'. Then click on 'Get Extension Key' button.
  7. Copy the extension key with the help of 'Select key' button.
  8. Paste the extension key and go for 'Install' button.
  9. Then it shows the 'Extension dependencies'. And its status will be 'Ready to install'. Then go for 'proceed' button.
  10. Then it will shows that theme installed successfully and go for 'Refresh' button.
  11. Then click on 'Return to Admin' button on top right.
  12. Go to System -> Design.
  13. Click 'Add Design Change' button.
  14. Choose the theme which installed now in 'Custom Design' field and click on 'Save' button.
  15. Reload your homepage.
     

Monday, April 28, 2014

Display/ Lists all magento products on Home Page

In Magento, almost all are facing an issue that products are not displaying in home page. This may be due to many reasons. Here i am explaining based on latest Magento 1.8. Mainly this occurs due to three reasons.
  1. Home page Layout configuration.
  2. Zero quantity product.
  3. Out of stock product.
Please ensure the following that you are correctly configured.
Home page Layout configuration
  1. Login into your Magento Admin Panel.
  2. Go to CMS -> Pages. In the 'Manage Pages' list, choose 'Home page'.
  3. Left side you can see 'Page Information'. In this choose 'Design'.
  4. On right you can see 'Page Layout'. And also can see 'Layout Update XML'.
  5. In this change the following

<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page">
to
<block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml">


Zero quantity product
  1.  Login into your Magento Admin Panel.
  2. Go to Catalog -> Manage Products. Select a product and ensure that the quantity of product is not zero.
  3. If it is zero, then open the product, On left side you can see 'Product Information'.
  4. Choose 'Inventory'. Then update the Qty to a number > zero.
Out of stock product
  1.  Login into your Magento Admin Panel.
  2.  Go to Catalog -> Manage Products. Select a product.
  3.  Open the product, On left side you can see 'Product Information'.
  4.  Choose 'Inventory'. Then change 'Stock Availability' to 'In Stock'.

Wednesday, November 20, 2013

Partners Geo-Localization Map in OpenERP


There is a module in openerp 'crm_partner_map' which help us to show the address of a partner in map. The module adds an additional tab in partner form 'Geolocalization'.There you can write the latitude and longitude of the partner location manually or there is a button 'Geo Localize' which automatically fetches the latitude and longitude from the partner address. Based on this it will show the location of a partner in google map in this tab itself.

Tuesday, October 01, 2013

OpenERP 7 integration with Moodle


OpenERP 7.0, The full featured ERP making the switch from an ERP to a suite of integrated business applications. So far, the world was split between ERPs and best of breed applications. With 7.0, OpenERP combines the key benefits of stand-alone apps (ease of use, quick to deploy, highly customizable, ...) with the integrations and feature coverage only ERPs used to provide to their customers. Moodle (Modular Object-Oriented Dynamic Learning Environment) is a free source e-learning software platform, also known as a Learning Management System, or Virtual Learning Environment (VLE).It was originally developed by Martin Dougiamas to help educators create online courses with a focus on interaction and collaborative construction of content, and is in continual evolution. The first version of Moodle was released on 20 August 2002. Moodle has several features considered typical of an e-learning platform, plus some original innovations (like its filtering system). Moodle is very similar to a learning management system. Moodle can be used in many types of environments such as in education, training and development, and business settings. Some typical features of Moodle are:
  • Assignment submission
  • Discussion forum
  • Files download
  • Grading
  • Moodle instant messages
  • Online calendar
  • Online news and announcement (College and course level)
  • Online quiz
To integrate openERP with moodle, first you need to install a moodle server(I used moodle 2.4.3 version).Then create an Admin user and activate the web service in moodle. For activate web service in moodle.
  • In moodle, site administration ->plugins ->web services ->manage protocols -> activate the xmlrpc web service.
  • In moodle, site administration ->plugins ->web services ->manage tokens -> create a token: When creating token, you need to select a web service.So you can select the existing web service or can create new service for this particular integration.If you want to create seprate web services for this integration, Goto site administration ->plugins ->web services -> External services -> add external service and add the functions.
  • In moodle, site administration ->plugins ->web services ->overview -> activate webservice.
In openERP 7.0, there is a module named 'event_moodle' which help us to interact with a Moodle platform.So first install 'event_moodle' module, when you installing, it will shows a pop up window to set up the configuration such as server name, token, user and password.Provide the server name, created token and the username, password of the admin user(admin user have all the privileges). In this integration, the openERP event is mapped to moodle courses and the registrations of event is mapped to moodle users.So when you create and confirming an event, correspondig course will be created in your moodle server.Similarly when you create and confirming a registration for a particular event, corresponding user will be created in moodle server and a role such as student, teacher etc is assigned to this created user.Here the default role is student. The username and password of this user is randomly generated and it is stored in registration form of OpenERP('Moodle username' and 'Password for Moodle User' fields).This user can login to the moodle server and he can add his own course,blogs,messages etc. As OpenERP is a concrete ERP solution and moodle is a good e-learning platform, so developers can extend the functionality by adding new plugins in moodle and corresponding changes in OpenERP.

Saturday, September 07, 2013

Get local languages on Opera Mini (Mobile browser)

Hi All,

You are here to overcome the situation that you cant able to read the local language content on mobile browser. Don't worry, its simple. Just follow the steps below:

Step 1: Download Opera Mini in your phone.

Step 2: Go to address bar of Opera Mini and type 'about:config' or 'config:' (please make sure that you are writing without quotes)


Step 3: In the config window, you can see a heading 'Use bitmap fonts for complex scripts'. Mark this as 'Yes' and go for 'Save' button.


Now the server will convert to required language even though the mobile is not supporting that particular local language. So you can read properly from now onwards.

Thanks

 
Twitter Facebook RSS YouTube Google
© 2014 | Distributed and Designed By Jasad Moozhiyan
↑