Monday, May 19, 2014

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

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.

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