50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
import sys
|
|
|
|
def cleanup(env):
|
|
target_company = env['res.company'].search([('name', 'ilike', 'Tenggilis')], limit=1)
|
|
|
|
if not target_company:
|
|
print("Tenggilis company not found")
|
|
return
|
|
|
|
print("Cleaning up copied payment methods...")
|
|
methods = env['pos.payment.method'].with_context(active_test=False).search([
|
|
('company_id', '=', target_company.id),
|
|
('create_date', '>=', '2026-02-24')
|
|
])
|
|
num_methods = len(methods)
|
|
for m in methods:
|
|
print(f" Deleting Payment Method: {m.name}")
|
|
methods.unlink()
|
|
|
|
print("Cleaning up copied journals...")
|
|
journals = env['account.journal'].with_context(active_test=False).search([
|
|
('company_id', '=', target_company.id),
|
|
('create_date', '>=', '2026-02-24')
|
|
])
|
|
num_journals = len(journals)
|
|
for j in journals:
|
|
print(f" Deleting Journal: {j.name}")
|
|
journals.unlink()
|
|
|
|
print("Cleaning up (copy) accounts...")
|
|
accounts = env['account.account'].with_context(active_test=False).search([
|
|
('company_id', '=', target_company.id),
|
|
'|',
|
|
('name', 'ilike', '(copy)'),
|
|
('create_date', '>=', '2026-02-24')
|
|
])
|
|
num_accounts = len(accounts)
|
|
for a in accounts:
|
|
print(f" Deleting Account: {a.name} ({a.code})")
|
|
accounts.unlink()
|
|
|
|
print(f"Cleanup complete. Deleted {num_methods} methods, {num_journals} journals, {num_accounts} accounts.")
|
|
env.cr.commit()
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
cleanup(env)
|
|
except NameError:
|
|
print("Run via odoo shell")
|