XML record creation bypasses ORM defaults causing NOT NULL violation on autopost_bills (added by account module). Hook uses ORM create() which applies all field defaults correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
24 lines
779 B
Python
24 lines
779 B
Python
from . import models, controllers
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _create_ai_bot_partner(env):
|
|
"""Create the ActiveBlue AI bot partner via ORM so all field defaults are applied."""
|
|
XID = 'activeblue_ai.partner_activeblue_ai'
|
|
if not env.ref(XID, raise_if_not_found=False):
|
|
partner = env['res.partner'].create({
|
|
'name': 'ActiveBlue AI',
|
|
'active': True,
|
|
'partner_share': False,
|
|
})
|
|
env['ir.model.data'].create({
|
|
'module': 'activeblue_ai',
|
|
'name': 'partner_activeblue_ai',
|
|
'model': 'res.partner',
|
|
'res_id': partner.id,
|
|
'noupdate': True,
|
|
})
|
|
_logger.info('Created ActiveBlue AI bot partner id=%d', partner.id)
|