Skip to content

Commit

Permalink
[MIG] account_invoice_merge_attachment: Migration to 16.0 (from 12.0-…
Browse files Browse the repository at this point in the history
…mig-account_invoice_merge_attachment)
  • Loading branch information
fcayre committed Oct 7, 2024
1 parent 1cb9bc5 commit 7b81867
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 47 deletions.
3 changes: 1 addition & 2 deletions account_invoice_merge_attachment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
"name": "Account Invoice Merge Attachment",
"summary": """
Consider attachment during invoice merge process""",
"version": "12.0.1.0.0",
"version": "16.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",
Expand Down
2 changes: 1 addition & 1 deletion account_invoice_merge_attachment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import account_invoice
from . import account_move
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from odoo import models


class AccountInvoice(models.Model):
class AccountMove(models.Model):

_inherit = "account.invoice"
_inherit = "account.move"

@api.multi
def do_merge(self, keep_references=True, date_invoice=False):
invoices_info = super(AccountInvoice, self).do_merge(
def do_merge(
self, keep_references=True, date_invoice=False, remove_empty_invoice_lines=True
):
invoices_info = super().do_merge(
keep_references=keep_references, date_invoice=date_invoice
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,40 @@
# Copyright 2016-2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase
from odoo import fields
from odoo.addons.account.tests.common import AccountTestInvoicingCommon


class TestAccountInvoiceMergeAttachment(TransactionCase):
def setUp(self):
super(TestAccountInvoiceMergeAttachment, self).setUp()
self.AttachmentObj = self.env["ir.attachment"]
self.InvoiceObj = self.env["account.invoice"]

self.partner = self.env.ref("base.main_partner")
self.product = self.env.ref("product.product_product_8")
self.product_account = (
self.product.property_account_income_id
or self.product.categ_id.property_account_income_categ_id
)

def create_invoice(self):
return self.InvoiceObj.create(
{
"partner_id": self.partner.id,
"name": "Test",
"invoice_line_ids": [
(
0,
0,
{
"product_id": self.product.id,
"name": self.product.name,
"account_id": self.product_account.id,
"quantity": 1,
"price_unit": 1,
},
)
],
}
)
@tagged("post_install", "-at_install")
class TestAccountInvoiceMergeAttachment(AccountTestInvoicingCommon):

def create_invoice_attachment(self, invoice):
return self.AttachmentObj.create(
{
"name": "Attach",
"datas_fname": "Attach",
"datas": "bWlncmF0aW9uIHRlc3Q=",
"res_model": "account.invoice",
"res_model": invoice._name,
"res_id": invoice.id,
}
)

def test_merge_invoice_attachments(self):
invoice1 = self.create_invoice()
today = fields.Date.today()
invoice1 = self.init_invoice(
"out_invoice",
partner=self.partner_a,
invoice_date=today,
products=self.product_a,
)
self.create_invoice_attachment(invoice1)

invoice2 = self.create_invoice()
invoice2 = self.init_invoice(
"out_invoice",
partner=self.partner_a,
invoice_date=today,
products=self.product_a,
)
self.create_invoice_attachment(invoice2)
self.create_invoice_attachment(invoice2)

Expand All @@ -63,7 +44,7 @@ def test_merge_invoice_attachments(self):
attach = self.AttachmentObj.search(
[
("res_id", "in", list(invoices_info.keys())),
("res_model", "=", "account.invoice"),
("res_model", "=", invoices._name),
]
)
self.assertEqual(
Expand Down
1 change: 0 additions & 1 deletion account_invoice_merge_attachment/wizards/invoice_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class InvoiceMerge(models.TransientModel):

link_attachment = fields.Boolean(string="Link attachments", default=True)

@api.multi
def merge_invoices(self):
self.ensure_one()
return super(
Expand Down

0 comments on commit 7b81867

Please sign in to comment.