Changeset - 3124a9a81f37
[Not reviewed]
0 1 0
Lance Edgar (lance) - 11 years ago 2014-01-26 16:53:24
lance@edbob.org
Remove reference to `Batch.iter_rows()`.
1 file changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rattail/batches/providers/labels.py
Show inline comments
 
@@ -19,27 +19,26 @@
 
#
 
#  You should have received a copy of the GNU Affero General Public License
 
#  along with Rattail.  If not, see <http://www.gnu.org/licenses/>.
 
#
 
################################################################################
 

	
 
"""
 
Print Labels Batch
 
"""
 

	
 
from sqlalchemy.orm import object_session
 

	
 
import rattail
 
from . import BatchProvider
 
from ...db import model
 
from rattail.batches.providers import BatchProvider
 

	
 

	
 
class PrintLabels(BatchProvider):
 

	
 
    name = 'print_labels'
 
    description = "Print Labels"
 

	
 
    default_profile = None
 
    default_quantity = 1
 

	
 
    def add_columns(self, batch):
 
        batch.add_column('F01')
 
@@ -70,25 +69,25 @@ class PrintLabels(BatchProvider):
 
        row.F94 = self.default_quantity
 
        batch.add_row(row)
 

	
 
    def execute(self, batch, progress=None):
 
        prog = None
 
        if progress:
 
            prog = progress("Loading product data", batch.rowcount)
 

	
 
        session = object_session(batch)
 
        profiles = {}
 

	
 
        cancel = False
 
        for i, row in enumerate(batch.iter_rows(), 1):
 
        for i, row in enumerate(batch.rows, 1):
 

	
 
            profile = profiles.get(row.F95)
 
            if not profile:
 
                q = session.query(model.LabelProfile)
 
                q = q.filter(model.LabelProfile.code == row.F95)
 
                profile = q.one()
 
                profile.labels = []
 
                profiles[row.F95] = profile
 

	
 
            q = session.query(model.Product)
 
            q = q.filter(model.Product.upc == row.F01)
 
            product = q.one()
0 comments (0 inline, 0 general)