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

[15.0][FIX] account_sale_stock_report_non_billed: Date can't be comparated with bool #1058

Conversation

CarlosRoca13
Copy link

cc @Tecnativa TT44745

fw-port of: #953

ping @pedrobaeza @stefan-tecnativa

@CarlosRoca13 CarlosRoca13 force-pushed the 15.0-FIX-account_sale_stock_report_non_billed branch from a4c5f03 to 67406b2 Compare August 16, 2023 12:49
@@ -127,6 +127,8 @@ def _compute_not_invoiced_values(self):
moves_in_date = invoices_not_cancel.mapped("move_line_ids").filtered(
lambda m: m.date_done >= date_start and m.date_done <= date_end
)
if not self.env.context.get("date_check_iterval_restrict", False):
date_start = False
Copy link
Member

Choose a reason for hiding this comment

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

I don't get why do you need this. Pass the minimum variables in context, and the absence of one of them means that no check should be done.

Copy link
Author

Choose a reason for hiding this comment

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

Because we need the date_start and the date_end to filter the move_line_ids in any situation, but when the user doesn't want to use this dates as a range for invoices too the date_start has to be reset to False.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, and that's why I say you only need to pass one variable: the start date. If not passed, then you use .get(..., False), and being False means that no check has to be done.

Copy link
Author

Choose a reason for hiding this comment

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

But I need the date_start to take the moves_in_date

Copy link
Member

Choose a reason for hiding this comment

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

OK, I'm getting it. They should be independent variables for avoiding that clunky logic. Pass these 3 possible variables to context:

  • non_billed_date: Old date_check_invoiced_moves
  • non_billed_date_start: Old date_check_invoiced_moves_start
  • non_billed_invoice_date_start: This one is set to self.stock_move_non_billed_threshold if self.interval_restrict_invoices.

and you get each of them on the computing code, with no inter-dependencies between them.

@pedrobaeza pedrobaeza added this to the 15.0 milestone Aug 17, 2023
@CarlosRoca13 CarlosRoca13 force-pushed the 15.0-FIX-account_sale_stock_report_non_billed branch from 67406b2 to 0d232de Compare August 17, 2023 08:04
@CarlosRoca13 CarlosRoca13 force-pushed the 15.0-FIX-account_sale_stock_report_non_billed branch from 0d232de to e229ebc Compare August 18, 2023 06:33
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.

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 15.0-ocabot-merge-pr-1058-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 6eea3f3 into OCA:15.0 Sep 7, 2023
5 of 6 checks passed
@OCA-git-bot
Copy link
Contributor

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

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