Skip to content
Snippets Groups Projects
Commit 8e553f06 authored by Preksha Chouhan's avatar Preksha Chouhan
Browse files

[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#120207

Signed-off-by: default avatarJoseph Caburnay (jcb) <jcb@odoo.com>
parent d0109dc5
No related branches found
No related tags found
No related merge requests found
......@@ -6140,6 +6140,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 !"
......
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]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment