From e229ebc5d0a92948a5e6601901813006046c51b0 Mon Sep 17 00:00:00 2001 From: CarlosRoca13 Date: Tue, 22 Nov 2022 15:47:05 +0100 Subject: [PATCH] [FIX] account_sale_stock_report_non_billed: Date can't be comparated with bool --- .../models/stock_move.py | 19 ++++++++++--------- ...ccount_sale_stock_report_non_billed_wiz.py | 8 ++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/account_sale_stock_report_non_billed/models/stock_move.py b/account_sale_stock_report_non_billed/models/stock_move.py index a0203ec2c0c3..f30aeb7304b7 100644 --- a/account_sale_stock_report_non_billed/models/stock_move.py +++ b/account_sale_stock_report_non_billed/models/stock_move.py @@ -108,29 +108,30 @@ 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 = self.env.context["non_billed_date_start"] + date_end = self.env.context["non_billed_date"] 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 + if self.env.context.get("non_billed_invoice_date_start", False): + invoice_date_start = 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 = ( diff --git a/account_sale_stock_report_non_billed/wizard/account_sale_stock_report_non_billed_wiz.py b/account_sale_stock_report_non_billed/wizard/account_sale_stock_report_non_billed_wiz.py index 0424a0c8148f..f054e93135dc 100644 --- a/account_sale_stock_report_non_billed/wizard/account_sale_stock_report_non_billed_wiz.py +++ b/account_sale_stock_report_non_billed/wizard/account_sale_stock_report_non_billed_wiz.py @@ -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",