16.01.26
This commit is contained in:
@@ -112,6 +112,7 @@ def register():
|
||||
forex.ForexBI,
|
||||
purchase.PnlBI,
|
||||
stock.Move,
|
||||
stock.Location,
|
||||
stock.InvoiceLine,
|
||||
stock.ShipmentIn,
|
||||
stock.ShipmentInternal,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelSQL, ModelView, fields, sequence_ordered, ModelSingleton
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
@@ -2031,6 +2031,10 @@ class LotShipping(Wizard):
|
||||
move = Move(l.move)
|
||||
move.shipment = shipment_origin
|
||||
Move.save([move])
|
||||
linked_transit_move = move.get_linked_transit_move()
|
||||
if linked_transit_move:
|
||||
linked_transit_move.shipment = shipment_origin
|
||||
Move.save([linked_transit_move])
|
||||
#Decrease forecasted virtual part shipped
|
||||
vlot_p = l.getVlot_p()
|
||||
l.updateVirtualPart(-l.get_current_quantity_converted(),shipment_origin,l.getVlot_s())
|
||||
|
||||
@@ -20,6 +20,24 @@ from collections import defaultdict
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Location(metaclass=PoolMeta):
|
||||
__name__ = 'stock.location'
|
||||
|
||||
@classmethod
|
||||
def get_transit_id(cls):
|
||||
transit = cls.search([('name', '=', 'Transit')], limit=1)
|
||||
if transit:
|
||||
return transit[0].id
|
||||
else:
|
||||
transit = cls()
|
||||
transit.name = 'Transit'
|
||||
transit.type = 'storage'
|
||||
cls.save([transit])
|
||||
return transit.id
|
||||
|
||||
def is_transit(self):
|
||||
if self.name == 'Transit':
|
||||
return True
|
||||
|
||||
class Move(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
@@ -28,17 +46,12 @@ class Move(metaclass=PoolMeta):
|
||||
lotqt = fields.One2Many('lot.qt','lot_move',"Lots")
|
||||
lot = fields.Many2One('lot.lot',"Lot")
|
||||
|
||||
# @fields.depends('lotqt','unit')
|
||||
# def on_change_with_quantity(self):
|
||||
# if self.lotqt:
|
||||
# pool = Pool()
|
||||
# Uom = pool.get('product.uom')
|
||||
# if self.unit:
|
||||
# return round(sum([(e.lot_quantity if e.lot_quantity else 0) for e in self.lotqt]),2)
|
||||
# else:
|
||||
# return 0
|
||||
# else:
|
||||
# return 0
|
||||
def get_linked_transit_move(self):
|
||||
if self.from_location.is_transit():
|
||||
Move = Pool().get('stock.move')
|
||||
Location = Pool().get('stock.location')
|
||||
moves = Move.search([('lot','=',self.lot),('to_location','=',Location.get_transit_id())],order=[('id', 'DESC')],limit=1)
|
||||
return moves[0] if moves else None
|
||||
|
||||
@classmethod
|
||||
def validate(cls, moves):
|
||||
|
||||
Reference in New Issue
Block a user