Update unit price after invoice posted and move done
issue9962 review292991002
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Update unit price after invoice posted and move done
|
||||
|
||||
Version 5.8.0 - 2020-11-02
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Remove support for Python 3.5
|
||||
|
||||
+12
@@ -57,6 +57,11 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
},
|
||||
depends=['type', 'product_uom_category', 'invoice', 'invoice_type'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls._check_modify_exclude.add('stock_moves')
|
||||
|
||||
@property
|
||||
def moved_quantity(self):
|
||||
'The quantity from linked stock moves in line unit'
|
||||
@@ -69,6 +74,13 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
stock_move.uom, stock_move.quantity, self.unit)
|
||||
return quantity
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
super().write(*args)
|
||||
lines = sum(args[0:None:2], [])
|
||||
moves = sum((l.stock_moves for l in lines), ())
|
||||
cls.update_unit_price(moves)
|
||||
|
||||
@classmethod
|
||||
def copy(cls, lines, default=None):
|
||||
if default is None:
|
||||
|
||||
@@ -29,6 +29,11 @@ class Move(metaclass=PoolMeta):
|
||||
fields.MultiSelection('get_invoice_types', "Invoice Types"),
|
||||
'on_change_with_invoice_types')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super().__setup__()
|
||||
cls._allow_modify_closed_period.add('invoice_lines')
|
||||
|
||||
@classmethod
|
||||
def get_invoice_types(cls):
|
||||
pool = Pool()
|
||||
@@ -75,6 +80,12 @@ class Move(metaclass=PoolMeta):
|
||||
super().do(moves)
|
||||
cls.update_unit_price(moves)
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
super().write(*args)
|
||||
moves = sum(args[0:None:2], [])
|
||||
cls.update_unit_price(moves)
|
||||
|
||||
@classmethod
|
||||
def update_unit_price(cls, moves):
|
||||
for move in moves:
|
||||
|
||||
Reference in New Issue
Block a user