Skip to content

Commit

Permalink
[FIX] account_move_service: move lines aren't generated when they don…
Browse files Browse the repository at this point in the history
…'t come from a sale order
  • Loading branch information
FrankC013 committed Oct 10, 2024
1 parent 38810e8 commit e13e8c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
25 changes: 13 additions & 12 deletions account_move_service/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def check_invoice_service_line_values(self, line):

def check_invoice_service_values(self, vals):
invoice_line_ids = vals.get("invoice_line_ids", False)
if not invoice_line_ids:
return False
if not all(item[0] == 0 for item in invoice_line_ids):
raise ValidationError(
_(
Expand Down Expand Up @@ -131,25 +129,28 @@ def prepare_invoice_service_line(self, line, agg_lines):
)

def prepare_invoice_service(self, vals):
agg_lines = {}

move_ok = self.check_invoice_service_values(vals)
if move_ok:
agg_lines = {}
for line in vals.get("invoice_line_ids"):
self.prepare_invoice_service_line(line[2], agg_lines)

return agg_lines
invoice_lines = [
(0, 0, agg_line)
for agg_line in [item_data for item_data in agg_lines.values()]
]
else:
invoice_lines = vals.get("invoice_line_ids")
return invoice_lines

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get("move_type", False) == "out_invoice":
if vals.get("move_type", False) == "out_invoice" and vals.get(
"invoice_line_ids", False
):
pid = vals.get("partner_id", False)
if pid and self.env["res.partner"].browse(pid).service_intermediary:
agg_lines = self.prepare_invoice_service(vals)
vals["invoice_line_ids"] = [
(0, 0, agg_line)
for agg_line in [item_data for item_data in agg_lines.values()]
]
invoice_lines = self.prepare_invoice_service(vals)
vals["invoice_line_ids"] = invoice_lines

return super(AccountMove, self).create(vals_list)
1 change: 1 addition & 0 deletions account_move_service/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def _get_price_total_and_subtotal_model(
)
if (
self.move_id.partner_id.service_intermediary
and self.sale_line_ids
and self.price_subtotal
and self.price_total
):
Expand Down

0 comments on commit e13e8c5

Please sign in to comment.