Skip to content

Instantly share code, notes, and snippets.

@denihida1216
Last active August 17, 2020 13:23
Show Gist options
  • Save denihida1216/ea3379b40cafeaf8ac00e14a19758e85 to your computer and use it in GitHub Desktop.
Save denihida1216/ea3379b40cafeaf8ac00e14a19758e85 to your computer and use it in GitHub Desktop.
Odoo Zero DB Table
@api.multi
def remove_account(self):
to_removes = [
['account.voucher.line', ],
['account.voucher', ],
['account.bank.statement.line', ],
['account.payment', ],
['account.analytic.line', ],
['account.analytic.account', ],
['account.invoice.line', ],
['account.invoice.refund', ],
['account.invoice', ],
['account.partial.reconcile', ],
['account.move.line', ],
['hr.expense.sheet', ],
['account.move', ],
]
try:
for line in to_removes:
obj_name = line[0]
obj = self.pool.get(obj_name)
if obj:
sql = "delete from %s" % obj._table
self._cr.execute(sql)
seqs = self.env['ir.sequence'].search([
'|', ('code', '=', 'account.reconcile'),
'|', ('code', '=', 'account.payment.customer.invoice'),
'|', ('code', '=', 'account.payment.customer.refund'),
'|', ('code', '=', 'account.payment.supplier.invoice'),
'|', ('code', '=', 'account.payment.supplier.refund'),
'|', ('code', '=', 'account.payment.transfer'),
'|', ('prefix', 'like', 'BNK1/'),
'|', ('prefix', 'like', 'CSH1/'),
'|', ('prefix', 'like', 'INV/'),
'|', ('prefix', 'like', 'EXCH/'),
('prefix', 'like', 'MISC/')
])
for seq in seqs:
seq.write({
'number_next': 1,
})
except Exception as e:
pass # raise Warning(e)
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment