27.01.26
This commit is contained in:
@@ -261,81 +261,88 @@ class AutomationDocument(ModelSQL, ModelView, Workflow):
|
|||||||
logger.info("DECLARATION_KEY:%s",dec_key)
|
logger.info("DECLARATION_KEY:%s",dec_key)
|
||||||
declaration = SaleLine.search(['note','=',dec_key])
|
declaration = SaleLine.search(['note','=',dec_key])
|
||||||
if declaration:
|
if declaration:
|
||||||
sale_line = declaration[0]
|
with Transaction().new_transaction() as trans1:
|
||||||
logger.info("WITH_DEC:%s",sale_line)
|
sale_line = declaration[0]
|
||||||
vlot = sale_line.lots[0]
|
logger.info("WITH_DEC:%s",sale_line)
|
||||||
lqt = LotQt.search([('lot_s','=',vlot.id)])
|
vlot = sale_line.lots[0]
|
||||||
if lqt and lqt[0].lot_p:
|
lqt = LotQt.search([('lot_s','=',vlot.id)])
|
||||||
logger.info("VLOT_P:%s",lqt[0].lot_p)
|
if lqt and lqt[0].lot_p:
|
||||||
lqt[0].lot_p.updateVirtualPart(round(lot_net_weight,2),sh[0],lqt[0].lot_s)
|
logger.info("VLOT_P:%s",lqt[0].lot_p)
|
||||||
|
lqt[0].lot_p.updateVirtualPart(round(lot_net_weight,2),sh[0],lqt[0].lot_s)
|
||||||
|
trans1.commit()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
sale = Sale()
|
sale = Sale()
|
||||||
sale_line = SaleLine()
|
sale_line = SaleLine()
|
||||||
sale.party = Party.getPartyByName(customer,'CLIENT')
|
with Transaction().new_transaction() as trans1:
|
||||||
logger.info("SALE_PARTY:%s",sale.party)
|
sale.party = Party.getPartyByName(customer,'CLIENT')
|
||||||
sale.reference = reference
|
logger.info("SALE_PARTY:%s",sale.party)
|
||||||
sale.company = 6
|
sale.reference = reference
|
||||||
if sale.party.addresses:
|
sale.company = 6
|
||||||
sale.invoice_address = sale.party.addresses[0]
|
if sale.party.addresses:
|
||||||
sale.shipment_address = sale.party.addresses[0]
|
sale.invoice_address = sale.party.addresses[0]
|
||||||
|
sale.shipment_address = sale.party.addresses[0]
|
||||||
if sell_price_currency == 'USC':
|
|
||||||
sale.currency = Currency.get_by_name('USD')
|
if sell_price_currency == 'USC':
|
||||||
sale_line.enable_linked_currency = True
|
sale.currency = Currency.get_by_name('USD')
|
||||||
sale_line.linked_currency = 1
|
sale_line.enable_linked_currency = True
|
||||||
sale_line.linked_unit = Uom.get_by_name(sell_price_unit)
|
sale_line.linked_currency = 1
|
||||||
sale_line.linked_price = round(sell_price,4)
|
sale_line.linked_unit = Uom.get_by_name(sell_price_unit)
|
||||||
sale_line.unit_price = sale_line.get_price_linked_currency()
|
sale_line.linked_price = round(sell_price,4)
|
||||||
else:
|
sale_line.unit_price = sale_line.get_price_linked_currency()
|
||||||
sale.currency = Currency.get_by_name(sell_price_currency)
|
else:
|
||||||
sale_line.unit_price = round(sell_price,4)
|
sale.currency = Currency.get_by_name(sell_price_currency)
|
||||||
sale_line.unit = Uom.get_by_name(sell_price_unit)
|
sale_line.unit_price = round(sell_price,4)
|
||||||
sale_line.premium = premium
|
sale_line.unit = Uom.get_by_name(sell_price_unit)
|
||||||
Sale.save([sale])
|
sale_line.premium = premium
|
||||||
sale_line.sale = sale.id
|
Sale.save([sale])
|
||||||
sale_line.quantity = round(lot_net_weight,2)
|
sale_line.sale = sale.id
|
||||||
sale_line.quantity_theorical = round(lot_net_weight,2)
|
sale_line.quantity = round(lot_net_weight,2)
|
||||||
sale_line.product = Product.get_by_name('BRAZIL COTTON')
|
sale_line.quantity_theorical = round(lot_net_weight,2)
|
||||||
logger.info("PRODUCT:%s",sale_line.product)
|
sale_line.product = Product.get_by_name('BRAZIL COTTON')
|
||||||
sale_line.unit = Uom.get_by_name(lot_unit)
|
logger.info("PRODUCT:%s",sale_line.product)
|
||||||
sale_line.price_type = 'priced'
|
sale_line.unit = Uom.get_by_name(lot_unit)
|
||||||
sale_line.created_by_code = False
|
sale_line.price_type = 'priced'
|
||||||
sale_line.note = dec_key
|
sale_line.created_by_code = False
|
||||||
SaleLine.save([sale_line])
|
sale_line.note = dec_key
|
||||||
|
SaleLine.save([sale_line])
|
||||||
|
trans1.commit()
|
||||||
|
|
||||||
ContractStart = Pool().get('contracts.start')
|
with Transaction().new_transaction() as trans2:
|
||||||
ContractDetail = Pool().get('contract.detail')
|
ContractStart = Pool().get('contracts.start')
|
||||||
ct = ContractStart()
|
ContractDetail = Pool().get('contract.detail')
|
||||||
d = ContractDetail()
|
ct = ContractStart()
|
||||||
ct.type = 'Purchase'
|
d = ContractDetail()
|
||||||
ct.matched = True
|
ct.type = 'Purchase'
|
||||||
ct.shipment_in = sh[0]
|
ct.matched = True
|
||||||
ct.lot = sale_line.lots[0]
|
ct.shipment_in = sh[0]
|
||||||
ct.product = sale_line.product
|
ct.lot = sale_line.lots[0]
|
||||||
ct.unit = sale_line.unit
|
ct.product = sale_line.product
|
||||||
d.party = Party.getPartyByName('FAIRCOT')
|
ct.unit = sale_line.unit
|
||||||
if sale_line.enable_linked_currency:
|
d.party = Party.getPartyByName('FAIRCOT')
|
||||||
d.currency_unit = str(sale_line.linked_currency.id) + '_' + str(sale_line.linked_unit.id)
|
if sale_line.enable_linked_currency:
|
||||||
else:
|
d.currency_unit = str(sale_line.linked_currency.id) + '_' + str(sale_line.linked_unit.id)
|
||||||
d.currency_unit = str(sale.currency.id) + '_' + str(sale_line.unit.id)
|
else:
|
||||||
d.quantity = sale_line.quantity
|
d.currency_unit = str(sale.currency.id) + '_' + str(sale_line.unit.id)
|
||||||
d.unit = sale_line.unit
|
d.quantity = sale_line.quantity
|
||||||
d.price = sale_line.unit_price
|
d.unit = sale_line.unit
|
||||||
d.price_type = 'priced'
|
d.price = sale_line.unit_price
|
||||||
d.crop = None
|
d.price_type = 'priced'
|
||||||
d.tol_min = 0
|
d.crop = None
|
||||||
d.tol_max = 0
|
d.tol_min = 0
|
||||||
d.incoterm = None
|
d.tol_max = 0
|
||||||
d.reference = str(sale.id)
|
d.incoterm = None
|
||||||
d.del_period = None
|
d.reference = str(sale.id)
|
||||||
d.from_del = None
|
d.del_period = None
|
||||||
d.to_del = None
|
d.from_del = None
|
||||||
ct.contracts = [d]
|
d.to_del = None
|
||||||
ContractFactory.create_contracts(
|
ct.contracts = [d]
|
||||||
ct.contracts,
|
ContractFactory.create_contracts(
|
||||||
type_=ct.type,
|
ct.contracts,
|
||||||
ct=ct,
|
type_=ct.type,
|
||||||
)
|
ct=ct,
|
||||||
|
)
|
||||||
|
trans2.commit()
|
||||||
|
|
||||||
#Lots creation
|
#Lots creation
|
||||||
# vlot = sale_line.lots[0]
|
# vlot = sale_line.lots[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user