12.0 Various snailmail Improvements

PRICING
--------------
The pricing on snailmail has changed and we now charge stamps for each letter.

 USABILITY
-----------------

Added a new error to help the user more specifically

Avoid spamming the user's mailbox with the next  activities when a letter can not be sent.

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

closes odoo/odoo#28290
This commit is contained in:
Robot Odoo
2018-11-05 11:58:07 +01:00
committed by GitHub
5 changed files with 38 additions and 35 deletions
+17 -12
View File
@@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server saas~11.5\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-02 10:06+0000\n"
"PO-Revision-Date: 2018-10-02 10:06+0000\n"
"POT-Creation-Date: 2018-10-30 12:25+0000\n"
"PO-Revision-Date: 2018-10-30 12:25+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -16,13 +16,13 @@ msgstr ""
"Plural-Forms: \n"
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:243
#: code:addons/snailmail/models/snailmail_letter.py:249
#, python-format
msgid "An error occured when sending the document by post.<br>Error: %s"
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:211
#: code:addons/snailmail/models/snailmail_letter.py:215
#, python-format
msgid "An unknown error happened. Please contact the support."
msgstr ""
@@ -161,7 +161,7 @@ msgid "Model"
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:209
#: code:addons/snailmail/models/snailmail_letter.py:211
#, python-format
msgid "One or more required fields are empty."
msgstr ""
@@ -172,7 +172,7 @@ msgid "Optional report to print and attach"
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:248
#: code:addons/snailmail/models/snailmail_letter.py:264
#, python-format
msgid "Post letter: an error occured."
msgstr ""
@@ -235,13 +235,19 @@ msgid "Status"
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:207
#: code:addons/snailmail/models/snailmail_letter.py:213
#, python-format
msgid "The attachment of the letter could not be sent. Please check its content and contact the support if the problem persists."
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:209
#, python-format
msgid "The country of the partner is not covered by Snailmail."
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:238
#: code:addons/snailmail/models/snailmail_letter.py:242
#, python-format
msgid "The document was correctly sent by post.<br>The tracking id is %ssend_id"
msgstr ""
@@ -259,14 +265,13 @@ msgid "When a letter is created, the status is 'Draft'.\n"
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:205
#: code:addons/snailmail/models/snailmail_letter.py:207
#, python-format
msgid "You don't have an IAP account registered for this service.<br>Please go to <a href=%s target=\"new\">iap.odoo.com</a> to claim your free credits."
msgstr ""
#. module: snailmail
#: code:addons/snailmail/models/snailmail_letter.py:202
#: code:addons/snailmail/models/snailmail_letter.py:204
#, python-format
msgid "You don't have enough credits to perform this operation.<br>Please go to your <a href=%s target=\"new\">iap account</a>."
msgstr ""
+9 -5
View File
@@ -209,7 +209,9 @@ class SnailmailLetter(models.Model):
return _('The country of the partner is not covered by Snailmail.')
if error == 'MISSING_REQUIRED_FIELDS':
return _('One or more required fields are empty.')
if error == 'SOMETHING_IS_WRONG':
if error == 'FORMAT_ERROR':
return _('The attachment of the letter could not be sent. Please check its content and contact the support if the problem persists.')
else:
return _('An unknown error happened. Please contact the support.')
return error
@@ -256,20 +258,22 @@ class SnailmailLetter(models.Model):
activity = MailActivity.search(domain, limit=1)
activity_data = {
'res_id': letter.res_id,
'res_model_id': self.env['ir.model']._get(letter.model).id,
'activity_type_id': self.env.ref('mail.mail_activity_data_warning').id,
'summary': '[SNAILMAIL] ' + _('Post letter: an error occured.'),
'note': note,
'user_id': letter.user_id.id,
'date_deadline': fields.Date.today()
}
if activity:
activity.update(activity_data)
else:
activity_data.update({
'user_id': letter.user_id.id,
'res_id': letter.res_id,
'res_model_id': self.env['ir.model']._get(letter.model).id,
})
MailActivity.create(activity_data)
letter.write({'info_msg': note})
letter.write({'info_msg': note, 'state': 'error'})
self.env.cr.commit()
@@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server saas~11.5\n"
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-09-21 13:17+0000\n"
"PO-Revision-Date: 2018-09-21 13:17+0000\n"
"POT-Creation-Date: 2018-11-05 09:29+0000\n"
"PO-Revision-Date: 2018-11-05 09:29+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -40,11 +40,6 @@ msgstr ""
msgid "Config Settings"
msgstr ""
#. module: snailmail_account
#: model:ir.model.fields,field_description:snailmail_account.field_account_invoice_send__snailmail_cost
msgid "Credits"
msgstr ""
#. module: snailmail_account
#: model:ir.model.fields,field_description:snailmail_account.field_account_invoice_send__currency_id
msgid "Currency"
@@ -81,3 +76,7 @@ msgstr ""
msgid "Send by Post"
msgstr ""
#. module: snailmail_account
#: model:ir.model.fields,field_description:snailmail_account.field_account_invoice_send__snailmail_cost
msgid "Stamp(s)"
msgstr ""
@@ -11,17 +11,10 @@ class AccountInvoiceSend(models.TransientModel):
partner_id = fields.Many2one('res.partner', compute='_get_partner', string='Partner')
snailmail_is_letter = fields.Boolean('Send by Post', help='Allows to send the document by snail mail (coventional posting delivery service)', default=lambda self: self.env.user.company_id.invoice_is_snailmail)
snailmail_cost = fields.Float(string='Credits', compute='_snailmail_estimate', store=True, readonly=True)
snailmail_cost = fields.Float(string='Stamp(s)', compute='_snailmail_estimate', store=True, readonly=True)
currency_id = fields.Many2one('res.currency', compute='_get_invoice_currency', string="Currency")
letter_ids = fields.Many2many('snailmail.letter', 'snailmail_letter_account_invoice_send_rel', ondelete='cascade')
@api.multi
@api.onchange('invoice_ids')
def _get_invoice_currency(self):
for wizard in self:
if wizard.invoice_ids:
wizard.currency_id = wizard.invoice_ids.mapped('currency_id')[0].id
@api.multi
@api.onchange('invoice_ids')
def _get_partner(self):
@@ -9,14 +9,16 @@
<xpath expr="//div[@name='option_email']" position='before'>
<div name="option_letter">
<field name="letter_ids" invisible="1"/>
<field name="currency_id" invisible="1"/>
<div name="option" class="text-left d-inline-block">
<field name="snailmail_is_letter" />
<b><label for="snailmail_is_letter"/></b>
</div>
<div class="text-left d-inline-block mr8" name='cost' attrs="{'invisible': [('snailmail_is_letter','=', False)]}">
<b>(
<field name="snailmail_cost" class="mr4" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<span>
<field name="snailmail_cost" options="{'digits':[0,0]}" class="mr4"/>
<label for="snailmail_cost" class="mr4"/>
</span>
<i class="fa fa-info-circle" role="img" aria-label="Warning" title="
The letter will be sent using the IAP service from Odoo.&#10;Make sure you have enough credits on your account or proceed to a recharge.&#10;The price is estimated based on 1 page per document.
"/>