Skip to content

Commit

Permalink
recover product operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Afonso Neves Caldas committed Nov 24, 2016
1 parent 6d11eba commit b7501ed
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/budy/models/bundle_line.py
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 @@ -225,6 +226,21 @@ def calculate_s(self):
def measure_s(self):
self.measure(force = True)
self.save()

@appier.operation(name = "Recover product")
def recover_s(self):
self.product.resolve()
if self.product.is_resolved():
return

from . import product
attributes = json.loads(self.attributes)
product_id = attributes.get("product_id", None)
product_id_s = str(product_id)

_product = product.Product.get(product_id = product_id_s)
self.product = _product
self.save(validate = False)

@property
def merchandise(self, name = "size", strict = False):
Expand Down

0 comments on commit b7501ed

Please sign in to comment.