From bf94300690a6db82209cdf9600de2cf311b2561c Mon Sep 17 00:00:00 2001 From: jmartin Date: Wed, 21 May 2014 10:29:26 +0200 Subject: [PATCH] Adapt signature of "def write()" --- work.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/work.py b/work.py index 60b527c..4698397 100644 --- a/work.py +++ b/work.py @@ -36,19 +36,23 @@ class Work: return works @classmethod - def write(cls, works, values): + def write(cls, *args): transaction = Transaction() context = transaction.context - if 'template' in values and not context.get('template', False): - to_update = cls.search([ - ('parent', 'child_of', [w.id for w in works]), - ('active', '=', True), - ]) + works + actions = iter(args) + args = [] + for works, values in zip(actions, actions): + if 'template' in values and not context.get('template', False): + to_update = cls.search([ + ('parent', 'child_of', [w.id for w in works]), + ('active', '=', True), + ]) + works - with transaction.set_context(template=True): - cls.write(to_update, {'template': values['template']}) - del values['template'] - return super(Work, cls).write(works, values) + with transaction.set_context(template=True): + cls.write(to_update, {'template': values['template']}) + else: + args.extend((works, values)) + return super(Work, cls).write(*args) @classmethod def create_from_template(cls, works, name, effort):