Skip to content

Commit

Permalink
[FIX] account_sale_stock_report_non_billed: Date can't be comparated …
Browse files Browse the repository at this point in the history
…with bool
  • Loading branch information
CarlosRoca13 committed Aug 17, 2023
1 parent ed5f6d3 commit 0d232de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
23 changes: 14 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,34 @@ def _set_not_invoiced_values(self, qty_to_invoice, invoiced_qty):
) * 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 = fields.Date.from_string(

Check warning on line 120 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

Added line #L120 was not covered by tests
self.env.context["non_billed_date_start"]
)
date_end = fields.Date.from_string(self.env.context["non_billed_date"])

Check warning on line 123 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#L123

Added line #L123 was 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 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
if self.env.context.get("non_billed_invoice_date_start", False):
invoice_date_start = fields.Date.from_string(

Check warning on line 132 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#L132

Added line #L132 was not covered by tests
self.env.context["non_billed_invoice_date_start"]
)
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

0 comments on commit 0d232de

Please sign in to comment.