Skip to Content
Menu
This question has been flagged
1 Reply
1376 Views
Hello, I am using a conditional field where I want to obtain quantities on hand from a specific location for example from my attached WH/Stock example


Avatar
Discard
Best Answer
Hello  Comimprint,

you can make that studio field as compute and depends on product_id and location_id. following method of stock.quant model will return available qty of spefic product and location.


@api.model
def _get_available_quantity(self, product_id, location_id, lot_id=None, package_id=None, owner_id=None, strict=False, allow_negative=False):
""" Return the available quantity, i.e. the sum of `quantity` minus the sum of
`reserved_quantity`, for the set of quants sharing the combination of `product_id,
location_id` if `strict` is set to False or sharing the *exact same characteristics*
otherwise.
This method is called in the following usecases:
- when a stock move checks its availability
- when a stock move actually assign
- when editing a move line, to check if the new value is forced or not
- when validating a move line with some forced values and have to potentially unlink an
equivalent move line in another picking
In the two first usecases, `strict` should be set to `False`, as we don't know what exact
quants we'll reserve, and the characteristics are meaningless in this context.
In the last ones, `strict` should be set to `True`, as we work on a specific set of
characteristics.

:return: available quantity as a float


Let us know if you still need any help on this, 

Thanks,


Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015

Avatar
Discard
Related Posts Replies Views Activity
1
Oct 24
175
2
Oct 24
1140
1
Jul 24
453
0
Jun 24
249
2
Feb 24
1122