[FIX] sale: ensure Down Payment product exists

In case the Down Payment product is removed/not accessible, trying to create
a down payment from a sale order to invoice produced an error "Record does not
exist or has been deleted. (Records: [42], User: 2)"

Add a exists for returning an empty recordset for a better fallback and create
a new Down Payment product using the wizard

closes odoo/odoo#32965

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
Swapnesh Shah
2019-07-16 16:01:40 +00:00
committed by Martin Trigaux
parent 7766b89aa0
commit 1e5fbb8e5b
@@ -30,7 +30,7 @@ class SaleAdvancePaymentInv(models.TransientModel):
@api.model
def _default_product_id(self):
product_id = self.env['ir.config_parameter'].sudo().get_param('sale.default_deposit_product_id')
return self.env['product.product'].browse(int(product_id))
return self.env['product.product'].browse(int(product_id)).exists()
@api.model
def _default_deposit_account_id(self):