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

[17.0][mig] mail_attach_existing_attachment_account #1547

Open
wants to merge 19 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4fd2758
[12.0][ADD]mail_attach_existing_attachment_account
tbaden Apr 24, 2019
e070402
[IMP] mail_attach_existing_attachment_account: black, isort, prettier
victoralmau Nov 11, 2021
14fbff0
[MIG] mail_attach_existing_attachment_account: Migration to 13.0
Rad0van Aug 28, 2020
f832d02
[IMP] mail_attach_existing_attachment_account: black, isort, prettier
victoralmau Nov 11, 2021
0374ebb
[MIG] mail_attach_existing_attachment_account: Migration to 14.0
Nov 10, 2021
48d30d4
[UPD] Update mail_attach_existing_attachment_account.pot
oca-travis Nov 11, 2021
586ebbc
[UPD] README.rst
OCA-git-bot Nov 11, 2021
227e391
[FIX] mail_attach_existing_attachment_account: Resilient tests on mul…
pedrobaeza Mar 16, 2022
12c9dc8
[MIG] mail_attach_existing_attachment_account from 14.0
sbidoul Nov 22, 2024
158e39e
[IMP] mail_attach_existing_attachment_account: pre-commit stuff
sbidoul Nov 22, 2024
a0bb431
[DOC] mail_attach_existing_attachment_account: improve description
sbidoul Nov 22, 2024
910bf7f
[IMP] mail_attach_existing_attachment_account: align with base module
sbidoul Nov 23, 2024
9f5e5bf
[UPD] Update mail_attach_existing_attachment_account.pot
Dec 17, 2024
a73ee82
[BOT] post-merge updates
OCA-git-bot Dec 17, 2024
753a37f
Added translation using Weblate (Italian)
mymage Dec 18, 2024
3bcc9e1
Translated using Weblate (Italian)
mymage Dec 18, 2024
db5f1a2
Translated using Weblate (Italian)
mymage Dec 19, 2024
8afe237
[IMP] mail_attach_existing_attachment_account: pre-commit auto fixes
damdam-s Jan 16, 2025
1ff4372
[MIG] mail_attach_existing_attachment_account: Migration to 17.0
damdam-s Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mail_attach_existing_attachment_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"author": "Thore Baden, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social",
"category": "Social Network",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"depends": ["account", "mail_attach_existing_attachment"],
"data": ["wizard/account_invoice_send_view.xml"],
"data": ["wizard/account_move_send_view.xml"],
"installable": True,
"auto_install": True,
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setUpClass(cls):

def test_account_invoice_send(self):
compose = Form(
self.env["account.invoice.send"].with_context(
self.env["account.move.send"].with_context(
active_ids=self.invoice.ids,
default_model=self.invoice._name,
default_res_id=self.invoice.id,
Expand Down
2 changes: 1 addition & 1 deletion mail_attach_existing_attachment_account/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import account_invoice_send
from . import account_move_send

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountMoveSend(models.TransientModel):
_inherit = "account.move.send"

can_attach_attachment = fields.Boolean()
object_attachment_ids = fields.Many2many(
comodel_name="ir.attachment",
relation="account_move_send_ir_attachments_object_rel",
column1="wizard_id",
column2="attachment_id",
string="Object Attachments",
)
display_object_attachment_ids = fields.One2many(
comodel_name="ir.attachment",
compute="_compute_display_object_attachment_ids",
)

@api.depends("move_ids")
def _compute_display_object_attachment_ids(self):
for wizard in self:
if self.move_ids:
attachments = self.env["ir.attachment"].search(

Check warning on line 27 in mail_attach_existing_attachment_account/wizard/account_move_send.py

View check run for this annotation

Codecov / codecov/patch

mail_attach_existing_attachment_account/wizard/account_move_send.py#L27

Added line #L27 was not covered by tests
[
("res_model", "=", "account.move"),
("res_id", "in", self.move_ids.ids),
]
)
wizard.display_object_attachment_ids = attachments

Check warning on line 33 in mail_attach_existing_attachment_account/wizard/account_move_send.py

View check run for this annotation

Codecov / codecov/patch

mail_attach_existing_attachment_account/wizard/account_move_send.py#L33

Added line #L33 was not covered by tests
else:
wizard.display_object_attachment_ids = False

Check warning on line 35 in mail_attach_existing_attachment_account/wizard/account_move_send.py

View check run for this annotation

Codecov / codecov/patch

mail_attach_existing_attachment_account/wizard/account_move_send.py#L35

Added line #L35 was not covered by tests

# def _prepare_mail_values(self, res_ids):
# res = super()._prepare_mail_values(res_ids)
# if self.object_attachment_ids.ids and self.model and len(res_ids) == 1:
# res[res_ids[0]].setdefault("attachment_ids", []).extend(
# self.object_attachment_ids.ids
# )
# return res
Comment on lines +37 to +43

Choose a reason for hiding this comment

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

Remove this commented out code please :)

Comment on lines +37 to +43

Choose a reason for hiding this comment

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

I suppose comment code could be removed


@api.model
def _get_invoice_extra_attachments(self, move):
res = super()._get_invoice_extra_attachments(move)
res |= self.object_attachment_ids
return res

@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
if (
res.get("move_ids")
and res.get("mode", "") != "invoice_multi"
and not res.get("can_attach_attachment")
):
res["can_attach_attachment"] = True # pragma: no cover
return res

can_attach_attachment = fields.Boolean()
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the duplicate field; it is already declared at the top of the file.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2019 Thore Baden
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<record id="account_move_send_form" model="ir.ui.view">
<field name="name">Send Invoice</field>
<field name="model">account.move.send</field>
<field name="inherit_id" ref="account.account_move_send_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='mail_attachments_widget']" position="after">
<field name="can_attach_attachment" invisible="1" />
<field
name="object_attachment_ids"
widget="many2many_checkboxes"
domain="[('res_model', '=', 'account.move'), ('res_id', 'in', move_ids)]"
invisible="can_attach_attachment==False"
Copy link

@alexandregaldeano alexandregaldeano Jan 24, 2025

Choose a reason for hiding this comment

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

Suggested change
invisible="can_attach_attachment==False"
invisible="not can_attach_attachment"

?

/>
</xpath>
</field>
</record>
</odoo>
Loading