How to use the domain name to decide which database to share

Source: Internet
Author: User

From: http://shine-it.net/index.php/topic,16199.msg27430.html

Currently OPENERP has only one function, is the company's internal use, but the boss has a request, need to customer side also use, but the use of the same software, different libraries, customers can not see other people use the library,
I feel that this feature should be more in multiple libraries, and now share the practice
1. There are two domain names, respectively, a.openerp.com b.openerp.com
2. When using a.openerp.com, Access database A, when using b.openerp.com, use database b
3. Find the function: \addons\web\controllers\main.py under the Db_list function, the function is modified to: # # # #中为添加的代码

defDb_list (req, force=False): Proxy= Req.session.proxy ("DB") DBS=proxy.list (Force) H= req.httprequest.environ['Http_host'].split (':') [0]####################Onedb=openerp.tools.config.get (H +'_db', False)ifonedb!=False:return[Onedb]####################D = H.split ('.') [0] R= openerp.tools.config['Dbfilter'].replace ('%h', h). replace ('%d', D) DBS= [I forIinchDbsifRe.match (R, i)]returnDbs

4. As you can see, it reads the contents of config, so you need to add the configuration in openerp-server.conf:
a.openerp.com_db=A   b.openerp.com_db=b

5. Complete
Description: The previous code does not affect normal use, if the configuration file does not write the corresponding database, will follow the old method to display the page, but if you have to configure the database, the login page will not display the database selection, enforcement and the database has been set.
Add ODOO8, modify the code file location is: D:\GreenOdoo\source\openerp\http.py
Modify the source code to:
defDb_filter (DBS, httprequest=None): HttpRequest= HttpRequestorrequest.httprequest H= Httprequest.environ.get ('Http_host',"'). Split (':') [0] D, _, R= H.partition ('.')    ##开始进行替换 =========    ifr=="':#only the first level domain nameD='www'R=openerp.tools.config.get (d+'_db', DBS)##替换结束 =============    ##原始内容    #if D = = "www" and R:    #d = r.partition ('. ') [0]    #r = openerp.tools.config[' Dbfilter '].replace ('%h ', h). Replace ('%d ', d)    ##原始内容结束DBS = [I forIinchDbsifRe.match (R, i)]returnDbs

How to use the domain name to decide which database to share

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.