Skip to content

Commit cd690c5

Browse files
committed
[ADD] base/0.0.0: fix NULL commercial_partner_id
The `commercial_partner_id` field is expected to always be set. Although the column is not marked as `NOT NULL`. Fight the Murphy's Law, and recompute the value on records with a NULL value.
1 parent 48de3cc commit cd690c5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
from odoo.addons.base.maintenance.migrations import util
3+
4+
5+
def migrate(cr, version):
6+
# The `commercial_partner_id` field is expected to always be set. Although the column is not marked as `NOT NULL`.
7+
# Fight the Murphy's Law, and recompute the value on partners with a NULL value.
8+
cr.execute("SELECT id FROM res_partner WHERE commercial_partner_id IS NULL")
9+
if cr.rowcount:
10+
util.recompute_fields(cr, "res.partner", ["commercial_partner_id"], ids=[id_ for id_, in cr.fetchall()])

0 commit comments

Comments
 (0)