This commit is contained in:
2026-03-09 16:11:42 +01:00
parent 7cafd8381f
commit dd06fc523c
3 changed files with 132 additions and 59 deletions

View File

@@ -23,6 +23,7 @@ import json
import jwt
from collections import defaultdict
from trytond.exceptions import UserWarning, UserError
from trytond.modules.purchase_trade.numbers_to_words import quantity_to_words, amount_to_currency_words, format_date_en
logger = logging.getLogger(__name__)
@@ -291,6 +292,78 @@ class Purchase(metaclass=PoolMeta):
def get_company_info(self,name):
return (self.company.party.name == 'MELYA')
@property
def report_terms(self):
if self.lines:
return self.lines[0].note
else:
return ''
@property
def report_qt(self):
if self.lines:
return quantity_to_words(self.lines[0].quantity)
else:
return ''
@property
def report_price(self):
if self.lines:
if self.lines[0].price_type == 'fixed':
return amount_to_currency_words(self.lines[0].unit_price)
elif self.lines[0].price_type == 'basis':
return amount_to_currency_words(self.lines[0].unit_price) + ' ' + self.lines[0].get_pricing_text()
else:
return ''
@property
def report_delivery(self):
del_date = 'PROMPT'
if self.lc_date:
return format_date_en(self.lc_date)
if self.lines:
if self.lines[0].estimated_date:
delivery_date = [dd.estimated_date for dd in self.lines[0].estimated_date if dd.trigger=='deldate']
if delivery_date:
del_date = delivery_date[0]
if del_date:
del_date = format_date_en(del_date)
return del_date
@property
def report_payment_date(self):
if self.lines:
Date = Pool().get('ir.date')
payment_date = self.lines[0].sale.payment_term.lines[0].get_date(Date.today(),self.lines[0])
if payment_date:
payment_date = format_date_en(payment_date)
return payment_date
@property
def report_shipment(self):
if self.lines:
if len(self.lines[0].lots)>1:
shipment = self.lines[0].lots[1].lot_shipment_in
lot = self.lines[0].lots[1].lot_name
if shipment:
info = 'B/L ' + shipment.bl_number
if shipment.container and shipment.container[0].container_no:
id = 1
for cont in shipment.container:
if id == 1:
info += ' Container(s)'
if cont.container_no:
info += ' ' + cont.container_no
else:
info += ' unnamed'
id += 1
info += ' (LOT ' + lot + ')'
if shipment.note:
info += ' ' + shipment.note
return info
else:
return ''
@classmethod
def default_viewer(cls):
country_start = "Zobiland"

View File

@@ -291,6 +291,8 @@ class Sale(metaclass=PoolMeta):
@property
def report_delivery(self):
del_date = 'PROMPT'
if self.lc_date:
return format_date_en(self.lc_date)
if self.lines:
if self.lines[0].estimated_date:
delivery_date = [dd.estimated_date for dd in self.lines[0].estimated_date if dd.trigger=='deldate']