I'm trying to create an invoice using the request below.
Q#1 Although I can see an invoice getting created on Odoo, the taxes are not applied.
I can see that :
the product from invoice line has taxes on it
the fiscal position is configured correctly with the same tax applied
When I try to create an invoice manually, the tax is getting applied.
Q#2 Although I send 2 invoice lines, only 1 appears on Odoo
Q#3 Although discount_fixed is seen on the model, I only see % discount on Odoo invoice
{
"jsonrpc": "2.0",
"id": "",
"method": "call",
"params": {
"service": "object",
"method": "execute",
"args": [
"{{databaseName}}",
{{userId}},
"{{password}}",
"account.move",
"create",
{
"name": "Test Create Invoice 1",
"state": "draft",
"currency_id": 2,
"create_uid": {{userId}},
"partner_id": 1,
"company_id": 1,
"journal_id": 1,
"fiscal_position_id":1,
"invoice_date": "2022-01-27",
"invoice_date_due": "2022-05-27",
"move_type": "out_invoice",
"type_name": "Invoice",
"invoice_line_ids": [[0, "_", {
"sequence": 1,
"product_id": 1,
"company_id": 1,
"account_id": 1,
"analytic_account_id": 1,
"analytic_segment_one_id": 1,
"name": "Test Invoice Line",
"quantity": 1,
"price_unit": 50,
"discount_fixed": 10
}],[0, "_", {
"sequence": 2,
"product_id": 2,
"company_id": 1,
"account_id": 2,
"analytic_account_id": 2,
"analytic_segment_one_id": 2,
"name": "Test Invoice Line",
"quantity": 2,
"price_unit": 10,
"discount_fixed": 10
}]]
}
]
}
}
A#1: onchange('product_id') method apply taxes, I recommends you to create your own method in order to achieve this behaviour: Create in memory invoice, call onchange and then create.
A#2: You sould sent a list of dict, every element its and invoice.
A#3: The A#1 could help you here too.
I hope this answer can be helpful for you.
Related
This is my Apartment integrated with services
"id": 26,
"user_id": 1,
"title": "SAN MARINO",
"slug": "san-marino",
"rooms": 1,
"bathrooms": 1,
"beds": 1,
"squared_meters": 12,
"address": "San Marino, Carpi",
"latitude": "44.80924",
"longitude": "10.91565",
"image": "apartment_image/BMRQZSXLdWviqDwmHgqLzrmzG1hJzJGOq7DujnRB.jpg",
"is_visible": 1,
"floor": 1,
"price": 120,
"description": "2",
"created_at": "2022-02-21T21:41:53.000000Z",
"updated_at": "2022-02-21T21:41:53.000000Z",
"services": [
{
"id": 2,
"name": "Posto Macchina",
"slug": "posto-macchina",
"created_at": "2022-02-21T08:59:53.000000Z",
"updated_at": "2022-02-21T08:59:53.000000Z",
"pivot": {
"apartment_id": 26,
"service_id": 2
}
}
]
}
I use to filter my collection( $apartment_list = ApartmentResource::collection(Apartment::with(['services'])->get());)
using multiple WHERE, like this: $apartment_list = $apartment_list->where('rooms', '>=', $rooms);
How can i filter my Apartment refering to the pivot column service_id or services[id]?
There is filter method for the collection. You may create a callback for a single apartament and filter in any way you want:
$apartment_list->filter(function ($apartament) {
// ...
});
you can use try with this:
$serviceId = value_of_service_id;
$apartment_list = ApartmentResource::collection(Apartment:: whereHas('services', function ($q) use ($serviceId) {
$q->where('service_id', $serviceId);
})->get());
I have a list of Conversations, that come from multiple pages as below:
[
{
"id": 1,
"page_id": 1,
"name": "name 1",
"assigned_user_ids": ["user1"]
},
{
"id": 2,
"page_id": 2,
"name": "name 2",
"assigned_user_ids": ["user2"]
},
{
"id": 3,
"page_id": 1,
"name": "name 3",
"assigned_user_ids": ["user2"]
},
{
"id": 4,
"page_id": 2,
"name": "name 4",
"assigned_user_ids": ["user1"]
}
]
Imagine that "User 1" is calling the query, and User 1 can get all items of page_id = 1 (because user 1 is administrator), but in page_id = 2 he/she
only get the items that has been assigned to, in this case is item with id = 4.
So when user 1 query, what I want to received is:
[
{
"id": 1,
"page_id": 1,
"name": "name 1",
"assigned_user_ids": ["user1"]
},
{
"id": 3,
"page_id": 1,
"name": "name 3",
"assigned_user_ids": ["user2"]
},
{
"id": 4,
"page_id": 2,
"name": "name 4",
"assigned_user_ids": ["user1"]
}
]
This is my existing query in SQL look like:
SELECT * FROM Conversations
WHERE PageId IN (1, 2)
Can any one tell me how to modify my SQL to resolve my problem?
Thank you very much!
You can use OR It will either give you what is on page one, so everything from there, or everything that has been assigned to userId 1. So effectively only the things that have been assigned on every other page.
SELECT * FROM Conversations
WHERE PageId = 1 OR userId = 1
If you want to restrict this to only some pages, you can still use IN.
SELECT * FROM Conversations
WHERE PageId = 1 OR userId = 1 AND pageId IN (2,3,4)
In RavenDB 4.0+ for a given Sample Northwind database (which is also available at http://live-test.ravendb.net/), what RQL queries one may use to:
Get Orders in which at least one of the Lines has Discount == 0?
Get Orders in which all the Lines have Discount != 0?
Get Orders in which at least one of the Lines has Discount != 0?
Get Orders in which all the Lines have Discount == 0?
Here's a sample document structure:
{
"Company": "companies/85-A",
"Employee": "employees/5-A",
"Freight": 32.38,
"Lines": [
{
"Discount": 0,
"PricePerUnit": 14,
"Product": "products/11-A",
"ProductName": "Queso Cabrales",
"Quantity": 12
},
{
"Discount": 0,
"PricePerUnit": 9.8,
"Product": "products/42-A",
"ProductName": "Singaporean Hokkien Fried Mee",
"Quantity": 10
},
{
"Discount": 0,
"PricePerUnit": 34.8,
"Product": "products/72-A",
"ProductName": "Mozzarella di Giovanni",
"Quantity": 5
}
],
"OrderedAt": "1996-07-04T00:00:00.0000000",
"RequireAt": "1996-08-01T00:00:00.0000000",
"ShipTo": {
"City": "Reims",
"Country": "France",
"Line1": "59 rue de l'Abbaye",
"Line2": null,
"Location": {
"Latitude": 49.25595819999999,
"Longitude": 4.1547448
},
"PostalCode": "51100",
"Region": null
},
"ShipVia": "shippers/3-A",
"ShippedAt": "1996-07-16T00:00:00.0000000",
"#metadata": {
"#collection": "Orders",
"#flags": "HasRevisions",
"#id": "orders/1-A",
"#last-modified": "2018-07-27T12:11:53.0447651Z",
"#change-vector": "A:417-EKrWjfz5kESi6lp7Nf442Q",
"#index-score": 1
}
}
I managed to find out some answers only for 1 and 2:
Get Orders in which at least one of the Lines has Discount == 0?
from Orders where Lines[].Discount == 0
from Orders where Lines[].Discount IN (0)
from Orders where Lines[].Discount ALL IN (0)
Get Orders in which all the Lines have Discount != 0?
from Orders where Lines[].Discount != 0
database screenshot [
{
"id": "901651",
"supplier_id": "180",
"price": "18.99",
"product_id": "books",
"name": "bookmate",
"quantity": "1"
},
{
"id": "1423326",
"supplier_id": "180",
"price": "53.99",
"product_id": "books",
"name": "classmate",
"quantity": "5"
}
]
"
[{"id":"3811088","supplier_id":"2609","price":"22.99","product_id":"book","name":"classmate","quantity":"10"}]"
I have my purchased books details stored in an array of json object in a field named items in table purchase_list. This corresponds to only one order.Field may contain single or multiple orders. There are multiple orders like this. how can i get the total number of each type of book purchased and the type of books only using pgsql query to generate jasper report. for eg: classmate:15, bookmate:1
you can unnest array and aggregate it:
t=# with c(j) as (values('[
{
"id": "901651",
"supplier_id": "180",
"price": "18.99",
"product_id": "books",
"name": "bookmate",
"quantity": "1"
},
{
"id": "1423326",
"supplier_id": "180",
"price": "53.99",
"product_id": "books",
"name": "classmate",
"quantity": "5"
}
,{"id":"3811088","supplier_id":"2609","price":"22.99","product_id":"book","name":"classmate","quantity":"10"}]'::jsonb))
, agg as (select jsonb_array_elements(j) jb from c)
, mid as (select format('"%s":"%s"',jb->>'name',sum((jb->>'quantity')::int)) from agg group by jb->>'name')
select format('{%s}',string_agg(format,','))::jsonb from mid;
format
--------------------------------------
{"bookmate": "1", "classmate": "15"}
(1 row)
looks ugly, but gives the idea
On the BigC dashboard, I can configure two types of discount applications to Category Level discount:
"products in this categories only"
"products in this category and its subcategories".
Example Customer Group Category Level
When retrieving the customer groups via the API, how can I tell which way it was configured? The API returns back very limited information pertaining to customer groups. For example:
[
{
"id": 1,
"name": "Sample Customer Group",
"is_default": false,
"category_access": {
"type": "all"
},
"discount_rules": [
{
"type": "category",
"category_id": "20",
"method": "fixed",
"amount": "9.0000"
},
{
"type": "category",
"category_id": "3",
"method": "percent",
"amount": "10.0000"
}
]
}
]
I can see the category it applies to, and the level of the discount, but the API doesn't return back whether the discount applies to just the category, or also it's subcategories. How can I get this info?