Reviewers: ,
Please review this at http://codereview.tryton.org/77006/
Affected files:
M tryton/gui/window/view_form/model/field.py
M tryton/gui/window/view_form/model/group.py
M tryton/gui/window/view_form/model/record.py
M tryton/gui/window/view_form/screen/screen.py
M tryton/gui/window/view_form/view/list.py
Index: tryton/gui/window/view_form/model/field.py
===================================================================
--- a/tryton/gui/window/view_form/model/field.py
+++ b/tryton/gui/window/view_form/model/field.py
@@ -332,7 +332,7 @@
value = record.parent.id
else:
value = False
- if value and isinstance(value, (int, long)) and value > 0:
+ if value and isinstance(value, (int, long)) and value >= 0:
args = ('model', self.attrs['relation'], 'read', value,
['rec_name'], rpc.CONTEXT)
try:
@@ -468,7 +468,7 @@
for record2 in record.value[self.name]:
if record2 in record_removed or record2 in record_deleted:
continue
- if record2.id > 0:
+ if record2.id >= 0:
values = record2.get(check_load=check_load,
get_readonly=readonly, get_modifiedonly=modified)
if record2.modified and values:
@@ -580,7 +580,7 @@
group.load_fields(fields_dict)
if record.value.get(self.name):
group.record_deleted.extend(x for x in record.value[self.name]
- if x.id > 0)
+ if x.id >= 0)
group.record_deleted.extend(record.value[self.name].record_deleted)
group.record_removed.extend(record.value[self.name].record_removed)
record.value[self.name] = group
@@ -687,7 +687,7 @@
class M2MField(O2MField):
def get_default(self, record):
- return [x.id for x in record.value.get(self.name) or [] if x.id >
0]
+ return [x.id for x in record.value.get(self.name) or [] if x.id >=
0]
def get_eval(self, record, check_load=True):
return [x.id for x in record.value.get(self.name) or []]
@@ -763,7 +763,7 @@
ref_id = int(ref_id)
if not ref_id:
ref_str = ''
- if not ref_str and ref_id > 0:
+ if not ref_str and ref_id >= 0:
args = ('model', ref_model, 'read', ref_id,
['rec_name'], rpc.CONTEXT)
try:
Index: tryton/gui/window/view_form/model/group.py
===================================================================
--- a/tryton/gui/window/view_form/model/group.py
+++ b/tryton/gui/window/view_form/model/group.py
@@ -297,7 +297,7 @@
def remove(self, record, remove=False, modified=True, signal=True,
force_remove=False):
idx = self.index(record)
- if self[idx].id > 0:
+ if self[idx].id >= 0:
if remove:
if self[idx] in self.record_deleted:
self.record_deleted.remove(self[idx])
@@ -312,7 +312,7 @@
if modified:
record.modified_fields.setdefault('id')
record.signal('record-modified')
- if not record.parent or self[idx].id <= 0 or force_remove:
+ if not record.parent or self[idx].id < 0 or force_remove:
self._remove(self[idx])
if len(self):
@@ -364,7 +364,7 @@
new = []
for record in self:
- if record.id <= 0:
+ if record.id < 0:
new.append(record)
ctx = context.copy()
Index: tryton/gui/window/view_form/model/record.py
===================================================================
--- a/tryton/gui/window/view_form/model/record.py
+++ b/tryton/gui/window/view_form/model/record.py
@@ -19,7 +19,10 @@
def __init__(self, model_name, obj_id, group=None):
super(Record, self).__init__()
self.model_name = model_name
- self.id = obj_id or Record.id
+ if obj_id is None:
+ self.id = Record.id
+ else:
+ self.id = obj_id
if self.id < 0:
Record.id -= 1
self._loaded = set()
@@ -35,7 +38,7 @@
self.autocompletion = {}
def __getitem__(self, name, raise_exception=False):
- if name not in self._loaded and self.id > 0:
+ if name not in self._loaded and self.id >= 0:
ids = [self.id]
if name == '*':
loading = reduce(
@@ -53,11 +56,11 @@
idx + n < length) and n < 100:
if idx - n >= 0:
record = self.group[idx - n]
- if name not in record._loaded and record.id > 0:
+ if name not in record._loaded and record.id >= 0:
ids.append(record.id)
if idx + n < length:
record = self.group[idx + n]
- if name not in record._loaded and record.id > 0:
+ if name not in record._loaded and record.id >= 0:
ids.append(record.id)
n += 1
if loading == 'eager':
Index: tryton/gui/window/view_form/screen/screen.py
===================================================================
--- a/tryton/gui/window/view_form/screen/screen.py
+++ b/tryton/gui/window/view_form/screen/screen.py
@@ -519,7 +519,7 @@
reload_ids = []
if self.current_view.view_type == 'form' and self.current_record:
record_id = self.current_record.id
- if delete and record_id > 0:
+ if delete and record_id >= 0:
context = {}
context.update(rpc.CONTEXT)
context.update(self.context)
Index: tryton/gui/window/view_form/view/list.py
===================================================================
--- a/tryton/gui/window/view_form/view/list.py
+++ b/tryton/gui/window/view_form/view/list.py
@@ -800,7 +800,7 @@
def sel_ids_get(self):
def _func_sel_get(store, path, iter, ids):
record = store.on_get_iter(path)
- if record and record.id > 0:
+ if record and record.id >= 0:
ids.append(record.id)
ids = []
sel = self.widget_tree.get_selection()
--
[email protected] mailing list