11from dateutil .relativedelta import relativedelta
2- from odoo import api , fields , models , _
2+ from odoo import api , fields , models
33from odoo .exceptions import UserError , ValidationError
44from odoo .tools .float_utils import float_compare , float_is_zero
55
@@ -69,7 +69,7 @@ def _onchange_garden_defaults(self) -> None:
6969 @api .ondelete (at_uninstall = False )
7070 def _unlink_except_new_or_cancelled (self ) -> None :
7171 if any (record .state not in {"new" , "cancelled" } for record in self ):
72- raise UserError (_ ("Cannot delete properties unless they are new or cancelled." ))
72+ raise UserError (self . env . _ ("Cannot delete properties unless they are new or cancelled." ))
7373
7474 # Public methods
7575 def action_set_sold (self ) -> bool :
@@ -78,7 +78,7 @@ def action_set_sold(self) -> bool:
7878 continue
7979
8080 if record .state == "cancelled" :
81- raise UserError (_ ("Cancelled properties cannot be sold." ))
81+ raise UserError (record . env . _ ("Cancelled properties cannot be sold." ))
8282
8383 record .state = "sold"
8484 return True
@@ -89,7 +89,7 @@ def action_set_cancelled(self) -> bool:
8989 continue
9090
9191 if record .state == "sold" :
92- raise UserError (_ ("Sold properties cannot be cancelled." ))
92+ raise UserError (record . env . _ ("Sold properties cannot be cancelled." ))
9393
9494 record .state = "cancelled"
9595 return True
@@ -110,4 +110,4 @@ def _restrict_selling_price(self) -> None:
110110 for record in self :
111111 # Selling price is zero when no offer has been accepted
112112 if not float_is_zero (record .selling_price , precision_digits = 2 ) and float_compare (record .selling_price , 0.9 * record .expected_price , precision_digits = 2 ) < 0 :
113- raise ValidationError (_ ("A property's selling price cannot be lower than 90 percent of its expected price." ))
113+ raise ValidationError (record . env . _ ("A property's selling price cannot be lower than 90 percent of its expected price." ))
0 commit comments