首页 > 解决方案 > 在 IOS 平台上恢复产品时出错

问题描述

我使用 react native expo,用于创建移动应用程序,担心在 android 上我尝试在 odoo 版本 12 上恢复的产品不会造成问题,但对于 IOS 平台,产品不会出现我设法通过两个平台连接到基地。

对于信息,我使用 react-native-odoo,将 Odoo 与我的应用程序链接起来。

这是我的代码:

import Odoo from 'react-native-odoo'

const odoo = new Odoo({
    host: ' ',
    port:  , /* Defaults to 80 if not specified */
    database: ' ',
    username: ' ', /* Optional if using a stored session_id */
    password: ' ', /* Optional if using a stored session_id */
    sid: ' ', /* Optional if using username/password */
    protocol: 'https' /* Defaults to http if not specified */
})

var foo = [];

for (var i = 3; i <= 2500; i++) {
    foo.push(i);
}

const params = {
    ids: foo,
    fields: ['name', 'list_price', 'image', 'categ_id'],
    limit: 3,
    order: 'categ_id',
};

export class testOdoo extends Component {

state = {
        products: [],
    }
     componentDidMount = async () => {
        await odoo.connect(function (err, resp) {
            if (err) { return console.log('error =' + JSON.stringify(err)); }
            console.log('connected with Odoo bd = ' + JSON.stringify(resp))
        });
        let that = this
        var product = await odoo.search_read('product.template', params, function (err, product) {
            if (err) { return console.log('erreur stock = ' + JSON.stringify(err)); }
            console.log('----------------------------------------------------')
            let a = product
            console.warn(a.length)
            let element = []

            for (var i = 0; i < a.length; i++) {
                if(product[i]){
                    element.push(product[i])
                }
           
            }
         
            that.setState({
                products: element,
            })
            console.log('----------------------------------------------------')
        });
        console.log('----------------------------------------------------')
}                          

                                                     

在 android 平台上生成的结果: 在 android 平台上

在IOS平台上: 在IOS平台上

预先感谢您的回答

标签: react-nativeapiexpoodoo

解决方案


推荐阅读