lims: acknowledgment of samples email: allow to hide recipients

This commit is contained in:
Adrián Bernardi 2022-03-30 12:20:13 -03:00
parent 273e82aa28
commit 9be382c59e
4 changed files with 21 additions and 4 deletions

View file

@ -152,6 +152,7 @@ class Configuration(ModelSingleton, ModelSQL, ModelView,
help="In the text will be added suffix with the entry report number")
mail_ack_body = fields.Text('Email body of Acknowledgment of Samples'
' Receipt')
mail_ack_hide_recipients = fields.Boolean('Hide recipients')
microbiology_laboratories = fields.Many2Many(
'lims.configuration-laboratory', 'configuration',
'laboratory', 'Microbiology Laboratories')
@ -245,6 +246,10 @@ class Configuration(ModelSingleton, ModelSQL, ModelView,
def default_entry_confirm_background():
return False
@staticmethod
def default_mail_ack_hide_recipients():
return True
@classmethod
def multivalue_model(cls, field):
pool = Pool()

View file

@ -642,6 +642,9 @@ class Entry(Workflow, ModelSQL, ModelView):
return success
def mail_acknowledgment_of_receipt(self):
pool = Pool()
Config = pool.get('lims.configuration')
if not self.ack_report_cache:
return
@ -650,10 +653,13 @@ class Entry(Workflow, ModelSQL, ModelView):
if not (from_addr and to_addrs):
return
config = Config(1)
hide_recipients = config.mail_ack_hide_recipients
subject, body = self.subject_body()
attachment_data = self.attachment()
msg = self.create_msg(from_addr, to_addrs, subject,
body, attachment_data)
body, hide_recipients, attachment_data)
return self.send_msg(from_addr, to_addrs, msg)
def subject_body(self):
@ -691,14 +697,14 @@ class Entry(Workflow, ModelSQL, ModelView):
}
return data
def create_msg(self, from_addr, to_addrs, subject, body, attachment_data):
def create_msg(self, from_addr, to_addrs, subject, body,
hide_recipients, attachment_data):
if not to_addrs:
return None
msg = MIMEMultipart('mixed')
msg['From'] = from_addr
hidden = True # TODO: HARDCODE!
if not hidden:
if not hide_recipients:
msg['To'] = ', '.join(to_addrs)
msg['Subject'] = subject

View file

@ -423,6 +423,10 @@ msgctxt "field:lims.configuration,mail_ack_body:"
msgid "Email body of Acknowledgment of Samples Receipt"
msgstr "Cuerpo del correo de Acuse de recibo de muestras"
msgctxt "field:lims.configuration,mail_ack_hide_recipients:"
msgid "Hide recipients"
msgstr "Ocultar destinatarios"
msgctxt "field:lims.configuration,mail_ack_subject:"
msgid "Email subject of Acknowledgment of Samples Receipt"
msgstr "Asunto del correo de Acuse de recibo de muestras"

View file

@ -67,6 +67,8 @@
</page>
<page string="Mail Acknowledgment of Samples Receipt"
id="mail_ack_samples" col="6">
<label name="mail_ack_hide_recipients"/>
<field name="mail_ack_hide_recipients"/>
<separator string="Email body of Acknowledgment of Samples Receipt"
colspan="4" id="mail_ack_body"/>
<field name="mail_ack_subject" colspan="4"/>