-
-
Notifications
You must be signed in to change notification settings - Fork 633
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
base: 17.0
Are you sure you want to change the base?
Changes from 1 commit
4fd2758
e070402
14fbff0
f832d02
0374ebb
48d30d4
586ebbc
227e391
12c9dc8
158e39e
a0bb431
910bf7f
9f5e5bf
a73ee82
753a37f
3bcc9e1
db5f1a2
8afe237
1ff4372
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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( | ||
[ | ||
("res_model", "=", "account.move"), | ||
("res_id", "in", self.move_ids.ids), | ||
] | ||
) | ||
wizard.display_object_attachment_ids = attachments | ||
else: | ||
wizard.display_object_attachment_ids = False | ||
|
||
# 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? |
||||||
/> | ||||||
</xpath> | ||||||
</field> | ||||||
</record> | ||||||
</odoo> |
There was a problem hiding this comment.
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 :)