Rename moves exception and simplify computation

This commit is contained in:
Cédric Krier committed 2023-03-12 22:11:34 +01:00
1 parent 640753a0d8
commit 881cbcfb2c
3 files changed
+24 -32

No files matched your search

+8 -10
View File
@@ -229,10 +229,10 @@ def order_line_mixin(prefix):
move = None
return move
def get_move_exception(self, name):
exception = super().get_move_exception(name)
def get_moves_exception(self, name):
exception = super().get_moves_exception(name)
if self.components:
exception = any(c.move_exception for c in self.components)
exception = any(c.moves_exception for c in self.components)
return exception
def get_moves_progress(self, name):
@@ -269,8 +269,8 @@ def order_line_component_mixin(prefix):
moves_recreated = fields.Many2Many(
prefix + '.line.component-recreated-stock.move',
'component', 'move', "Recreated Moves", readonly=True)
move_exception = fields.Function(
fields.Boolean('Moves Exception'), 'get_move_exception')
moves_exception = fields.Function(
fields.Boolean('Moves Exception'), 'get_moves_exception')
moves_progress = fields.Function(
fields.Float("Moves Progress", digits=(1, 4)),
'get_moves_progress')
@@ -351,13 +351,11 @@ def order_line_component_mixin(prefix):
move.uom, move.quantity, self.unit)
return quantity
def get_move_exception(self, name):
def get_moves_exception(self, name):
skips = set(self.moves_ignored)
skips.update(self.moves_recreated)
for move in self.moves:
if move.state == 'cancelled' and move not in skips:
return True
return False
return any(
m.state == 'cancelled' for m in self.moves if m not in skips)
def get_moves_progress(self, name):
progress = None
+8 -11
View File
@@ -633,7 +633,7 @@ class Purchase(
Return the shipment state for the purchase.
'''
if self.moves:
if any(l.move_exception for l in self.lines):
if any(l.moves_exception for l in self.lines):
return 'exception'
elif all(l.moves_progress >= 1 for l in self.lines
if l.moves_progress is not None):
@@ -1225,8 +1225,8 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
'purchase_line', 'move', 'Ignored Moves', readonly=True)
moves_recreated = fields.Many2Many('purchase.line-recreated-stock.move',
'purchase_line', 'move', 'Recreated Moves', readonly=True)
move_exception = fields.Function(fields.Boolean('Moves Exception'),
'get_move_exception')
moves_exception = fields.Function(
fields.Boolean("Moves Exception"), 'get_moves_exception')
moves_progress = fields.Function(
fields.Float("Moves Progress", digits=(1, 4)),
'get_moves_progress')
@@ -1344,14 +1344,11 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
quantity -= Uom.compute_qty(move.uom, move.quantity, self.unit)
return quantity
def get_move_exception(self, name):
skip_ids = set(x.id for x in self.moves_ignored
+ self.moves_recreated)
for move in self.moves:
if move.state == 'cancelled' \
and move.id not in skip_ids:
return True
return False
def get_moves_exception(self, name):
skips = set(self.moves_ignored)
skips.update(self.moves_recreated)
return any(
m.state == 'cancelled' for m in self.moves if m not in skips)
def get_moves_progress(self, name):
progress = None
+8 -11
View File
@@ -643,7 +643,7 @@ class Sale(
Return the shipment state for the sale.
'''
if self.moves:
if any(l.move_exception for l in self.lines):
if any(l.moves_exception for l in self.lines):
return 'exception'
elif all(l.moves_progress >= 1.0 for l in self.lines
if l.moves_progress is not None):
@@ -1291,8 +1291,8 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
'sale_line', 'move', 'Ignored Moves', readonly=True)
moves_recreated = fields.Many2Many('sale.line-recreated-stock.move',
'sale_line', 'move', 'Recreated Moves', readonly=True)
move_exception = fields.Function(fields.Boolean('Moves Exception'),
'get_move_exception')
moves_exception = fields.Function(
fields.Boolean("Moves Exception"), 'get_moves_exception')
moves_progress = fields.Function(
fields.Float("Moves Progress", digits=(1, 4)),
'get_moves_progress')
@@ -1373,14 +1373,11 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
quantity -= Uom.compute_qty(move.uom, move.quantity, self.unit)
return quantity
def get_move_exception(self, name):
skip_ids = set(x.id for x in self.moves_ignored)
skip_ids.update(x.id for x in self.moves_recreated)
for move in self.moves:
if move.state == 'cancelled' \
and move.id not in skip_ids:
return True
return False
def get_moves_exception(self, name):
skips = set(self.moves_ignored)
skips.update(self.moves_recreated)
return any(
m.state == 'cancelled' for m in self.moves if m not in skips)
def get_moves_progress(self, name):
progress = None