Fix allow_mail_archived_partner causing system notifications to send emails
This commit is contained in:
@@ -7,37 +7,23 @@ from odoo import models, api, fields
|
|||||||
class AccountInvoiceSend(models.TransientModel):
|
class AccountInvoiceSend(models.TransientModel):
|
||||||
_inherit = "account.invoice.send"
|
_inherit = "account.invoice.send"
|
||||||
|
|
||||||
# OVERRIDE THE FIELD DEFINITION
|
|
||||||
partner_ids = fields.Many2many(
|
|
||||||
'res.partner',
|
|
||||||
string='Recipients',
|
|
||||||
help='Contacts of the invoice that will receive the email.',
|
|
||||||
context={'active_test': False},
|
|
||||||
check_company=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def default_get(self, fields):
|
def default_get(self, fields):
|
||||||
_logger.info("=== ACCOUNT.INVOICE.SEND DEFAULT_GET ===")
|
|
||||||
|
|
||||||
res = super().default_get(fields)
|
res = super().default_get(fields)
|
||||||
|
|
||||||
active_ids = self.env.context.get('active_ids', [])
|
active_ids = self.env.context.get('active_ids', [])
|
||||||
|
|
||||||
if active_ids:
|
if active_ids:
|
||||||
moves = self.env['account.move'].with_context(
|
moves = self.env['account.move'].with_context(
|
||||||
active_test=False
|
active_test=False
|
||||||
).browse(active_ids)
|
).browse(active_ids)
|
||||||
|
|
||||||
partner_ids = []
|
partners = moves.mapped('partner_id').filtered(lambda p: p.email)
|
||||||
for move in moves:
|
|
||||||
if move.partner_id:
|
if partners:
|
||||||
partner_ids.append(move.partner_id.id)
|
res['partner_ids'] = [(6, 0, partners.ids)]
|
||||||
|
res['email_to'] = ", ".join(partners.mapped('email'))
|
||||||
if partner_ids:
|
|
||||||
res['partner_ids'] = [(6, 0, partner_ids)]
|
|
||||||
_logger.info(f"SET partner_ids: {res['partner_ids']}")
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def action_send_and_print(self):
|
def action_send_and_print(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user