Add warning about different product between invoice line and stock move
This allow to overcome the assert in update_anglo_saxon_quantity_product_cost. issue6803 review38801002
This commit is contained in:
1 parent
6baf250a54
commit
09ed117eb0
3 files changed
+28
-3
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Add warning about different product between invoice line and stock move
|
||||
|
||||
Version 4.4.0 - 2017-05-01
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Use stock_moves from account_invoice_stock
|
||||
|
||||
+25
-1
@@ -11,6 +11,16 @@ class InvoiceLine:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(InvoiceLine, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'stock_move_different_product': (
|
||||
"The invoice line '%(line)s' is linked to stock moves "
|
||||
"for other products than '%(product)s'.\n"
|
||||
"This may compute a wrong COGS."),
|
||||
})
|
||||
|
||||
def _get_anglo_saxon_move_lines(self, amount, type_):
|
||||
'''
|
||||
Return account move for anglo-saxon stock accounting
|
||||
@@ -73,7 +83,21 @@ class InvoiceLine:
|
||||
return result
|
||||
|
||||
# an empty list means we'll use the current cost price
|
||||
moves = [move for move in self.stock_moves if move.state == 'done']
|
||||
moves = []
|
||||
for move in self.stock_moves:
|
||||
if move.state != 'done':
|
||||
continue
|
||||
# remove move for different product
|
||||
if move.product != self.product:
|
||||
warning_name = '%s.stock.different_product' % self
|
||||
self.raise_user_warning(
|
||||
warning_name, 'stock_move_different_product', {
|
||||
'line': self.rec_name,
|
||||
'product': self.product.rec_name,
|
||||
})
|
||||
else:
|
||||
moves.append(move)
|
||||
|
||||
if self.invoice.type == 'in':
|
||||
type_ = 'in_supplier'
|
||||
elif self.invoice.type == 'out':
|
||||
|
||||
@@ -152,8 +152,7 @@ class Move:
|
||||
pool = Pool()
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
for move in moves:
|
||||
assert move.product == product, 'wrong product'
|
||||
assert all(m.product == product for m in moves), 'wrong product'
|
||||
assert type_.startswith('in_') or type_.startswith('out_'), \
|
||||
'wrong type'
|
||||
|
||||
|
||||
Reference in new issue
Block a user