Split customer moves when splitting supplier moves of drop shipment
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Split customer moves when splitting supplier moves
|
||||
* Rename 'done' button to 'do'
|
||||
|
||||
Version 7.0.0 - 2023-10-30
|
||||
|
||||
@@ -30,3 +30,7 @@ def register():
|
||||
party.Replace,
|
||||
party.Erase,
|
||||
module='sale_supply_drop_shipment', type_='wizard')
|
||||
Pool.register(
|
||||
stock.MoveSplit,
|
||||
module='sale_supply_drop_shipment', type_='model',
|
||||
depends=['stock_split'])
|
||||
|
||||
@@ -12,5 +12,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_drop_shipment_delete_cancel">
|
||||
<field name="text">To delete drop shipment "%(shipment)s" you must cancel it.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_move_split_drop">
|
||||
<field name="text">To split move from drop shipment, you must use the split wizard.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -588,6 +588,37 @@ class Move(metaclass=PoolMeta):
|
||||
|
||||
@classmethod
|
||||
def copy(cls, moves, default=None):
|
||||
context = Transaction().context
|
||||
if (context.get('_stock_move_split')
|
||||
and not context.get('_stock_move_split_drop')):
|
||||
for move in moves:
|
||||
if move.moves_drop:
|
||||
raise AccessError(
|
||||
gettext('sale_supply_drop_shipment'
|
||||
'.msg_move_split_drop'))
|
||||
default = default.copy() if default is not None else {}
|
||||
default.setdefault('moves_drop')
|
||||
return super().copy(moves, default=default)
|
||||
|
||||
|
||||
class MoveSplit(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
|
||||
def split(self, quantity, unit, count=None):
|
||||
with Transaction().set_context(_stock_move_split_drop=True):
|
||||
moves = super().split(quantity, unit, count=count)
|
||||
if self.moves_drop:
|
||||
to_save = []
|
||||
moves_drop = list(self.moves_drop)
|
||||
for move in moves:
|
||||
remainder = move.quantity
|
||||
while remainder > 0 and moves_drop:
|
||||
move_drop = moves_drop.pop(0)
|
||||
splits = move_drop.split(remainder, move.unit, count=1)
|
||||
move_drop.origin_drop = move
|
||||
remainder -= move_drop.quantity
|
||||
to_save.append(move_drop)
|
||||
splits.remove(move_drop)
|
||||
moves_drop.extend(splits)
|
||||
self.__class__.save(to_save)
|
||||
return moves
|
||||
|
||||
@@ -10,6 +10,7 @@ class SaleSupplyDropShipmentTestCase(
|
||||
PartyCompanyCheckEraseMixin, CompanyTestMixin, ModuleTestCase):
|
||||
'Test SaleSupplyDropShipment module'
|
||||
module = 'sale_supply_drop_shipment'
|
||||
extras = ['stock_split']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
|
||||
@@ -9,6 +9,8 @@ depends:
|
||||
sale
|
||||
sale_supply
|
||||
stock
|
||||
extras_depend:
|
||||
stock_split
|
||||
xml:
|
||||
stock.xml
|
||||
sale.xml
|
||||
|
||||
Reference in New Issue
Block a user