Merge pull request #32 from expsa/data_patch

data_patch
This commit is contained in:
esam-sermah 2025-10-01 14:08:31 +03:00 committed by GitHub
commit a636c63679
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,24 @@
from odoo.exceptions import ValidationError
def post_init_hook(env):
update_due_date_in_transaction_model(env)
env.cr.commit()
raise ValidationError("Intentional error: This module is not designed to be installed.\nData Applied Successfully!")
def update_due_date_in_transaction_model(env):
transaction_models = ['outgoing.transaction', 'internal.transaction', 'incoming.transaction']
for transaction_model in transaction_models:
if transaction_model in env.registry:
model = env[transaction_model]
records = model.search([])
if records:
records.compute_due_date()
else:
print(f"Model '{transaction_model}' not found in registry. Skipping patch.")

View File

@ -0,0 +1,15 @@
{
'name': 'Data Patches with Hook',
'version': '18.0.1.0', # تم التحديث ليتوافق مع أودو 18
'summary': 'A module to apply data patches using a hook.',
'category': 'Tools',
'author': 'Expert Co.',
'description': """
This module apply data patches via hooks.
""",
'depends': ['base'],
'data': [],
'installable': True,
'application': False,
'post_init_hook': 'post_init_hook',
}

View File

@ -0,0 +1 @@