Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Show model data in popup opened from button

By
Tobias Wetzel
on 8/5/15, 6:11 AM 820 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?

0

Drees Far

--Drees Far--
1130
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
On 8/5/15, 7:03 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/5/15, 6:11 AM
Seen: 820 times
Last updated: 8/5/15, 7:03 AM