Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rental_base_extension/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from .hooks import post_init_hook
1 change: 1 addition & 0 deletions rental_base_extension/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"author": "NuoBiT Solutions SL",
"website": "https://github.com/nuobit/odoo-addons",
"license": "AGPL-3",
"post_init_hook": "post_init_hook",
"depends": [
"rental_base",
],
Expand Down
26 changes: 26 additions & 0 deletions rental_base_extension/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2026 NuoBiT Solutions SL - Eric Antones <eantones@nuobit.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

import logging

from odoo import SUPERUSER_ID, api

_logger = logging.getLogger(__name__)


def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
normal_type = env.ref("sale_order_type.normal_sale_type")
cr.execute(
"UPDATE sale_order SET type_id = %s WHERE type_id IS NULL",
[normal_type.id],
)
_logger.info("Updated %d sale orders with default type_id", cr.rowcount)
cr.execute("UPDATE sale_order_line SET rental = False WHERE rental IS NULL")
_logger.info("Updated %d sale order lines with rental = False", cr.rowcount)
cr.execute(
"UPDATE sale_order_line SET can_sell_rental = False WHERE can_sell_rental IS NULL"
)
_logger.info(
"Updated %d sale order lines with can_sell_rental = False", cr.rowcount
)
Loading