You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys.
I work on the C# transfer app that should export some data from one database and import it to Odoo. And I use this library. It helps me very lot. But I encountered some strange behavior.
I have a ResPartnerOdooModel:
[OdooTableName("res.partner")]
[JsonConverter(typeof(OdooModelConverter))]
public class ResPartnerOdooModel : IOdooModel
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("country_id")]
public long? CountryId { get; set; }
}
In my code, I have some method that returns the ID of the record from the Odoo database for the specific country by country name:
So what happened?
In my data from the source database, there are 2 records with the same name but in the first record Country = "NULL", and in the second record Country = "United States". The code for the "United States" in the Odoo database is 233.
So, I import the first record:
var model = OdooDictionaryModel.Create(() => new ResPartnerOdooModel()
{
Name = name,
CountryId = null,
});
var createResult = await repository.CreateAsync(model);
if (createResult.Succeed)
{
// ID of the created record
long createdRecordId = createResult.Value;
}
All good. I see the correct record in the Odoo database.
After this I check by Name if I already have the imported record:
var filter = OdooFilter<ResPartnerOdooModel>.Create().EqualTo(r => r.Name, name);
var partnerResult = await repository.Query().Where(filter).FirstOrDefaultAsync();
var partnerId = partnerResult.Value.Id;
It returns the correct ID of the first created record in the Odoo database.
After this, I try to update this record with new data, where CountryId = 233:
var model = OdooDictionaryModel.Create(() => new ResPartnerOdooModel()
{
Name = name,
CountryId = 233,
});
var createResult = await repository.UpdateAsync(model, partnerId);
But after calling the Update method I still see the record in the database where the cell in the "country_id" = "NULL".
I also tried to replace the Update method by calling:
var deleteResult = await repository.DeleteAsync(partnerId);
if (deleteResult.Succeed && deleteResult.Value)
{
var createResult = await repository.CreateAsync(model);
}
It removes the old record and should create a new record with CountryId = 233. And I see that record was created, it has a new "id" and new "create_date" values, but still "country_id" = "NULL".
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys.
I work on the C# transfer app that should export some data from one database and import it to Odoo. And I use this library. It helps me very lot. But I encountered some strange behavior.
I have a ResPartnerOdooModel:
In my code, I have some method that returns the ID of the record from the Odoo database for the specific country by country name:
So what happened?
In my data from the source database, there are 2 records with the same name but in the first record Country = "NULL", and in the second record Country = "United States". The code for the "United States" in the Odoo database is 233.
So, I import the first record:
All good. I see the correct record in the Odoo database.
After this I check by Name if I already have the imported record:
It returns the correct ID of the first created record in the Odoo database.
After this, I try to update this record with new data, where CountryId = 233:
But after calling the Update method I still see the record in the database where the cell in the "country_id" = "NULL".
I also tried to replace the Update method by calling:
It removes the old record and should create a new record with CountryId = 233. And I see that record was created, it has a new "id" and new "create_date" values, but still "country_id" = "NULL".
Why it doesn't want to update the "country_id"?
Beta Was this translation helpful? Give feedback.
All reactions