Consider load orders created from sale.

This commit refs #3517
This commit is contained in:
Sergio Morillo 2017-12-07 13:14:51 +01:00
parent f3cb35c159
commit 4ad56f981e
4 changed files with 16 additions and 12 deletions

18
load.py
View file

@ -16,9 +16,13 @@ class LoadOrder:
super(LoadOrder, cls).__setup__()
cls._transitions.add(('done', 'running'))
cls._buttons.update({
'run': {'icon': 'tryton-go-previous',
'invisible': Or(Eval('state') != 'done', ~Eval('groups', []).contains(
Id('carrier_load_done2running', 'group_force_undo_load')))},
'run': {
'icon': 'tryton-go-previous',
'invisible': Or(Eval('state') != 'done', ~Eval('groups',
[]).contains(Id('carrier_load_done2running',
'group_force_undo_load')
))
},
})
cls._error_messages.update({
'sale_state': 'Cannot cancel Sale "%s" due to it is confirmed.'})
@ -34,15 +38,17 @@ class LoadOrder:
to_run = [r for r in records if r.state == 'done']
if to_run:
for item in to_run:
if item.sale and item.sale.state not in ('draft', 'quotation'):
if (item.sale and item.sale.origin == item and
item.sale.state not in ('draft', 'quotation')):
cls.raise_user_error('sale_state', item.sale.rec_name)
sales = [r.sale for r in to_run if r.sale]
sales = [r.sale for r in to_run if r.sale and r.sale.origin != r]
shipments_out = [r.shipment for r in to_run
if r.type == 'out' and r.shipment]
shipments_internal = [r.shipment for r in to_run
if r.type == 'internal' and r.shipment]
moves = [m for s in shipments_out + shipments_internal for m in s.moves]
moves = [m for s in shipments_out + shipments_internal
for m in s.moves]
order_moves = [m for r in to_run for m in r.outgoing_moves]
order_moves.extend([m for r in to_run for m in r.inventory_moves])
with Transaction().set_context(check_origin=False):

View file

@ -1,4 +1,4 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
@ -11,8 +11,8 @@ msgid "Force undo load"
msgstr "Forzar reapertura de carga"
msgctxt "view:carrier.load.order:"
msgid "Sale and Shipment out will be deleted."
msgstr "Venta y Albarán de cliente van a eliminarse."
msgid "Shipment and Sale (if proceed) will be deleted."
msgstr "Albarán y Venta (si procede) van a eliminarse."
msgctxt "view:carrier.load.order:"
msgid "Back to run"

View file

@ -333,8 +333,6 @@ Finish loading::
Check sale::
>>> len(order.sales)
1
>>> order.sale != None
True
>>> order.sale.state

View file

@ -4,6 +4,6 @@ this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/group[@id='state_buttons']/group[@id='buttons']" position="inside">
<button name="run" string="Back to run"
confirm="Sale and Shipment out will be deleted."/>
confirm="Shipment and Sale (if proceed) will be deleted."/>
</xpath>
</data>