Calendar view domain

Hi,

I’m trying to use calendar view on a model with workflow (draft, waiting, done, cancel).
Here’s my model:

    company = fields.Many2One('company.company', "Company", required=True)
    shipment = fields.Reference("Shipment", selection='get_shipment',
        select=True, required=True,
        states={
            'readonly': Eval('state') != 'draft',
            },
        domain=[
            ('company', '=', Eval('company', -1)),
            ],
        depends=['state', 'company'],
        help="The shipment that should be planned.")
    planned_date = fields.Date("Planned Date",
        select=True, required=True,
        states={
            'readonly': Eval('state').in_(['cancelled', 'done']),
            },
        depends=['state'],
        help="When the shipement is expected to be shipped or received.")
    calendar_background_color = fields.Function(
        fields.Char("Background Color"), 'get_calendar_background_color')
    state = fields.Selection([
        ('draft', 'Draft'),
        ('waiting', 'Waiting'),
        ('done', 'Done'),
        ('cancelled', 'Cancelled'),
        ], 'State', select=True, readonly=True,
        help="The current state of the event.")

Is it possible to filter calendar view based on specific states ? (i mean, for instance, i don’t want to see cancelled events in the calendar view).
Thanks for help :slight_smile:

Yes, on the Action window that includes the calendar view you should add a domain field to restrict the records that you want to include on such view.

Thanks @pokoli !
I did this way:

        <record model="ir.action.act_window" id="act_shipment_event_calendar">
            <field name="name">Shipment Events Calendar</field>
            <field name="res_model">stock.shipment.event</field>
            <field name="domain" eval="[('state', '!=', 'cancelled')]" pyson="1"/>
        </record>
        <record model="ir.action.act_window.view"
            id="act_shipment_event_calendar_view1">
            <field name="sequence" eval="10"/>
            <field name="view" ref="shipment_event_view_calendar"/>
            <field name="act_window" ref="act_shipment_event_calendar"/>
        </record>
...

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.