Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
3811 Zobrazení

 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.

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
úno 17
7390
2
pro 23
12974
3
čvc 22
23413
2
čvn 21
18746
0
zář 20
3838