how to put button in treeview into feild more over when i click register button display another form like a popup window
can anyone help me
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
how to put button in treeview into feild more over when i click register button display another form like a popup window
can anyone help me
put the button in the tree view and in function return an action to popup window. I can give you an example.
<button name="return_action" string="register" type="object">
@api.multi
def return_action(self):
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'your.model.name',
'views': [(False,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context': {},
}
not working hilar may i write widget for this?? i dont know i am new to odoo
it will work. change your model name, check the button name given has given correct, or share your code here.
<button name="button" string="register" type="object"/>
@api.multi
def button(self):
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'dform.data',
'views': [(False,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context': {},
}
button displayed but didnot open form when i click button
same code write in form view its working in tree view(table view) doesnot working hilar
update your code here. The full code of tree view.
xml:<record model="ir.ui.view" id="dformentry_form_view">
<field name="name">dformentry.form</field>
<field name="model">dform.entry</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="">
<sheet>
<group>
<group>
<field name="name"/>
<field name = "colleges"/>
<field name = "dateofexam"/>
</group>
</group>
<separator string="Dform Data "/>
<field name="dform_data" widget="one2many_list" >
<tree editable="bottom" >
<field name="cc" />
<field name = "course_id"/>
<field name = "reg"/>
<field name="year_sem" />
<field name = "subcode"/>
<field name = "branch_id"/>
<field name="dateofexam" />
<field name = "clleges"/>
<field name = "no_stds"/>
<button name="button" string="register" type="object" class="oe_highlight"/>
<field name="upload_data" type = "object" />
<field name = "dform_status"/>
<field name = "online_report"/>
</tree>
</field>
py:class dformentry(models.Model):
_name='dform.entry'
_description='Dform Entry'
name=fields.Many2one('course.course',string='Course')
colleges = fields.Many2one('colleges.colleges',string = 'Colleges')
dform_data=fields.One2many('page.dform','dform_data1' )
dateofexam = fields.Char('Date of Exam')
class dormentrypage(models.Model):
_name='page.dform'
_description='Student registration'
cc = fields.Char('CC')
course_id = fields.Char('Course')
reg = fields.Char('Reg')
year_sem = fields.Char('year sem')
subcode = fields.Char('SubCode')
branch_id = fields.Char('Branch')
dateofexam = fields.Char('DateOfExam')
clleges = fields.Date('Colleges')
no_stds = fields.Char('No stds')
upload_data = fields.Char('Upload data')
dform_status = fields.Char('Dform Status')
online_report = fields.Char('Online Report')
dform_data1=fields.Many2one('dform.entry','dformdata')
@api.multi
def button(self):
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'colleges.colleges',#this is the which form i want when i clcik button
'views': [(False,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
'context': {},
}
Have you upgraded your addon? It should work, nothing wrong in button's code. okay Put button as the first column and try again.
yes hilar before saving the form didnot work after that working and when i click buttin openening the form i wantt that action before saving the form
The button works only on a saved record where a button type is an object. It activates only after saving the record. You can try JS with Button, for that you have to inherit templates of the tree and also need to do some js scripts. Don't make so complicated, First, think any other logics.
I have the same problem! I need a dropdown button in each line of tree view. I can add a button, but not a dropdown button. the code is:
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
and it works in form view, but not in tree view. I get an error saying " Invalid view definition". Can anyone help me?
simply you can add drop down like this in tree view class
class some_x(models.Model):
_description = 'abcd'
_name = 'some.some'
field = fields.Selection([('monday', 'Monday'),
('tuesday', 'Tuesday'),
('wednesday', 'Wednesday'),
('thursday', 'Thursday'),
('friday', 'Friday'),
('saturday', 'Saturday'),
('sunday', 'Sunday')], "x day",)
@Hilar AK , But when we add button in form view it works properly without saving records. Why had it not done with tree view?
Do you mean list view inside a form view? if yes, no record will get saved when you adding any details in one2many or many2many lists. You must save the record to activate the button. Here we are defining the button of type object and works only on an object, not for data on the fly.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Nov 24
|
18021 | ||
|
1
Sep 23
|
1209 | ||
|
3
May 23
|
4096 | ||
|
7
Apr 23
|
47103 | ||
Barcode scanner from mobile
Solved
|
|
1
Dec 22
|
6439 |