Skip to content

Commit

Permalink
Merge pull request OCA#68 from yvaucher/8.0-fix-sale_sourced_by_line-…
Browse files Browse the repository at this point in the history
…is_delivered

8.0 sale_sourced_by_line - Fix is_shipped method
  • Loading branch information
lepistone committed Dec 1, 2014
2 parents 0add860 + 361866f commit 19eeca6
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions sale_sourced_by_line/model/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,33 @@ def action_ship_create(self, cr, uid, ids, context=None):
# OVERRIDE to use sale.order.line's procurement_group_id from lines
###
def _get_shipped(self, cr, uid, ids, name, args, context=None):
""" As procurement is per sale line basis, we check each line
If at least a line has no procurement group defined, it means it
isn't shipped yet.
Only when all procurement are done or cancelled, we consider
the sale order as being shipped.
And if there is no line, we have nothing to ship, thus it isn't
shipped.
"""
res = {}
for sale in self.browse(cr, uid, ids, context=context):
if not sale.order_line:
res[sale.id] = False
continue

groups = set([line.procurement_group_id
for line in sale.order_line])
is_shipped = False
is_shipped = True
for group in groups:
if group:
is_shipped &= all([proc.state in ['cancel', 'done']
for proc in group.procurement_ids])
if not group:
is_shipped = False
break
is_shipped &= all([proc.state in ['cancel', 'done']
for proc in group.procurement_ids])
res[sale.id] = is_shipped
return res

Expand Down

0 comments on commit 19eeca6

Please sign in to comment.