This question has been flagged
1 Reply
11573 Views

Hi,

I have a model and a tree view defined for listing all the entrys. Now I want to have a button in this tree view and when I click on it a popup should be opened and show specific data from the entry that has been clicked on, similar to a tree view in a notebook page in the models form view.

This is my model:

class Paper(models.Model):
_name = 'paper_submission.paper'
_rec_name = "title"

title = fields.Char(string='Title', required='True')
review_ids = fields.One2many('paper_submission.review', 'paper_id', string='Reviews')

The tree view:

<record id="paper_submission_paper_tree" model="ir.ui.view">
<field
name="name">Paper List View</field>
<field
name="model">paper_submission.paper</field>
<field
name="arch" type="xml">
<tree>
<field
name="title"/>
<field
name="state" invisible="1"/>
<button
string="Assign Reviews" type="action" attrs="{'invisible': [('state','!=','submitted')]}"/>
</tree>
</field>
</record>

When I click on the button I want to have a popup tree view where I can create new reviews and list the currently available reviews like this:

<record id="paper_submission_assigned_review_tree" model="ir.ui.view">
<field
name="name">Assigned Review Tree</field>
<field
name="model">paper_submission.review</field>
<field
name="arch" type="xml">
<tree
create="true">
<field
name="reviewer_id"/>
            <field name="avg_grade"/>  
</field>
</record>

How can I achieve this?

Avatar
Discard
Best Answer

In your XML you have to add some thing like this:

<button name="open_sale_order_lines" string="Open Form" type="object">

And in your python:

def open_sale_order_lines(self,cr,uid,ids,context=None):

if context is None:

context = {}

sale_ids = self.pool.get('sale.order').search(cr,uid,[('project_id','=',context.get('search_default_project_id',False)),('partner_id','in',context.get('search_default_partner_id',False))])

names = [record.name for record in self.browse(cr, uid, ids, context=context)]

name = _('Sales Order Lines of %s') % ','.join(names)

return {

'type': 'ir.actions.act_window',

'name': name,

'view_type': 'form',

'view_mode': 'tree,form',

'context': context,

'domain' : [('order_id','in',sale_ids)],

'res_model': 'sale.order.line',

'nodestroy': True,

}

Try to learn from those useful links:

http://codeimplementer.blogspot.com/2013/10/create-active-window-popup-in-openerp.html

https://answers.launchpad.net/openobject-server/+question/178972

Regards.

Avatar
Discard