parent
66e8f003da
commit
c8503aee2e
|
@ -9,6 +9,7 @@ def register():
|
|||
Pool.register(
|
||||
shipment.ShipmentOut,
|
||||
shipment.ShipmentIn,
|
||||
shipment.SendLinkStart,
|
||||
configuration.Configuration,
|
||||
module='stock_shipment_web_link', type_='model')
|
||||
Pool.register(
|
||||
|
|
|
@ -69,3 +69,11 @@ msgstr "Enviar enlace web de albarán"
|
|||
msgctxt "error:stock.shipment.out:"
|
||||
msgid "The action \"Send link\" must be done from draft state."
|
||||
msgstr "La acción \"Enviar enlace\" debe hacerse desde el estado borrador."
|
||||
|
||||
msgctxt "wizard_button:stock.shipment.send_link,start,end:"
|
||||
msgid "Cancel"
|
||||
msgstr "Cancelar"
|
||||
|
||||
msgctxt "wizard_button:stock.shipment.send_link,start,sent_link:"
|
||||
msgid "Send link"
|
||||
msgstr "Enviar enlace"
|
||||
|
|
44
shipment.py
44
shipment.py
|
@ -11,7 +11,7 @@ from trytond.report import Report
|
|||
from cryptography.fernet import Fernet
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from trytond.wizard import Wizard, StateTransition
|
||||
from trytond.wizard import Wizard, StateView, Button, StateTransition
|
||||
import logging
|
||||
|
||||
try:
|
||||
|
@ -19,7 +19,7 @@ try:
|
|||
except ImportError:
|
||||
html2text = None
|
||||
|
||||
__all__ = ['ShipmentOut', 'SendLink']
|
||||
__all__ = ['ShipmentOut', 'SendLink', 'SendLinkStart']
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ class ShipmentWebLinkMixin(object):
|
|||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('mail_sent')
|
||||
def send_link(cls, shipments, length=8, from_=None, send_mail=True):
|
||||
def send_link(cls, shipments, email, length=8, from_=None, send_mail=True):
|
||||
pool = Pool()
|
||||
User = pool.get('res.user')
|
||||
Move = pool.get('stock.move')
|
||||
|
@ -117,9 +117,9 @@ class ShipmentWebLinkMixin(object):
|
|||
return
|
||||
msg, title = shipment.get_email_shipment_flask(user)
|
||||
msg['From'] = from_
|
||||
msg['To'] = shipment.get_to_email()
|
||||
msg['To'] = email
|
||||
msg['Subject'] = Header(title, 'utf-8')
|
||||
sendmail_transactional(from_, [shipment.get_to_email()], msg)
|
||||
sendmail_transactional(from_, [email], msg)
|
||||
|
||||
def get_encrypted_id(self, name=None):
|
||||
fernet = self.get_fernet()
|
||||
|
@ -202,23 +202,39 @@ class ShipmentIn(ShipmentWebLinkMixin):
|
|||
'stock.shipment.in.web_link', self, self.get_languages(user))
|
||||
|
||||
|
||||
class SendLinkStart(ModelView):
|
||||
"""Shipment Send Link Start"""
|
||||
__name__ = 'stock.shipment.send_link.start'
|
||||
|
||||
email = fields.Char('Email', required=True)
|
||||
|
||||
|
||||
class SendLink(Wizard):
|
||||
"""Shipment Send Link"""
|
||||
__name__ = 'stock.shipment.send_link'
|
||||
|
||||
start_state = 'sent_link'
|
||||
start = StateView('stock.shipment.send_link.start',
|
||||
'stock_shipment_web_link.send_link_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Send link', 'sent_link', 'tryton-ok', default=True),
|
||||
])
|
||||
sent_link = StateTransition()
|
||||
|
||||
def default_start(self, fields):
|
||||
pool = Pool()
|
||||
Shipment = pool.get(Transaction().context['active_model'])
|
||||
|
||||
context = Transaction().context
|
||||
shipment = Shipment(context['active_id'])
|
||||
return {
|
||||
'email': shipment.get_to_email()
|
||||
}
|
||||
|
||||
def transition_sent_link(self):
|
||||
pool = Pool()
|
||||
ShipmentOut = pool.get('stock.shipment.out')
|
||||
ShipmentIn = pool.get('stock.shipment.in')
|
||||
Shipment = pool.get(Transaction().context['active_model'])
|
||||
|
||||
context = Transaction().context
|
||||
if Transaction().context.get('active_model') == 'stock.shipment.out':
|
||||
shipments = ShipmentOut.browse(context['active_ids'])
|
||||
ShipmentOut.send_link(shipments)
|
||||
elif Transaction().context.get('active_model') == 'stock.shipment.in':
|
||||
shipments = ShipmentIn.browse(context['active_ids'])
|
||||
ShipmentIn.send_link(shipments)
|
||||
shipments = Shipment.browse(context['active_ids'])
|
||||
Shipment.send_link(shipments, self.start.email)
|
||||
return 'end'
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
<field name="group" ref="group_send_link"/>
|
||||
</record>
|
||||
|
||||
<!-- Wizard -->
|
||||
<record model="ir.ui.view" id="send_link_start_view_form">
|
||||
<field name="model">stock.shipment.send_link.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">send_link_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="act_send_link">
|
||||
<field name="name">Send link</field>
|
||||
<field name="wiz_name">stock.shipment.send_link</field>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="email"/>
|
||||
<field name="email"/>
|
||||
</form>
|
Loading…
Reference in New Issue