Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] account_invoice_merge - record set used instead of list of ids in do_merge #104

Closed
wants to merge 17 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions account_invoice_merge/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ def make_key(br, fields):
so_obj = self.env['sale.order']\
if 'sale.order' in self.env.registry else False
invoice_line_obj = self.env['account.invoice.line']
# None if purchase is not installed
for new_invoice_id in invoices_info:
if so_obj:
if so_obj is not False:
todos = so_obj.search(
[('invoice_ids', 'in', invoices_info[new_invoice_id])])
todos.write({'invoice_ids': [(4, new_invoice_id)]})
Expand All @@ -207,8 +206,9 @@ def make_key(br, fields):
[('product_id', '=', so_line.product_id.id),
('invoice_id', '=', new_invoice_id)])
if invoice_line_ids:
invoice_line_ids_list = [x.id for x in invoice_line_ids]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better if you renamed that variable invoice_lines as search returns a record set. Thus you can do: invoice_lines.ids to get a list of ids.

so_line.write(
{'invoice_lines': [(6, 0, invoice_line_ids)]})
{'invoice_lines': [(6, 0, invoice_line_ids_list)]})
# recreate link (if any) between original analytic account line
# (invoice time sheet for example) and this new invoice
anal_line_obj = self.env['account.analytic.line']
Expand Down