43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
from odoo import models, fields, api
|
|
|
|
|
|
class FusionRuleWizard(models.TransientModel):
|
|
_name = 'fusion.accounting.rule.wizard'
|
|
_description = 'Create Fusion Rule from AI Suggestion'
|
|
|
|
name = fields.Char(string='Rule Name', required=True)
|
|
rule_type = fields.Selection(
|
|
selection=[
|
|
('match', 'Match'), ('classify', 'Classify'),
|
|
('audit', 'Audit'), ('fee', 'Fee'),
|
|
('routing', 'Routing'), ('followup', 'Follow-Up'),
|
|
],
|
|
string='Type', required=True, default='match',
|
|
)
|
|
description = fields.Text(string='Description')
|
|
match_logic = fields.Text(string='Match Logic')
|
|
fee_account_id = fields.Many2one('account.account', string='Fee Account')
|
|
write_off_account_id = fields.Many2one('account.account', string='Write-Off Account')
|
|
journal_ids = fields.Many2many('account.journal', string='Journals')
|
|
|
|
def action_create_rule(self):
|
|
self.ensure_one()
|
|
rule = self.env['fusion.accounting.rule'].create({
|
|
'name': self.name,
|
|
'rule_type': self.rule_type,
|
|
'description': self.description,
|
|
'match_logic': self.match_logic,
|
|
'fee_account_id': self.fee_account_id.id,
|
|
'write_off_account_id': self.write_off_account_id.id,
|
|
'journal_ids': [(6, 0, self.journal_ids.ids)],
|
|
'created_by': 'admin',
|
|
'approval_tier': 'needs_approval',
|
|
})
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'res_model': 'fusion.accounting.rule',
|
|
'res_id': rule.id,
|
|
'view_mode': 'form',
|
|
'target': 'current',
|
|
}
|