[FIX] account: communication size
- Create 5 vendor bills with a long reference (> 1000 characters), for the same partner. - Select the bills and register a payment An error arise: 'psycopg2.OperationalError: index row size 3256 exceeds maximum 2712 for index "account_move_line_partner_id_ref_idx"'. As mentioned, the index row size limit is 2712 bytes, which is exceeded in that use case. Indeed, the reference of the payment is computed based on the vendor reference of all bills. We limit the number of characters to 2000. This seems reasonable knowing that UTF-8 characters use sequences of 1 to 4 bytes [1]. Characters with a code less than 128 require 1 byte only, and it is expected that most vendor references will only use these characters. It is indeed unlikely that special characters (such as Chinese characters, taking up to 4 bytes) are used for such references. [1] https://tools.ietf.org/html/rfc3629 opw-1998823 closes odoo/odoo#33457 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -115,7 +115,7 @@ class account_abstract_payment(models.AbstractModel):
|
||||
'payment_type': total_amount > 0 and 'inbound' or 'outbound',
|
||||
'partner_id': False if multi else invoices[0].commercial_partner_id.id,
|
||||
'partner_type': False if multi else MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].type],
|
||||
'communication': ' '.join([ref for ref in invoices.mapped('reference') if ref]),
|
||||
'communication': ' '.join([ref for ref in invoices.mapped('reference') if ref])[:2000],
|
||||
'invoice_ids': [(6, 0, invoices.ids)],
|
||||
'multi': multi,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user