Skip to content

Commit

Permalink
Merge pull request #29 from hivesolutions/acaldas_recover
Browse files Browse the repository at this point in the history
Recover product operation
  • Loading branch information
joamag committed Nov 24, 2016
2 parents 6d11eba + 5fac2a3 commit a6c29a0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/budy/models/bundle_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
__license__ = "Apache License, Version 2.0"
""" The license for the module """

import json
import commons

import appier
Expand Down Expand Up @@ -226,6 +227,26 @@ def measure_s(self):
self.measure(force = True)
self.save()

@appier.operation(name = "Recover product")
def recover_s(self):
from . import product

self.product.resolve()
if self.product.is_resolved(): return

if not self.attributes: return
attributes = json.loads(self.attributes)

product_id = attributes.get("product_id", None)
if not product_id: return
product_id_s = str(product_id)

_product = product.Product.get(product_id = product_id_s)
if not _product: return

self.product = _product
self.save(validate = False, pre_save = False)

@property
def merchandise(self, name = "size", strict = False):
if not self.size: return self.product
Expand Down

0 comments on commit a6c29a0

Please sign in to comment.