コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1432 ビュー

hi, i would like to know how to combine between two models

i'm displaying products and i need to display their prices but they r not in the same model


this is the function i use to display the products' names:


  Future auth() async {    await client.authenticate(db, username, password);  }
  Future fetchProduct() async {    await auth();    var product = await client.callKw({      'model': 'product.template',      'method': 'search_read',      'args': [],      'kwargs': {        'context': {'lang': 'fr_FR', 'bin_size': true},        'domain': [],        'fields': ['id', 'name', 'image_128'],        'limit': 80,      },    });    print(product);    return (product);      }
  String buildListItem(BuildContext context, dynamic data) {    // Assuming the image URL is available in the 'image' field of the product data    return data.toString();  }

アバター
破棄
最善の回答

Hi,

First of all am not sure about the second model that you refers too.  Anyway, Here you have to make to repeat the same code to fetch the data from the second model, once the data is fetched from both models, you can process the results to get the data in the needed format from your side. 


Also if you have access to backend db structure, you can make necessary adjustments, so that you will have all needed data in the product.template model and then using a single search_read you can get all data from there.

Thanks

アバター
破棄