02.02.26
This commit is contained in:
@@ -310,7 +310,7 @@ class AutomationCron(ModelSQL, ModelView):
|
|||||||
ShipmentIn.save([shipment])
|
ShipmentIn.save([shipment])
|
||||||
shipment._create_lots_from_fintrade()
|
shipment._create_lots_from_fintrade()
|
||||||
shipment.controller = shipment.get_controller()
|
shipment.controller = shipment.get_controller()
|
||||||
shipment.instructions = shipment.get_instructions_html()
|
shipment.instructions = shipment.get_instructions()
|
||||||
ShipmentIn.save([shipment])
|
ShipmentIn.save([shipment])
|
||||||
trans_shipment.commit()
|
trans_shipment.commit()
|
||||||
successful_shipments += 1
|
successful_shipments += 1
|
||||||
|
|||||||
@@ -466,45 +466,45 @@ class ShipmentIn(metaclass=PoolMeta):
|
|||||||
if c.party.IsAvailableForControl(self):
|
if c.party.IsAvailableForControl(self):
|
||||||
return c.party
|
return c.party
|
||||||
|
|
||||||
def get_instructions_html(self):
|
# def get_instructions_html(self):
|
||||||
lines = [
|
|
||||||
"<p>Hi,</p>",
|
|
||||||
"<p>Please find details below for the requested control</p>",
|
|
||||||
f"<p><strong>BL number:</strong> {self.bl_number}</p>",
|
|
||||||
]
|
|
||||||
|
|
||||||
if self.incoming_moves:
|
|
||||||
for m in self.incoming_moves:
|
|
||||||
if m.lot:
|
|
||||||
lines.append(
|
|
||||||
"<p>"
|
|
||||||
f"<strong>Lot nb:</strong> {m.lot.lot_name} | "
|
|
||||||
f"<strong>Net Qt:</strong> {m.lot.get_current_quantity()} {m.lot.lot_unit_line.symbol} | "
|
|
||||||
f"<strong>Gross Qt:</strong> {m.lot.get_current_gross_quantity()} {m.lot.lot_unit_line.symbol}"
|
|
||||||
"</p>"
|
|
||||||
)
|
|
||||||
|
|
||||||
return "".join(lines)
|
|
||||||
|
|
||||||
# def get_instructions(self):
|
|
||||||
# lines = [
|
# lines = [
|
||||||
# "Hi,",
|
# "<p>Hi,</p>",
|
||||||
# "",
|
# "<p>Please find details below for the requested control</p>",
|
||||||
# "Please find details below for the requested control",
|
# f"<p><strong>BL number:</strong> {self.bl_number}</p>",
|
||||||
# f"BL number: {self.bl_number}",
|
|
||||||
# ""
|
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
# if self.incoming_moves:
|
# if self.incoming_moves:
|
||||||
# for m in self.incoming_moves:
|
# for m in self.incoming_moves:
|
||||||
# if m.lot:
|
# if m.lot:
|
||||||
# lines.append(
|
# lines.append(
|
||||||
# f"Lot nb: {m.lot.lot_name} | "
|
# "<p>"
|
||||||
# f"Net Qt: {m.lot.get_current_quantity()} {m.lot.lot_unit.symbol} | "
|
# f"<strong>Lot nb:</strong> {m.lot.lot_name} | "
|
||||||
# f"Gross Qt: {m.lot.get_current_gross_quantity()} {m.lot.lot_unit.symbol}"
|
# f"<strong>Net Qt:</strong> {m.lot.get_current_quantity()} {m.lot.lot_unit_line.symbol} | "
|
||||||
|
# f"<strong>Gross Qt:</strong> {m.lot.get_current_gross_quantity()} {m.lot.lot_unit_line.symbol}"
|
||||||
|
# "</p>"
|
||||||
# )
|
# )
|
||||||
|
|
||||||
# return "\n".join(lines)
|
# return "".join(lines)
|
||||||
|
|
||||||
|
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_name} | "
|
||||||
|
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):
|
def _create_lots_from_fintrade(self):
|
||||||
t = Table('freight_booking_lots')
|
t = Table('freight_booking_lots')
|
||||||
@@ -676,11 +676,11 @@ class ShipmentIn(metaclass=PoolMeta):
|
|||||||
|
|
||||||
return sale_line
|
return sale_line
|
||||||
|
|
||||||
def html_to_text(self,html_content):
|
# def html_to_text(self,html_content):
|
||||||
text = re.sub(r"<br\s*/?>", "\n", html_content, flags=re.IGNORECASE)
|
# text = re.sub(r"<br\s*/?>", "\n", html_content, flags=re.IGNORECASE)
|
||||||
text = re.sub(r"</p\s*>", "\n\n", text, flags=re.IGNORECASE)
|
# text = re.sub(r"</p\s*>", "\n\n", text, flags=re.IGNORECASE)
|
||||||
text = re.sub(r"<[^>]+>", "", text)
|
# text = re.sub(r"<[^>]+>", "", text)
|
||||||
return html.unescape(text).strip()
|
# return html.unescape(text).strip()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
@@ -697,7 +697,7 @@ class ShipmentIn(metaclass=PoolMeta):
|
|||||||
payload = {
|
payload = {
|
||||||
"to": [contact[0].value],
|
"to": [contact[0].value],
|
||||||
"subject": "Request for control",
|
"subject": "Request for control",
|
||||||
"body": sh.html_to_text(sh.instructions),
|
"body": sh.instructions,
|
||||||
# "attachments": [
|
# "attachments": [
|
||||||
# {
|
# {
|
||||||
# "filename": "instruction.pdf",
|
# "filename": "instruction.pdf",
|
||||||
|
|||||||
Reference in New Issue
Block a user