This question has been flagged
2 Replies
4702 Views

Hi,

I'm curious about why it is only possible to increase the quantity to receive and not decrease.

addons/purchase/models/purchase.py#L733
if float_compare(diff_quantity, 0.0,  precision_rounding=self.product_uom.rounding) >0:

Because it is not possible to decrease below received quantity.

addons/purchase/models/purchase.py#L654
if float_compare(line.product_qty, line.qty_received, line.product_uom.rounding) <0:

Nonetheless, you could possibly want to decrease the quantity before you have receive any goods.

Thanks.

Avatar
Discard
Best Answer

I was stuck at this problem as well, but finally I figured out i guess, if you want to allow to decrease the qty on picking while decreasing on po line, update _prepare_stock_moves  method at addons/purchase_stock/model/purchase.py at purchase.order.line model:

        if float_compare(diff_quantity, 0.0,  precision_rounding=self.product_uom.rounding) > 0:
            po_line_uom = self.product_uom
            quant_uom = self.product_id.uom_id
            product_uom_qty, product_uom = po_line_uom._adjust_uom_quantities(diff_quantity, quant_uom)
            template['product_uom_qty'] = product_uom_qty
            template['product_uom'] = product_uom.id
            res.append(template)
        return res


Remove that        if float_compare(diff_quantity, 0.0,  precision_rounding=self.product_uom.rounding) > 0: condition, it should work. Thanks
Avatar
Discard

What do you think of this solution? Is this the right approach? There must be a reason odoo implemented this constraint

Best Answer

Hi @Bishal what is the value of diff_quantity?

Avatar
Discard