Home > Mobile >  Can't group employees list without years
Can't group employees list without years

Time:05-10

my issue is that when I want to group a set of employees according to the month of their birth date, Odoo separates the months by years, which I want to avoid because i wanna generate a list of people who have their birthday in the month.

This is code:

<filter
    name="birthday_groupby"
    string="Birthday month"
    domain="[]"
    context="{'group_by': 'birthday:week'}"
/>

And this is result:

List screenshot

As you can see, it separates by months, but also by years. I think solution may be more easier than than I think, but i can't figure it out.

CodePudding user response:

Create a birthday month computed field.

# i did not test the code, It can be selection as well
birthday_month = fields.Integer(string="Birthday Month", compute='_compute_bm', store=True, index=True, readonly=True)

@api.depends('birthday')
def _compute_bm(self):
    for record in self:
        if record.birthyday:
            record.birthday_month = record.birthday.month
        else:
            record.birthday_month = False

something like that.

  • Related