1- from odoo import api , fields , models , _
1+ from odoo import api , fields , models
22from odoo .exceptions import UserError , ValidationError
33from odoo .tools .float_utils import float_compare , float_is_zero
44from dateutil .relativedelta import relativedelta
@@ -63,7 +63,7 @@ class EstateProperty(models.Model):
6363 def _check_selling_price (self ):
6464 for record in self :
6565 if not float_is_zero (record .selling_price , precision_digits = 2 ) and float_compare (record .selling_price , record .expected_price * 0.9 , precision_digits = 2 ) <= 0 :
66- raise ValidationError ("The selling price cannot be lower than 90 percent of the expected price." )
66+ raise ValidationError (self . env . _ ( "The selling price cannot be lower than 90 percent of the expected price." ) )
6767
6868
6969 @api .depends ('living_area' , 'garden_area' )
@@ -81,7 +81,7 @@ def _compute_best_price(self):
8181 def _prevent_property_deletion (self ):
8282 for record in self :
8383 if record .state not in ('new' , 'cancelled' ):
84- raise UserError (_ ("Only new or cancelled properties can be deleted." ))
84+ raise UserError (self . env . _ ("Only new or cancelled properties can be deleted." ))
8585
8686 @api .onchange ('garden' )
8787 def _onchange_garden (self ):
@@ -97,13 +97,13 @@ def action_set_sold(self):
9797 if record .state != 'cancelled' :
9898 record .state = 'sold'
9999 else :
100- raise UserError (_ ("Sold properties cannot be cancelled." ))
100+ raise UserError (self . env . _ ("Sold properties cannot be cancelled." ))
101101 return True
102102
103103 def action_set_cancelled (self ):
104104 for record in self :
105105 if record .state != 'sold' :
106106 record .state = 'cancelled'
107107 else :
108- raise UserError (_ ("Sold properties cannot be cancelled." ))
108+ raise UserError (self . env . _ ("Sold properties cannot be cancelled." ))
109109 return True
0 commit comments