03.02.26
This commit is contained in:
@@ -75,6 +75,8 @@ def register():
|
|||||||
dashboard.Demos,
|
dashboard.Demos,
|
||||||
party.Party,
|
party.Party,
|
||||||
party.PartyExecution,
|
party.PartyExecution,
|
||||||
|
party.PartyExecutionSla,
|
||||||
|
party.PartyExecutionPlace,
|
||||||
payment_term.PaymentTerm,
|
payment_term.PaymentTerm,
|
||||||
payment_term.PaymentTermLine,
|
payment_term.PaymentTermLine,
|
||||||
purchase.Purchase,
|
purchase.Purchase,
|
||||||
|
|||||||
@@ -3151,135 +3151,8 @@ class CreateContracts(Wizard):
|
|||||||
type_=self.ct.type,
|
type_=self.ct.type,
|
||||||
ct=self.ct,
|
ct=self.ct,
|
||||||
)
|
)
|
||||||
# SaleLine = Pool().get('sale.line')
|
|
||||||
# Sale = Pool().get('sale.sale')
|
|
||||||
# PurchaseLine = Pool().get('purchase.line')
|
|
||||||
# Purchase = Pool().get('purchase.purchase')
|
|
||||||
# LotQt = Pool().get('lot.qt')
|
|
||||||
# LotQtHist = Pool().get('lot.qt.hist')
|
|
||||||
# LotQtType = Pool().get('lot.qt.type')
|
|
||||||
# Lot = Pool().get('lot.lot')
|
|
||||||
# Date = Pool().get('ir.date')
|
|
||||||
# self.sale_lines = []
|
|
||||||
# type = self.ct.type
|
|
||||||
# base_contract = self.ct.lot.sale_line.sale if type == 'Purchase' else self.ct.lot.line.purchase
|
|
||||||
# for c in self.ct.contracts:
|
|
||||||
# contract = Purchase() if type == 'Purchase' else Sale()
|
|
||||||
# contract_line = PurchaseLine() if type == 'Purchase' else SaleLine()
|
|
||||||
# parts = c.currency_unit.split("_")
|
|
||||||
# if int(parts[0]) != 0:
|
|
||||||
# contract.currency = int(parts[0])
|
|
||||||
# else:
|
|
||||||
# contract.currency = 1
|
|
||||||
# contract.party = c.party
|
|
||||||
# contract.crop = c.crop
|
|
||||||
# contract.tol_min = c.tol_min
|
|
||||||
# contract.tol_max = c.tol_max
|
|
||||||
# if type == 'Purchase':
|
|
||||||
# contract.purchase_date = Date.today()
|
|
||||||
# else:
|
|
||||||
# contract.sale_date = Date.today()
|
|
||||||
# contract.reference = c.reference
|
|
||||||
# if base_contract.from_location and base_contract.to_location:
|
|
||||||
# if type == 'Purchase':
|
|
||||||
# contract.to_location = base_contract.from_location
|
|
||||||
# else:
|
|
||||||
# contract.from_location = base_contract.to_location
|
|
||||||
# if base_contract.from_location.type == 'supplier' and base_contract.to_location.type == 'customer':
|
|
||||||
# contract.from_location = base_contract.from_location
|
|
||||||
# contract.to_location = base_contract.to_location
|
|
||||||
# if c.party.wb:
|
|
||||||
# contract.wb = c.party.wb
|
|
||||||
# if c.party.association:
|
|
||||||
# contract.association = c.party.association
|
|
||||||
# if type == 'Purchase':
|
|
||||||
# if c.party.supplier_payment_term:
|
|
||||||
# contract.payment_term = c.party.supplier_payment_term
|
|
||||||
# else:
|
|
||||||
# if c.party.customer_payment_term:
|
|
||||||
# contract.payment_term = c.party.customer_payment_term
|
|
||||||
# contract.incoterm = c.incoterm
|
|
||||||
# if c.party.addresses:
|
|
||||||
# contract.invoice_address = c.party.addresses[0]
|
|
||||||
# if type == 'Sale':
|
|
||||||
# contract.shipment_address = c.party.addresses[0]
|
|
||||||
# contract.__class__.save([contract])
|
|
||||||
# contract_line.quantity = c.quantity
|
|
||||||
# contract_line.quantity_theorical = c.quantity
|
|
||||||
# contract_line.product = self.ct.product
|
|
||||||
# contract_line.price_type = c.price_type
|
|
||||||
# contract_line.unit = self.ct.unit
|
|
||||||
# if type == 'Purchase':
|
|
||||||
# contract_line.purchase = contract.id
|
|
||||||
# else:
|
|
||||||
# contract_line.sale = contract.id
|
|
||||||
# contract_line.created_by_code = self.ct.matched
|
|
||||||
# contract_line.premium = Decimal(0)
|
|
||||||
# if int(parts[0]) == 0:
|
|
||||||
# contract_line.enable_linked_currency = True
|
|
||||||
# contract_line.linked_currency = 1
|
|
||||||
# contract_line.linked_unit = int(parts[1])
|
|
||||||
# contract_line.linked_price = c.price
|
|
||||||
# contract_line.unit_price = contract_line.get_price_linked_currency()
|
|
||||||
# else:
|
|
||||||
# contract_line.unit_price = c.price if c.price else Decimal(0)
|
|
||||||
# contract_line.del_period = c.del_period
|
|
||||||
# contract_line.from_del = c.from_del
|
|
||||||
# contract_line.to_del = c.to_del
|
|
||||||
# contract_line.__class__.save([contract_line])
|
|
||||||
# logger.info("CREATE_ID:%s",contract.id)
|
|
||||||
# logger.info("CREATE_LINE_ID:%s",contract_line.id)
|
|
||||||
# if self.ct.matched:
|
|
||||||
# lot = Lot()
|
|
||||||
# if type == 'Purchase':
|
|
||||||
# lot.line = contract_line.id
|
|
||||||
# else:
|
|
||||||
# lot.sale_line = contract_line.id
|
|
||||||
# lot.lot_qt = None
|
|
||||||
# lot.lot_unit = None
|
|
||||||
# lot.lot_unit_line = contract_line.unit
|
|
||||||
# lot.lot_quantity = round(contract_line.quantity,5)
|
|
||||||
# lot.lot_gross_quantity = None
|
|
||||||
# lot.lot_status = 'forecast'
|
|
||||||
# lot.lot_type = 'virtual'
|
|
||||||
# lot.lot_product = contract_line.product
|
|
||||||
# lqtt = LotQtType.search([('sequence','=',1)])
|
|
||||||
# if lqtt:
|
|
||||||
# lqh = LotQtHist()
|
|
||||||
# lqh.quantity_type = lqtt[0]
|
|
||||||
# lqh.quantity = round(lot.lot_quantity,5)
|
|
||||||
# lqh.gross_quantity = round(lot.lot_quantity,5)
|
|
||||||
# lot.lot_hist = [lqh]
|
|
||||||
# Lot.save([lot])
|
|
||||||
# vlot = self.ct.lot
|
|
||||||
# shipment_origin = None
|
|
||||||
# if self.ct.shipment_in:
|
|
||||||
# shipment_origin = 'stock.shipment.in,' + str(self.ct.shipment_in.id)
|
|
||||||
# elif self.ct.shipment_internal:
|
|
||||||
# shipment_origin = 'stock.shipment.internal,' + str(self.ct.shipment_internal.id)
|
|
||||||
# elif self.ct.shipment_out:
|
|
||||||
# shipment_origin = 'stock.shipment.out,' + str(self.ct.shipment_out.id)
|
|
||||||
|
|
||||||
# qt = c.quantity
|
|
||||||
# if type == 'Purchase':
|
|
||||||
# if not lot.updateVirtualPart(qt,shipment_origin,vlot):
|
|
||||||
# lot.createVirtualPart(qt,shipment_origin,vlot)
|
|
||||||
# #Decrease forecasted virtual part non matched
|
|
||||||
# lot.updateVirtualPart(-qt,shipment_origin,vlot,'only sale')
|
|
||||||
# else:
|
|
||||||
# if not vlot.updateVirtualPart(qt,shipment_origin,lot):
|
|
||||||
# vlot.createVirtualPart(qt,shipment_origin,lot)
|
|
||||||
# #Decrease forecasted virtual part non matched
|
|
||||||
# vlot.updateVirtualPart(-qt,shipment_origin,None)
|
|
||||||
|
|
||||||
return 'end'
|
return 'end'
|
||||||
|
|
||||||
# def do_matching(self, action):
|
|
||||||
# return action, {
|
|
||||||
# 'ids': self.sale_lines,
|
|
||||||
# 'model': str(self.ct.lot.id),
|
|
||||||
# }
|
|
||||||
|
|
||||||
def end(self):
|
def end(self):
|
||||||
return 'reload'
|
return 'reload'
|
||||||
|
|
||||||
@@ -3309,7 +3182,6 @@ class ContractsStart(ModelView):
|
|||||||
def default_matched(cls):
|
def default_matched(cls):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class ContractDetail(ModelView):
|
class ContractDetail(ModelView):
|
||||||
|
|
||||||
"Contract Detail"
|
"Contract Detail"
|
||||||
|
|||||||
@@ -16,6 +16,43 @@ class PartyExecution(ModelSQL,ModelView):
|
|||||||
def get_percent(self,name):
|
def get_percent(self,name):
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
class PartyExecutionSla(ModelSQL,ModelView):
|
||||||
|
"Party Execution Sla"
|
||||||
|
__name__ = 'party.execution.sla'
|
||||||
|
|
||||||
|
party = fields.Many2One('party.party',"Party")
|
||||||
|
reference = fields.Char("Reference")
|
||||||
|
product = fields.Many2One('product.product',"Product")
|
||||||
|
date_from = fields.Date("From")
|
||||||
|
date_to = fields.Date("To")
|
||||||
|
places = fields.One2Many('party.execution.place','pes',"")
|
||||||
|
|
||||||
|
class PartyExecutionPlace(ModelSQL,ModelView):
|
||||||
|
"Party Sla Place"
|
||||||
|
__name__ = 'party.execution.place'
|
||||||
|
|
||||||
|
pes = fields.Many2One('party.execution.sla',"Sla")
|
||||||
|
location = fields.Many2One('stock.location',"Location")
|
||||||
|
cost = fields.Numeric("Cost",digits=(16,4))
|
||||||
|
currency_unit = fields.Selection('get_currency_unit',string="Curr/Unit")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_currency_unit():
|
||||||
|
Currency = Pool().get('currency.currency')
|
||||||
|
Uom = Pool().get('product.uom')
|
||||||
|
|
||||||
|
result = []
|
||||||
|
currencies = Currency.search([('concatenate','=',True)])
|
||||||
|
units = Uom.search([('concatenate','=',True)])
|
||||||
|
result.append(("0_5","USC/lb"))
|
||||||
|
result.append(("0_37","USC/mt"))
|
||||||
|
for c in currencies:
|
||||||
|
for u in units:
|
||||||
|
key = "%s_%s" % (c.id, u.id)
|
||||||
|
value = "%s / %s" % (c.name, u.symbol or u.name)
|
||||||
|
result.append((key, value))
|
||||||
|
return result
|
||||||
|
|
||||||
class Party(metaclass=PoolMeta):
|
class Party(metaclass=PoolMeta):
|
||||||
__name__ = 'party.party'
|
__name__ = 'party.party'
|
||||||
|
|
||||||
@@ -24,6 +61,7 @@ class Party(metaclass=PoolMeta):
|
|||||||
wb = fields.Many2One('purchase.weight.basis',"Weight basis")
|
wb = fields.Many2One('purchase.weight.basis',"Weight basis")
|
||||||
association = fields.Many2One('purchase.association',"Association")
|
association = fields.Many2One('purchase.association',"Association")
|
||||||
execution = fields.One2Many('party.execution','party',"")
|
execution = fields.One2Many('party.execution','party',"")
|
||||||
|
sla = fields.One2Many('party.execution.sla','party', "Sla")
|
||||||
|
|
||||||
def IsAvailableForControl(self,sh):
|
def IsAvailableForControl(self,sh):
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -5,10 +5,25 @@
|
|||||||
<field name="inherit" ref="party.party_view_form"/>
|
<field name="inherit" ref="party.party_view_form"/>
|
||||||
<field name="name">party_form</field>
|
<field name="name">party_form</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.ui.view" id="party_exec_view_form">
|
<record model="ir.ui.view" id="party_exec_view_list">
|
||||||
<field name="model">party.execution</field>
|
<field name="model">party.execution</field>
|
||||||
<field name="type">tree</field>
|
<field name="type">tree</field>
|
||||||
<field name="name">party_exec_tree</field>
|
<field name="name">party_exec_tree</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.ui.view" id="party_exec_sla_view_form">
|
||||||
|
<field name="model">party.execution.sla</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">party_exec_sla_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="party_exec_sla_view_list">
|
||||||
|
<field name="model">party.execution.sla</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="name">party_exec_sla_tree</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="party_exec_place_view_form">
|
||||||
|
<field name="model">party.execution.place</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="name">party_exec_place_tree</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
5
modules/purchase_trade/view/party_exec_place_tree.xml
Normal file
5
modules/purchase_trade/view/party_exec_place_tree.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<tree>
|
||||||
|
<field name="location"/>
|
||||||
|
<field name="cost"/>
|
||||||
|
<field name="currency_unit"/>
|
||||||
|
</tree>
|
||||||
6
modules/purchase_trade/view/party_exec_sla_tree.xml
Normal file
6
modules/purchase_trade/view/party_exec_sla_tree.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<tree>
|
||||||
|
<field name="reference"/>
|
||||||
|
<field name="product"/>
|
||||||
|
<field name="date_from"/>
|
||||||
|
<field name="date_to"/>
|
||||||
|
</tree>
|
||||||
Reference in New Issue
Block a user