Hi
how to add quantity of stock for all locations in any product to view tree
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi
how to add quantity of stock for all locations in any product to view tree
Thanks
Oussama, when you say 'add' is to include it in the tree view or to increase the quantity? If you need to include the quantity field (there are 2 quantity fields) you just need to include it in the product's tree view. The fields name are qty_available and virtual_available. The virtual_available includes all potential (not completed) movements while qty_available includes only completed movements. If you didn't specify anything else you get the total (in - out) movement into all locations that are attached to Warehouses' Stock location including their children. In principle this is the stock that the company holds. Any location that are considered company's stock should be within the Warehouse's Stock location structure.
If you want to increase the quantity, you need to do it through export-import of stock.move. Each product and location pairs are increased using one stock.move record.
Thanks john, My question is how to include quantity of product for all location (for example i have location "A" with qty_available 30 and lacation "B" with qty_available 50 , I want to display in the view tree of model product.product the qty_available for location "A" and qty_available for location "B" for each product. thanks a lot
Oussama, what I can think on top of my head is to create a function field which returns the data that you want. Unfortunately I don't think it can be made into a tabulized layout (cross-tab query if you understand it). A very simple implementation is a function field of type text that will return the name of locations with qty_available and the qty_available. I would imagine that this would need quite a bit of processing power and time, though.
Oussama, what I can think on top of my head is to create a function field which returns the data that you want. Unfortunately I don't think it can be made into a tabulized layout (cross-tab query if you understand it). A very simple implementation is a function field of type text that will return the name of locations with qty_available and the qty_available. I would imagine that this would need quite a bit of processing power and time, though.
--
John Doe
Sent by Odoo Inc. using Odoo about Forum Post False
You need to elaborate what do you mean by not working. The code that you have crafted will show the monetary value (not quantity) of the stock in the last internal location in company_id that is equal to 'sousse1'. Now, do you have company which ID is 'sousse1' (I doubt it because company_ids are integer)? Do you have any location which belong to that company? Do you have any product in that location?
You need to elaborate what do you mean by not working. The code that you have crafted will show the monetary value (not quantity) of the stock in the last internal location in company_id that is equal to 'sousse1'. Now, do you have company which ID is 'sousse1' (I doubt it because company_ids are integer)? Do you have any location which belong to that company? Do you have any product in that location?
It's a bit unusual to search by a specific company. In a single-company situation, it does not matter if you filter by company or not. In a multi-company situation, filtering by a specific company instead of the company the user is currently in may lead into cross-company data inconsistency (a transaction that is made with data from various companies). It is more usual to filter by the company the user is currently logged into. To do so, you can use the following domain: [('usage', '=', 'internal'),('company_id', 'child_of', user.company_id.id)]. But, again your code will show the monetary value (not quantity) of the stock in the last internal location in the company that the user is logged into. If you want to show the total of the monetary value in all locations, you need to aggregate record.stock_real. So use res[record.a] += record.stock_real. Put the res[record.a] = {'sousse1' : 0.0} outside the for loop but assign a 0.0 instead. If you want to show the quantity per location, as I've mentioned before you need to text field instead of float. Then you can construct a string with the location's name and value. If you want to show the quantity instead of monetary value, use product.product's qty_available. You need to browse the product several times with different context. Read the get_product_available method in stock/product.py to understand the working of qty_available. (get_product_available is the method called to calculate qty_available).
It's a bit unusual to search by a specific company. In a single-company situation, it does not matter if you filter by company or not. In a multi-company situation, filtering by a specific company instead of the company the user is currently in may lead into cross-company data inconsistency (a transaction that is made with data from various companies). It is more usual to filter by the company the user is currently logged into. To do so, you can use the following domain: [('usage', '=', 'internal'),('company_id', 'child_of', user.company_id.id)]. But, again your code will show the monetary value (not quantity) of the stock in the last internal location in the company that the user is logged into. If you want to show the total of the monetary value in all locations, you need to aggregate record.stock_real. So use res[record.a] += record.stock_real. Put the res[record.a] = {'sousse1' : 0.0} outside the for loop but assign a 0.0 instead. If you want to show the quantity per location, as I've mentioned before you need to text field instead of float. Then you can construct a string with the location's name and value. If you want to show the quantity instead of monetary value, use product.product's qty_available. You need to browse the product several times with different context. Read the get_product_available method in stock/product.py to understand the working of qty_available. (get_product_available is the method called to calculate qty_available).
Then you can try to use ['company_id.name', '=', 'sousse1'] instead. There are 2 catches. Catch No. 1, it will search by Company's name, so if the Company's name changed, the filter will fail. It is better to use XML ID, however the implementation will be quite different. Catch No. 2, if the user logs into a company that does not have access to 'sousse1', then the view may not be displayed at all due to permission error.
Then you can try to use ['company_id.name', '=', 'sousse1'] instead. There are 2 catches. Catch No. 1, it will search by Company's name, so if the Company's name changed, the filter will fail. It is better to use XML ID, however the implementation will be quite different. Catch No. 2, if the user logs into a company that does not have access to 'sousse1', then the view may not be displayed at all due to permission error.
Well those would be good restrictions to have. If you want to display the quantity only to admin, you can create a group (with proper XMLID) and make that field visible only to that group. And make sure that only admin belongs to that group. Note that although admin may have access to all company, at any point in time the admin user need to log in to a company. If the company admin user logs into does not have access to sousse1 company, the user still may get an error.
Well those would be good restrictions to have. If you want to display the quantity only to admin, you can create a group (with proper XMLID) and make that field visible only to that group. And make sure that only admin belongs to that group. Note that although admin may have access to all company, at any point in time the admin user need to log in to a company. If the company admin user logs into does not have access to sousse1 company, the user still may get an error.
Sorry Oussama, if you cannot elaborate further than "it not worked", I'm afraid I can't help you further.
Sorry Oussama, if you cannot elaborate further than "it not worked", I'm afraid I can't help you further.