-
-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] account_invoice_merge_attachment: pre-commit stuff
- Loading branch information
Showing
9 changed files
with
127 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016-2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Account Invoice Merge Attachment', | ||
'summary': """ | ||
"name": "Account Invoice Merge Attachment", | ||
"summary": """ | ||
Consider attachment during invoice merge process""", | ||
'version': '12.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'ACSONE SA/NV, Odoo Community Association (OCA)', | ||
'website': 'https://www.acsone.eu', | ||
'depends': [ | ||
'account_invoice_merge', | ||
'document', | ||
"version": "12.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "ACSONE SA/NV, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/account-invoicing", | ||
"depends": [ | ||
"account_invoice_merge", | ||
"document", | ||
], | ||
'data': [ | ||
'wizards/invoice_merge.xml', | ||
"data": [ | ||
"wizards/invoice_merge.xml", | ||
], | ||
'auto_install': True, | ||
"auto_install": True, | ||
} |
24 changes: 10 additions & 14 deletions
24
account_invoice_merge_attachment/models/account_invoice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016-2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
from odoo import models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
|
||
_inherit = 'account.invoice' | ||
_inherit = "account.invoice" | ||
|
||
@api.multi | ||
def do_merge(self, keep_references=True, date_invoice=False): | ||
invoices_info = super(AccountInvoice, self).do_merge( | ||
keep_references=keep_references, date_invoice=date_invoice) | ||
keep_references=keep_references, date_invoice=date_invoice | ||
) | ||
|
||
if self.env.context.get('link_attachment'): | ||
AttachmentObj = self.env['ir.attachment'] | ||
if self.env.context.get("link_attachment"): | ||
AttachmentObj = self.env["ir.attachment"] | ||
for new_invoice_id in invoices_info: | ||
old_invoice_ids = invoices_info[new_invoice_id] | ||
attachs = AttachmentObj.search([ | ||
('res_model', '=', self._name), | ||
('res_id', 'in', old_invoice_ids) | ||
]) | ||
attachs = AttachmentObj.search( | ||
[("res_model", "=", self._name), ("res_id", "in", old_invoice_ids)] | ||
) | ||
for attach in attachs: | ||
attach.copy(default={ | ||
'res_id': new_invoice_id, | ||
'name': attach.name | ||
}) | ||
attach.copy(default={"res_id": new_invoice_id, "name": attach.name}) | ||
|
||
return invoices_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.