Database replication between 2 postgresql Odoo 8.0 databases with different schemas

We have a situation where we need to implement replication between two Odoo v8 databases located in different datacenters thousands of kilometers away (so we need to take latency into account). Databases have different schemas, tables are almost the same, but the columns in these tables are different, and replication must be done at the database level. All warnings to the client that this will bypass the ORM and therefore any Python level constraints that are different from each other as custom code is different (Odoo source will be the same) fell on deaf ears. Replication should only be done for certain tables (still to be clarified), one of which is the sale_order table, however this means that any tables pointed to by the relationship columns (foreign key) should also be in sync.So, if a sales order has partner_id of 5, that means the res_partner table must have a row with id 5 in both databases, and the data in all the corresponding columns must match, and many of those columns will also be foreign key columns. which point to other tables, etc. etc. The code base is not only different, it is significantly different - dozens of completely different modules and thousands of lines of code. I am a bit confused about how to implement this, there is an Odoo module (base_synchro) that can potentially work to get the desired result, except that it works through xml-rpc requests, so not at the database level and therefore not an option. Does anyone have experience with something similar that could be weighed? Or is it impossible to do,without creating a complete mess in both databases?

+3


source to share


1 answer


We also have a problem, we have over 100 companies due to network loss, we have to put an odoo instance in each company, and we need a central server to consolidate data for our main company for statistics, etc. The solution we are making now is to modify the models.py code in the create method to create a specific identifier for the company.

let's say the company has code = 120

, so we ran the odoo implementation to add every id should be 1200000000 + id

, so when you save the firsr entry in that company id != 1

, but id = 1200000001

also others company id = 1990000001

with code 199, so when we consolidate the data we didn't have to set foreign keys, because we will never have an ID that exists in two companies. even this decision was not made, because we have many companies, we are losing a lot of data, so the maximum value for ours is id = 9 999 999

for you. you have 2 companies so max id = 999 999 999

, now we change the id type from serial to bigserial, but this requires a lot of code editing because we had to change a lot of field and integer fields ...

code for id:



def _create(self, cr, user, vals, context=None):
   ...
   ...
   updates = [
        # list of column assignments defined as tuples like:
        #   (column_name, format_string, column_value)
        #   (column_name, sql_formula)
        # Those tuples will be used by the string formatting for the INSERT
        # statement below.
        ('id', "nextval('%s')+%s" % (self._sequence, 1000000000)),
    ]

      

of course you can make this dynamic with the current user's company_id code.

data with prefix ids and begserial id

+1


source







All Articles