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; }

Tuesday, 10 July 2012

_constraints in Openerp

_constraints

    _constraint is a predefine field in OpenERP. It is used for adding a constraint on the object. It takes list of touple as its argument.The touple inside the list contains three parameter

1. Method(to check the constraint)
2. The Message(Constraint for End User)
3. List of Fields(fields to apply the constraint)
   
    _constraint will fire if the condition returns False on creation and updation of the record and display the message.

    The example code for the _constraint is displayed bellow.
   

 def _check_length(self, cr, uid, ids, context=None):
    record = self.browse(cr, uid, ids, context=context)
    for data in record:
        if data.length < 0:
            return False
    return True

 _columns = {
        'length': fields.integer('Length'),
    }

 _constraints = [(_check_length, 'Error: Length must be Positive', ['length'])]



    In the folloeing example the constraint is set on length field, when the record saved in the database it will check if the length is positive or negative, if it 's negative the constraint gets fired and the message will be display to end user.