// [Fact] public async Task Can_create_product_and_delete_using_object() { var odooClient = new OdooClient(Config); var model = new OdooCreateProduct() { Name = "Prod test Kg", UomId = 3, UomPoId = 3 }; var createResult = await odooClient.CreateAsync(model); createResult.Succeed.Should().BeTrue(); var createdProductId = createResult.Value; var query = OdooQuery <ProductProductOdooDto> .Create().ById(createdProductId); var product = await odooClient.GetAsync <ProductProductOdooDto>(query); product.Succeed.Should().BeTrue(); product.Value.First().Name.Should().Be(model.Name); var deleteProductResult = await odooClient.DeleteAsync(product.Value.First()); deleteProductResult.Succeed.Should().BeTrue(); deleteProductResult.Value.Should().BeTrue(); }
// [Fact] public async Task Can_create_product_from_dictionary_model() { var odooClient = new OdooClient(Config); var dictModel = OdooDictionaryModel.Create(() => new ProductProductOdooDto { Name = "test OdooCreateDictionary", }); var dictModel2 = OdooDictionaryModel.Create <ProductProductOdooDto>(x => x.CombinationIndices, "create test"); var dictModel3 = OdooDictionaryModel.Create <ProductProductOdooDto>(x => x.InvoicePolicy, InvoicingPolicyOdooEnum.DeliveredQuantities); dictModel.Add <ProductProductOdooDto>(x => x.CombinationIndices, "sadasd"); dictModel.Add <ProductProductOdooDto>(x => x.InvoicePolicy, InvoicingPolicyOdooEnum.DeliveredQuantities); var createResult = await odooClient.CreateAsync(dictModel); createResult.Succeed.Should().BeTrue(); createResult.Value.Should().BeGreaterThan(0); var deleteProductResult = await odooClient.DeleteAsync("product.product", createResult.Value); deleteProductResult.Succeed.Should().BeTrue(); deleteProductResult.Value.Should().BeTrue(); }
//[Fact] public async Task Can_create_update_delete_product() { var odooClient = new OdooClient(Config); var model = new OdooCreateProduct() { Name = "Prod test Kg", UomId = 3, UomPoId = 3, InvoicePolicy = InvoicingPolicyOdooEnum.DeliveredQuantities }; var createResult = await odooClient.CreateAsync(model); createResult.Succeed.Should().BeTrue(); var createdProductId = createResult.Value; var query = OdooQuery <ProductProductOdooDto> .Create() .Where(x => x.Id, OdooOperator.EqualsTo, createdProductId); var products = await odooClient.GetAsync <ProductProductOdooDto>(query); products.Succeed.Should().BeTrue(); products.Value.Length.Should().Be(1); products.Value.First().Name.Should().Be(model.Name); model.Name += " update"; var updateProductResult = await odooClient.UpdateAsync(model, createdProductId); updateProductResult.Succeed.Should().BeTrue(); var query2 = OdooQuery <ProductProductOdooDto> .Create() .Where(x => x.Id, OdooOperator.EqualsTo, createdProductId); var products2 = await odooClient.GetAsync <ProductProductOdooDto>(query2); products2.Succeed.Should().BeTrue(); products2.Value.Length.Should().Be(1); products2.Value.First().Name.Should().Be(model.Name); var deleteProductResult = await odooClient.DeleteAsync(model.OdooTableName(), createdProductId); deleteProductResult.Succeed.Should().BeTrue(); deleteProductResult.Value.Should().BeTrue(); }
public async Task Can_create_update_and_delete_product() { var odooClient = new OdooClient(TestConfig); var model = OdooDictionaryModel.Create(() => new ProductProductOdooModel { Name = "test name", UomId = 3, UomPoId = 3, CompanyId = 1 }); var createResult = await odooClient.CreateAsync(model); createResult.Error.Should().BeNull(); createResult.Succeed.Should().BeTrue(); var query = OdooQuery <ProductProductOdooModel> .Create() .ById(createResult.Value); var products = await odooClient.GetAsync <ProductProductOdooModel>(query); products.Succeed.Should().BeTrue(); products.Value.First().CompanyId.Should().Be(1); var dict = OdooDictionaryModel.Create(() => new ProductProductOdooModel { CompanyId = null }); var updateResult = await odooClient.UpdateAsync(dict, createResult.Value); updateResult.Succeed.Should().BeTrue(); var products2 = await odooClient.GetAsync <ProductProductOdooModel>(query); products2.Succeed.Should().BeTrue(); products2.Value.First().CompanyId.Should().BeNull(); var deleteResult = await odooClient.DeleteAsync(products2.Value.First()); deleteResult.Succeed.Should().BeTrue(); }
public async Task Can_create_update_get_and_delete_customer() { var model = OdooDictionaryModel.Create(() => new ResPartnerOdooModel() { Name = "dupa", CountryId = 20, City = "dupa", Zip = "dupa", Street = "dupa", CompanyType = CompanyTypeResPartnerOdooEnum.Individual }); var odooClient = new OdooClient(TestConfig); var products = await odooClient.CreateAsync(model); products.Succeed.Should().BeTrue(); products.Value.Should().BePositive(); model.Add(x => x.Name, "new name"); var editedCustomer = await odooClient.UpdateAsync(model, products.Value); editedCustomer.Succeed.Should().BeTrue(); var query = new OdooQuery(); query.Filters.EqualTo("id", products.Value); var customers = await odooClient.GetAsync <ResPartnerOdooModel>(query); customers.Succeed.Should().BeTrue(); customers.Value.Length.Should().Be(1); customers.Value.First().Name.Should().Be("new name"); var deleteResult = await odooClient.DeleteAsync(customers.Value.First()); deleteResult.Succeed.Should().BeTrue(); }