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

pull/1058/head
CarlosRoca13 2022-11-22 15:47:05 +01:00 committed by Carlos Roca
parent ed5f6d3239
commit e229ebc5d0
2 changed files with 16 additions and 11 deletions

View File

@ -108,29 +108,30 @@ class StockMove(models.Model):
) * 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 = (

View File

@ -118,11 +118,15 @@ class AccountSaleStockReportNonBilledWiz(models.TransientModel):
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",