11.02.26
This commit is contained in:
@@ -236,20 +236,22 @@ class AutomationDocument(ModelSQL, ModelView, Workflow):
|
|||||||
doc.notes = (doc.notes or "") + f"Shipment found: {sh[0].number}\n"
|
doc.notes = (doc.notes or "") + f"Shipment found: {sh[0].number}\n"
|
||||||
logger.info("BL_NUMBER:%s",sh[0].bl_number)
|
logger.info("BL_NUMBER:%s",sh[0].bl_number)
|
||||||
if sh[0].incoming_moves:
|
if sh[0].incoming_moves:
|
||||||
weight_total = sum([m.lot.lot_quantity for m in sh[0].incoming_moves if m.lot.lot_type == 'physic'])
|
factor_net = wr.net_landed_kg / wr.bales if wr.bales else 1
|
||||||
factor = weight_total / wr.net_landed_kg if wr.net_landed_kg else 1
|
factor_gross = wr.gross_landed_kg / wr.bales if wr.bales else 1
|
||||||
for move in sh[0].incoming_moves:
|
for move in sh[0].incoming_moves:
|
||||||
lot = move.lot
|
lot = move.lot
|
||||||
if lot.lot_type == 'physic':
|
if lot.lot_type == 'physic':
|
||||||
wr_payload = {
|
wr_payload = {
|
||||||
"chunk_key": lot.lot_chunk_key,
|
"chunk_key": lot.lot_chunk_key,
|
||||||
"gross_weight": float(round(lot.lot_gross_quantity / factor,5)),
|
"gross_weight": float(round(lot.lot_qt * factor_gross,5)),
|
||||||
"net_weight": float(round(lot.lot_quantity / factor,5)),
|
"net_weight": float(round(lot.lot_qt * factor_net,5)),
|
||||||
"tare_total": float(round(wr.tare_kg * (lot.lot_quantity / weight_total),5)) ,
|
"tare_total": float(round(wr.tare_kg * (lot.lot_qt / wr.bales),5)) ,
|
||||||
"bags": int(lot.lot_qt),
|
"bags": int(lot.lot_qt),
|
||||||
"surveyor_code": 231,
|
"surveyor_code": sh[0].controller.get_alf(),
|
||||||
"place_key": 0,
|
"place_key": sh[0].to_location.get_places(),
|
||||||
"report_date": 20260127
|
"report_date": wr.report_date,
|
||||||
|
"weight_date": wr.weight_date,
|
||||||
|
"agent": sh[0].agent.get_alf()
|
||||||
}
|
}
|
||||||
logger.info("PAYLOAD:%s",wr_payload)
|
logger.info("PAYLOAD:%s",wr_payload)
|
||||||
data = doc.create_weight_report(wr_payload)
|
data = doc.create_weight_report(wr_payload)
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ class AutomationCron(ModelSQL, ModelView):
|
|||||||
shipment.to_location = loc_to
|
shipment.to_location = loc_to
|
||||||
shipment.carrier = None #carrier
|
shipment.carrier = None #carrier
|
||||||
shipment.supplier = agent
|
shipment.supplier = agent
|
||||||
|
shipment.agent = agent
|
||||||
shipment.vessel = vessel
|
shipment.vessel = vessel
|
||||||
shipment.cargo_mode = 'bulk'
|
shipment.cargo_mode = 'bulk'
|
||||||
shipment.bl_number = bl_number
|
shipment.bl_number = bl_number
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from trytond.exceptions import UserError
|
|||||||
from trytond.modules.purchase_trade.purchase import (TRIGGERS)
|
from trytond.modules.purchase_trade.purchase import (TRIGGERS)
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from decimal import getcontext, Decimal, ROUND_HALF_UP
|
from decimal import getcontext, Decimal, ROUND_HALF_UP
|
||||||
|
from sql import Table
|
||||||
|
|
||||||
class PartyExecution(ModelSQL,ModelView):
|
class PartyExecution(ModelSQL,ModelView):
|
||||||
"Party Execution"
|
"Party Execution"
|
||||||
@@ -75,6 +76,17 @@ class Party(metaclass=PoolMeta):
|
|||||||
if sp:
|
if sp:
|
||||||
return round(((sp[0].cost / Decimal(100)) * Decimal(2.2046)),4)
|
return round(((sp[0].cost / Decimal(100)) * Decimal(2.2046)),4)
|
||||||
|
|
||||||
|
def get_alf(self,name):
|
||||||
|
t = Table('alf')
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
cursor.execute(*t.select(
|
||||||
|
t.ALF_CODE,
|
||||||
|
where=t.SHORT_NAME.ilike(f'%{name}%')
|
||||||
|
))
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
if rows:
|
||||||
|
return int(rows[0][0])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getPartyByName(cls, party, category=None):
|
def getPartyByName(cls, party, category=None):
|
||||||
party = party.upper()
|
party = party.upper()
|
||||||
|
|||||||
@@ -32,6 +32,17 @@ logger = logging.getLogger(__name__)
|
|||||||
class Location(metaclass=PoolMeta):
|
class Location(metaclass=PoolMeta):
|
||||||
__name__ = 'stock.location'
|
__name__ = 'stock.location'
|
||||||
|
|
||||||
|
def get_places(self,name):
|
||||||
|
t = Table('places')
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
cursor.execute(*t.select(
|
||||||
|
t.PLACE_KEY,
|
||||||
|
where=t.PLACE_NAME.ilike(f'%{name}%')
|
||||||
|
))
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
if rows:
|
||||||
|
return int(rows[0][0])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getLocationByName(cls, location, type):
|
def getLocationByName(cls, location, type):
|
||||||
location = location.upper()
|
location = location.upper()
|
||||||
@@ -436,6 +447,7 @@ class ShipmentIn(metaclass=PoolMeta):
|
|||||||
add_invoice = fields.Boolean("Add invoice")
|
add_invoice = fields.Boolean("Add invoice")
|
||||||
returned_id = fields.Char("Returned ID")
|
returned_id = fields.Char("Returned ID")
|
||||||
result = fields.Char("Result",readonly=True)
|
result = fields.Char("Result",readonly=True)
|
||||||
|
agent = fields.Many2One('party.party',"Booking Agent")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<newline/>
|
<newline/>
|
||||||
<label name="booking_date"/>
|
<label name="booking_date"/>
|
||||||
<field name="booking_date"/>
|
<field name="booking_date"/>
|
||||||
|
<label name="agent"/>
|
||||||
|
<field name="agent"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label name="note" />
|
<label name="note" />
|
||||||
<field name="note" colspan="4"/>
|
<field name="note" colspan="4"/>
|
||||||
|
|||||||
@@ -61,7 +61,6 @@
|
|||||||
<label name="bales"/>
|
<label name="bales"/>
|
||||||
<field name="bales"/>
|
<field name="bales"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group id="weights" colspan="8" col="8">
|
<group id="weights" colspan="8" col="8">
|
||||||
<label name="gross_landed_kg"/>
|
<label name="gross_landed_kg"/>
|
||||||
<field name="gross_landed_kg"/>
|
<field name="gross_landed_kg"/>
|
||||||
@@ -76,6 +75,9 @@
|
|||||||
<field name="gain_loss_kg"/>
|
<field name="gain_loss_kg"/>
|
||||||
<label name="gain_loss_percent"/>
|
<label name="gain_loss_percent"/>
|
||||||
<field name="gain_loss_percent"/>
|
<field name="gain_loss_percent"/>
|
||||||
|
<newline/>
|
||||||
|
<label name="weight_date"/>
|
||||||
|
<field name="weight_date"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<!-- <group id="buttons" colspan="8">
|
<!-- <group id="buttons" colspan="8">
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class WeightReport(ModelSQL, ModelView):
|
|||||||
arrival_date = fields.Date('Arrival Date')
|
arrival_date = fields.Date('Arrival Date')
|
||||||
weighing_place = fields.Char('Weighing Place')
|
weighing_place = fields.Char('Weighing Place')
|
||||||
weighing_method = fields.Char('Weighing Method')
|
weighing_method = fields.Char('Weighing Method')
|
||||||
|
weight_date = fields.Date('Weight Date')
|
||||||
bales = fields.Integer('Number of Bales')
|
bales = fields.Integer('Number of Bales')
|
||||||
|
|
||||||
# Weights Information
|
# Weights Information
|
||||||
@@ -90,13 +91,17 @@ class WeightReport(ModelSQL, ModelView):
|
|||||||
report['file_no'] = report_data.get('file_no', '')
|
report['file_no'] = report_data.get('file_no', '')
|
||||||
|
|
||||||
# Conversion de la date (format: "28 October 2025")
|
# Conversion de la date (format: "28 October 2025")
|
||||||
date_str = report_data.get('date', '')
|
|
||||||
if date_str:
|
|
||||||
try:
|
|
||||||
report['report_date'] = dt.strptime(date_str, '%d %B %Y').date()
|
|
||||||
except:
|
|
||||||
report['report_date'] = None
|
|
||||||
|
|
||||||
|
def parse_date(date_str):
|
||||||
|
for fmt in ('%d %B %Y', '%d %b %Y'):
|
||||||
|
try:
|
||||||
|
return dt.strptime(date_str, fmt).date()
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
|
report['report_date'] = parse_date(report_data.get('date', ''))
|
||||||
|
report['weight_date'] = parse_date(report_data.get('weight_date', ''))
|
||||||
# 3. Contract Information
|
# 3. Contract Information
|
||||||
contract_data = json_data.get('contract', {})
|
contract_data = json_data.get('contract', {})
|
||||||
report['contract_no'] = contract_data.get('contract_no', '')
|
report['contract_no'] = contract_data.get('contract_no', '')
|
||||||
|
|||||||
Reference in New Issue
Block a user