Skip to content

Commit

Permalink
Merge PR OCA#399 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Mar 3, 2025
2 parents 87b725e + 5e82455 commit 410ab8a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions purchase_variant_configurator/models/product_supplierinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ def search(self, args, offset=0, limit=None, order=None, count=False):
return super().search(
args, offset=offset, limit=limit, order=order, count=count
)

def sorted(self, key=None, reverse=False):
# Override this function to avoid a problem using NewId in the sorted sequence
# because Odoo converts the .id to it when handling one2many of a virtual
# record, and thus getting the error:
# TypeError: '<' not supported between instances of 'NewId' and 'NewId'
# The workaround is to remove the id sorting criteria for this specific case.
if callable(key):
if key.__code__.co_names == ("sequence", "min_qty", "price", "id"):
key = lambda s=self: (s.sequence, -s.min_qty, s.price) # noqa
return super().sorted(key=key, reverse=reverse)

0 comments on commit 410ab8a

Please sign in to comment.