0
votes

First of all, i'm very new to Odoo and python. I have to fix a bug but I'm a bit lost. Here is my issue :

I have a custom mobule called "patient" and each patient has calendars. In the left menu, I can acces to a view "patient" which shows all patients and "calendar" which shows all calendars. When I click on a patient, there is a button "show calendar" which shows the calendars from this patient only. When I click on this button, it shows the calendars for the patient but I'm unable to open the calendars (this is like just text, no action). I have to click on calendars on the left menu, filter on the patient en then I can click on the calendars from the patient (I do manually what the button should do ...).

The button :

<header>
    <field name="x_is_dept_patients" invisible="1"/>
    <button name="btnVoirCalendriers"
        type="object" string="Voir Calendriers"
        attrs="{'invisible':[('x_is_dept_patients', '==', False)]}"/>
</header>

The function :

@api.multi
def btnVoirCalendriers(self):
    self.ensure_one()
    return {
        'type'     : 'ir.actions.act_window',
        'res_model': 'calendrier',
        'view_mode': 'tree',
        'domain'   : "[('patient_id', '=', %d)]" % self.id
    }

What I notice is that the urls are a bit different, when I click on the "show calendar", I have something like this ".../web#page=0&limit=80&view_type=list&model=calendrier&active_id=4" and when I click on "calendars" on the left menu to get all calendars I have ".../web#page=0&limit=80&view_type=list&model=calendrier&menu_id=271&action=354". Does this have some consequence ?

As I'm not aware of all of this new environment, do not hesitate to ask for more details.

1

1 Answers

1
votes

If I've understood you well, you're opening the list of the calendars of each patient rightly filtered, but the problem is that when you click on any of these records, it does nothing, and you need to open the calendar in a form view.

If so, specify in your button that you also want to open the form view of the calendrier model, not only the tree view:

@api.multi
def btnVoirCalendriers(self):
    self.ensure_one()
    return {
        'type'     : 'ir.actions.act_window',
        'res_model': 'calendrier',
        'view_mode': 'tree,form',
        'domain'   : "[('patient_id', '=', %d)]" % self.id
    }