[FIX] point_of_sale: prevent ValueError when tip product is deleted
"ValueError: No record found for unique ID point_of_sale.product_product_tip. It may have been deleted." is generated when user delete 'Tips' from the product and try to enable tip payment from the POS setting. Step to produce: 1. Install point_of_sale 2. Open product and delete 'Tips' product 3. Open POS > Configure > Setting 4. Enable Tips in payment > select any product in tip product 5. click save >>> Traceback generated This commit solves the above issue by passing 'raise_if_not_found=False' to ensure it does not throw an error when the tip product is not found. sentry-4232555961 closes odoo/odoo#124435 X-original-commit: b3675accd7d4ddfe97712060cda1259cf0b131f6 Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com> Signed-off-by: ANSARI MAHAMADASIF (maan) <maan@odoo.com>
This commit is contained in:
@@ -246,7 +246,7 @@ class PosConfig(models.Model):
|
||||
@api.depends('iface_tipproduct')
|
||||
def _compute_tip_product_id(self):
|
||||
for pos_config in self:
|
||||
pos_config.tip_product_id = self.env.ref("point_of_sale.product_product_tip")
|
||||
pos_config.tip_product_id = self.env.ref("point_of_sale.product_product_tip", raise_if_not_found=False)
|
||||
if not pos_config.tip_product_id:
|
||||
pos_config.tip_product_id = self.env['product.product'].search([('default_code', '=', 'TIPS')], limit=1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user