[FIX] slug: fallback to positive ID when slug appears to contain a missing negative ID
Cherry-pick from dcac4cc0df
This commit is contained in:
parent
29d16f756c
commit
05f9b45ef1
|
@ -202,8 +202,13 @@ class ModelConverter(ir.ir_http.ModelConverter):
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
m = re.match(self.regex, value)
|
m = re.match(self.regex, value)
|
||||||
_uid = RequestUID(value=value, match=m, converter=self)
|
_uid = RequestUID(value=value, match=m, converter=self)
|
||||||
|
record_id = int(m.group(2))
|
||||||
|
if record_id < 0:
|
||||||
|
# limited support for negative IDs due to our slug pattern, assume abs() if not found
|
||||||
|
if not request.registry[self.model].exists(request.cr, _uid, [record_id]):
|
||||||
|
record_id = abs(record_id)
|
||||||
return request.registry[self.model].browse(
|
return request.registry[self.model].browse(
|
||||||
request.cr, _uid, int(m.group(2)), context=request.context)
|
request.cr, _uid, record_id, context=request.context)
|
||||||
|
|
||||||
def generate(self, cr, uid, query=None, args=None, context=None):
|
def generate(self, cr, uid, query=None, args=None, context=None):
|
||||||
obj = request.registry[self.model]
|
obj = request.registry[self.model]
|
||||||
|
|
Loading…
Reference in New Issue