Merge pull request 'dev' (#5) from dev into main
Reviewed-on: https://srv413259.hstgr.cloud/admin/tradon/pulls/5
This commit was merged in pull request #5.
This commit is contained in:
@@ -1990,8 +1990,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
'''
|
||||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
InvoiceLine = pool.get('account.invoice.line')
|
||||
Uom = pool.get('product.uom')
|
||||
Location = pool.get('stock.location')
|
||||
if self.type != 'line':
|
||||
return
|
||||
if not self.product:
|
||||
@@ -2049,24 +2048,24 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
move.from_location = from_location
|
||||
|
||||
if to_location.type != 'customer':
|
||||
move.to_location = 8
|
||||
move.to_location = Location.get_transit_id()
|
||||
else:
|
||||
move.to_location = to_location
|
||||
|
||||
unit_price = l.get_lot_price()
|
||||
if l.invoice_line_prov != None :
|
||||
prov_inv = InvoiceLine(l.invoice_line_prov)
|
||||
quantity -= prov_inv.quantity
|
||||
if quantity < 0 :
|
||||
move.from_location = self.purchase.to_location
|
||||
move.to_location = 16
|
||||
elif quantity > 0 :
|
||||
move.from_location = 16
|
||||
move.to_location = self.purchase.to_location
|
||||
quantity = abs(quantity)
|
||||
unit_price = prov_inv.unit_price
|
||||
if quantity == 0:
|
||||
continue
|
||||
# if l.invoice_line_prov != None :
|
||||
# prov_inv = InvoiceLine(l.invoice_line_prov)
|
||||
# quantity -= prov_inv.quantity
|
||||
# if quantity < 0 :
|
||||
# move.from_location = self.purchase.to_location
|
||||
# move.to_location = 16
|
||||
# elif quantity > 0 :
|
||||
# move.from_location = 16
|
||||
# move.to_location = self.purchase.to_location
|
||||
# quantity = abs(quantity)
|
||||
# unit_price = prov_inv.unit_price
|
||||
# if quantity == 0:
|
||||
# continue
|
||||
move.quantity = quantity
|
||||
move.unit = self.unit
|
||||
move.product = l.lot_product
|
||||
@@ -2086,7 +2085,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
moves.append(move)
|
||||
if move.to_location.type != 'customer':
|
||||
move_to, = Move.copy([move.id], default={
|
||||
'from_location': 8,
|
||||
'from_location': Location.get_transit_id(),
|
||||
'to_location': to_location,
|
||||
})
|
||||
moves.append(move_to)
|
||||
|
||||
@@ -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