Odoo-mobile / framework

Odoo Mobile Framework
https://play.google.com/store/apps/dev?id=8607973775002477408
Other
327 stars 374 forks source link

Auto sync is not working properly #94

Open ghost opened 8 years ago

ghost commented 8 years ago

Hello,

I am facing problem when using auto sync. Auto sync feature is working on one side, i.e. if I make any changes on device, it is running properly at every interval. But if I make changes on server, auto sync doesn't work. If anyone has solution then please help me or guide me if I have missed something.

shangx commented 8 years ago

Did you manage to fix the auto sync issue ?

ghost commented 8 years ago

Unfortunately I haven't found solution for auto sync. Though it is working one way i.e. from device to server, I am not able to identify the issue.

shangx commented 8 years ago

In our case the sync works fine both ways, but when we try to add one2many fields, it does'nt sync from device to server anymore.

Kelbethor commented 8 years ago

If autosync enabled it's android syncmanager who fires syncing tasks. It should work if model is correctly set and directional properties (candeletelocal, canupdateserver... etc) and sync is enabled on android account settings. Android fires according to available connection a device load... (Even when you're setting periodicsync, it fires 1 min with wifi conn or 10 with mobile conn. At least this is for me)

Edit: I've read a bit more about and it seems this behavior depens on system sync manager implementation, on some devices is reported to work as expected and when periodic sync is added greedy autosync wont fires.

shangx commented 8 years ago

I know the model works , because if I try with all the fields except the one2many, everything works fine. But when I add the one2many field to my model, the data only syncs one way, from server to device.

ghost commented 8 years ago

@Kelbethor: I agree with what you said, it is android syncmanager who manages sync operations. Moreover in my case sync is fired in one direction properly. That means my model is working fine, then I am not getting where am I lacking?!

@shangx: If you are not able to sync from device to server, then there could be chances that you have problem with field values. Possibly, you have not set required values.

shangx commented 8 years ago

Yes, but i can't find anywhere what values must be stored in the one2many field before passing it to server. And moreover I don't even want to modify that field, I just use it to get more info, so the value is never changed in the field, it's the exact same value that it gets from the server.

If you have any idea what type of values must be in the one2many field before synking with server I would appreciate a hint ;). Because when I get it from server its an com.odoo.core.orm.OO2MRecord object

Kelbethor commented 8 years ago

Well...

First: I'm neither developer nor contributor in the project (yet),

just trying to help. That is I'm totally wrong or at least not completely right.

Second: SO, according to source code one2many fields it's yet-to-be-implemented feature:

public enum FieldType {
        Text, Boolean, ManyToOne, Chips, Selection, Date, Time, DateTime, Blob, RelationType;

        public static FieldType getTypeValue(int type_val) {
            switch (type_val) {
                case 0:
                    return FieldType.Text;
                case 1:
                    return FieldType.Boolean;
                case 2:
                    return FieldType.ManyToOne;
                case 3:
                    return FieldType.Chips;
                case 4:
                    return FieldType.Selection;
                case 5:
                    return FieldType.Date;
                case 6:
                    return FieldType.DateTime;
                case 7:
                    return FieldType.Blob;
                case 8:
                    return FieldType.Time;
            }
            return FieldType.Text;
        }
    }

So you should handle it without using framework features or implement it.

Third: what odoo-mobile orm is expecting from a o2m column?:

A List with related model rows ids

Fourth: I suggest...

If your model is working just fine without defining o2m column just don't do it. Define m2o column on the other model and then just query it at the right place for showing required info in , for example, a listview...

shangx commented 8 years ago

@Kelbethor, That is the approach we are trying now, just implementing models without the one2many, but I wanted to avoid the extra queries and just get all data with one sync :(

Thank you very much for your reply :)