This commit is contained in:
2026-02-02 15:59:20 +01:00
parent 70a0a41787
commit 38a903469c
3 changed files with 29 additions and 8 deletions

View File

@@ -310,6 +310,7 @@ class AutomationCron(ModelSQL, ModelView):
ShipmentIn.save([shipment])
shipment._create_lots_from_fintrade()
shipment.controller = shipment.get_controller()
shipment.instructions = shipment.get_instructions()
ShipmentIn.save([shipment])
trans_shipment.commit()
successful_shipments += 1

View File

@@ -463,6 +463,26 @@ class ShipmentIn(metaclass=PoolMeta):
if c.party.IsAvailableForControl(self):
return c.party
def get_instructions(self):
lines = [
"Hi,",
"",
"Please find details below for the requested control",
f"BL number: {self.bl_number}",
""
]
if self.incoming_moves:
for m in self.incoming_moves:
if m.lot:
lines.append(
f"Lot nb: {m.lot.lot_number} | "
f"Net Qt: {m.lot.get_current_quantity()} {m.lot.lot_unit.symbol} | "
f"Gross Qt: {m.lot.get_current_gross_quantity()} {m.lot.lot_unit.symbol}"
)
return "\n".join(lines)
def _create_lots_from_fintrade(self):
t = Table('freight_booking_lots')
cursor = Transaction().connection.cursor()
@@ -671,7 +691,8 @@ class ShipmentIn(metaclass=PoolMeta):
response.raise_for_status()
data = response.json()
logger.info("SEND_FROM_SHIPMENT:%s",data)
sh.result = "Email sent on " + Date.today()
now = datetime.datetime.now()
sh.result = f"Email sent on {now.strftime('%d/%m/%Y %H:%M')}"
sh.save()
@classmethod

View File

@@ -113,19 +113,18 @@ this repository contains the full copyright notices and license terms. -->
<page string="Weight Report" col="4" id="wr">
<label name="controller"/>
<field name="controller"/>
<button name="send" string="Send"/>
<button name="send" string="Send email to controller"/>
<newline/>
<label name="result"/>
<field name="result"/>
<newline/>
<label name="instructions"/>
<field name="instructions"/>
<newline/>
<label name="add_bl"/>
<field name="add_bl"/>
<label name="add_invoice"/>
<field name="add_invoice"/>
<newline/>
<label name="instructions"/>
<field name="instructions" widget="html_viewer" colspan="4" height="100"/>
<label name="add_bl"/>
<field name="add_bl"/>
<newline/>
<label name="returned_id"/>
<field name="returned_id"/>
<newline/>