server action, python too many values to unpack (expected 1)

Update the standard cost by PO vendor price.

Traceback (most recent call last):

  line 4721, in ensure_one

    _id, = self._ids

ValueError: too many values to unpack (expected 1)

When you get the above error in server action python code, you should get the single value by using loop. 

Incorrect approach, it will pull two values and store into one single field 

#record['standard_price'] = record['seller_ids'].price

Correct approach, using loop to get the value from list. Store only the first record.

for x in record['seller_ids']:

  record['standard_price'] = x.price

  break

Article Details

Article ID:
31
Category:
Rating :

Related articles