Last active
August 9, 2020 00:36
-
-
Save ray-odoo/5c3c23f4698cad572c14ac36ddd63d52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for record in self: | |
if record.delivery_count > 0: | |
record['x_delivery_status'] = 'draft' | |
else: | |
global_done = False | |
for picking in record.picking_ids.sorted(key=lambda r: r.id): | |
local_done = False | |
if picking.state in ['waiting','confirmed']: | |
record['x_delivery_status'] = 'waiting' | |
if picking.state in ['assigned']: | |
record['x_delivery_status'] = 'ready' | |
if picking.state in ['done']: | |
record['x_delivery_status'] = 'partial' | |
local_done = True | |
if not global_done and local_done: | |
global_done = True | |
if global_done and not local_done: | |
global_done = False | |
if global_done: | |
record['x_delivery_status'] = 'done' | |
#draft Not Confirmed | |
#waiting Waiting | |
#ready Ready | |
#partial Partially Delivered | |
#done Fully Delivered | |
#dependencies: picking_ids.state |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment