This commit is contained in:
2026-02-11 07:26:48 +01:00
parent 1eb86892de
commit e37cd4a1cc
7 changed files with 51 additions and 15 deletions

View File

@@ -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()

View File

@@ -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):

View File

@@ -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"/>

View File

@@ -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">

View File

@@ -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', '')