[FIX] point_of_sale: prevent traceback while name of coins/bill is string
When we input some string in many2many field under Coins/Bills in configuration setting of point of sale module . it will give an error with the message - 'could not convert string to float' Steps to Produce:- 1. Go to Point of Sale then configuration 2. click on 'Settings' 3. Under 'Payment' input some string in Coins/Bills Trace-back will be generated. Reason - The 'name_create' method of the 'pos_bill' model generates an error when a string is provided as input for the 'name' field, since the expression 'float(name)' is unable to convert a string to a float. Applying these changes will resolve this issue. Sentry - 4122478677 closes odoo/odoo#122094 X-original-commit: 8e553f06f1a8e63dbfb4439e989ef27d577ea50f Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com> Signed-off-by: Preksha Chouhan (prec) <prec@odoo.com>
This commit is contained in:
@@ -6397,6 +6397,13 @@ msgid ""
|
||||
" Please contact your manager to accept the closing difference."
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#. odoo-python
|
||||
#: code:addons/point_of_sale/models/pos_bill.py:0
|
||||
#, python-format
|
||||
msgid "The name of the Coins/Bills must be a number."
|
||||
msgstr ""
|
||||
|
||||
#. module: point_of_sale
|
||||
#: model:ir.model.constraint,message:point_of_sale.constraint_pos_session_uniq_name
|
||||
msgid "The name of this POS Session must be unique!"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class Bill(models.Model):
|
||||
@@ -12,5 +13,9 @@ class Bill(models.Model):
|
||||
|
||||
@api.model
|
||||
def name_create(self, name):
|
||||
result = super().create({"name": name, "value": float(name)})
|
||||
try:
|
||||
value = float(name)
|
||||
except:
|
||||
raise UserError(_("The name of the Coins/Bills must be a number."))
|
||||
result = super().create({"name": name, "value": value})
|
||||
return result.name_get()[0]
|
||||
|
||||
Reference in New Issue
Block a user