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

[IMP][16.0] mis_builder: use company of report.instance when querying #625

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

AnizR
Copy link
Contributor

@AnizR AnizR commented Aug 27, 2024

Description

Adds the possibility to specify a company field on queries.
This field will be used to filter records that are on the company of the instance report (using 'query_company_ids')

@OCA-git-bot
Copy link
Contributor

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

@AnizR AnizR changed the title [IMP] mis_builder: use company of report.instance when querying [IMP][16.0] mis_builder: use company of report.instance when querying Aug 28, 2024
Copy link

@SAnnabelle SAnnabelle left a comment

Choose a reason for hiding this comment

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

Functionally it's correct

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@AnizR AnizR force-pushed the imp-add-company-on-query branch from 906fd56 to 359d267 Compare October 22, 2024 11:37
mis_builder/models/mis_report.py Outdated Show resolved Hide resolved
@AnizR AnizR force-pushed the imp-add-company-on-query branch from 359d267 to 4d3dca5 Compare October 22, 2024 12:22
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

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

Looks good. A couple of questions.

if (company_field := query.sudo().company_field_id) and (
instance_companies := self.report_instance_id.query_company_ids
):
domain = AND([domain, [(company_field.name, "in", instance_companies.ids)]])
Copy link
Member

Choose a reason for hiding this comment

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

Why doing an AND with empty domain?

return []
domain = []
if (company_field := query.sudo().company_field_id) and (
instance_companies := self.report_instance_id.query_company_ids
Copy link
Member

Choose a reason for hiding this comment

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

I think query_company_ids cannot be empty. And if it was, it would be surprising if the company field on the query was ignored. So may be we could simply assert self.report_instance_id.query_company_ids if company_field_id is set.

company_field_id = fields.Many2one(
comodel_name="ir.model.fields",
ondelete="set null",
domain="[('model_id', '=', model_id)]",
Copy link
Member

Choose a reason for hiding this comment

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

This domain seems correct, but I wonder why it is not on the date_field above.

@sbidoul sbidoul added the 16.0 label Dec 11, 2024
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.

5 participants