Saturday, October 5, 2013

[Postgresql] command line restore db on windows

SET PGPASSFILE=C:\foo\bar\PG_BACKUP\PGPASSFILE\pgpass.conf
C:\Python27>"C:\Program Files\PostgreSQL\9.3\bin\psql.exe" -U openerp db
 < "C:\Users\user\Downloads\db.dump"

Monday, September 2, 2013

How to Generate a SSL certificate for OpenERP



To connect via xml-rpc secure protocol (8071) we need to generate a certificate and a private key file for the OpenERP . Below are the steps which can guide you to achieve this.

Step 1: Create a Directory eg: "SSL" under openerp-server/bin

Step 2: Go to "SSL" directory. cd ssl

Step 3: Generate Private key(pkey) as
execute command :openssl genrsa - des3 -out server.pkey 2048
enter the details that is asked for.

Step 4: Certificate
execute command openssl req-new-key server.pkey -out server.csr
enter details that is asked for.

Step 5: copy the .pkey file:
cp server.pkey server.pkey.org
enter password

Step 6: openssl rsa -in server.pkey.org -out server.pkey

Step 7: Generate CA private key
openssl genrsa - des3 -out ca.pkey 2048
enter password (enter different password then before)

Step 8: Generate a certificate in x509 format
execute: openssl req-new -x509 -days 365 -key ca.pkey -out ca.crt
Enter details that is asked for.

Step 9: sign the pkey
openssl x509 -req -in server.csr -out server.crt -CA ca.crt -CAkey ca.pkey
-CAcreateserial -CAserial ca.srl
Enter password same as entered in step 7

Step 10: start openerp server with --cert-file=YOUR .crt FILE PATH --pkey-
file=YOUR pkey FILE PATH

eg: server$ ./openerp-server --addons-path=../openobject-addons/ --cert-
file=bin/ssl/server.crt --pkey-file=bin/ssl/server.pkey


Thanks,
Naresh Soni(nch)
Team Lead, OpenERP Support / OPW

How to create OpenERP development Environment on windows

# This doc explains the steps to be taken 
# if you want to deploy openerp on windows or create openerp.exe for windows
# or want to create OpenERP Setup exe.
# Note : you can get all the packages from http://nightly.openerp.com/6.1/windows_dependencies/

Install following packages:

1: Install python2.6.5
   Set environment path c:\python26

2: Install all in one pygtk package:  pygtk-all-in-one-2.22.5.win32-py2.6 (default instllation)
   Set environment variable
 Variable name: GTK_RUNTIME
 Variable value: C:\Python26\Lib\site-packages\gtk-2.0\runtime 

3: from http://nightly.openerp.com/6.1/windows_dependencies/ download the "add_to_dist" folder which contains *.dlls
  set environment variable:
 Variable name: openerp_dlls
 Variable value: path to the folder "add_to_dist" 
  eg:c:\Desktop
  
4: Install setuptools-0.6c11.win32-py2.6

5: Install python-dateutil-1.5.win32
   (Note: you can create .win32.exe from python package using  
   >>>python setup.py bdist_wininst command it create python-dateutil-1.5.win32in dist directory)

6: Install pywin32-214.win32-py2.6

7: Install lxml-2.2.2.win32-py2.6

8: Install pydot-1.0.3.win32
     Note: you can create .win32.exe from python package using  
 >>>python setup.py bdist_wininst

Now your GTK client is ready to start from the command prompt like you do in linux

9: Install matplotlib-0.99.1.win32-py2.6

10: Install numpy-1.6.0-win32-superpack-python2.6

11: Install pyparsing-1.5.5.win32
   Note: you can create .win32.exe from python package using  
 >>>python setup.py bdist_wininst

12: Install pyOpenSSL-0.11.winxp32-py2.6

13: Install py2exe-0.6.9.win32-py2.6

14:Install nsis-2.46-setup.exe for creating auto installer

15: Copy libhippocanvas-1-0.dll and hippo.pyd of add_to_dist directory to C:\Python26\DLLs

start create exe use following command

15.  >>>path_to_openerp_client_dir>python setup.py py2exe

    it will take some time
    it create a build and dist directory in client then inside the dist dir you will find the openerp_X_Y.exe(x,y are version no)
 
16:To create a auto installer
 go to openerp client/
        right click on setup.nsi and select compile with nsis 
        this operation will take time and a setup installer will be created.



Thanks,
Naresh Soni(nch) Team Lead, OpenERP Support / OPW
Follow Naresh Soni on

Thursday, August 22, 2013

delete lenh san xuat

update stock_picking set state='draft' where name='IN/00330'
update purchase_order set state='draft' where name='PO00162'

select * from mrp_production_workcenter_line where production_id=1188
delete from mrp_production_workcenter_line where production_id=1188
select * from mrp_production_processing_votedeliveryline
where workorder_id=2596
delete from mrp_production_processing_votedeliveryline where workorder_id=2594
select * from mrp_production where name='MO/00487'
delete from mrp_production where name='MO/00487'
select * from product_production_select
where production_id=1188
delete from product_production_select where production_id=1188
select * from stock_move

Wednesday, July 24, 2013

OpenERP Magento/Prestashop connector Business – Solutions

OpenERP Magento/Prestashop connector

Business – Solutions

