Skip to Content
Menu
This question has been flagged
2 Replies
3519 Views

So I have this code:


@api.multi
    def write(self, vals):
        if vals.get('price_unit'):
            price = self.order_id.pricelist_id.get_product_price(self.product_id, self.product_uom_qty, self.order_id.partner_id)
            if vals.get('price_unit') < price:
                raise UserError(_("You cannot confirm this SO because the new price %s is less than the system price %s for this product %s '!") % (vals.get('price_unit'), price, self.product_id.name))
        return super(SaleOrderLine, self).write(vals)


And in the SO in debug mode I can see that price_unit is the Unit Price of the item.  And this code above is comparing it to price, which is a local variable in the python file equal to:


self.order_id.pricelist_id.get_product_price(self.product_id, self.product_uom_qty, self.order_id.partner_id)


So im guessing that is a function self.order_id.pricelist_id.get_product_price().  This rule is incorrectly coded because it should be comparing it to the cost, not the price.  If the price_unit < purchase_price, then ERROR.


How do I get the purchase_price?


Avatar
Discard

Hello Marcio,

can you please us know on which version you working or you need this?

Author

v11 CE