Odoo / UI / *Add New button to existing module
New button to existing module
-
Step 1:
Task is to add new button at the top
1. _mainfest.py
1. add depends module
2. add view xml
'depends' : ['hr', 'account'], 'data': [ 'views/hr_employee_views.xml' ], 2. model
1. add '_inherit'
2. add new field
class HrEmployee(models.Model): _inherit = 'hr.employee' attachment_ids = fields.One2many('ir.attachment', 'id') 3. view
Complete code of view
custom.employee.form.view hr.employee Add action_create_invoice() in model
def action_create_invoice(self): Complete code of model
from odoo import models, fields, _ from odoo.exceptions import UserError class HrEmployee(models.Model): _inherit = 'hr.employee' joining_date = fields.Date('Joining Date') attachment_ids = fields.One2many('ir.attachment', 'id') salary_amount = fields.Float('Salary') def action_create_invoice(self):