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"
|
||||
logger.info("BL_NUMBER:%s",sh[0].bl_number)
|
||||
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 = weight_total / wr.net_landed_kg if wr.net_landed_kg else 1
|
||||
factor_net = wr.net_landed_kg / wr.bales if wr.bales else 1
|
||||
factor_gross = wr.gross_landed_kg / wr.bales if wr.bales else 1
|
||||
for move in sh[0].incoming_moves:
|
||||
lot = move.lot
|
||||
if lot.lot_type == 'physic':
|
||||
wr_payload = {
|
||||
"chunk_key": lot.lot_chunk_key,
|
||||
"gross_weight": float(round(lot.lot_gross_quantity / factor,5)),
|
||||
"net_weight": float(round(lot.lot_quantity / factor,5)),
|
||||
"tare_total": float(round(wr.tare_kg * (lot.lot_quantity / weight_total),5)) ,
|
||||
"gross_weight": float(round(lot.lot_qt * factor_gross,5)),
|
||||
"net_weight": float(round(lot.lot_qt * factor_net,5)),
|
||||
"tare_total": float(round(wr.tare_kg * (lot.lot_qt / wr.bales),5)) ,
|
||||
"bags": int(lot.lot_qt),
|
||||
"surveyor_code": 231,
|
||||
"place_key": 0,
|
||||
"report_date": 20260127
|
||||
"surveyor_code": sh[0].controller.get_alf(),
|
||||
"place_key": sh[0].to_location.get_places(),
|
||||
"report_date": wr.report_date,
|
||||
"weight_date": wr.weight_date,
|
||||
"agent": sh[0].agent.get_alf()
|
||||
}
|
||||
logger.info("PAYLOAD:%s",wr_payload)
|
||||
data = doc.create_weight_report(wr_payload)
|
||||
|
||||
@@ -300,6 +300,7 @@ class AutomationCron(ModelSQL, ModelView):
|
||||
shipment.to_location = loc_to
|
||||
shipment.carrier = None #carrier
|
||||
shipment.supplier = agent
|
||||
shipment.agent = agent
|
||||
shipment.vessel = vessel
|
||||
shipment.cargo_mode = 'bulk'
|
||||
shipment.bl_number = bl_number
|
||||
|
||||
@@ -4,6 +4,7 @@ from trytond.exceptions import UserError
|
||||
from trytond.modules.purchase_trade.purchase import (TRIGGERS)
|
||||
from trytond.transaction import Transaction
|
||||
from decimal import getcontext, Decimal, ROUND_HALF_UP
|
||||
from sql import Table
|
||||
|
||||
class PartyExecution(ModelSQL,ModelView):
|
||||
"Party Execution"
|
||||
@@ -75,6 +76,17 @@ class Party(metaclass=PoolMeta):
|
||||
if sp:
|
||||
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
|
||||
def getPartyByName(cls, party, category=None):
|
||||
party = party.upper()
|
||||
|
||||
@@ -32,6 +32,17 @@ logger = logging.getLogger(__name__)
|
||||
class Location(metaclass=PoolMeta):
|
||||
__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
|
||||
def getLocationByName(cls, location, type):
|
||||
location = location.upper()
|
||||
@@ -436,6 +447,7 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
add_invoice = fields.Boolean("Add invoice")
|
||||
returned_id = fields.Char("Returned ID")
|
||||
result = fields.Char("Result",readonly=True)
|
||||
agent = fields.Many2One('party.party',"Booking Agent")
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
||||
@@ -89,6 +89,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<newline/>
|
||||
<label name="booking_date"/>
|
||||
<field name="booking_date"/>
|
||||
<label name="agent"/>
|
||||
<field name="agent"/>
|
||||
<newline/>
|
||||
<label name="note" />
|
||||
<field name="note" colspan="4"/>
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
<label name="bales"/>
|
||||
<field name="bales"/>
|
||||
</group>
|
||||
|
||||
<group id="weights" colspan="8" col="8">
|
||||
<label name="gross_landed_kg"/>
|
||||
<field name="gross_landed_kg"/>
|
||||
@@ -76,6 +75,9 @@
|
||||
<field name="gain_loss_kg"/>
|
||||
<label name="gain_loss_percent"/>
|
||||
<field name="gain_loss_percent"/>
|
||||
<newline/>
|
||||
<label name="weight_date"/>
|
||||
<field name="weight_date"/>
|
||||
</group>
|
||||
|
||||
<!-- <group id="buttons" colspan="8">
|
||||
|
||||
@@ -36,6 +36,7 @@ class WeightReport(ModelSQL, ModelView):
|
||||
arrival_date = fields.Date('Arrival Date')
|
||||
weighing_place = fields.Char('Weighing Place')
|
||||
weighing_method = fields.Char('Weighing Method')
|
||||
weight_date = fields.Date('Weight Date')
|
||||
bales = fields.Integer('Number of Bales')
|
||||
|
||||
# Weights Information
|
||||
@@ -90,13 +91,17 @@ class WeightReport(ModelSQL, ModelView):
|
||||
report['file_no'] = report_data.get('file_no', '')
|
||||
|
||||
# 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
|
||||
contract_data = json_data.get('contract', {})
|
||||
report['contract_no'] = contract_data.get('contract_no', '')
|
||||
|
||||
Reference in New Issue
Block a user