Skip to content

Commit

Permalink
Merge PR #1058 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Sep 7, 2023
2 parents 8a7ceee + e229ebc commit 6eea3f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
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 @@ 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 = (
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 6eea3f3

Please sign in to comment.