[FIX] sale_timesheet: handle blank uom in product form view
Even though `uom_id` is required by product.template, it's still possible for users to delete it within the product view and trigger a compute that depends on it before saving. Steps to reproduce: 1 - install sale_timesheet + activate UoM 2 - open any product form, click on uom_id and delete the uom Expected result: No UoM + user cannot save Actual result: traceback + user can appear to save (but uom defaults back to last selected UoM While this isn't a blocking problem since users won't be able to save no UoM being selected, we would still rather avoid the traceback so we default to no service_upsell_threshold_ratio message in this case and properly prevent the saving. Task: 2689438 Also fully fixes: odoo/odoo#78693 closes odoo/odoo#80868 X-original-commit: f60786a7490cc09a31fe0dd0d74cf97368184bd9 Signed-off-by: Steve Van Essche <svs@odoo.com> Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
@@ -35,6 +35,9 @@ class ProductTemplate(models.Model):
|
||||
def _compute_service_upsell_threshold_ratio(self):
|
||||
product_uom_hour = self.env.ref('uom.product_uom_hour')
|
||||
for record in self:
|
||||
if not record.uom_id:
|
||||
record.service_upsell_threshold_ratio = False
|
||||
continue
|
||||
record.service_upsell_threshold_ratio = f"1 {record.uom_id.name} = {product_uom_hour.factor / record.uom_id.factor:.2f} Hours"
|
||||
|
||||
def _compute_visible_expense_policy(self):
|
||||
|
||||
Reference in New Issue
Block a user