Automated merge with ssh://tycho.b2ck.org///home/hg/trytond

This commit is contained in:
Bertrand Chenal committed 2008-04-22 16:25:35 +02:00
commit 8c4f905c69
10 files changed
+293 -7

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
== Graph view ==
The dtd that describe the xml for a graph view is stored in trytond/ir/ui/graph.dtd.
* XML description:
- tag "graph":
- "type": vbar, hbar, line, pie
- "string": the name of the graph
- "background": an hexaecimal value for the color of the background
- "color": the main color
- "legend": a boolean to specify if the legend must be display
- tag "x", "y":
Describe the field that must be used for axis.
"x" must contain only one tag "field" and "y" must at least one but may contain many.
- tag "field":
- "name": the name of the field on the object to use
- "string": allow to override the string that comes from the object
- "key": can be used to distinguish fields with the same name but that are different with domain
- "domain": a string that is evaluate with the object value as context. If the result is true the field value is added to the graph otherwise not
- "fill": defined if the graph must be fill
* Example:
<graph string="Invoice by date" type="vbar">
<x>
<field name="invoice_date"/>
</x>
<y>
<field name="total_amount"/>
</y>
</graph>
+3
View File
@@ -1,5 +1,6 @@
"Default"
from trytond.osv import fields, OSV
from decimal import Decimal
class Default(OSV):
@@ -37,6 +38,8 @@ class Default(OSV):
test_clause = False
continue
break
ctx = {}
ctx['Decimal'] = Decimal
for default in self.browse(cursor, user, default_ids, context=context):
if default.field.name not in res:
res[default.field.name] = eval(default.value)
+56
View File
@@ -0,0 +1,56 @@
<!ELEMENT board (image|separator|labe|newline|notebook|group|hpaned|vpaned|action)*>
<!ATTLIST board string CDATA "Unknown">
<!ATTLIST board col CDATA "4">
<!ELEMENT image EMPTY>
<!ATTLIST image name CDATA #REQUIRED>
<!ATTLIST image colspan CDATA "1">
<!ATTLIST image expand (0|1) "0">
<!ATTLIST image fill (0|1) "0">
<!ATTLIST image help CDATA #IMPLIED>
<!ELEMENT separator EMPTY>
<!ATTLIST separator string CDATA "">
<!ATTLIST separator name CDATA #IMPLIED>
<!ATTLIST separator states CDATA #IMPLIED>
<!ATTLIST separator align CDATA "0.0">
<!ATTLIST separator colspan CDATA "1">
<!ATTLIST separator expand (0|1) "0">
<!ATTLIST separator fill (0|1) "0">
<!ATTLIST separator help CDATA #IMPLIED>
<!ELEMENT label EMPTY>
<!ATTLIST label string CDATA "">
<!ATTLIST label name CDATA #IMPLIED>
<!ATTLIST label states CDATA #IMPLIED>
<!ATTLIST label align CDATA "0.0">
<!ATTLIST label expand (0|1) "0">
<!ATTLIST label fill (0|1) "0">
<!ATTLIST label xexpand (0|1) "0">
<!ATTLIST label xfill (0|1) "1">
<!ATTLIST label colspan CDATA "1">
<!ATTLIST label help CDATA #IMPLIED>
<!ELEMENT newline EMPTY>
<!ELEMENT notebook (page*)>
<!ATTLIST notebook tabpos (up|down|left|right) #IMPLIED>
<!ATTLIST notebook colspan CDATA "4">
<!ELEMENT page (image|separator|labe|newline|notebook|group|hpaned|vpaned|action)*>
<!ATTLIST page angle CDATA #IMPLIED>
<!ATTLIST page string CDATA "Unknown">
<!ATTLIST page col CDATA "4">
<!ELEMENT group (image|separator|labe|newline|notebook|group|hpaned|vpaned|action)*>
<!ATTLIST group string CDATA #IMPLIED>
<!ATTLIST group colspan CDATA "1">
<!ATTLIST group expand (0|1) "0">
<!ATTLIST group fill (0|1) "1">
<!ATTLIST group rowspan CDATA "1">
<!ATTLIST group col CDATA "4">
<!ELEMENT hpaned (child1?,child2?)>
<!ATTLIST hpaned colspan CDATA "4">
<!ATTLIST hpaned position CDATA #IMPLIED>
<!ELEMENT vpaned (child1?,child2?)>
<!ATTLIST vpaned colspan CDATA "4">
<!ATTLIST vpaned position CDATA #IMPLIED>
<!ELEMENT child1 (image|separator|labe|newline|notebook|group|hpaned|vpaned|action)*>
<!ELEMENT child2 (image|separator|labe|newline|notebook|group|hpaned|vpaned|action)*>
<!ELEMENT data (xpath+)>
<!ELEMENT xpath ANY>
<!ATTLIST xpath expr CDATA #REQUIRED>
<!ATTLIST xpath position (inside|replace|after|before) "inside">
+92
View File
@@ -0,0 +1,92 @@
<!ELEMENT form (label|field|image|separator|newline|button|notebook|group|hpaned|vpaned|properties)*>
<!ATTLIST form string CDATA "Unknown">
<!ATTLIST form on_write CDATA #IMPLIED>
<!ATTLIST form col CDATA "4">
<!ELEMENT tree (field+)>
<!ATTLIST tree string CDATA "Unknown">
<!ATTLIST tree on_write CDATA #IMPLIED>
<!ATTLIST tree editable (top|bottom) #IMPLIED>
<!ATTLIST tree sequence CDATA #IMPLIED>
<!ATTLIST tree color CDATA #IMPLIED>
<!ELEMENT label EMPTY>
<!ATTLIST label string CDATA "">
<!ATTLIST label name CDATA #IMPLIED>
<!ATTLIST label states CDATA #IMPLIED>
<!ATTLIST label align CDATA "0.0">
<!ATTLIST label expand (0|1) "0">
<!ATTLIST label fill (0|1) "0">
<!ATTLIST label xexpand (0|1) "0">
<!ATTLIST label xfill (0|1) "1">
<!ATTLIST label colspan CDATA "1">
<!ATTLIST label help CDATA #IMPLIED>
<!ELEMENT field (tree|form)*>
<!ATTLIST field name CDATA #REQUIRED>
<!ATTLIST field colspan CDATA "1">
<!ATTLIST field widget (date|char|many2one|date|one2many|selection|float|numeric|float_time|interger|datetime|boolean|text|url|email|callto|sip|sha|reference|binary|many2many|image) #IMPLIED>
<!ATTLIST field saves (0|1) #IMPLIED>
<!ATTLIST field expand (0|1) #IMPLIED>
<!ATTLIST field fill (0|1) #IMPLIED>
<!ATTLIST field xexpand (0|1) "1">
<!ATTLIST field xfill (0|1) "1">
<!ATTLIST field help CDATA #IMPLIED>
<!ATTLIST field width CDATA #IMPLIED>
<!ATTLIST field height CDATA #IMPLIED>
<!ATTLIST field readonly CDATA #IMPLIED>
<!ATTLIST field required CDATA #IMPLIED>
<!ATTLIST field tree_invisible (0|1) "0">
<!ATTLIST field mode CDATA #IMPLIED>
<!ATTLIST field completion (0|1) "0">
<!ATTLIST field invisible (0|1) "0">
<!ATTLIST field sum CDATA #IMPLIED>
<!ELEMENT image EMPTY>
<!ATTLIST image name CDATA #REQUIRED>
<!ATTLIST image colspan CDATA "1">
<!ATTLIST image expand (0|1) "0">
<!ATTLIST image fill (0|1) "0">
<!ATTLIST image help CDATA #IMPLIED>
<!ELEMENT separator EMPTY>
<!ATTLIST separator string CDATA "">
<!ATTLIST separator name CDATA #IMPLIED>
<!ATTLIST separator states CDATA #IMPLIED>
<!ATTLIST separator align CDATA "0.0">
<!ATTLIST separator colspan CDATA "1">
<!ATTLIST separator expand (0|1) "0">
<!ATTLIST separator fill (0|1) "0">
<!ATTLIST separator help CDATA #IMPLIED>
<!ELEMENT newline EMPTY>
<!ELEMENT button EMPTY>
<!ATTLIST button colspan CDATA "1">
<!ATTLIST button help CDATA #IMPLIED>
<!ATTLIST button string CDATA "Unknown">
<!ATTLIST button icon CDATA #IMPLIED>
<!ATTLIST button type (workflow|object|action) "workflow">
<!ATTLIST button confirm (0|1) "0">
<!ATTLIST button name CDATA #REQUIRED>
<!ATTLIST button states CDATA #IMPLIED>
<!ELEMENT notebook (page*)>
<!ATTLIST notebook tabpos (up|down|left|right) #IMPLIED>
<!ATTLIST notebook colspan CDATA "4">
<!ELEMENT page (label|field|image|separator|newline|button|notebook|group|hpaned|vpaned|properties)*>
<!ATTLIST page angle CDATA #IMPLIED>
<!ATTLIST page string CDATA "Unknown">
<!ATTLIST page col CDATA "4">
<!ELEMENT group (label|field|image|separator|newline|button|notebook|group|hpaned|vpaned|properties)*>
<!ATTLIST group string CDATA #IMPLIED>
<!ATTLIST group colspan CDATA "1">
<!ATTLIST group expand (0|1) "0">
<!ATTLIST group fill (0|1) "1">
<!ATTLIST group rowspan CDATA "1">
<!ATTLIST group col CDATA "4">
<!ELEMENT hpaned (child1?,child2?)>
<!ATTLIST hpaned colspan CDATA "4">
<!ATTLIST hpaned position CDATA #IMPLIED>
<!ELEMENT vpaned (child1?,child2?)>
<!ATTLIST vpaned colspan CDATA "4">
<!ATTLIST vpaned position CDATA #IMPLIED>
<!ELEMENT child1 (label|field|image|separator|newline|button|notebook|group|hpaned|vpaned|properties)*>
<!ELEMENT child2 (label|field|image|separator|newline|button|notebook|group|hpaned|vpaned|properties)*>
<!ELEMENT properties EMPTY>
<!ELEMENT data (xpath+)>
<!ELEMENT xpath ANY>
<!ATTLIST xpath expr CDATA #REQUIRED>
<!ATTLIST xpath position (inside|replace|after|before) "inside">
+18
View File
@@ -0,0 +1,18 @@
<!ELEMENT graph (x, y)>
<!ATTLIST graph type (vbar|hbar|line|pie) "vbar">
<!ATTLIST graph string CDATA "Unknown">
<!ATTLIST graph background CDATA "#f5f5f5">
<!ATTLIST graph color CDATA "blue">
<!ATTLIST graph legend (0|1) "1">
<!ELEMENT x (field)>
<!ELEMENT y (field+)>
<!ELEMENT field EMPTY>
<!ATTLIST field name CDATA #REQUIRED>
<!ATTLIST field string CDATA #IMPLIED>
<!ATTLIST field key CDATA #IMPLIED>
<!ATTLIST field domain CDATA #IMPLIED>
<!ATTLIST field fill (0|1) #IMPLIED>
<!ELEMENT data (xpath+)>
<!ELEMENT xpath ANY>
<!ATTLIST xpath expr CDATA #REQUIRED>
<!ATTLIST xpath position (inside|replace|after|before) "inside">
+20
View File
@@ -0,0 +1,20 @@
<!ELEMENT tree (field+)>
<!ATTLIST tree string CDATA "Unknown">
<!ATTLIST tree on_write CDATA #IMPLIED>
<!ATTLIST tree editable (top|bottom) #IMPLIED>
<!ATTLIST tree sequence CDATA #IMPLIED>
<!ATTLIST tree colors CDATA #IMPLIED>
<!ATTLIST tree toolbar (0|1) "0">
<!ELEMENT field EMPTY>
<!ATTLIST field name CDATA #REQUIRED>
<!ATTLIST field readonly CDATA #IMPLIED>
<!ATTLIST field required CDATA #IMPLIED>
<!ATTLIST field widget (char|many2one|date|one2many|selection|float|numeric|float_time|interger|datetime|boolean|text|url|email|callto|sip) #IMPLIED>
<!ATTLIST field select (0|1|2) "0">
<!ATTLIST field tree_invisible (0|1) "0">
<!ATTLIST field icon CDATA #IMPLIED>
<!ATTLIST field sum CDATA #IMPLIED>
<!ELEMENT data (xpath+)>
<!ELEMENT xpath ANY>
<!ATTLIST xpath expr CDATA #REQUIRED>
<!ATTLIST xpath position (inside|replace|after|before) "inside">
+21 -2
View File
@@ -2,6 +2,8 @@
from trytond.osv import fields, OSV
from xml import dom
from difflib import SequenceMatcher
import os
from trytond.netsvc import Logger, LOG_ERROR, LOG_WARNING
class View(OSV):
@@ -31,8 +33,7 @@ class View(OSV):
]
def default_arch(self, cursor, user, context=None):
return '<?xml version="1.0"?>\n' \
'<tree title="Unknwown">\n\t<field name="name"/>\n</tree>'
return '<?xml version="1.0"?>'
def default_priority(self, cursor, user, context=None):
return 16
@@ -59,6 +60,24 @@ class View(OSV):
('db_id', 'in', ids),
])
for view in views:
logger = Logger()
try:
from Ft.Xml.Domlette import ValidatingReader
xml = '<?xml version="1.0"?>\n<!DOCTYPE %s SYSTEM "file://%s/%s.dtd">\n'\
% (view.inherit and 'data' or view.type,
os.path.dirname(__file__),
view.inherit and view.inherit.type or view.type)
xml += view.arch.strip()
try:
ValidatingReader.parseString(xml)
except Exception, exception:
logger.notify_channel('ir', LOG_ERROR,
'Invalid xml view: %s' % (str(exception)))
return False
except:
logger.notify_channel('ir', LOG_WARNING,
'Could not import Ft.Xml.Domlette, please install 4Suite ' \
'to have xml validation')
try:
document = dom.minidom.parseString(view.arch)
except:
+33 -1
View File
@@ -1208,6 +1208,9 @@ class ORM(object):
obj = self.pool.get(fld_def._obj)
if not obj.search(cursor, user, [('id', '=', field_value)]):
continue
if isinstance(field_value, (int, long)):
field_value = obj.name_get(cursor, user, field_value,
context=context)[0]
if fld_def._type in ('many2many'):
obj = self.pool.get(fld_def._obj)
field_value2 = []
@@ -1220,7 +1223,7 @@ class ORM(object):
if fld_def._type in ('one2many'):
obj = self.pool.get(fld_def._obj)
field_value2 = []
for i in range(len(field_value)):
for i in range(len(field_value or [])):
field_value2.append({})
for field2 in field_value[i]:
if obj._columns[field2]._type \
@@ -1229,12 +1232,41 @@ class ORM(object):
if not obj2.search(cursor, user,
[('id', '=', field_value[i][field2])]):
continue
if isinstance(field_value[i][field2],
(int, long)):
field_value[i][field2] = obj2.name_get(
cursor, user,
field_value[i][field2],
context=context)[0]
# TODO add test for many2many and one2many
field_value2[i][field2] = field_value[i][field2]
field_value = field_value2
value[field] = field_value
value = self._default_on_change(cursor, user, value, context=context)
return value
def _default_on_change(self, cursor, user, value, context=None):
res = value.copy()
val = {}
for i in self._inherits.keys():
val.update(self.pool.get(i)._default_on_change(cursor, user,
value, context=context))
for field in value.keys():
if field in self._columns:
if self._columns[field].on_change:
args = {}
for arg in self._columns[field].on_change:
args[arg] = value.get(arg, False)
val.update(getattr(self, 'on_change_' + field)(cursor, user,
[], args, context=context))
if self._columns[field]._type in ('many2many', 'one2many'):
obj = self.pool.get(self._columns[field]._obj)
for val2 in res[field]:
val2.update(obj._default_on_change(cursor, user,
val, context=context))
res.update(val)
return res
def unlink(self, cursor, user, ids, context=None):
if context is None:
context = {}
+2 -1
View File
@@ -19,7 +19,8 @@ class User(OSV):
#address_id = fields.Many2One('res.partner.address', 'Address')
active = fields.Boolean('Active')
action = fields.Many2One('ir.action', 'Home Action')
menu = fields.Many2One('ir.action', 'Menu Action')
menu = fields.Many2One('ir.action', 'Menu Action',
domain=[('usage','=','menu')], required=True)
groups = fields.Many2Many('res.group', 'res_group_user_rel',
'uid', 'gid', 'Groups')
rule_groups = fields.Many2Many('ir.rule.group', 'user_rule_group_rel',
+1 -3
View File
@@ -33,9 +33,7 @@
<label name="action"/>
<field name="action" required="1"/>
<label name="menu"/>
<field name="menu"
domain="[('usage','=','menu')]"
required="True"/>
<field name="menu"/>
<separator name="signature" colspan="4"/>
<field name="signature" colspan="4"/>
</page>