'Add or set product quantity, add_qty can be negative'

@api.multi
def _cart_update(self, product_id=None, line_id=None, add_qty=0, set_qty=0, attributes=None, **kwargs):

    self.ensure_one()
    SaleOrderLineSudo = self.env['sale.order.line'].sudo()
    quantity = 0
    order_line = False
    if (self.state != 'draft'):
        request.session['sale_order_id'] = None
        raise UserError(_('It    is    forbidden    to    modify    a    sale    order    which    is    not    in    draft    status'))
    if (line_id is not False):
        order_lines = self._cart_find_product_line(product_id, line_id, **kwargs)
        order_line = (order_lines and order_lines[0])
    if (not order_line):
        values = self._website_product_id_change(self.id, product_id, qty=1)
        values['name'] = self._get_line_description(self.id, product_id, attributes=attributes)
        order_line = SaleOrderLineSudo.create(values)
        try:
            order_line._compute_tax_id()
        except ValidationError as e:
            _logger.debug(('ValidationError    occurs    during    tax    compute.    %s' % e))
        if add_qty:
            add_qty -= 1
    if set_qty:
        quantity = set_qty
    elif (add_qty is not None):
        quantity = (order_line.product_uom_qty + (add_qty or 0))
    if (quantity <= 0):
        order_line.unlink()
    else:
        values = self._website_product_id_change(self.id, product_id, qty=quantity)
        if ((self.pricelist_id.discount_policy == 'with_discount') and (not self.env.context.get('fixed_price'))):
            order = self.sudo().browse(self.id)
            product_context = dict(self.env.context)
            product_context.setdefault('lang', order.partner_id.lang)
            product_context.update({'partner': order.partner_id.id, 'quantity': quantity, 'date': order.date_order, 'pricelist': order.pricelist_id.id})
            product = self.env['product.product'].with_context(product_context).browse(product_id)
            values['price_unit'] = self.env['account.tax']._fix_tax_included_price(order_line._get_display_price(product), order_line.product_id.taxes_id, order_line.tax_id)
        order_line.write(values)
    return {'line_id': order_line.id, 'quantity': quantity}
