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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions account_sale_stock_report_non_billed/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,30 @@
) * self.sale_line_id.price_reduce

@api.depends("sale_line_id")
@api.depends_context("date_check_invoiced_moves")
@api.depends_context("non_billed_date")
def _compute_not_invoiced_values(self):
for move in self:
if not self.env.context.get("date_check_invoiced_moves"):
if not self.env.context.get("non_billed_date") or not self.env.context.get(
"non_billed_date_start"
):
move.quantity_not_invoiced = 0
move.price_not_invoiced = 0
continue
date_start = self.env.context.get("date_check_invoiced_moves_start", False)
date_end = self.env.context.get("date_check_invoiced_moves", False)
if date_start:
date_start = fields.Date.from_string(date_start)
if date_end:
date_end = fields.Date.from_string(date_start)
date_start = self.env.context["non_billed_date_start"]
date_end = self.env.context["non_billed_date"]

Check warning on line 121 in account_sale_stock_report_non_billed/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

account_sale_stock_report_non_billed/models/stock_move.py#L120-L121

Added lines #L120 - L121 were not covered by tests
invoices_not_cancel = move.invoice_line_ids.filtered(
lambda l: l.move_id.state != "cancel"
)
moves_in_date = invoices_not_cancel.mapped("move_line_ids").filtered(
lambda m: m.date_done >= date_start and m.date_done <= date_end
)
invoice_date_start = False

Check warning on line 128 in account_sale_stock_report_non_billed/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

account_sale_stock_report_non_billed/models/stock_move.py#L128

Added line #L128 was not covered by tests
if self.env.context.get("non_billed_invoice_date_start", False):
invoice_date_start = self.env.context["non_billed_invoice_date_start"]

Check warning on line 130 in account_sale_stock_report_non_billed/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

account_sale_stock_report_non_billed/models/stock_move.py#L130

Added line #L130 was not covered by tests
inv_lines = moves_in_date.mapped("invoice_line_ids").filtered(
lambda l: l.check_invoice_line_in_date(
date_end,
date_start=date_start,
date_start=invoice_date_start,
)
)
qty_to_invoice = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ def open_at_date(self):
search_view_id = self.env.ref(
"account_sale_stock_report_non_billed.view_move_search"
).id
context = dict(self.env.context, date_check_invoiced_moves=self.date_check)
context = dict(
self.env.context,
non_billed_date=self.date_check,
non_billed_date_start=self.stock_move_non_billed_threshold,
)
if self.interval_restrict_invoices:
context = dict(
context,
date_check_invoiced_moves_start=self.stock_move_non_billed_threshold,
non_billed_invoice_date_start=self.stock_move_non_billed_threshold,
)
action = {
"type": "ir.actions.act_window",
Expand Down
Loading