Allow to send internal shipment links

This commit refs #14613


(cherry picked from commit bfa7d23bc6)
This commit is contained in:
Francisco jose 2020-10-07 07:01:36 +00:00 committed by Sergio Morillo
parent abb79ebe92
commit f0f0ef8642
5 changed files with 77 additions and 1 deletions

View File

@ -10,6 +10,7 @@ def register():
Pool.register(
shipment.ShipmentOut,
shipment.ShipmentIn,
shipment.ShipmentInternal,
shipment.SendLinkStart,
configuration.Configuration,
company.Company,

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html xmlns:py="http://genshi.edgewall.org/">
<head>
<title>Web link to Shipment Internal</title>
</head>
<body>
<div style="display: block; text-align: center">
<div>
<h1>Web link to Shipment Internal</h1>
<entry py:for="record in records">
<p><a href="${ record.encrypted_url }">Go to Shipment Internal</a></p>
</entry>
</div>
<hr style="margin-top: 20px; border-style: solid none none; border-color: #EEE"></hr>
</div>
</body>
</html>

View File

@ -58,6 +58,10 @@ msgctxt "selection:stock.shipment.in,state:"
msgid "Mail sent"
msgstr "Correo enviado"
msgctxt "selection:stock.shipment.internal,state:"
msgid "Mail sent"
msgstr "Correo enviado"
msgctxt "model:ir.action.act_window.domain,name:act_shipment_out_form_domain_mail_sent"
msgid "Mail sent"
msgstr "Correo enviado"
@ -66,6 +70,10 @@ msgctxt "model:ir.action.act_window.domain,name:act_shipment_in_form_domain_mail
msgid "Mail sent"
msgstr "Correo enviado"
msgctxt "model:ir.action.act_window.domain,name:act_shipment_internal_form_domain_mail_sent"
msgid "Mail sent"
msgstr "Correo enviado"
msgctxt "model:ir.action,name:act_send_link"
msgid "Send link"
msgstr "Enviar enlace"
@ -82,6 +90,10 @@ msgctxt "error:stock.shipment.in:"
msgid "The action \"Send link\" must be done from draft state."
msgstr "La acción \"Enviar enlace\" debe hacerse desde el estado borrador."
msgctxt "error:stock.shipment.internal:"
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"

View File

@ -1,7 +1,7 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval
from trytond.pyson import Eval, Not
from trytond.model import ModelView, fields, Workflow
from trytond.config import config
from trytond.transaction import Transaction
@ -148,6 +148,8 @@ class ShipmentWebLinkMixin(object):
_type = 'shipment_in/'
if self.__name__ == 'stock.shipment.out':
_type = 'shipment_out/'
elif self.__name__ == 'stock.shipment.internal':
_type = 'shipment_internal/'
return config.shipment_link_url + _type + self.encrypted_id
def get_languages(self, user):
@ -230,6 +232,29 @@ class ShipmentIn(ShipmentWebLinkMixin, metaclass=PoolMeta):
email=email, send_mail=send_mail, raise_error=raise_error)
class ShipmentInternal(ShipmentWebLinkMixin, metaclass=PoolMeta):
__name__ = 'stock.shipment.internal'
@classmethod
def __setup__(cls):
super().__setup__()
cls._buttons['wait']['invisible'] = Not(Eval('state').in_(
['assigned', 'draft', 'mail_sent']))
cls._transitions |= set((
('draft', 'mail_sent'),
('mail_sent', 'waiting'),
('mail_sent', 'draft'),
('waiting', 'mail_sent')))
def get_email_shipment_flask(self, user):
return self.get_email(
'stock.shipment.internal.web_link', self, self.get_languages(user))
def get_to_email(self):
return self.company.party.email
class SendLinkStart(ModelView):
"""Shipment Send Link Start"""
__name__ = 'stock.shipment.send_link.start'

View File

@ -31,6 +31,11 @@
<field name="model">stock.shipment.in,-1</field>
<field name="action" ref="act_send_link"/>
</record>
<record model="ir.action.keyword" id="act_send_link_shipment_internal">
<field name="keyword">form_action</field>
<field name="model">stock.shipment.internal,-1</field>
<field name="action" ref="act_send_link"/>
</record>
<record model="ir.action-res.group"
id="shipment_send_link_group_send_link">
<field name="action" ref="act_send_link"/>
@ -55,6 +60,15 @@
<field name="act_window" ref="stock.act_shipment_in_form"/>
</record>
<!-- Shipment Internal -->
<record model="ir.action.act_window.domain" id="act_shipment_internal_form_domain_mail_sent">
<field name="name">Mail sent</field>
<field name="sequence" eval="10"/>
<field name="domain" eval="[('state', '=', 'mail_sent')]" pyson="1"/>
<field name="count" eval="True"/>
<field name="act_window" ref="stock.act_shipment_internal_form"/>
</record>
<!-- Reports -->
<record model="ir.action.report" id="report_shipment_out_web_link">
<field name="name">Web link to Shipment Out</field>
@ -70,5 +84,12 @@
<field name="report">stock_shipment_web_link/email_shipment_in.html</field>
<field name="template_extension">html</field>
</record>
<record model="ir.action.report" id="report_shipment_internal_web_link">
<field name="name">Web link to Shipment Internal</field>
<field name="model">stock.shipment.internal</field>
<field name="report_name">stock.shipment.internal.web_link</field>
<field name="report">stock_shipment_web_link/email_shipment_internal.html</field>
<field name="template_extension">html</field>
</record>
</data>
</tryton>