Faircot action
This commit is contained in:
@@ -195,8 +195,9 @@ def register():
|
||||
stock.Move,
|
||||
stock.Location,
|
||||
stock.InvoiceLine,
|
||||
stock.ShipmentIn,
|
||||
stock.ShipmentWR,
|
||||
stock.ShipmentIn,
|
||||
stock.ShipmentControllerEmailStart,
|
||||
stock.ShipmentWR,
|
||||
stock.ShipmentInternal,
|
||||
stock.ShipmentOut,
|
||||
stock.StatementOfFacts,
|
||||
@@ -336,9 +337,10 @@ def register():
|
||||
lot.LotUnship,
|
||||
lot.LotRemove,
|
||||
lot.LotInvoice,
|
||||
lot.LotAdding,
|
||||
lot.LotImporting,
|
||||
stock.FindVessel,
|
||||
lot.LotAdding,
|
||||
lot.LotImporting,
|
||||
stock.ShipmentControllerEmail,
|
||||
stock.FindVessel,
|
||||
stock.SofUpdate,
|
||||
stock.Revaluate,
|
||||
purchase.GoToBi,
|
||||
|
||||
@@ -2852,11 +2852,9 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def send(cls, shipments):
|
||||
Date = Pool().get('ir.date')
|
||||
Attachment = Pool().get('ir.attachment')
|
||||
@classmethod
|
||||
def _send_controller_email(cls, shipments, body_by_shipment=None):
|
||||
Attachment = Pool().get('ir.attachment')
|
||||
|
||||
for sh in shipments:
|
||||
sh.result = "Email not sent"
|
||||
@@ -2879,13 +2877,14 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
Contact = Pool().get('party.contact_mechanism')
|
||||
contact = Contact.search(['party','=',sh.controller.id])
|
||||
if contact:
|
||||
payload = {
|
||||
"to": [contact[0].value],
|
||||
"subject": "Request for control",
|
||||
"body": sh.html_to_text(sh.instructions),
|
||||
"attachments": attachment,
|
||||
"meta": {
|
||||
"shipment": sh.bl_number,
|
||||
payload = {
|
||||
"to": [contact[0].value],
|
||||
"subject": "Request for control",
|
||||
"body": (body_by_shipment or {}).get(
|
||||
sh.id, sh.html_to_text(sh.instructions or '')),
|
||||
"attachments": attachment,
|
||||
"meta": {
|
||||
"shipment": sh.bl_number,
|
||||
"controller": sh.controller.id
|
||||
}
|
||||
}
|
||||
@@ -2922,11 +2921,16 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
logger.info("PAYLOAD:%s",so_payload)
|
||||
data = sh.create_service_order(so_payload)
|
||||
logger.info("SO_NUMBER:%s",data.get('service_order_number'))
|
||||
sh.result += f" / SO Nb {data.get('service_order_number')}"
|
||||
sh.service_order_key = int(data.get('service_order_key'))
|
||||
sh.save()
|
||||
|
||||
@classmethod
|
||||
sh.result += f" / SO Nb {data.get('service_order_number')}"
|
||||
sh.service_order_key = int(data.get('service_order_key'))
|
||||
sh.save()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('purchase_trade.act_send_controller_email')
|
||||
def send(cls, shipments):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
def compute(cls, shipments):
|
||||
Sof = Pool().get('sof.statement')
|
||||
@@ -3313,6 +3317,50 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
]
|
||||
)
|
||||
|
||||
class ShipmentControllerEmailStart(ModelView):
|
||||
"Send Controller Email"
|
||||
__name__ = 'stock.shipment.in.send.controller.email.start'
|
||||
|
||||
body = fields.Text("Message", required=True)
|
||||
|
||||
|
||||
class ShipmentControllerEmail(Wizard):
|
||||
"Send Controller Email"
|
||||
__name__ = 'stock.shipment.in.send.controller.email'
|
||||
|
||||
start = StateView(
|
||||
'stock.shipment.in.send.controller.email.start',
|
||||
'purchase_trade.shipment_controller_email_start_view_form',
|
||||
[
|
||||
Button("Cancel", 'end', 'tryton-cancel'),
|
||||
Button("Send", 'send_', 'tryton-ok', default=True),
|
||||
])
|
||||
send_ = StateTransition()
|
||||
|
||||
def _shipment(self):
|
||||
Shipment = Pool().get('stock.shipment.in')
|
||||
active_ids = Transaction().context.get('active_ids') or []
|
||||
if len(active_ids) != 1:
|
||||
raise UserError("Select one shipment.")
|
||||
return Shipment(active_ids[0])
|
||||
|
||||
def default_start(self, fields):
|
||||
shipment = self._shipment()
|
||||
return {
|
||||
'body': shipment.html_to_text(shipment.instructions or ''),
|
||||
}
|
||||
|
||||
def transition_send_(self):
|
||||
Shipment = Pool().get('stock.shipment.in')
|
||||
shipment = self._shipment()
|
||||
Shipment._send_controller_email(
|
||||
[shipment], {shipment.id: self.start.body or ''})
|
||||
return 'end'
|
||||
|
||||
def end(self):
|
||||
return 'reload'
|
||||
|
||||
|
||||
class FindVessel(Wizard):
|
||||
__name__ = 'stock.shipment.in.vf'
|
||||
start_state = 'vf'
|
||||
|
||||
@@ -13,6 +13,15 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="inherit" ref="stock.shipment_in_view_tree"/>
|
||||
<field name="name">shipment_in_tree</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="shipment_controller_email_start_view_form">
|
||||
<field name="model">stock.shipment.in.send.controller.email.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">shipment_controller_email_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="act_send_controller_email">
|
||||
<field name="name">Send email to controller</field>
|
||||
<field name="wiz_name">stock.shipment.in.send.controller.email</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain" id="stock.act_shipment_in_form_domain_all">
|
||||
<field name="sequence" eval="1"/>
|
||||
</record>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<form>
|
||||
<label name="body"/>
|
||||
<field name="body" colspan="4" height="260"/>
|
||||
</form>
|
||||
@@ -162,7 +162,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="result"/>
|
||||
<newline/>
|
||||
<label name="instructions"/>
|
||||
<field name="instructions" colspan="4" height="200"/>
|
||||
<field name="instructions" widget="html_viewer" colspan="4" height="200"/>
|
||||
<newline/>
|
||||
<label name="returned_id"/>
|
||||
<field name="returned_id"/>
|
||||
|
||||
Reference in New Issue
Block a user