Fix tests

This commit is contained in:
Sergi Almacellas Abellana 2014-05-14 16:58:02 +02:00
parent 4277d8ec3f
commit 6fa83746e0
2 changed files with 9 additions and 6 deletions

View file

@ -54,10 +54,10 @@ class MoveEvent:
cls.raise_user_error('weight_required_in_sale_move_event', cls.raise_user_error('weight_required_in_sale_move_event',
(event.rec_name,)) (event.rec_name,))
sales_to_process.add(event.origin.sale.id) sales_to_process.add(event.origin.sale.id)
super(MoveEvent, cls).validate_event(events) with Transaction().set_user(0, set_context=True):
if sales_to_process: super(MoveEvent, cls).validate_event(events)
with Transaction().set_user(0, set_context=True): if sales_to_process:
Sale.process(Sale.browse(list(sales_to_process))) Sale.process(Sale.browse(list(sales_to_process)))
class Sale: class Sale:

View file

@ -299,6 +299,7 @@ state::
>>> config.user = farm_user.id >>> config.user = farm_user.id
>>> MoveEvent = Model.get('farm.move.event') >>> MoveEvent = Model.get('farm.move.event')
>>> move_event = MoveEvent(move_event.id)
>>> move_event.weight = Decimal('2365.0') >>> move_event.weight = Decimal('2365.0')
>>> move_event.save() >>> move_event.save()
>>> MoveEvent.validate_event([move_event.id], config.context) >>> MoveEvent.validate_event([move_event.id], config.context)
@ -309,17 +310,19 @@ state::
>>> sale.reload() >>> sale.reload()
>>> sale.shipment_state >>> sale.shipment_state
u'sent' u'sent'
>>> invoice, = sale.invoices
Post invoice:: Post invoice::
>>> config.user = account_user.id >>> config.user = account_user.id
>>> Invoice = Model.get('account.invoice') >>> Invoice = Model.get('account.invoice')
>>> Invoice.post([i.id for i in sale.invoices], config.context) >>> invoice = Invoice(invoice.id)
>>> Invoice.post([invoice.id], config.context)
>>> config.user = sale_user.id >>> config.user = sale_user.id
>>> sale.reload() >>> sale.reload()
>>> len(sale.shipments), len(sale.shipment_returns), len(sale.invoices) >>> len(sale.shipments), len(sale.shipment_returns), len(sale.invoices)
(1, 0, 1) (0, 0, 1)
Pay invoice (TODO) and check unit price of Move event and Lot cost price is Pay invoice (TODO) and check unit price of Move event and Lot cost price is
updated:: updated::