Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[om_account_followup/report/followup_print.py] fix for TypeError: '<=' not supported between instances of 'datetime.date' and 'str' #112

Open
tilleul opened this issue Oct 26, 2023 · 1 comment

Comments

@tilleul
Copy link

tilleul commented Oct 26, 2023

FYI; there's a bug in this file for versions 14, 15 & 16 ...

Code from version 14 (line 239-240) reads:

elif date and date <= fups[followup_line_id][0].strftime(
                    '%Y-%m-%d'):

But it should be

elif date and fields.Date.to_string(date) <= fups[followup_line_id][0].strftime(
                    '%Y-%m-%d'):

otherwise you get the error message mentioned in the title of this post.

Other versions have the same line in the same file but in different locations.

@marcelogpereira
Copy link

Why are u converting to dates to string? you can just check them as dates

change this:

            if date_maturity:
                date_maturity = fields.Date.to_string(date_maturity)
                if date_maturity <= fups[followup_line_id][0].strftime(
                        '%Y-%m-%d'):
                    if stat_line_id not in partner_list:
                        partner_list.append(stat_line_id)
                    to_update[str(id)] = {'level': fups[followup_line_id][1],
                                          'partner_id': stat_line_id}
            elif date and date <= fups[followup_line_id][0].strftime(
                    '%Y-%m-%d'):

to this:

fups_first_followup_line_date = fups[followup_line_id][0]
            if date_maturity:
                if date_maturity <= fups_first_followup_line_date:
                    if stat_line_id not in partner_list:
                        partner_list.append(stat_line_id)
                    to_update[str(id)] = {'level': fups[followup_line_id][1],
                                          'partner_id': stat_line_id}
            elif date and fups_first_followup_line_date and date <= fups_first_followup_line_date:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants