Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1439 Widoki

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();  }

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć