跳至内容
菜单
此问题已终结
2 回复
2559 查看
class JobCenter(models.Model):
_name = 'job.center'
_description = 'Budget Name'

name = fields.Char('Name')
location = fields.Char('Location')
class JobCreate(models.Model):
_name = 'job.create'
_description = 'Budget Description'

job_center_id = fields.Many2one('job.center', string='Job Center', required=True, create=False)
name = fields.Char('Job Name')
description = fields.Char('Job Description')
reference_no = fields.Integer('Reference No')
start_date = fields.Date('Start Date')
end_date = fields.Date('End Date')
user_id = fields.Many2one(comodel_name="res.users",
string='Assign To', required=True, default=lambda self: self.env.uid)
super_visor = fields.Many2one(comodel_name="res.users",
string='Supervisor', required=True, default=lambda self: self.env.uid)

here in model job.center form view I want to create a smart button if click on this smart button then this will take me to job.create model and show only those data which are related with job.center model name field 


Jobs
job.create
tree,form
[('job_center_id', '=', active_id)]
{'search_default_my_request': 1}



Add a new job




i have create it but not meet my requirement
i want in my job.center model all from view must have this smart button



形象
丢弃
最佳答案

Hi,

We can add a smart button inside <sheet> tag of form view as follows,


                    <div name="button_box" class="oe_button_box">
                        <button class="oe_stat_button" type="object"
name="action_view_journal_items" strinh="smart button"
                                attrs="{'invisible' : [('move_id','=',False)]}"
                                icon="fa-bars">


For more details, please refer to the blog:

https://www.cybrosys.com/blog/how-to-add-smart-buttons-in-odoo-15" target="_blank">https://www.cybrosys.com/blog/how-to-add-smart-buttons-in-odoo-15


Hope it helps

形象
丢弃
最佳答案

Hi,
You can refer to this video, which explains the working of smart button and its type.

See:  How To Add Smart Buttons In Odoo14

Thanks

形象
丢弃