Odoo Help

0

How may I integrate "Note" module with Contacts like "Opportunities/SalesOrder/Meeting"Regards

By
Paramita
on 2/10/16, 9:15 AM 766 views

 am trying to trickle up the "Note" module with the Contacts and for that I have created a xml file which have a button box just like "Opportunities/SalesOrder/Meeting" in "Contacts" form view.

Here is my Code

<record id="res_partner_view_button" model="ir.ui.view">

     <field name="name">res.partner.view.buttons</field

    <field name="model">res.partner</field

    <field name="inherit_id" ref="base.view_partner_form"></field

    <field name="priority" eval="20"/>

    <field name="arch" type="xml"/>

      <div name="button_box" position="inside">

     <button class="oe_stat button" type="action" name="%(note.action_note_note)d" attrs="{'invisible':[('customer','=',False)]}"

    <field string="Notes" name="x_note_count" widgrt="statinfo"/>

     </div>

If I click onto my button box which is Called "Notes" it'll redirect me to the "Notes" kanban view,Which is fine for me.

But now I want exactly the same thing like "Sales/Opportunities". Eg:- If I click onto the "Notes" button  from  one particular Contact("ABC Company") it'll show me the list of Notes of "ABC Company" or that Particular Contact.

0
Axel Mendoza
On 2/10/16, 10:19 AM

For that you need to have the button of type object that will execute the method defined in the model and specified in the name attribute of the button tag. In the method then you need to return the action dict with a domain to restrict the ids of the notes for the contact, like this:

<button class="oe_stat button" type="object" name="view_notes" attrs="{'invisible':[('customer','=',False)]}">
    <field string="Notes" name="x_note_count" widget="statinfo"/>
</button>

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

mod_obj = self.pool.get('ir.model.data')

result = mod_obj.get_object_reference(cr, uid, 'note', 'action_note_note')

id = result and result[1] or False

result = act_obj.read(cr, uid, [id], context=context)[0]

notes_ids = [note.id for note in self.browse(cr, uid, ids[0], context).notes_ids]

result['domain'] = "[('id','in',[" + ','.join(map(str, notes_ids)) + "])]"

return result

With that in place you only need to build the value of the list of notes_ids to filter all the notes to show only those related to the contact, I just put an example of how to do it

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 2/10/16, 9:15 AM
Seen: 766 times
Last updated: 2/10/16, 10:19 AM