Enforce unit price on drop and customer return moves
Those values are interesting information for reporting or to compare with the cost price. issue9402 review327421002
This commit is contained in:
1 parent
cd8fd31d0b
commit
671e1b2599
3 files changed
+25
-15
No files matched your search
@@ -432,14 +432,16 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
from_type = self.from_location.type if self.from_location else None
|
||||
to_type = self.to_location.type if self.to_location else None
|
||||
|
||||
if from_type == 'supplier' and to_type == 'storage':
|
||||
if from_type == 'supplier' and to_type in {'storage', 'drop'}:
|
||||
return True
|
||||
if from_type == 'production':
|
||||
return True
|
||||
if from_type == 'storage' and to_type == 'customer':
|
||||
if from_type in {'storage', 'drop'} and to_type == 'customer':
|
||||
return True
|
||||
if from_type == 'storage' and to_type == 'supplier':
|
||||
return True
|
||||
if from_type == 'customer' and to_type == 'storage':
|
||||
return True
|
||||
return False
|
||||
|
||||
@fields.depends('from_location', 'to_location')
|
||||
|
||||
+19
-13
@@ -1113,7 +1113,7 @@ class ShipmentOut(ShipmentMixin, Workflow, ModelSQL, ModelView):
|
||||
'Return inventory move for the outgoing move'
|
||||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
return Move(
|
||||
inventory_move = Move(
|
||||
from_location=self.warehouse_storage,
|
||||
to_location=move.from_location,
|
||||
product=move.product,
|
||||
@@ -1122,11 +1122,13 @@ class ShipmentOut(ShipmentMixin, Workflow, ModelSQL, ModelView):
|
||||
shipment=self,
|
||||
planned_date=move.planned_date,
|
||||
company=move.company,
|
||||
currency=move.currency,
|
||||
unit_price=move.unit_price,
|
||||
origin=move,
|
||||
state='staging' if move.state == 'staging' else 'draft',
|
||||
)
|
||||
if inventory_move.on_change_with_unit_price_required():
|
||||
inventory_move.unit_price = move.unit_price
|
||||
inventory_move.currency = move.currency
|
||||
return inventory_move
|
||||
|
||||
@classmethod
|
||||
@Workflow.transition('assigned')
|
||||
@@ -1164,11 +1166,13 @@ class ShipmentOut(ShipmentMixin, Workflow, ModelSQL, ModelView):
|
||||
)
|
||||
if template:
|
||||
move.origin = template.origin
|
||||
move.currency = template.currency
|
||||
move.unit_price = template.unit_price
|
||||
else:
|
||||
move.currency = self.company.currency
|
||||
move.unit_price = 0
|
||||
if move.on_change_with_unit_price_required():
|
||||
if template:
|
||||
move.unit_price = template.unit_price
|
||||
move.currency = template.currency
|
||||
else:
|
||||
move.unit_price = 0
|
||||
move.currency = self.company.currency
|
||||
return move
|
||||
|
||||
@classmethod
|
||||
@@ -2224,11 +2228,13 @@ class ShipmentInternal(ShipmentMixin, Workflow, ModelSQL, ModelView):
|
||||
)
|
||||
if template:
|
||||
move.origin = template.origin
|
||||
move.currency = template.currency
|
||||
move.unit_price = template.unit_price
|
||||
else:
|
||||
move.currency = self.company.currency
|
||||
move.unit_price = 0
|
||||
if move.on_change_with_unit_price_required():
|
||||
if template:
|
||||
move.unit_price = template.unit_price
|
||||
move.currency = template.currency
|
||||
else:
|
||||
move.unit_price = 0
|
||||
move.currency = self.company.currency
|
||||
return move
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -66,6 +66,8 @@ Create Shipment Out Return::
|
||||
>>> move.quantity = 1
|
||||
>>> move.from_location = customer_loc
|
||||
>>> move.to_location = storage1
|
||||
>>> move.unit_price = Decimal('20')
|
||||
>>> move.currency = company.currency
|
||||
>>> shipment.save()
|
||||
|
||||
>>> len(shipment.incoming_moves)
|
||||
|
||||
Reference in new issue
Block a user