Use split function to add lots on move when available
The split function ensures that customer moves of drop shipment are split also when splitting supplier moves. Closes #13037
This commit is contained in:
1 parent
e686904520
commit
e052849c3d
6 files changed
+39
-15
No files matched your search
@@ -47,7 +47,10 @@ for dep in info.get('depends', []):
|
||||
requires.append(get_require_version('trytond_%s' % dep))
|
||||
requires.append(get_require_version('trytond'))
|
||||
|
||||
tests_require = [get_require_version('proteus')]
|
||||
tests_require = [
|
||||
get_require_version('proteus'),
|
||||
get_require_version('trytond_stock_split'),
|
||||
]
|
||||
|
||||
setup(name=name,
|
||||
version=version,
|
||||
|
||||
+25
-13
@@ -541,20 +541,32 @@ class MoveAddLots(Wizard):
|
||||
lot = line.get_lot(self.record)
|
||||
lots.append(lot)
|
||||
Lot.save(lots)
|
||||
if quantity_remaining:
|
||||
self.record.quantity = quantity_remaining
|
||||
self.record.save()
|
||||
for i, (line, lot) in enumerate(zip(self.start.lots, lots)):
|
||||
if not i and not quantity_remaining:
|
||||
self.record.quantity = line.quantity
|
||||
self.record.lot = lot
|
||||
if hasattr(self.model, 'split'):
|
||||
move = self.record
|
||||
for line, lot in zip(self.start.lots, lots):
|
||||
splits = move.split(line.quantity, self.record.unit, count=1)
|
||||
splits.remove(move)
|
||||
move.lot = lot
|
||||
move.save()
|
||||
if splits:
|
||||
move, = splits
|
||||
else:
|
||||
break
|
||||
else:
|
||||
if quantity_remaining:
|
||||
self.record.quantity = quantity_remaining
|
||||
self.record.save()
|
||||
else:
|
||||
with Transaction().set_context(_stock_move_split=True):
|
||||
self.model.copy([self.record], {
|
||||
'quantity': line.quantity,
|
||||
'lot': lot.id,
|
||||
})
|
||||
for i, (line, lot) in enumerate(zip(self.start.lots, lots)):
|
||||
if not i and not quantity_remaining:
|
||||
self.record.quantity = line.quantity
|
||||
self.record.lot = lot
|
||||
self.record.save()
|
||||
else:
|
||||
with Transaction().set_context(_stock_move_split=True):
|
||||
self.model.copy([self.record], {
|
||||
'quantity': line.quantity,
|
||||
'lot': lot.id,
|
||||
})
|
||||
return 'end'
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[
|
||||
{"stock_split": false}
|
||||
,{"stock_split": true}
|
||||
]
|
||||
@@ -12,7 +12,10 @@ Imports::
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('stock_lot')
|
||||
>>> modules = ['stock_lot']
|
||||
>>> if globals().get('stock_split', False):
|
||||
... modules.append('stock_split')
|
||||
>>> config = activate_modules(modules)
|
||||
|
||||
Create company::
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from trytond.transaction import Transaction
|
||||
class StockLotTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test Stock Lot module'
|
||||
module = 'stock_lot'
|
||||
extras = ['stock_split']
|
||||
|
||||
@with_transaction()
|
||||
def test_products_by_location(self):
|
||||
|
||||
@@ -6,6 +6,7 @@ depends:
|
||||
stock
|
||||
extras_depend:
|
||||
sale_supply_drop_shipment
|
||||
stock_split
|
||||
xml:
|
||||
ir.xml
|
||||
stock.xml
|
||||
|
||||
Reference in new issue
Block a user