The connector between the Open Source solutions OpenERP and Magento/PrestaShop allows to centrally and automatically manage a large volume of orders (several hundred orders per day). Each solution has its own strengths: the feature-rich e-Commerce platforms provide online merchants with unprecedented flexibility and control over the look, content and functionality of their e-Shop (promotion of products and sales) while OpenERP manages sales, logistics and finance.
OpenERP’s first Gold Partner and winner of the 2012 and 2013 “OpenERP Best Contributor” award, Camptocamp specializes in the development of e-Commerce business managementsolutions and can assist you in implementing the solution from both a business and a technical perspective.

OFFICIAL OPENERP MAGENTO/PRESTASHOP CONNECTOR DEVELOPED BY CAMPTOCAMP

Co-developed by Camptocamp, the connector between OpenERP and the two Open SourceMagento and PrestaShop e-Commerce platforms allows you to centrally manage fromOpenERP youronline stores in an automated and centralized manner. This integration allows to usea single tool, consequently avoiding multiple double or triple entries, and thus minimizingerrors and lost time.
  • Automated synchronization of orders, customers, product cataloginventory levelsorder status, parcel track number, etc.
  • Customization and automation of workflows related to means of payment and shipping methods
  • Management of invoicing and partial deliveries
  • Multi-shop, multi-language, multi-country, multi-currency

GENERAL WORKFLOW

Workflow supported by OpenERP connector Magento/PrestaShop results in:
  1. The product catalog is managed in OpenERP and pushed on the e-Shop
  2. The customer places an order and pays online
  3. The order is retrieved by OpenERP, and the customer is created if he doesn’t already exist
  4. The order generates a logistics workflow resulting in a delivery order and a financial workflow, which, in turn,generates an invoice. The invoice automatically creates the related accounting entries
  5. The order status is sent back to the e-Shop
  6. Inventories are managed in OpenERP
  7. OpenERP generates purchase orders (PO) and/or production orders,if needed
  8. The inventory level is sent back to the e-Shop
  9. By integrating all sales channels, OpenERP becomes the central back office tool

CAMPTOCAMP : OPENERP INTEGRATOR AND E-COMMERCE EXPERT

Based on an innovative methodology for managing projects, Camptocamp Business Solutionsdivision offers a full range of services focused around OpenERP: analysis of your business processes, implementation, training, maintenance, support and hosting.
  • Official Gold partner since 2006
  • Winner of the “BestOpenERP Contributor” award 2012 and 2013
  • Co-developer of the official connectors with Magento andPrestaShop
  • Technical and business expertise: e-Commerce, logistics, sales, finance
  • Several key e-Commerce references in various industries: up to hundreds of orders per day

Tuesday, July 23, 2013

Java Servlet Filter Tutorial Example Using Eclipse & Tomcat


We we use Eclipse for developing our application and Apache Tomcat for deploying and running our application.

Step 1: Create dynamic web project in Eclipse.

Starts eclipse and create a new dynamic web project with name ServletFilterProject. Select Target runtime environment. I have selected Apache Tomcat v6.0, you can select any Tomcat version that you have installed. Click on Finish.

Step 2: Create package & Servlet Filter class.

Create a package for Servlet Filters in your source folder of Project. I have created a packagenet.viralpatel.servlet.filters. Inside the package, create a Java class file called LogFilter.java.

Step 3: Writting Servlet Filter class code.

Modify the LogFilter class and add following code into it.
package net.viralpatel.servlet.filters;
 
import java.io.IOException;
import java.util.Date;
 
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
 
public class LogFilter implements Filter {
 
    public void doFilter(ServletRequest req, ServletResponse res,
            FilterChain chain) throws IOException, ServletException {
 
        HttpServletRequest request = (HttpServletRequest) req;
         
        //Get the IP address of client machine.
        String ipAddress = request.getRemoteAddr();
         
        //Log the IP address and current timestamp.
        System.out.println("IP "+ipAddress + ", Time "
                            + new Date().toString());
         
        chain.doFilter(req, res);
    }
    public void init(FilterConfig config) throws ServletException {
         
        //Get init parameter
        String testParam = config.getInitParameter("test-param");
         
        //Print the init parameter
        System.out.println("Test Param: " + testParam);
    }
    public void destroy() {
        //add code to release any resource
    }
}
In this filter example, we have implemented an interface javax.servlet.Filter and override its methods init, doFilter and destroy.
The init() method is used to initialize any code that is used by Filter. Also note that, init() method will get an object of FilterConfig which contains different Filter level information as well as init parameters which is passed from Web.xml (Deployment descriptor).
The doFilter() method will do the actual logging of information. You can modify this method and add your code which can modify request/session/response, add any attribute in request etc.
The destroy() method is called by the container when it wants to garbage collect the filter. This is usually done when filter is not used for long time and server wants to allocate memory for other applications.

Step 4: Create Servlet Filter Mapping in Web.xml

Open web.xml file from WEB-INF directory of your Project and add following entry for filter tag.
<filter>
    <filter-name>LogFilter</filter-name>
    <filter-class>
        net.viralpatel.servlet.filters.LogFilter
    </filter-class>
    <init-param>
        <param-name>test-param</param-name>
        <param-value>This parameter is for testing.</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>LogFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
In this entry, we have added LogFilter class in Web xml and mapped it with URL /*. Hence any request from client will generated a call to this filter. Also we have passed a parameter test-param. This is just to show how to pass and retrieve a parameter in servlet filter.

Step 5: Execute the web application

We are done with the coding part of Servlet Filter example. Now execute the project by Run -> Run As -> Run on server (shortcut Alt+Shift+X, R).
Check the console you will see the output that we print using System.out.
Change the code in the way you want your filter to work.