// [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(); }
public void Can_create_simple_dictionary() { var model = OdooDictionaryModel.Create(() => new PurchaseOrderOdooModel() { CompanyId = 1, PartnerId = 2, CurrencyId = 3, XStudioPickupAddress = "pickupAddress", State = StatusPurchaseOrderOdooEnum.PurchaseOrder }); model.TableName.Should().NotBeEmpty(); model.Should().NotBeEmpty(); model.Count.Should().Be(5); model.First().Key.Should().Be("company_id"); model.First().Value.Should().Be(1); model.Skip(1).First().Key.Should().Be("partner_id"); model.Skip(1).First().Value.Should().Be(2); model.Skip(2).First().Key.Should().Be("currency_id"); model.Skip(2).First().Value.Should().Be(3); model.Skip(3).First().Key.Should().Be("x_studio_pickup_address"); model.Skip(3).First().Value.Should().Be("pickupAddress"); model.Skip(4).First().Key.Should().Be("state"); model.Skip(4).First().Value.Should().Be(StatusPurchaseOrderOdooEnum.PurchaseOrder); }
public async Task Can_Create_customer() { var name = "dupa"; var city = "dupa"; var postalCode = "dupa"; var vatEu = "test"; var address = "dupa"; var isCompany = true; CompanyTypeResPartnerOdooEnum?test = CompanyTypeResPartnerOdooEnum.Company; var model = OdooDictionaryModel.Create(() => new ResPartnerOdooModel() { Name = name, CountryId = 20, City = city, Zip = postalCode, //Vat = vatEu, Street = address, CompanyType = test ?? CompanyTypeResPartnerOdooEnum.Individual }); var odooClient = new OdooClient(Config); var products = await odooClient.CreateAsync(model); products.Succeed.Should().BeTrue(); }
private static string GetTableName(OdooDictionaryModel model, string tableName = null) { if (tableName != null) return tableName; else if (model.TableName != null) return model.TableName; else throw new ArgumentException( $"TableName not set in {nameof(OdooDictionaryModel)}, use ctor or {nameof(OdooDictionaryModel.Create)} method with param"); }
// [Fact] public async Task Can_create_sale_order() { var odooClient = new OdooClient(Config); var companyResult = await odooClient.GetAsync <CompanyOdooDto>(OdooQuery <CompanyOdooDto> .Create().ById(1)); companyResult.Succeed.Should().BeTrue(); var company = companyResult.Value.First(); var partnerResult = await odooClient.GetAsync <ResPartnerOdooModel>(OdooQuery <ResPartnerOdooModel> .Create().ById(9)); partnerResult.Succeed.Should().BeTrue(); var partner = partnerResult.Value.First(); var productQuery = OdooQuery <ProductProductOdooDto> .Create().ById(41); var productsResult = await odooClient.GetAsync <ProductProductOdooDto>(productQuery); productsResult.Succeed.Should().BeTrue(); var product = productsResult.Value.First(); var dictModel = OdooDictionaryModel.Create(() => new SaleOrderOdooModel { PricelistId = 17, PartnerId = partner.Id, PartnerInvoiceId = partner.Id, PartnerShippingId = partner.Id, CompanyId = company.Id, DateOrder = DateTime.Now, }); var createResult = await odooClient.CreateAsync(dictModel); createResult.Message.Should().BeNullOrEmpty(); createResult.Succeed.Should().BeTrue(); var lineModel = OdooDictionaryModel.Create(() => new SaleOrderLineOdooDto() { OrderId = createResult.Value, Name = "test line", ProductId = product.Id, ProductUomQty = 24, PriceUnit = 15 }); var createLineResult = await odooClient.CreateAsync(lineModel); createLineResult.Succeed.Should().BeTrue(); }
// [Fact(Skip = "Test for working on Odoo")] public async Task CreatePurchaseOrderAsync() { var odooCompanyId = 32; var accountTaxOdooRepository = new OdooRepository <AccountTaxOdooModel>(Config); var purchaseOrderOdooRepository = new OdooRepository <PurchaseOrderOdooModel>(Config); var purchaseOrderLineOdooRepository = new OdooRepository <PurchaseOrderLineOdooModel>(Config); var odooCompanyTaxes = await accountTaxOdooRepository.Query() .Where(x => x.CompanyId, OdooOperator.EqualsTo, odooCompanyId) .Where(x => x.AmountType, OdooOperator.EqualsTo, TaxComputationAccountTaxOdooEnum.PercentageOfPrice) .ToListAsync(); // odooCompanyTaxes.Succeed.Should().BeTrue(); // odooCompanyTaxes.Value.Should().NotBeNull().And.NotBeEmpty(); var purchaseOrderModel = OdooDictionaryModel.Create(() => new PurchaseOrderOdooModel() { CompanyId = odooCompanyId, DateOrder = GetTestdate(), PartnerId = 1, CurrencyId = 1, XStudioPickupAddress = "pickupAddress", XStudioPickupDate = GetTestdate(), State = StatusPurchaseOrderOdooEnum.PurchaseOrder }); // var orderResult = await purchaseOrderOdooRepository.CreateAsync(purchaseOrderModel); // orderResult.Succeed.Should().BeTrue(); // var taxId = odooCompanyTaxes.Value.FirstOrDefault(x => x.Amount == 6); // taxId.Should().NotBeNull(); var model = OdooDictionaryModel.Create(() => new PurchaseOrderLineOdooModel() { PriceUnit = 10, ProductId = 12, ProductQty = 11, // OrderId = orderResult.Value, State = StatusPurchaseOrderLineOdooEnum.PurchaseOrder, TaxesId = new long[] { 12, 11 } }); // var createPurchaseOrderLineResult = await purchaseOrderLineOdooRepository.CreateAsync(model); // createPurchaseOrderLineResult.Succeed.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 void Can_create_dictionary_with_create_instance() { var model = OdooDictionaryModel.Create(() => new PurchaseOrderLineOdooModel() { DateOrder = new DateTime(), }); model.Add(x => x.CreateDate, new DateTime()); model.TableName.Should().NotBeEmpty(); model.Should().NotBeEmpty(); model.Count.Should().Be(2); model.First().Key.Should().Be("date_order"); model.First().Value.Should().Be(new DateTime()); model.Skip(1).First().Key.Should().Be("create_date"); model.Skip(1).First().Value.Should().Be(new DateTime()); }
public void Can_create_dictionary_with_call_method() { var model = OdooDictionaryModel.Create(() => new PurchaseOrderLineOdooModel() { Name = TestString(), }); model.Add(x => x.DisplayName, TestString()); model.TableName.Should().NotBeEmpty(); model.Should().NotBeEmpty(); model.Count.Should().Be(2); model.First().Key.Should().Be("name"); model.First().Value.Should().BeOfType <string>(); model.Skip(1).First().Key.Should().Be("display_name"); model.Skip(1).First().Value.Should().BeOfType <string>(); }
public void Can_create_dictionary_with_create_instance() { var model = OdooDictionaryModel.Create(() => new ProductProductOdooModel() { Name = "test name", }); model.Add(x => x.CreateDate, new DateTime()); model.TableName.Should().NotBeEmpty(); model.Should().NotBeEmpty(); model.Count.Should().Be(2); model.First().Key.Should().Be("name"); model.First().Value.Should().Be("test name"); model.Skip(1).First().Key.Should().Be("create_date"); model.Skip(1).First().Value.Should().Be(new DateTime()); }
public void Can_create_dictionary_with_array() { var model = OdooDictionaryModel.Create(() => new PurchaseOrderLineOdooModel() { AnalyticTagIds = new long[] { 1, 2, 3 } }); model.Add(x => x.InvoiceLines, new long[] { 4, 5, 6 }); model.TableName.Should().NotBeEmpty(); model.Should().NotBeEmpty(); model.Count.Should().Be(2); model.First().Key.Should().Be("analytic_tag_ids"); model.First().Value.Should().BeOfType <long[]>().And.NotBeNull(); model.First().Value.Should().BeEquivalentTo(new long[] { 1, 2, 3 }); model.Skip(1).First().Key.Should().Be("invoice_lines"); model.Skip(1).First().Value.Should().BeOfType <long[]>().And.NotBeNull(); model.Skip(1).First().Value.Should().BeEquivalentTo(new long[] { 4, 5, 6 }); }
public void Can_create_dictionary_with_array() { var model = OdooDictionaryModel.Create(() => new ProductProductOdooModel() { ActivityIds = new long[] { 1, 2, 3 } }); model.Add(x => x.MessageFollowerIds, new long[] { 4, 5, 6 }); model.TableName.Should().NotBeEmpty(); model.Should().NotBeEmpty(); model.Count.Should().Be(2); model.First().Key.Should().Be("activity_ids"); model.First().Value.Should().BeOfType <long[]>().And.NotBeNull(); model.First().Value.Should().BeEquivalentTo(new long[] { 1, 2, 3 }); model.Skip(1).First().Key.Should().Be("message_follower_ids"); model.Skip(1).First().Value.Should().BeOfType <long[]>().And.NotBeNull(); model.Skip(1).First().Value.Should().BeEquivalentTo(new long[] { 4, 5, 6 }); }
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(); }
public async Task <OdooResult <bool> > UpdateRangeAsync(OdooDictionaryModel model, long[] ids) { return(await ExecuteWitrAccesDenideRetryAsync(userUid => UpdateRangeAsync(_config, userUid, model, ids))); }
public async Task<OdooResult<long>> CreateAsync(OdooDictionaryModel model, OdooContext context = null) { return await ExecuteWitrAccesDenideRetryAsync(userUid => CreateAsync(Config, userUid, model, SelectContext(context , Config.Context))); }
public async Task <OdooResult <long> > CreateAsync(OdooDictionaryModel model) { return(await OdooClient.CreateAsync(model)); }
public async Task <OdooResult <bool> > UpdateAsync(OdooDictionaryModel model, long id) { return(await OdooClient.UpdateAsync(model, id)); }
public async Task <OdooResult <bool> > UpdateAsync(OdooDictionaryModel model, long id) { return(await UpdateRangeAsync(model, new[] { id })); }
public static async Task <OdooResult <bool> > UpdateAsync(OdooConfig odooConfig, int userUid, OdooDictionaryModel model, long id) { return(await UpdateRangeAsync(odooConfig, userUid, model, new[] { id })); }
public async Task<OdooResult<bool>> UpdateRangeAsync(OdooDictionaryModel model, long[] ids, OdooContext context = null) { return await ExecuteWitrAccesDenideRetryAsync(userUid => UpdateRangeAsync(Config, userUid, model, ids, SelectContext(context , Config.Context))); }
public async Task <OdooResult <bool> > UpdateAsync(OdooDictionaryModel model, long id, OdooContext context = null) { return(await OdooClient.UpdateAsync(model, id, context)); }
public static async Task <OdooResult <bool> > UpdateRangeAsync(OdooConfig odooConfig, int userUid, OdooDictionaryModel model, long[] ids) { var request = OdooRequestModel.Update(odooConfig, userUid, GetTableName(model), ids, model); return(await CallAndDeserializeAsync <bool>(request)); }
public async Task <OdooResult <long> > CreateAsync(OdooDictionaryModel model) { return(await ExecuteWitrAccesDenideRetryAsync(userUid => CreateAsync(_config, userUid, model))); }
public async Task <OdooResult <long> > CreateAsync(OdooDictionaryModel model, OdooContext context = null) { return(await OdooClient.CreateAsync(model, context)); }
public static async Task <OdooResult <long> > CreateAsync(OdooConfig odooConfig, int userUid, OdooDictionaryModel model) { var request = OdooRequestModel.Create(odooConfig, userUid, GetTableName(model), model); var result = await CallAndDeserializeAsync <long[]>(request); return(result.Succeed ? result.ToResult(result.Value.FirstOrDefault()) : OdooResult <long> .FailedResult(result)); }
public async Task <OdooResult <bool> > UpdateRangeAsync(OdooDictionaryModel model, long[] ids, OdooContext context = null) { model.TableName = TableName; return(await OdooClient.UpdateRangeAsync(model, ids, context)); }
public async Task<OdooResult<bool>> UpdateAsync(OdooDictionaryModel model, long id, OdooContext context = null) { return await UpdateRangeAsync(model, new[] { id }, SelectContext(context , Config.Context)); }