From 73235ad6aeb1dadf12fbfd3db05a1e4c06de9314 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Thu, 23 May 2019 09:36:53 +0000 Subject: [PATCH] [FIX] purchase: truncate description for stock.move.line Before this commit, when creating a PO line with a description that was long enough (~2712 bytes long) and then confirming the PO, a traceback would pop up with an error from postgres "index row size exceeds maximum". This is because when confirming a PO, a stock.move is created with a stock.move.line mirroring the purchase.order.line, however the "name" field on stock.move.line is indexed (whereas the purchase.order.line is not), thus triggering the aforementioned error. This commit solves this issue by truncating the name field on the stock.move.line to 2000 bytes (for simplicity's sake) upon creation. Fixes #33549 closes odoo/odoo#33607 Signed-off-by: Raphael Collet (rco) --- addons/purchase/models/purchase.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 2c566528530..cf22d15e040 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -722,7 +722,9 @@ class PurchaseOrderLine(models.Model): for move in self.move_ids.filtered(lambda x: x.state != 'cancel' and not x.location_dest_id.usage == "supplier"): qty += move.product_uom._compute_quantity(move.product_uom_qty, self.product_uom, rounding_method='HALF-UP') template = { - 'name': self.name or '', + # truncate to 2000 to avoid triggering index limit error + # TODO: remove index in master? + 'name': (self.name or '')[:2000], 'product_id': self.product_id.id, 'product_uom': self.product_uom.id, 'date': self.order_id.date_approve,