Monday 31 December 2012

Install required python packages for OpenERP v 7.0

To install OpenERP v7 on linux machine you required various python library. Run below command, it includes all python libraries in only one line.
sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi python-psutil

Friday 28 December 2012

Python script to backup all database

list all the database from the  postgresql server, 
run the query in postgresql 

psql SELECT datname FROM pg_database;

it will list all the database from the postgres server. copy and paste it in one text file. and run the script.

import os

lines = [line.strip() for line in open('<<path to file>>')]
for i in lines:
    print os.system("pg_dump %s >
<<path to file>>%s.out" % (i,i))

it will dump all the database in particulate folder

Tuesday 6 November 2012

List Used Port in Ubantu

netstat is the command which prints network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
change the user as root using
sudo -i
netstat -tulpn
 

it will list all the local address on the local system used by the program.

Wednesday 31 October 2012

How to Install all modules at once in OpenERP

while starting the server you can add parameter in the server path like
./openerp-server --addons ../addons/,
                  ../openerp-web/addons/ -i <comma separated module name> -d <database name>
give list of module name separated by comma, it will install in the module in the given database.
 How to get the name of the all OpenERP module name:
module_id  = self.pool.get('ir.module.module')
module_ids = module_id.search(cr, uid, [])
string = ''
for i in module_id.browse(cr, uid, module_ids):
     string += str(i.name)+','
print "Module ::",string
 it will give you result like:
crm,account_voucher,point_of_sale,project,account_accountant,hr,sale,hr_timesheet_sheet,stock,mrp,purchase,project_gtd,project_issue,hr_recruitment,hr_holidays,hr_expense,account_asset,hr_payroll,account,account_analytic_analysis,account_analytic_default,account_analytic_plans,account_anglo_saxon,account_bank_statement_extensions,account_budget,account_cancel,account_chart,account_check_writing,account_coda,account_creditcard,account_enttec,account_followup,account_invoice_layout,account_payment,account_payment_creditcard,account_report,account_sequence,analytic,analytic_journal_billing_rate,analytic_user_function,anonymization,appf_recruitment,appraisal_survery,association,auction,audittrail,auth_openid,base,base_action_rule,base_calendar,base_contact,base_crypt,base_external_file_protocole,base_external_referentials,base_file_protocole,base_iban,base_module_doc_rst,base_module_quality,base_module_record,base_onchange_player,base_pop_up,base_report_designer,base_sale_multichannels,base_sale_report_synchronizer,base_scheduler_creator,base_setup,base_synchro,base_tools,base_vat,board,caldav,claim_from_delivery,crm_caldav,crm_claim,crm_fundraising,crm_helpdesk,crm_partner_assign,crm_profiling,crm_todo,decimal_precision,delivery,delivery_interface,document,document_ftp,document_webdav,edi,email_template,event,event_project,fetchmail,fetchmail_crm,fetchmail_crm_claim,fetchmail_hr_recruitment,fetchmail_project_issue,file_exchange,ftp_share,google_base_account,google_map,google_translate,hr_attendance,hr_contract,hr_evaluation,hr_payroll_account,hr_timesheet,hr_timesheet_invoice,html_view,idea,import_base,import_enttec,import_google,import_sugarcrm,knowledge,l10n_at,l10n_be,l10n_be_hr_payroll,l10n_be_invoice_bba,l10n_be_postal_subscriber,l10n_be_report,l10n_br,l10n_ca,l10n_ca-qc,l10n_ca_toponyms,l10n_ch,l10n_chart_ar,l10n_chart_at,l10n_chart_au,l10n_chart_be_frnl,l10n_chart_br,l10n_chart_ca_en,l10n_chart_ca_fr,l10n_chart_ch_german,l10n_chart_cl,l10n_chart_cn,l10n_chart_cn_traditional,l10n_chart_co,l10n_chart_cz,l10n_chart_da,l10n_chart_de_skr03,l10n_chart_hu,l10n_chart_in,l10n_chart_it,l10n_chart_it_cc2424,l10n_chart_lv,l10n_chart_nl,l10n_chart_nl_standard,l10n_chart_no,l10n_chart_pa,l10n_chart_pl,l10n_chart_se,l10n_chart_se_church,l10n_chart_se_food,l10n_chart_uk,l10n_chart_uk_netinsight,l10n_chart_us_general,l10n_chart_us_manufacturing,l10n_chart_us_service,l10n_chart_us_ucoa,l10n_chart_us_ucoa_ez,l10n_chart_ve,l10n_ch_vat_brut,l10n_ch_vat_forfait,l10n_ch_vat_net,l10n_cn,l10n_cr,l10n_de,l10n_ec,l10n_es,l10n_fr,l10n_fr_account_generation,l10n_fr_pcg,l10n_fr_report,l10n_fr_rib,l10n_fr_tva_franchise,l10n_fr_tva_reel,l10n_gr,l10n_gt,l10n_hn,l10n_in,l10n_it,l10n_lu,l10n_lu_report,l10n_ma,l10n_multilang,l10n_mx,l10n_nl,l10n_pe,l10n_pl,l10n_ro,l10n_simple,l10n_syscohada,l10n_th,l10n_tr,l10n_uk,l10n_us,l10n_uy,l10n_ve,lunch,magentoerpconnect,magentoerpconnect_bundle,magentoerpconnect_bundle_split,magentoerpconnect_init_stock,magentoerpconnect_partner_fiscal_category,magentoerpconnect_payment,magentoerpconnect_product_variant,magentoerpconnect_report_synchronizer,magento_product_auto_sku,magento_sku_is_code,mail,marketing,marketing_campaign,marketing_campaign_crm_demo,membership,mrp_enttec,mrp_jit,mrp_operations,mrp_repair,mrp_subproduct,multi_company,Multiple_SMTP_Serever,npg_account_make_deposit,pad,pad_project,plugin,plugin_outlook,plugin_thunderbird,portal,print_barcode_label,process,procurement,product,product_brand,product_enttec,product_expiry,product_gift,product_images_olbs,product_links,product_links_goodies,product_links_sync,product_m2mcategories,product_manufacturer,product_margin,product_multi_price,product_quick_stock_rule,product_sequence,product_serialno,product_visible_discount,profile_tools,project_issue_sheet,project_long_term,project_mailgate,project_messages,project_mrp,project_planning,project_retro_planning,project_scrum,project_timesheet,purchase_analytic_plans,purchase_double_validation,purchase_requisition,report_aeroo,report_aeroo_ooo,report_aeroo_printscreen,report_aeroo_sample,report_designer,report_intrastat,report_synchronizer,report_webkit,report_webkit_sample,resource,sale_analytic_plans,sale_automatic_workflow,sale_crm,sale_enttec,sale_exceptions,sale_journal,sale_layout,sale_margin,sale_mrp,sale_order_dates,sale_quick_payment,sale_weight,share,ship_management,shop_floor_interface,stock_enttec,stock_invoice_directly,stock_location,stock_no_autopicking,stock_planning,subscription,survey,users_ldap,warning,web,web_calendar,web_dashboard,web_diagram,web_gantt,web_graph,web_hello,web_kanban,web_livechat,web_mobile,web_process,web_rpc,web_tests,web_uservoice,wiki,wiki_faq,wiki_quality_manual,wiki_sale_faq,

Monday 27 August 2012

Divide a number by 3 without using *, /, +, -, % operators

How would you divide a number by 3 without using *, /, +, -, %, operators?
The number may be signed or unsigned.

There is a simple function I found here. but it's using the + operator, so you have to add the values with the bit-operators:
// replaces the + operator
int add(int x, int y) {
    int a, b;
    do {
        a = x & y;
        b = x ^ y;
        x = a << 1;
        y = b;
    } while (a);
    return b;
}
int divideby3 (int num) {
    int sum = 0;
    while (num > 3) {
        sum = add(num >> 2, sum);
        num = add(num >> 2, num & 3);
    }
    if (num == 3)
        sum = add(sum, 1);
    return sum; }