Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

3

How to create a database from openerp form?

By
vadivel
on 11/20/15, 6:04 AM 653 views

Hi Friends,

Can anyone help me in this situation. Have to create database from openerp form on a button click.Please do help

6
Kazim Mirza
On 11/20/15, 6:14 AM

import openerp.netsvc as netsvc

from openerp.service.web_services import db

def create_db(self, cr, uid, ids, context=None):


     db = db(netsvc.ExportService)

     db.exp_create_database('test', True, 'en_US', user_password='admin') #exp_create_database(self, db_name, demo,  lang, user_password='admin'):

    return True


Please accept the answer if you find it helpful.

Error thrown as no named db.Im using version openerp 7.0

vadivel
on 11/20/15, 6:28 AM

Please can u post full code to create db function with import files.Do help me

vadivel
on 11/20/15, 11:04 PM

I have udated answer.

Kazim Mirza
on 11/21/15, 12:57 AM

UnboundLocalError: local variable 'db' referenced before assignment

vadivel
on 11/21/15, 1:25 AM

you need to import import openerp.netsvc as netsvc from openerp.service.web_services import db

Kazim Mirza
on 11/21/15, 1:28 AM

I used your code as it is. But it is shown error as UnboundLocalError: local variable 'db' referenced before assignment

vadivel
on 11/21/15, 1:38 AM

I have tested it and it works .. you are doing something wrong .. share a screenshot here

Kazim Mirza
on 11/21/15, 1:43 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/20/15, 6:04 AM
Seen: 653 times
Last updated: 1/13/16, 2:47 AM