Intechnity-com / OdooJsonRpcClient

Odoo Client Json Rpc
MIT License
67 stars 29 forks source link

API returning old data for bulk updated records using Import feature #60

Open pavan-atliis opened 1 year ago

pavan-atliis commented 1 year ago

Steps to reproduce the issue:

  1. log in to Odoo and navigate to Products.
  2. Create a product with the name "TestProduct".
  3. Try to read this product using the API. You will get the correct product name as "TestProduct".
  4. Now, go to Products and export that product as an importable row in excel.
  5. Update the product name to "Product123" in the excel sheet and import it back into the Odoo.
  6. Now, try to read the same product using API. You will still get the old product name as "TestProduct".
patricoos commented 1 year ago

Are you using multiple languages?

pavan-atliis commented 1 year ago

No. Single language, testing on a fresh Odoo 16 instance.

pavan-atliis commented 1 year ago

I just tested again and found that not only with the bulk import, if you update the product directly in the Odoo we can see the same issue. This means we are not able to get the updated data of any record.

patricoos commented 1 year ago

please add a code example

pavan-atliis commented 1 year ago
namespace Odoo.Models
{
    [OdooTableName("product.template")]
    [JsonConverter(typeof(OdooModelConverter))]
    public class ProductTemplate : IOdooModel
    {
        [JsonProperty("id")]
        public long Id { get; set; }

        [JsonProperty("name")]
        public string Name { get; set; }

        [JsonProperty("__last_update")]
        public DateTime LastUpdated { get; set; }
    }
}

//GET Product Data

long ID = 2;
OdooRepository<ProductTemplate> Repository = new OdooRepository<ProductTemplate>(Global.GetOdooConfig());
ProductTemplate product = Repository.Query().ById(ID).FirstOrDefaultAsync().Result.Value;
Console.WriteLine(product.Name);
patricoos commented 1 year ago

Ale you sure that you are updating product.template not product.product?

pavan-atliis commented 1 year ago

Yes. I can see the LastUpdated value changed but not other field values.

To simplify the testing, you can create a new product.template. Use the newly created ID in the code to read the data. Now update something and run the same code. You will still get the old values except LastUpdated as the latest value.

patricoos commented 1 year ago

Please check another fields, maybe you update something else

pavan-atliis commented 1 year ago

I have tried reading another field and it gives me the updated values. I think the only issue is with the name field.

patricoos commented 1 year ago

I mean the name you change may not be name property but something else

pavan-atliis commented 1 year ago

It is name property for sure. When I hover over the value in Odoo, I see the field name. I also tried reading the display_name field, but I got the same old value.

image