當前位置: 首頁>>代碼示例>>Java>>正文


Java OdooResult類代碼示例

本文整理匯總了Java中odoo.helper.utils.gson.OdooResult的典型用法代碼示例。如果您正苦於以下問題:Java OdooResult類的具體用法?Java OdooResult怎麽用?Java OdooResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OdooResult類屬於odoo.helper.utils.gson包,在下文中一共展示了OdooResult類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeNonExistRecordFromLocal

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
/**
 * Removes non exist record from local database
 *
 * @param model
 */
private void removeNonExistRecordFromLocal(OModel model) {
    List<Integer> ids = model.getServerIds();
    try {
        ODomain domain = new ODomain();
        domain.add("id", "in", ids);
        OdooFields fields = new OdooFields();
        fields.addAll(new String[]{"id"});
        OdooResult result = mOdoo.searchRead(model.getModelName(), fields, domain, 0, 0, null);
        List<OdooRecord> records = result.getRecords();
        if (!records.isEmpty()) {
            for (OdooRecord record : records) {
                ids.remove(ids.indexOf(record.getInt("id")));
            }
        }
        int removedCounter = 0;
        if (ids.size() > 0) {
            removedCounter = model.deleteRecords(ids, true);
        }
        Log.i(TAG, removedCounter + " Records removed from local database.");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:29,代碼來源:OSyncAdapter.java

示例2: nameSearch

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public List<ODataRow> nameSearch(String name, ODomain domain, int limit) {
    List<ODataRow> items = new ArrayList<>();
    if (mApp.inNetwork()) {
        OdooResult result = mOdoo.nameSearch(mModel.getModelName(), name, domain, limit);
        if (!result.getRecords().isEmpty()) {
            for (OdooRecord record : result.getRecords()) {
                // FIXME : What response i'll get. I DON'T KNOW YET
                    /*ODataRow row = new ODataRow();
                    row.put("id", record.getInt("id"));
                    row.put(mModel.getDefaultNameColumn(), record.getString("name"));
                    items.add(row); */
            }
        }
    }
    return items;
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:17,代碼來源:ServerDataHelper.java

示例3: createRecordsOnServer

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
private List<Integer> createRecordsOnServer(ResPartner partner) {
    List<Integer> ids = new ArrayList<>();
    for (ListRow row : partner.select("id = ?", "0")) {
        ORecordValues values = new ORecordValues();

        for (OColumn column : partner.getColumns()) {
            if (!column.isLocal && !column.name.equals("id")) {
                Object value = row.get(column.name);
                if (!value.toString().equals("false") ||
                        column.columnType == ColumnType.BOOLEAN) {
                    switch (column.columnType) {
                        case MANY2ONE:
                            //TODO: To be implemented.
                            continue;
                    }
                    values.put(column.name, value);
                }
            }
        }

        // Creating record on server
        OdooResult result = odoo.createRecord(partner.getModelName(), values);
        int newServerId = result.getInt("result");
        ids.add(newServerId);
        // Updating local record with new created server id
        ContentValues newValues = new ContentValues();
        newValues.put("id", newServerId);
        partner.update(newValues, "_id = ?", row.getString("_id"));
    }
    return ids;
}
 
開發者ID:odoo-mobile-intern,項目名稱:android-odoo-contacts-2016,代碼行數:32,代碼來源:ContactSyncAdapter.java

示例4: OSyncDataUtils

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public OSyncDataUtils(Context context, Odoo odoo, OModel model, OUser user, OdooResult response,
                      SyncResult result, Boolean createRelRecord) {
    mContext = context;
    mOdoo = odoo;
    mModel = model;
    mUser = user;
    this.response = response;
    mResult = result;
    mCreateRelationRecords = createRelRecord;
    List<OdooRecord> updateInLocal = checkLocalUpdatedRecords();
    handleResult(updateInLocal);
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:13,代碼來源:OSyncDataUtils.java

示例5: createOnServer

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
private int createOnServer(OModel model, ORecordValues values) {
    int id = OModel.INVALID_ROW_ID;
    try {
        if (values != null) {
            OdooResult result = mOdoo.createRecord(model.getModelName(), values);
            id = result.getInt("result");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return id;
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:13,代碼來源:OSyncAdapter.java

示例6: read

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public OdooRecord read(odoo.helper.OdooFields fields, int id) {
    if (mApp.inNetwork()) {
        OdooResult result = mOdoo.read(mModel.getModelName(), id, fields);
        List<OdooRecord> records = result.getArray("result");
        return records.get(0);
    }
    return null;
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:9,代碼來源:ServerDataHelper.java

示例7: searchRecords

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public List<ODataRow> searchRecords(OdooFields fields, ODomain domain, int limit) {
    List<ODataRow> items = new ArrayList<>();
    if (mApp.inNetwork()) {
        OdooResult result = mOdoo.searchRead(mModel.getModelName(), fields, domain, 0, limit, null);
        if (!result.getRecords().isEmpty()) {
            for (OdooRecord record : result.getRecords()) {
                items.add(OdooRecordUtils.toDataRow(record));
            }
        }
    }
    return items;
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:13,代碼來源:ServerDataHelper.java

示例8: callMethod

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public Object callMethod(String model, String method, OArguments args,
                         HashMap<String, Object> context, HashMap<String, Object> kwargs) {
    if (context != null) {
        args.add(mOdoo.updateContext(context));
    }
    OdooResult result = mOdoo.callMethod(model, method, args, kwargs, context);
    if (result.has("result")) {
        return result.get("result");
    }
    return false;
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:12,代碼來源:ServerDataHelper.java

示例9: getDatasFromServer

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public String getDatasFromServer(Integer row_id) {
    ODomain domain = new ODomain();
    domain.add("id", "=", selectServerId(row_id));
    OdooFields fields = new OdooFields();
    fields.addAll(new String[]{"datas"});
    OdooResult result = getServerDataHelper().read(fields, selectServerId(row_id));
    if (result != null && result.has("result") && result.get("result") instanceof ArrayList) {
        OdooRecord res = (OdooRecord) result.getArray("result").get(0);
        return res.getString("datas");
    }
    return "false";
}
 
開發者ID:Odoo-mobile,項目名稱:hr,代碼行數:13,代碼來源:IrAttachment.java

示例10: searchRecords

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public List<ODataRow> searchRecords(OdooFields fields, ODomain domain, int limit) {
    List<ODataRow> items = new ArrayList<>();
    if (mApp.inNetwork()) {
        OdooResult result = mOdoo.searchRead(mModel.getModelName(), fields, domain, 0, limit, null);
        if (result != null && !result.getRecords().isEmpty()) {
            for (OdooRecord record : result.getRecords()) {
                items.add(OdooRecordUtils.toDataRow(record));
            }
        }
    }
    return items;
}
 
開發者ID:Odoo-mobile,項目名稱:hr,代碼行數:13,代碼來源:ServerDataHelper.java

示例11: createOrUpdateRecords

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
private List<Integer> createOrUpdateRecords(ResPartner partner) {
    OdooFields fields = new OdooFields();
    fields.addAll(partner.getServerColumn());
    ODomain domain = new ODomain();

    /**
     * Adding create_date compare with last sync date.
     */
    String lastSyncDatetime = pref.getString(KEY_LAST_SYNC_DATETIME, null);
    if (lastSyncDatetime != null) {
        String utcLastSyncDate = ODateUtils.convertToUTC(lastSyncDatetime,
                ODateUtils.DEFAULT_FORMAT);

        domain.add("|");
        domain.add("create_date", ">=", utcLastSyncDate);
        domain.add("write_date", ">=", utcLastSyncDate);
    }

    // getting records from odoo server.
    OdooResult result = odoo.searchRead(partner.getModelName(), fields, domain, 0, 0, null);

    List<Integer> recordIds = new ArrayList<>();

    // filtering each of the record with the column values.
    for (OdooRecord record : result.getRecords()) {
        ContentValues values = new ContentValues();

        // looping with each column and setting the content value as per its type.
        for (OColumn column : partner.getColumns()) {
            if (!column.isLocal) {
                switch (column.columnType) {
                    case VARCHAR:
                        values.put(column.name, record.getString(column.name));
                        break;
                    case BOOLEAN:
                        values.put(column.name, record.getBoolean(column.name));
                        break;
                    case BLOB:
                        values.put(column.name, record.getString(column.name));
                        break;
                    case INTEGER:
                        values.put(column.name, record.getInt(column.name));
                        break;
                    case DATETIME:
                        values.put(column.name, record.getString(column.name));
                        break;
                    case MANY2ONE:

                        // Here many to one record refers another table.
                        // so creating primary record for that table and adding
                        // primary key field unique id to reference value

                        OdooRecord m2oRecord = record.getM20(column.name);
                        int m2oId = 0;
                        if (m2oRecord != null) {
                            String modelName = column.relModel;
                            OModel model = OModel.createInstance(modelName, mContext);
                            if (model != null) {
                                ContentValues m2oValues = new ContentValues();
                                m2oValues.put("id", m2oRecord.getInt("id"));
                                m2oValues.put("name", m2oRecord.getString("name"));
                                m2oId = model.update_or_create(m2oValues, "id = ?",
                                        m2oRecord.getInt("id") + "");
                            }
                        }
                        values.put(column.name, m2oId);
                        break;
                }
            }
        }
        // Creating or updating record in the database..
        int record_id = partner.update_or_create(values, "id = ?", record.getInt("id") + "");
        recordIds.add(record_id);
    }
    return recordIds;
}
 
開發者ID:odoo-mobile-intern,項目名稱:android-odoo-contacts-2016,代碼行數:77,代碼來源:ContactSyncAdapter.java

示例12: executeWorkFlow

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public OdooResult executeWorkFlow(int server_id, String signal) {
    return mOdoo.executeWorkFlow(mModel.getModelName(), server_id, signal);
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:4,代碼來源:ServerDataHelper.java

示例13: createOnServer

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public int createOnServer(ORecordValues data) {
    OdooResult result = mOdoo.createRecord(mModel.getModelName(), data);
    return result.getInt("result");
}
 
開發者ID:dpr-odoo,項目名稱:trainee-om-shop,代碼行數:5,代碼來源:ServerDataHelper.java

示例14: read

import odoo.helper.utils.gson.OdooResult; //導入依賴的package包/類
public OdooResult read(odoo.helper.OdooFields fields, int id) {
    if (mApp.inNetwork()) {
        return mOdoo.read(mModel.getModelName(), id, fields);
    }
    return null;
}
 
開發者ID:Odoo-mobile,項目名稱:hr,代碼行數:7,代碼來源:ServerDataHelper.java


注:本文中的odoo.helper.utils.gson.OdooResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。