bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
476,600
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
476,601
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
476,602
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
476,603
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
476,604
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
def test_deserialize_clears_old_error_on_success(self): BundleDeserializationError.objects.create( bundle = self.bundle, error_message="not important").save() mock = self.mocker.patch(self.bundle) expect(mock._do_deserialize()) self.mocker.replay() self.bundle.deserialize() # note we cannot check for self.bundle.deserialization_error # directly due to the way django handles operations that affect # existing instances (it does not touch them like storm would # IIRC). self.assertRaises( BundleDeserializationError.DoesNotExist, BundleDeserializationError.objects.get, bundle=self.bundle)
476,605
def dispatch(self): args = self.parser.parse_args() command = args.command_cls(self.parser, args) command.invoke(args)
def dispatch(self, args=None): args = self.parser.parse_args(args) command = args.command_cls(self.parser, args) command.invoke(args)
476,606
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ users = set() groups = set() bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] users.add(user) initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] groups.add(group) initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams for bundle_stream in bundle_streams: bundle_stream.delete() for user in users: user.delete() for group in groups: group.delete()
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] users.add(user) initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] groups.add(group) initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams for bundle_stream in bundle_streams: bundle_stream.delete() for user in users: user.delete() for group in groups: group.delete()
476,607
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ users = set() groups = set() bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] users.add(user) initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] groups.add(group) initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams for bundle_stream in bundle_streams: bundle_stream.delete() for user in users: user.delete() for group in groups: group.delete()
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ users = set() groups = set() bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] groups.add(group) initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams for bundle_stream in bundle_streams: bundle_stream.delete() for user in users: user.delete() for group in groups: group.delete()
476,608
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ users = set() groups = set() bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] users.add(user) initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] groups.add(group) initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams for bundle_stream in bundle_streams: bundle_stream.delete() for user in users: user.delete() for group in groups: group.delete()
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ users = set() groups = set() bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] users.add(user) initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams for bundle_stream in bundle_streams: bundle_stream.delete() for user in users: user.delete() for group in groups: group.delete()
476,609
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ users = set() groups = set() bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] users.add(user) initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] groups.add(group) initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams for bundle_stream in bundle_streams: bundle_stream.delete() for user in users: user.delete() for group in groups: group.delete()
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ users = set() groups = set() bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] users.add(user) initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] groups.add(group) initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
476,610
def test_get_json_attr_types(self): self.assertEqual(DashboardBundle.get_json_attr_types(), {'test_runs': [TestRuns]})
def test_get_json_attr_types(self): self.assertEqual(DashboardBundle.get_json_attr_types(), {'test_runs': [TestRuns]})
476,611
def __init__(self, parser, args): super(XMLRPCCommand, self).__init__(parser, args) parts = urlparse.urlsplit(args.dashboard_url) if args.username and args.password: netloc = "%s:%s@%s:%d" % ( args.username, args.password, parts.host, parts.port or 80) else: netloc = parts.netloc urltext = urlparse.urlunsplit((parts.scheme, netloc, "/xml-rpc/", "", "")) self.server = xmlrpclib.ServerProxy(urltext, use_datetime=True, allow_none=True, verbose=args.verbose_xml_rpc)
def __init__(self, parser, args): super(XMLRPCCommand, self).__init__(parser, args) parts = urlparse.urlsplit(args.dashboard_url) if args.username and args.password: netloc = "%s:%s@%s" % ( args.username, args.password, parts.host, parts.port or 80) else: netloc = parts.netloc urltext = urlparse.urlunsplit((parts.scheme, netloc, "/xml-rpc/", "", "")) self.server = xmlrpclib.ServerProxy(urltext, use_datetime=True, allow_none=True, verbose=args.verbose_xml_rpc)
476,612
def __init__(self, parser, args): super(XMLRPCCommand, self).__init__(parser, args) parts = urlparse.urlsplit(args.dashboard_url) if args.username and args.password: netloc = "%s:%s@%s:%d" % ( args.username, args.password, parts.host, parts.port or 80) else: netloc = parts.netloc urltext = urlparse.urlunsplit((parts.scheme, netloc, "/xml-rpc/", "", "")) self.server = xmlrpclib.ServerProxy(urltext, use_datetime=True, allow_none=True, verbose=args.verbose_xml_rpc)
def __init__(self, parser, args): super(XMLRPCCommand, self).__init__(parser, args) parts = urlparse.urlsplit(args.dashboard_url) if args.username and args.password: netloc = "%s:%s@%s:%d" % ( args.username, args.password, parts.netloc) else: netloc = parts.netloc urltext = urlparse.urlunsplit((parts.scheme, netloc, "/xml-rpc/", "", "")) self.server = xmlrpclib.ServerProxy(urltext, use_datetime=True, allow_none=True, verbose=args.verbose_xml_rpc)
476,613
def mock_imports(self, reload_list=None): """ Make prohibit_importing() work by hiding and importing again all the modules that depended on an imported prohibited module.
def mock_imports(self, reload_list=None): """ Make prohibit_importing() work by hiding and importing again all the modules that depended on an imported prohibited module.
476,614
def clean(self): cleaned_data = self.cleaned_data print cleaned_data if (cleaned_data.get('user', '') is not None and cleaned_data.get('group') is not None): raise forms.ValidationError('BundleStream cannot have both user ' 'and name set at the same time') return super(BundleStreamAdminForm, self).clean()
def clean(self): cleaned_data = self.cleaned_data if (cleaned_data.get('user', '') is not None and cleaned_data.get('group') is not None): raise forms.ValidationError('BundleStream cannot have both user ' 'and name set at the same time') return super(BundleStreamAdminForm, self).clean()
476,615
def register_arguments(cls, parser): group = parser.add_argument_group("Dashboard Server options") group.add_argument("--dashboard-url", required=True, metavar="URL", help="URL of your validation dashboard") group.add_argument("--verbose-xml-rpc", action="store_true", default=False, help="Show XML-RPC data")
def register_arguments(cls, parser): group = parser.add_argument_group("Dashboard Server options") group.add_argument("--dashboard-url", required=True, metavar="URL", help="URL of your validation dashboard") group.add_argument("--verbose-xml-rpc", action="store_true", default=False, help="Show XML-RPC data")
476,616
def _set_measurement(self, value): valid_types = (int, long, float, Decimal, NoneType) if not isinstance(value, valid_types): raise TypeError("Measurement must be an int, long, float, Decimal or None") self._measurement = value
def _set_measurement(self, value): valid_types = (int, long, float, Decimal, NoneType) if not isinstance(value, valid_types): raise TypeError("Measurement must be an int, long, float, Decimal or None") self._measurement = value
476,617
def _set_measurement(self, value): valid_types = (int, long, float, Decimal, NoneType) if not isinstance(value, valid_types): raise TypeError("Measurement must be an int, long, float, Decimal or None") self._measurement = value
def _set_measurement(self, value): valid_types = (int, long, float, Decimal, NoneType) if not isinstance(value, valid_types): raise TypeError("Measurement must be an int, long, float, Decimal or None") self._measurement = value
476,618
def _set_duration(self, duration): if duration is not None and not isinstance(duration, timedelta): raise TypeError("Duration must be None or timedelta " "instance") if duration is not None and duration.days < 0: raise ValueError("Duration cannot be negative") self._duration = duration
def _set_duration(self, duration): if duration is not None and not isinstance(duration, timedelta): raise TypeError("Duration must be None or timedelta " "instance") if duration is not None and duration.days < 0: raise ValueError("Duration cannot be negative") self._duration = duration
476,619
def test_get_help_defaults_to_None(self): class mysterious(Command): pass self.assertEqual(mysterious.get_help(), None)
def test_get_help_defaults_to_None(self): class mysterious(Command): pass self.assertEqual(mysterious.get_help(), None)
476,620
def test_template_used(self): response = self.client.get("/streams" + self.bundle_stream.pathname) if self.bundle_stream.can_access(self.user): self.assertTemplateUsed(response, "dashboard_app/bundle_stream_detail.html") else: self.assertTemplateUsed(response, "403.html")
def test_template_used(self): response = self.client.get("/streams" + self.bundle_stream.pathname) if self.bundle_stream.can_access(self.user): self.assertTemplateUsed(response, "dashboard_app/bundle_stream_detail.html") else: self.assertTemplateUsed(response, "403.html")
476,621
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification. spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
476,622
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification `spec`: list of dictionaries List of values to make_bundle_stream() yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
476,623
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of BundleStream List of created bundle stream objects """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
476,624
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: initargs = { 'user': None, 'group': None, 'slug': stream_args.get('slug', ''), 'name': stream_args.get('name', '')} username = stream_args.get('user') if username: user = User.objects.get_or_create(username=username)[0] initargs['user'] = user groupname = stream_args.get('group') if groupname: group = Group.objects.get_or_create(name=groupname)[0] initargs['group'] = group bundle_stream = BundleStream.objects.create(**initargs) bundle_stream.save() bundle_streams.append(bundle_stream) yield bundle_streams
def created_bundle_streams(spec): """ Helper context manager that creates bundle streams according to specification spec is a list of dictionaries with the following keys: user: string indicating user name to create [optional] group: string indicating group name to create [optional] slug: slug-like name [optional] name: name of the stream to create [optional] yields: list of created bundle streams """ bundle_streams = [] for stream_args in spec: bundle_streams.append(make_bundle_stream(stream_args)) yield bundle_streams
476,625
def deserialize(self): """ Deserialize the contents of this bundle.
def deserialize(self): """ Deserialize the contents of this bundle.
476,626
... def _deserialize(cls, doc):
... def _deserialize(cls, doc):
476,627
def __eq__(self, other): return self.name == other.name and \ debian_version_compare(self.version, other.version) == 0
def __eq__(self, other): return self.name == other.name and \ debian_version_compare(self.version, other.version) == 0
476,628
def invoke_remote(self): response = self.server.get(self.args.SHA1) if self.args.output is None: filename = response['content_filename'] if os.path.exists(filename) and not self.args.overwrite: print "File {filename!r} already exists".format( filename=filename) print "You may pass --overwrite to write over it" return stream = open(filename, "wb") else: stream = self.args.output filename = self.args.output.name stream.write(response['content']) print "Downloaded bundle {0} to file {1!r}".format( self.args.BUNDLE_ID, filename)
def invoke_remote(self): response = self.server.get(self.args.SHA1) if self.args.output is None: filename = response['content_filename'] if os.path.exists(filename) and not self.args.overwrite: print "File {filename!r} already exists".format( filename=filename) print "You may pass --overwrite to write over it" return stream = open(filename, "wb") else: stream = self.args.output filename = self.args.output.name stream.write(response['content']) print "Downloaded bundle {0} to file {1!r}".format( self.args.BUNDLE_ID, filename)
476,629
def __init__(self, test_result, test_id=None, message=None, timestamp=None, duration=None): """ Initialize qualitative sample instance.
def __init__(self, test_result, test_id=None, message=None, timestamp=None, duration=None): """ Initialize qualitative sample instance.
476,630
def test_debian_import_failure(self): """ Make sure we import debian_bundle if debian is not available """ self.prohibit_importing('debian.debian_support') self.mock_imports('launch_control.sw_profile') mocker = Mocker() obj = mocker.replace('debian_bundle.debian_support.version_compare') mocker.replay() import launch_control.sw_profile self.assertTrue(launch_control.sw_profile.debian_version_compare is obj) mocker.verify() mocker.restore()
def test_debian_import_failure(self): """ Make sure we import debian_bundle if debian is not available """ self.prohibit_importing('debian.debian_support') self.mock_imports('launch_control.sw_profile') mocker = Mocker() obj = mocker.replace('debian_bundle.debian_support.version_compare') mocker.replay() import launch_control.sw_profile self.assertTrue(launch_control.sw_profile.debian_version_compare is obj) mocker.verify() mocker.restore()
476,631
def _set_log_filename(self, log_filename): self._log_filename = log_filename
def _set_log_filename(self, log_filename): self._log_filename = log_filename
476,632
def _set_log_lineno(self, log_lineno): self._log_lineno = log_lineno
def _set_log_lineno(self, log_lineno): self._log_lineno = log_lineno
476,633
def deserialize(self, content_sha1): """ Name ---- `deserialize` (`content_sha1`)
def deserialize(self, content_sha1): """ Name ---- `deserialize` (`content_sha1`)
476,634
def memory_model_to_db_model(self, c_bundle, s_bundle): """ Translate a memory model to database model """ from dashboard_app.models import ( Attachment, HardwareDevice, NamedAttribute, SoftwarePackage, Test, TestCase, TestResult, TestRun, ) # All variables prefixed with c_ refer to CLIENT SIDE models # All variables prefixed with s_ refer to SERVER SIDE models for c_test_run in c_bundle.test_runs: s_test, test_created = Test.objects.get_or_create( test_id = c_test_run.test_id) if test_created: s_test.save() s_test_run = TestRun.objects.create( bundle = s_bundle, test = s_test, analyzer_assigned_uuid = c_test_run.analyzer_assigned_uuid, analyzer_assigned_date = c_test_run.analyzer_assigned_date, time_check_performed = c_test_run.time_check_performed, sw_image_desc = (c_test_run.sw_context.sw_image.desc if c_test_run.sw_context and c_test_run.sw_context.sw_image else "")) s_test_run.save() # needed for foreign key models below # Software Context: if c_test_run.sw_context: for c_package in c_test_run.sw_context.packages: s_package, package_created = SoftwarePackage.objects.get_or_create( name=c_package.name, version=c_package.version) if package_created: s_package.save() s_test_run.packages.add(s_package) # Hardware Context: if c_test_run.hw_context: for c_device in c_test_run.hw_context.devices: s_device = HardwareDevice.objects.create( device_type = c_device.device_type, description = c_device.description) s_device.save() for name, value in c_device.attributes.iteritems(): s_device.attributes.create(name=name, value=value) s_test_run.devices.add(s_device) # Test Results: for c_test_result in c_test_run.test_results: if c_test_result.test_case_id: s_test_case, test_case_created = TestCase.objects.get_or_create( test_case_id = c_test_result.test_case_id, test = s_test_run.test, defaults = {'units': c_test_result.units}) if test_case_created: s_test_case.save() else: s_test_case = None s_test_result = TestResult.objects.create( test_run = s_test_run, test_case = s_test_case, result = self._translate_result_string(c_test_result.result), measurement = c_test_result.measurement, filename = c_test_result.log_filename, lineno = c_test_result.log_lineno, message = c_test_result.message, timestamp = c_test_result.timestamp, duration = c_test_result.duration) s_test_result.save() # needed for foreign key models below for name, value in c_test_result.attributes.iteritems(): s_test_result.attributes.create( name=name, value=value) # Test Run Attachments for filename, lines in c_test_run.attachments.iteritems(): s_attachment = s_test_run.attachments.create(content_filename=filename) s_attachment.save() s_attachment.content.save( "attachment-{0}.txt".format(s_attachment.pk), ContentFile("".join(lines).encode("UTF-8"))) # Test Run Attributes for name, value in c_test_run.attributes.iteritems(): s_test_run.attributes.create( name=str(name), value=str(value))
def memory_model_to_db_model(self, c_bundle, s_bundle): """ Translate a memory model to database model """ from dashboard_app.models import ( Attachment, HardwareDevice, NamedAttribute, SoftwarePackage, Test, TestCase, TestResult, TestRun, ) # All variables prefixed with c_ refer to CLIENT SIDE models # All variables prefixed with s_ refer to SERVER SIDE models for c_test_run in c_bundle.test_runs: s_test, test_created = Test.objects.get_or_create( test_id = c_test_run.test_id) if test_created: s_test.save() s_test_run = TestRun.objects.create( bundle = s_bundle, test = s_test, analyzer_assigned_uuid = str(c_test_run.analyzer_assigned_uuid), analyzer_assigned_date = c_test_run.analyzer_assigned_date, time_check_performed = c_test_run.time_check_performed, sw_image_desc = (c_test_run.sw_context.sw_image.desc if c_test_run.sw_context and c_test_run.sw_context.sw_image else "")) s_test_run.save() # needed for foreign key models below # Software Context: if c_test_run.sw_context: for c_package in c_test_run.sw_context.packages: s_package, package_created = SoftwarePackage.objects.get_or_create( name=c_package.name, version=c_package.version) if package_created: s_package.save() s_test_run.packages.add(s_package) # Hardware Context: if c_test_run.hw_context: for c_device in c_test_run.hw_context.devices: s_device = HardwareDevice.objects.create( device_type = c_device.device_type, description = c_device.description) s_device.save() for name, value in c_device.attributes.iteritems(): s_device.attributes.create(name=name, value=value) s_test_run.devices.add(s_device) # Test Results: for c_test_result in c_test_run.test_results: if c_test_result.test_case_id: s_test_case, test_case_created = TestCase.objects.get_or_create( test_case_id = c_test_result.test_case_id, test = s_test_run.test, defaults = {'units': c_test_result.units}) if test_case_created: s_test_case.save() else: s_test_case = None s_test_result = TestResult.objects.create( test_run = s_test_run, test_case = s_test_case, result = self._translate_result_string(c_test_result.result), measurement = c_test_result.measurement, filename = c_test_result.log_filename, lineno = c_test_result.log_lineno, message = c_test_result.message, timestamp = c_test_result.timestamp, duration = c_test_result.duration) s_test_result.save() # needed for foreign key models below for name, value in c_test_result.attributes.iteritems(): s_test_result.attributes.create( name=name, value=value) # Test Run Attachments for filename, lines in c_test_run.attachments.iteritems(): s_attachment = s_test_run.attachments.create(content_filename=filename) s_attachment.save() s_attachment.content.save( "attachment-{0}.txt".format(s_attachment.pk), ContentFile("".join(lines).encode("UTF-8"))) # Test Run Attributes for name, value in c_test_run.attributes.iteritems(): s_test_run.attributes.create( name=str(name), value=str(value))
476,635
def test_echo(self): self.assertEqual(self.xml_rpc_call("echo", 1), 1) self.assertEqual(self.xml_rpc_call("echo", "string"), "string") self.assertEqual(self.xml_rpc_call("echo", 1.5), 1.5) retval = self.xml_rpc_call("ping") self.assertEqual(retval, "pong")
def test_echo(self): self.assertEqual(self.xml_rpc_call("echo", 1), 1) self.assertEqual(self.xml_rpc_call("echo", "string"), "string") self.assertEqual(self.xml_rpc_call("echo", 1.5), 1.5) retval = self.xml_rpc_call("ping") self.assertEqual(retval, "pong")
476,636
def version(self): """ Name ---- `version` ()
def version(self): """ Name ---- `version` ()
476,637
def __unicode__(self): return _(u"{name}: {value}").format( name = self.name, value = self.value)
def __unicode__(self): return _(u"{name}: {value}").format( name = self.name, value = self.value)
476,638
def mock_imports(self, reload_list=None): """ Make prohibit_importing() work by hiding and importing again all the modules that depended on an imported prohibited module.
def mock_imports(self, reload_list=None): """ Make prohibit_importing() work by hiding and importing again all the modules that depended on an imported prohibited module.
476,639
def test_test_result__unknown(self): obj = TestResult(result=TestResult.RESULT_UNKNOWN, id=1) self.assertEqual(unicode(obj), "#1 unknown")
def test_test_result__unknown(self): obj = TestResult(result=TestResult.RESULT_UNKNOWN, id=1) self.assertEqual(unicode(obj), "#1 unknown")
476,640
def test_csrf_not_protecting_xml_rpc_views(self): """call version and check that we didn't get 403""" endpoint_path = reverse("dashboard_app.dashboard_xml_rpc_handler") request_body = xmlrpclib.dumps((), methodname="version") response = self.client.post(endpoint_path, request_body, "text/xml") self.assertContains(response, "<methodResponse>", status_code=200)
def test_csrf_not_protecting_xml_rpc_views(self): """call version and check that we didn't get 403""" endpoint_path = reverse("xml-rpc") request_body = xmlrpclib.dumps((), methodname="version") response = self.client.post(endpoint_path, request_body, "text/xml") self.assertContains(response, "<methodResponse>", status_code=200)
476,641
def __init__(self, format=None, test_runs=None): self.format = format or self.FORMAT self.test_runs = test_runs or []
def __init__(self, format=None, test_runs=None): self.format = format or self.FORMAT self.test_runs = test_runs or []
476,642
def test_cross_site_login_fails(self): response = self.client.post(self.login_path, { 'user': 'user', 'pass': 'pass'}) self.assertEquals(response.status_code, 403)
def test_cross_site_login_fails(self): response = self.client.post(self.login_path, { 'user': 'user', 'pass': 'pass'}) self.assertEquals(response.status_code, 403)
476,643
def test_csrf_not_protecting_xml_rpc_views(self): """call version and check that we didn't get 403""" request_body = xmlrpclib.dumps((), methodname="version") response = self.client.post( self.endpoint_path, request_body, "text/xml") self.assertContains(response, "<methodResponse>", status_code=200)
def test_csrf_not_protecting_xml_rpc_views(self): """call version and check that we didn't get 403""" request_body = xmlrpclib.dumps((), methodname="version") response = self.client.post(endpoint_path, request_body, "text/xml") self.assertContains(response, "<methodResponse>", status_code=200)
476,644
def parse(data): header = {} signals = {1:('0',0),2:('1',0),3:('Local',0)} modules = {} for token in data: objtype=token.get('ObjTp','') if objtype=='Hd': header['dealer']=token.get('DlrNm','n/a') header['programer']=token.get('PgmNm','n/a') header['file']=token.get('PrNm','n/a') header['hint']=token.get('CltNm','n/a') elif objtype=='Sg': snumber = int(token.get('H', '-1')) # for debug purpose sname = token.get('Nm','n/a') stype = int(token.get('SgTp','1')) if stype not in [1,2,4]: stype=0 elif stype==4: stype=3 signals[snumber]=(sname, stype) elif objtype=='Sm': mtag = token.get('H', '-1') minfo = get_info(token) mtype = int(token.get('SmC','-1')) mname = token.get('Nm') mcomment = token.get('Cmn1','') if mname is None: mname = database.get(mtype,{}).get('name','!unknown') if mtype in moduleAPI: module = make_module(mname+" - in", mtype, [], minfo['ins'], minfo['params'], minfo['comps'], mcomment) modules["m"+mtag+"i"] = module module = make_module(mname+" - out", mtype, minfo['outs'], comment=mcomment) modules["m"+mtag+"o"] = module elif mtype in interconnectAPI: module = make_module(mname+" - feedback", mtype, minfo['ins'], [], minfo['params'], minfo['comps'], mcomment) modules["m"+mtag+"i"] = module module = make_module(mname+" - input", mtype, outs=minfo['outs'], comment=mcomment) modules["m"+mtag+"o"] = module else: module = make_module( mname, mtype, minfo['ins'], minfo['outs'], minfo['params'], minfo['comps'], mcomment) modules["m"+mtag] = module return header, signals, modules
def parse(data): header = {} signals = {1:('0',0),2:('1',0),3:('Local',0)} modules = {} for token in data: objtype=token.get('ObjTp','') if objtype=='Hd': header['dealer']=token.get('DlrNm','n/a') header['programer']=token.get('PgmNm','n/a') header['file']=token.get('PrNm','n/a') header['hint']=token.get('CltNm','n/a') elif objtype=='Sg': snumber = int(token.get('H', '-1')) # for debug purpose sname = token.get('Nm','n/a') stype = int(token.get('SgTp','1')) if stype not in [1,2,4]: stype=0 elif stype==4: stype=3 signals[snumber]=(sname, stype) elif objtype=='Sm': mtag = token.get('H', '-1') minfo = get_info(token) mtype = int(token.get('SmC','-1')) mname = token.get('Nm') mcomment = token.get('Cmn1','') if mname is None: mname = database.get(mtype,{}).get('name','!unknown') if mtype in moduleAPI: module = make_module(mname+" - in", mtype, [], minfo['ins'], minfo['params'], minfo['comps'], mcomment) modules["m"+mtag+"i"] = module module = make_module(mname+" - out", mtype, minfo['outs'], comment=mcomment) modules["m"+mtag+"o"] = module elif mtype in interconnectAPI: module = make_module(mname+" - feedback", mtype, minfo['ins'], [], minfo['params'], minfo['comps'], mcomment) modules["m"+mtag+"i"] = module module = make_module(mname+" - input", mtype, outs=minfo['outs'], comment=mcomment) modules["m"+mtag+"o"] = module else: module = make_module( mname, mtype, minfo['ins'], minfo['outs'], minfo['params'], minfo['comps'], mcomment) modules["m"+mtag] = module return header, signals, modules
476,645
def nonum(name): return filter(lambda x: not x.isdigit(), name)
def nonum(name): return filter(lambda x: not x.isdigit(), name)
476,646
def make_dot(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] checkT = False checkF = False limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() for m in limit_mods: dot_file.append(make_node(m, modules[m])) checkT = 2 in modules[m]['ins'] or checkT checkF = 1 in modules[m]['ins'] or checkF if checkF: dot_file.append(' 0 [shape="circle"];') if checkT: dot_file.append(' 1 [shape="circle"];') dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) extended_sigs = {} #extended_sigs = { (src,dst):[(name0,type0),(name1,type1)] } for s in limit_sigs: sname, stype = signals[s] outs = filter(lambda m: s in modules[m]['outs'], limit_mods) if sname == '0': outs.append('0') if sname == '1': outs.append('1') ins = filter(lambda m: s in modules[m]['ins'], limit_mods) pack = set() for o in outs: for i in ins: pack.add((o,i)) for line in pack: if extended_sigs.get(line) is None: extended_sigs[line]=[] extended_sigs[line].append(signals[s]) # bus signals agregate for addr in extended_sigs: if len(extended_sigs[addr])==1: sname, stype = extended_sigs[addr][0] dot_file.append(make_direct_signal(addr,sname,stype)) else: pack = {} for n,t in extended_sigs[addr]: tag = (nonum(n),t) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(n) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
def make_dot(header, signals, modules): dot_file = [make_head(header)] checkT = False checkF = False limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() for m in limit_mods: dot_file.append(make_node(m, modules[m])) checkT = 2 in modules[m]['ins'] or checkT checkF = 1 in modules[m]['ins'] or checkF if checkF: dot_file.append(' 0 [shape="circle"];') if checkT: dot_file.append(' 1 [shape="circle"];') dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) extended_sigs = {} #extended_sigs = { (src,dst):[(name0,type0),(name1,type1)] } for s in limit_sigs: sname, stype = signals[s] outs = filter(lambda m: s in modules[m]['outs'], limit_mods) if sname == '0': outs.append('0') if sname == '1': outs.append('1') ins = filter(lambda m: s in modules[m]['ins'], limit_mods) pack = set() for o in outs: for i in ins: pack.add((o,i)) for line in pack: if extended_sigs.get(line) is None: extended_sigs[line]=[] extended_sigs[line].append(signals[s]) # bus signals agregate for addr in extended_sigs: if len(extended_sigs[addr])==1: sname, stype = extended_sigs[addr][0] dot_file.append(make_direct_signal(addr,sname,stype)) else: pack = {} for n,t in extended_sigs[addr]: tag = (nonum(n),t) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(n) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
476,647
def make_dot(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] checkT = False checkF = False limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() for m in limit_mods: dot_file.append(make_node(m, modules[m])) checkT = 2 in modules[m]['ins'] or checkT checkF = 1 in modules[m]['ins'] or checkF if checkF: dot_file.append(' 0 [shape="circle"];') if checkT: dot_file.append(' 1 [shape="circle"];') dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) extended_sigs = {} #extended_sigs = { (src,dst):[(name0,type0),(name1,type1)] } for s in limit_sigs: sname, stype = signals[s] outs = filter(lambda m: s in modules[m]['outs'], limit_mods) if sname == '0': outs.append('0') if sname == '1': outs.append('1') ins = filter(lambda m: s in modules[m]['ins'], limit_mods) pack = set() for o in outs: for i in ins: pack.add((o,i)) for line in pack: if extended_sigs.get(line) is None: extended_sigs[line]=[] extended_sigs[line].append(signals[s]) # bus signals agregate for addr in extended_sigs: if len(extended_sigs[addr])==1: sname, stype = extended_sigs[addr][0] dot_file.append(make_direct_signal(addr,sname,stype)) else: pack = {} for n,t in extended_sigs[addr]: tag = (nonum(n),t) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(n) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
def make_dot(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] checkT = False checkF = False limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() for m in limit_mods: dot_file.append(make_node(m, modules[m])) checkT = 2 in modules[m]['ins'] or checkT checkF = 1 in modules[m]['ins'] or checkF if checkF: dot_file.append(' 0 [shape="circle"];') if checkT: dot_file.append(' 1 [shape="circle"];') dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) extended_sigs = {} #extended_sigs = { (src,dst):[(name0,type0),(name1,type1)] } for s in limit_sigs: sname, stype = signals[s] outs = filter(lambda m: s in modules[m]['outs'], limit_mods) if sname == '0': outs.append('0') if sname == '1': outs.append('1') ins = filter(lambda m: s in modules[m]['ins'], limit_mods) pack = set() for o in outs: for i in ins: pack.add((o,i)) for line in pack: if extended_sigs.get(line) is None: extended_sigs[line]=[] extended_sigs[line].append(signals[s]) # bus signals agregate for addr in extended_sigs: if len(extended_sigs[addr])==1: sname, stype = extended_sigs[addr][0] dot_file.append(make_direct_signal(addr,sname,stype)) else: pack = {} for n,t in extended_sigs[addr]: tag = (nonum(n),t) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(n) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(make_tail()) return "\n".join(dot_file)
476,648
def make_dot_merged(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_direct_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
def make_dot_merged(header, signals, modules): dot_file = [make_head(header)] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_direct_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
476,649
def make_dot_merged(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_direct_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
def make_dot_merged(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
476,650
def make_dot_merged(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_direct_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
def make_dot_merged(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_direct_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(make_tail()) return "\n".join(dot_file)
476,651
def make_dot_merged(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_direct_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
def make_dot_merged(header, signals, modules): head = """// file: %s\n// dealer: %s\n// programmer: %s\n// hint: %s\n\ndigraph {"""%( header['file'],header['dealer'],header['programer'],header['hint']) tail = """}""" dot_file = [head] limit_mods = filter(lambda m: adv_len(modules[m]['ins']) or adv_len(modules[m]['outs']), modules) limit_mods.sort() dot_file.extend(map(lambda m: make_node(m, modules[m]), limit_mods)) dot_file.append('') limit_sigs = filter(lambda s: is_significant(signals[s][0]), signals) limit_sigs.sort() direct_sigs = {} # for every signal get set of pairs (signal,module) and (module, signal) # bus unable to create for s in limit_sigs: sname, stype = signals[s] stag = "s%d"%s outs = filter(lambda m: s in modules[m]['outs'], limit_mods) ins = filter(lambda m: s in modules[m]['ins'], limit_mods) # filtering out single signals if len(outs)==1 and len(ins)==1: line = (outs[0],ins[0]) if direct_sigs.get(line) is None: direct_sigs[line]=[] direct_sigs[line].append(signals[s]) # for single signals don't create dots # we will add them later continue # for others create packets pack = set() map(lambda m: pack.add((m,stag)), outs) map(lambda m: pack.add((stag,m)), ins) if len(pack)>1: dot_file.append(make_direct_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) elif len(pack)==1: dot_file.append(make_signal(stag, sname, stype)) for src, dst in pack: dot_file.append(make_link(src,dst,stype)) # adding single signals, some of them aggregating into bus for addr in direct_sigs: pack = {} for sname, stype in direct_sigs[addr]: tag = (nonum(sname),stype) if pack.get(tag) is None: pack[tag]=[] pack[tag].append(sname) for bulk in pack: if len(pack[bulk])==1: dot_file.append(make_direct_signal(addr,pack[bulk][0],bulk[1])) else: dot_file.append(make_signal_bus(addr,pack[bulk],bulk[1])) dot_file.append(tail) return "\n".join(dot_file)
476,652
def main(): if len(sys.argv) != 2: print 'Please specify one filename on the command line.' sys.exit(1) text = open(sys.argv[1],"rt").read() tree = tokenize(text) header,sigs,mods = parse(tree) print make_dot(header,sigs,mods) #print make_dot_merged(header,sigs,mods)
def main(): usage = "usage: %prog [options] inputfile\ninputfile of smw/umc/cmc Crestron's filetypes" parser = OptionParser(usage=usage) parser.add_option("-o","--output", dest="output", help="write result to FILE", metavar="FILE") parser.add_option("-m","--merged", dest="merge", action="store_true", help="make \"merged signals\" version", default=False) (options,args) = parser.parse_args() if len(args) != 1: parser.error("input file is required") (filename,) = args text = open(filename, "rt").read() tree = tokenize(text) header,sigs,mods = parse(tree) print make_dot(header,sigs,mods) #print make_dot_merged(header,sigs,mods)
476,653
def main(): if len(sys.argv) != 2: print 'Please specify one filename on the command line.' sys.exit(1) text = open(sys.argv[1],"rt").read() tree = tokenize(text) header,sigs,mods = parse(tree) print make_dot(header,sigs,mods) #print make_dot_merged(header,sigs,mods)
def main(): if len(sys.argv) != 2: print 'Please specify one filename on the command line.' sys.exit(1) text = open(sys.argv[1],"rt").read() tree = tokenize(text) header,sigs,mods = parse(tree) print make_dot(header,sigs,mods) #print make_dot_merged(header,sigs,mods)
476,654
def checkEqual(var1, var2): check(var1 == var2, "Values not equal: '" + str(var1) + "' !='" + str(var2) + "'")
def checkEqual(var1, var2): check(var1 == var2, "Values not equal: '" + str(var1) + "' !='" + str(var2) + "'")
476,655
def checkEqual(var1, var2): check(var1 == var2, "Values not equal: '" + str(var1) + "' !='" + str(var2) + "'")
def checkEqual(var1, var2): check(var1 == var2, "Values not equal: '" + str(var1) + "' !='" + str(var2) + "'")
476,656
def checkEqual(var1, var2): check(var1 == var2, "Values not equal: '" + str(var1) + "' !='" + str(var2) + "'")
def checkEqual(var1, var2): check(var1 == var2, "Values not equal: '" + str(var1) + "' !='" + str(var2) + "'")
476,657
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,658
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,659
def _user(self, cr, uid, ids, name, arg, context=None): res = {} cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] for id in ids: ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])]) if ids2: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: res[id] = [] return res
def _user(self, cr, uid, ids, name, arg, context=None): res = {} cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] for id in ids: ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])]) if ids2: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: res[id] = [] return res
476,660
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if context is None: context = {} if not ids: return []
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if context is None: context = {} if not ids: return []
476,661
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND account_analytic_journal.type = 'sale' \ GROUP BY account_analytic_line.account_id", (parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} res_final = {} child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) for i in child_ids: res[i] = {} for n in [name]: res[i][n] = 0.0 if not child_ids: return res if child_ids: cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND account_analytic_journal.type = 'sale' \ GROUP BY account_analytic_line.account_id", (parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
476,662
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND account_analytic_journal.type = 'sale' \ GROUP BY account_analytic_line.account_id", (parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND account_analytic_journal.type = 'sale' \ GROUP BY account_analytic_line.account_id", (child_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
476,663
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND account_analytic_journal.type = 'sale' \ GROUP BY account_analytic_line.account_id", (parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND account_analytic_journal.type = 'sale' \ GROUP BY account_analytic_line.account_id", (parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
476,664
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND amount<0 \ GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} res_final = {} child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) for i in child_ids: res[i] = {} for n in [name]: res[i][n] = 0.0 if not child_ids: return res if child_ids: cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND amount<0 \ GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
476,665
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND amount<0 \ GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND amount<0 \ GROUP BY account_analytic_line.account_id""",(child_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
476,666
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND amount<0 \ GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ FROM account_analytic_line \ JOIN account_analytic_journal \ ON account_analytic_line.journal_id = account_analytic_journal.id \ WHERE account_analytic_line.account_id IN %s \ AND amount<0 \ GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
476,667
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
476,668
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
476,669
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
476,670
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): dp = 2 res = dict([(i, {}) for i in ids])
476,671
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context)
476,672
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
476,673
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
476,674
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context=None): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ * hr.factor)),0.0) as somme from account_analytic_line \ left join account_analytic_journal \ on (account_analytic_line.journal_id = account_analytic_journal.id) \ join product_product pp \ on (account_analytic_line.product_id = pp.id) \ join product_template pt \ on (pp.product_tmpl_id = pt.id) \ join account_analytic_account a \ on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ and account_analytic_journal.type IN ('purchase','general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) res2.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) res[obj_id] += res2.get(child_id, 0.0) # sum both result on account_id for id in ids: res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2) return res
476,675
def _user(self, cr, uid, ids, name, arg, context=None): res = {} cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] for id in ids: parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: res[id] = [] return res
def _user(self, cr, uid, ids, name, arg, context=None): res = {} cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] for id in ids: parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: res[id] = [] return res
476,676
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
476,677
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, tuple(user_ids),)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
476,678
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ 'WHERE account_id IN %s ' \ 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)))])]): if child_id != int(str(obj_id/max_user - (obj_id%max_user == 0 and 1 or 0))): res[obj_id] += res.get((child_id * max_user) + obj_id -((obj_id/max_user - (obj_id%max_user == 0 and 1 or 0)) * max_user), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
476,679
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
476,680
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ 'WHERE account_id IN %s ' \ 'AND month_id IN %s ',(parent_ids, month_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(int(obj_id))[:-6])])]): if child_id != int(str(int(obj_id))[:-6]): res[obj_id] += res.get(int(child_id * 1000000 + int(str(int(obj_id))[-6:])), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ 'WHERE account_id IN %s ' \ 'AND month_id IN %s ',(parent_ids, month_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(int(obj_id))[:-6])])]): if child_id != int(str(int(obj_id))[:-6]): res[obj_id] += res.get(int(child_id * 1000000 + int(str(int(obj_id))[-6:])), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
476,681
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ 'WHERE account_id IN %s ' \ 'AND month_id IN %s ',(parent_ids, month_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(int(obj_id))[:-6])])]): if child_id != int(str(int(obj_id))[:-6]): res[obj_id] += res.get(int(child_id * 1000000 + int(str(int(obj_id))[-6:])), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
def _unit_amount(self, cr, uid, ids, name, arg, context=None): res = {} account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ 'WHERE account_id IN %s ' \ 'AND month_id IN %s ',(parent_ids, tuple(month_ids),)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in account_obj.search(cr, uid, [('parent_id', 'child_of', [int(str(int(obj_id))[:-6])])]): if child_id != int(str(int(obj_id))[:-6]): res[obj_id] += res.get(int(child_id * 1000000 + int(str(int(obj_id))[-6:])), 0.0) for id in ids: res[id] = round(res.get(id, 0.0), 2) return res
476,682
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
476,683
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: context={} if not ids: return []
476,684
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
476,685
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
476,686
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
476,687
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type = 'sale' \ group by account_analytic_line.account_id" ,(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
476,688
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
476,689
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
476,690
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id IN %s \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
476,691
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ AS ca_to_invoice \ FROM product_template \ join product_product \ on product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ on account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id =ANY(%s) \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ GROUP BY account_analytic_account.id;""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2)
476,692
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ GROUP BY account_analytic_line.account_id;",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ GROUP BY account_analytic_line.account_id;",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,693
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ GROUP BY account_analytic_line.account_id;",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ GROUP BY account_analytic_line.account_id;",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,694
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ GROUP BY account_analytic_line.account_id;",(ids2,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ GROUP BY account_analytic_line.account_id;",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,695
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ GROUP BY account_analytic_line.account_id",(ids2,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ GROUP BY account_analytic_line.account_id",(ids2,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,696
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ GROUP BY account_analytic_line.account_id",(ids2,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type='general' \ GROUP BY account_analytic_line.account_id",(ids2,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,697
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ GROUP BY account_analytic_line.account_id",(ids2,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id =ANY(%s) \ and account_analytic_journal.type='general' \ GROUP BY account_analytic_line.account_id",(parent_ids,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) for obj_id in ids: res.setdefault(obj_id, 0.0) for child_id in self.search(cr, uid, [('parent_id', 'child_of', [obj_id])]): if child_id != obj_id: res[obj_id] += res.get(child_id, 0.0) for id in ids: res[id] = round(res.get(id, 0.0),2) return res
476,698
def _total_cost_calc(self, cr, uid, ids, name, arg, context={}): res = {} ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if ids2: acc_set = ",".join(map(str, ids2)) cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
def _total_cost_calc(self, cr, uid, ids, name, arg, context={}): res = {} parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if parent_ids: cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
476,699