Skip to content

[15.0][FIX][project_timesheet_time_control] Error: AttributeError: type object 'expression' has no attribute AND #1092

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

Merged
merged 1 commit into from
Mar 20, 2023

Conversation

ignaciord
Copy link
Contributor

It seems that "expression" is not correctly imported from odoo.osv.

This causes the error:

"AttributeError: type object 'expression' has no attribute 'AND'" when this code block is executed:

return expression.AND( [ domain, [ "|", ("privacy_visibility", "!=", "followers"), ("message_partner_ids", "in", [self.env.user.partner_id.id]), ], ] )

@ignaciord ignaciord changed the title Fix error: AttributeError: type object 'expression' has no attribute AND [15.0][FIX] Error: AttributeError: type object 'expression' has no attribute AND Mar 18, 2023
@OCA-git-bot
Copy link
Contributor

Hi @ernestotejeda,
some modules you are maintaining are being modified, check this out!

@ignaciord ignaciord changed the title [15.0][FIX] Error: AttributeError: type object 'expression' has no attribute AND [15.0][FIX][project_timesheet_time_control] Error: AttributeError: type object 'expression' has no attribute AND Mar 18, 2023
Error: AttributeError: type object 'expression' has no attribute AND
@pedrobaeza
Copy link
Member

Is this problem reproducible in runboat (accessible from "Runbot | Try me" button in the readme)?

If not, the problem is in your deployment method, mangling import paths.

@ignaciord
Copy link
Contributor Author

ignaciord commented Mar 18, 2023

Is this problem reproducible in runboat (accessible from "Runbot | Try me" button in the readme)?

If not, the problem is in your deployment method, mangling import paths.

Yes, the problem is reproducible in runboat.

These are the steps to reach the error:

  1. Log in with user with no "group_timesheet_manager" privileges (for example user "Marc Demo" with login name "demo").

  2. Go to Project Module and try to start a task, for example in project named "Office Design" (the first one).

  3. The wizard does not launch and and "Odoo server error" window shows this error:

` File "/opt/odoo/odoo/fields.py", line 2659, in _description_domain
return self.domain(env[self.model_name]) if callable(self.domain) else self.domain
File "/mnt/data/odoo-addons-dir/project_timesheet_time_control/wizards/hr_timesheet_switch.py", line 16, in _domain_project_id
return expression.AND(
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/odoo/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
AttributeError: type object 'expression' has no attribute 'AND'`

@pedrobaeza pedrobaeza added this to the 15.0 milestone Mar 20, 2023
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious that this works for timesheet managers, but not timesheet users.

Let's fast-track it to fix the problem:

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 15.0-ocabot-merge-pr-1092-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 1cc7a47 into OCA:15.0 Mar 20, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at cedba4c. Thanks a lot for contributing to OCA. ❤️

@ignaciord
Copy link
Contributor Author

Curious that this works for timesheet managers, but not timesheet users.

Let's fast-track it to fix the problem:

/ocabot merge patch

I think that works for timesheet managers but not timesheet users becouse the expression return expression.AND( is only evaluated when this condition is true: if not self.user_has_groups("hr_timesheet.group_timesheet_manager"):

Thanks a lot Pedro for the fast merge.

@ignaciord ignaciord deleted the 15.0 branch March 21, 2023 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants