Merge with 1037

bzr revid: jean-baptiste.aubort@camptocamp.com-20080902153903-ti0a1hzxduwc6ocy
This commit is contained in:
Jean-Baptiste Aubort
2008-09-02 17:39:03 +02:00
16 changed files with 243 additions and 163 deletions
+4 -1
View File
@@ -173,7 +173,10 @@ def create_graph(module_list, force=None):
for module in module_list:
if module[-4:]=='.zip':
module = module[:-4]
mod_path = get_module_path(module)
try:
mod_path = get_module_path(module)
except IOError:
continue
terp_file = get_module_resource(module, '__terp__.py')
if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path):
try:
+3 -1
View File
@@ -4,8 +4,10 @@
<menuitem icon="terp-administration" id="menu_administration" name="Administration" sequence="20"/>
<menuitem id="menu_custom" name="Custom" parent="base.menu_administration" sequence="2"/>
<menuitem id="menu_translation" name="Translations" parent="base.menu_administration" sequence="4"/>
<menuitem id="menu_translation_app" name="Application Terms" parent="base.menu_translation" sequence="4"/>
<menuitem id="menu_translation_export" name="Import / Export" parent="base.menu_translation" sequence="4"/>
<menuitem id="menu_users" name="Users" parent="base.menu_administration" sequence="6"/>
<menuitem id="menu_security" name="Security" parent="base.menu_administration" sequence="8"/>
<menuitem id="menu_management" name="Modules Management" parent="base.menu_administration" sequence="10"/>
</data>
</terp>
</terp>
+1 -20
View File
@@ -6,26 +6,7 @@
Languages
======================
-->
<record id="view_lang" model="ir.ui.view">
<field name="name">Languages</field>
<field name="model">res.lang</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Language">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="translatable"/>
<field name="direction"/>
</form>
</field>
</record>
<record id="action_lang" model="ir.actions.act_window">
<field name="name">Languages</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.lang</field>
<field name="view_type">form</field>
</record>
<menuitem id="next_id_2" name="Interface" parent="base.menu_custom"/><menuitem action="action_lang" id="menu_action_lang" parent="next_id_2"/>
<menuitem id="next_id_2" name="Interface" parent="base.menu_custom"/>
<!--
======================
-2
View File
@@ -1,6 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_ir_act_window_group_user,ir_act_window group_user,model_ir_act_window,group_user,1,0,0,0
access_ir_act_window_view_group_user,ir_act_window_view group_user,model_ir_act_window_view,group_user,1,0,0,0
access_ir_attachment_group_system,ir_attachment group_system,model_ir_attachment,group_system,1,0,0,0
access_ir_cron_group_cron,ir_cron group_cron,model_ir_cron,group_cron,1,1,1,1
access_ir_default_group_system,ir_default group_system,model_ir_default,group_system,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
access_ir_act_window_group_user ir_act_window group_user model_ir_act_window group_user 1 0 0 0
access_ir_act_window_view_group_user ir_act_window_view group_user model_ir_act_window_view group_user 1 0 0 0
2 access_ir_attachment_group_system ir_attachment group_system model_ir_attachment group_system 1 0 0 0
3 access_ir_cron_group_cron ir_cron group_cron model_ir_cron group_cron 1 1 1 1
4 access_ir_default_group_system ir_default group_system model_ir_default group_system 1 0 0 0
+71 -37
View File
@@ -96,7 +96,8 @@
<field name="view_id" ref="sequence_view_tree"/>
<field name="context">{'active_test': False}</field>
</record>
<menuitem id="next_id_5" name="Sequences" parent="base.menu_custom"/><menuitem action="ir_sequence_form" id="menu_ir_sequence_form" parent="next_id_5"/>
<menuitem id="next_id_5" name="Sequences" parent="base.menu_custom"/>
<menuitem action="ir_sequence_form" id="menu_ir_sequence_form" parent="next_id_5"/>
<!-- Sequences Types -->
<record id="sequence_type_form_view" model="ir.ui.view">
@@ -154,7 +155,8 @@
<field name="view_type">form</field>
<field name="view_id" ref="action_view_tree"/>
</record>
<menuitem id="next_id_6" name="Actions" parent="base.next_id_4"/><menuitem action="ir_sequence_actions" id="menu_ir_sequence_actions" parent="next_id_6"/>
<menuitem id="next_id_6" name="Actions" parent="base.next_id_4"/>
<menuitem action="ir_sequence_actions" id="menu_ir_sequence_actions" parent="next_id_6"/>
<record id="act_report_custom_view" model="ir.ui.view">
<field name="name">ir.actions.report.custom</field>
@@ -631,21 +633,32 @@
<field name="state"/>
</tree>
<form string="Fields Description">
<field name="name" select="1"/>
<field colspan="4" name="field_description" select="1"/>
<field name="ttype" select="1"/>
<field name="relation" select="1"/>
<field name="required" select="2"/>
<field name="readonly" select="2"/>
<field name="size" select="1"/>
<field name="on_delete" select="1"/>
<field name="select_level" select="2"/>
<field name="translate"/>
<field name="selection"/>
<field name="domain"/>
<field name="state" readonly="1"/>
<group colspan="4" col="4">
<field name="name" select="1"/>
<field colspan="4" name="field_description" select="2"/>
</group>
<group colspan="2" col="2">
<separator string="Field Type" colspan="2"/>
<field name="ttype" select="2"/>
<field name="relation" select="2"/>
<field name="selection"/>
<field name="size"/>
<field name="state"/>
<field name="domain"/>
</group>
<group colspan="2" col="2">
<separator string="Properties" colspan="2"/>
<field name="required" select="2"/>
<field name="readonly" select="2"/>
<field name="select_level"/>
<field name="translate"/>
<field name="relate"/>
<field name="on_delete"/>
</group>
<separator string="Security on Groups" colspan="4"/>
<field name="groups" colspan="4" nolabel="1"/>
</form>
</field>
<separator colspan="4" string="Status"/>
@@ -693,22 +706,34 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Fields">
<field name="name" select="1"/>
<field name="model_id" readonly="1"/>
<field colspan="4" name="field_description" select="2"/>
<field name="ttype" select="2"/>
<field name="relation" select="2"/>
<group colspan="4" col="6">
<field name="name" select="1"/>
<field name="field_description" colspan="4" select="2"/>
<field name="model_id" readonly="1"/>
</group>
<field name="required" select="2"/>
<field name="readonly" select="2"/>
<group colspan="2" col="2">
<separator string="Field Type" colspan="2"/>
<field name="ttype" select="2"/>
<field name="relation" select="2"/>
<field name="selection"/>
<field name="size"/>
<field name="state"/>
<field name="domain"/>
</group>
<group colspan="2" col="2">
<separator string="Properties" colspan="2"/>
<field name="required" select="2"/>
<field name="readonly" select="2"/>
<field name="select_level"/>
<field name="translate"/>
<field name="relate"/>
<field name="on_delete"/>
</group>
<field name="size" select="1"/>
<field name="on_delete" select="1"/>
<field name="select_level" select="2"/>
<field name="translate"/>
<field name="selection"/>
<field name="domain"/>
<field name="state" readonly="1"/>
<separator string="Security on Groups" colspan="4"/>
<field name="groups" colspan="4" nolabel="1"/>
</form>
</field>
</record>
@@ -782,7 +807,15 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_translation_tree"/>
</record>
<menuitem action="action_translation" id="menu_action_translation" parent="base.menu_translation"/>
<menuitem action="action_translation" id="menu_action_translation" parent="base.menu_translation_app"/>
<record id="action_translation_untrans" model="ir.actions.act_window">
<field name="name">Untranslated terms</field>
<field name="res_model">ir.translation</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_translation_tree"/>
<field name="domain">[('value','=','')]</field>
</record>
<menuitem action="action_translation_untrans" id="menu_action_translation_untrans" parent="menu_action_translation"/>
<!--
=============================================================
@@ -906,7 +939,8 @@ Cron Jobs
<field name="context">{'active_test': False}</field>
<field name="view_id" ref="ir_cron_view_tree"/>
</record>
<menuitem id="next_id_10" name="Scheduler" parent="base.menu_custom"/><menuitem action="ir_cron_act" id="menu_ir_cron_act" parent="next_id_10"/>
<menuitem id="next_id_10" name="Scheduler" parent="base.menu_custom"/>
<menuitem action="ir_cron_act" id="menu_ir_cron_act" parent="next_id_10"/>
<record id="ir_access_view_tree" model="ir.ui.view">
@@ -1196,15 +1230,15 @@ Cron Jobs
<page string="Create / Write" attrs="{'invisible':[('state','=','python'),('state','=','dummy'),('state','=','trigger'), ('state','=','sms'), ('state','=','email'), ('state','=','client_action'), ('state','=','other')]}">
<separator colspan="4" string="Fields Mapping"/>
<field name="otype"/>
<field name="srcmodel_id" select="2" attrs="{'readonly':[('type','!=','new'),('type','!=','object_create')]}"/>
<field name="srcmodel_id" select="2" attrs="{'readonly':[('type','!=','new'),('type','=','copy'),('state','=','write_create')]}"/>
<field name="fields_lines" nolabel="1" select="2" colspan="4">
<tree string="Field Mappings" editable="top">
<field name="col1" domain="[('model_id','=',parent.srcmodel_id)]"/>
<field name="col1" domain="[('model_id','=',parent.srcmodel_id or parent.model_id)]"/>
<field name="type"/>
<field name="value"/>
<field name="value" colsapan="4"/>
</tree>
<form string="Field Mapping">
<field name="col1" domain="[('model_id','=',parent.srcmodel_id)]"/>
<field name="col1" domain="[('model_id','=',parent.srcmodel_id or parent.model_id)]"/>
<field name="type"/>
<field name="value" colsapan="4"/>
</form>
+12 -6
View File
@@ -385,7 +385,7 @@ class actions_server(osv.osv):
'otype': fields.selection([
('copy','Create in Same Model'),
('new','Create in Other Model')
], 'Create Model', required=True, size=32, change_default=True),
], 'Create Model', size=32, change_default=True),
}
_defaults = {
'state': lambda *a: 'dummy',
@@ -399,7 +399,8 @@ class actions_server(osv.osv):
# - uid
# - ids
# If you plan to return an action, assign: action = {...}
"""
""",
'otype': lambda *a: 'copy',
}
def get_field_value(self, cr, uid, action, context):
@@ -496,7 +497,6 @@ class actions_server(osv.osv):
logger.notifyChannel('sms', netsvc.LOG_INFO, 'SMS successfully send to : %s' % (action.address))
else:
logger.notifyChannel('sms', netsvc.LOG_ERROR, 'Failed to send SMS to : %s' % (action.address))
if action.state == 'other':
localdict = {
'self': self.pool.get(action.model_id.model),
@@ -535,9 +535,15 @@ class actions_server(osv.osv):
else:
expr = exp.value
res[exp.col1.name] = expr
obj_pool = self.pool.get(action.model_id.model)
id = context.get('active_id')
obj_pool.copy(cr, uid, id, res)
obj_pool = None
if action.state == 'object_create' and action.otype == 'new':
obj_pool = self.pool.get(action.srcmodel_id.model)
obj_pool.create(cr, uid, res)
else:
obj_pool = self.pool.get(action.model_id.model)
id = context.get('active_id')
obj_pool.copy(cr, uid, id, res)
return False
actions_server()
+2 -2
View File
@@ -275,7 +275,7 @@ class module(osv.osv):
mdemo = True
for dep in module.dependencies_id:
if dep.state == 'unknown':
raise orm.except_orm(_('Error'), _('Unmet dependency: %s') % (dep.name,))
raise orm.except_orm(_('Error'), _('You try to install a module that depends on the module: %s.\nBut this module is not available in your system.') % (dep.name,))
if dep.state != newstate:
ids2 = self.search(cr, uid, [('name','=',dep.name)])
mdemo = self.state_update(cr, uid, ids2, newstate, states_to_update, context, level-1,) and mdemo
@@ -566,7 +566,7 @@ class module_config_wizard_step(osv.osv):
'note':fields.text('Text'),
'action_id':fields.many2one('ir.actions.act_window', 'Action', select=True,required=True, ondelete='cascade'),
'sequence':fields.integer('Sequence'),
'state':fields.selection([('open', 'Open'),('done', 'Done'),('skip','Skip')], string='State', required=True)
'state':fields.selection([('open', 'Not Started'),('done', 'Done'),('skip','Skipped')], string='State', required=True)
}
_defaults={
'state': lambda *a: 'open',
+65 -58
View File
@@ -5,99 +5,106 @@
<field name="name">Import module</field>
<field name="wiz_name">base.module.import</field>
</record>
<menuitem action="wizard_base_module_import" id="menu_wizard_module_import" parent="base.menu_management" type="wizard"/>
<menuitem action="wizard_base_module_import" id="menu_wizard_module_import" parent="menu_management" type="wizard"/>
<record id="wizard_update" model="ir.actions.wizard">
<field name="name">Download module list</field>
<field name="name">Update Modules List</field>
<field name="wiz_name">module.module.update</field>
</record>
<menuitem action="wizard_update" icon="STOCK_CONVERT" id="menu_module_update" parent="base.menu_management" type="wizard"/>
<menuitem action="wizard_update" icon="STOCK_CONVERT" id="menu_module_update" parent="menu_management" type="wizard"/>
<wizard id="wizard_upgrade" model="ir.module.module" name="module.upgrade" string="Apply Scheduled Upgrades"/>
<menuitem action="wizard_upgrade" id="menu_wizard_upgrade" parent="base.menu_management" type="wizard"/>
<menuitem action="wizard_upgrade" id="menu_wizard_upgrade" parent="menu_management" type="wizard"/>
<record id="wizard_lang_install" model="ir.actions.wizard">
<field name="name">Install new language file</field>
<field name="wiz_name">module.lang.install</field>
</record>
<menuitem action="wizard_lang_install" id="menu_wizard_lang_install" parent="base.menu_translation" type="wizard"/>
<menuitem action="wizard_lang_install" id="menu_wizard_lang_install" parent="menu_translation" type="wizard"/>
<record id="wizard_lang_export" model="ir.ui.view">
<field name="name">Export Language</field>
<record id="wizard_lang_export" model="ir.ui.view">
<field name="name">Export a Translation File</field>
<field name="model">wizard.module.lang.export</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form col="3" string="Export language">
<image name="gtk-dialog-info"/>
<group col="2" states="choose" fill="0" height="500">
<separator string="Export translation file" colspan="2"/>
<field name="lang" width="300"/>
<field name="format"/>
<field name="modules" width="500" height="200"/>
<field name="state" invisible="1"/>
<newline/><label/>
</group>
<group col="1" states="get" fill="0">
<separator string="Export done"/>
<field name="data" readonly="1" nolabel="1"/>
<field name="advice" nolabel="1" height="80"/>
</group>
<group col="2" colspan="3" fill="0">
<button states="choose" icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/>
<button states="choose" icon="gtk-ok" name="act_getfile" string="Get file" type="object"/>
<button states="get" icon="gtk-close" name="act_destroy" special="cancel" string="Close" type="object"/>
</group>
</form>
</field>
<field name="arch" type="xml">
<form col="3" string="Export language">
<image name="gtk-dialog-info"/>
<group col="2" states="choose" fill="0" height="500">
<separator string="Export translation file" colspan="2"/>
<field name="lang" width="300" required="1"/>
<field name="format" required="1"/>
<field name="modules" width="500" height="200"/>
<label colspan="2" string="The official translations pack of all OpenERP/OpenObjects module are
managed through launchpad. We use their online interface to synchronize
all translations efforts.
To improve some terms of the official translations of OpenERP, you should
modify the terms directly on the launchpad interface. If you made lots
of translations for your own module, you can also publish all your
translation at once. To do this, you must:
If you created a new module, you must send the generated .pot file by email to
the translation group: ... They will review and integrate." align="0.0"/>
<field name="state" invisible="1"/>
<newline/>
</group>
<group col="1" states="get" fill="0">
<separator string="Export done"/>
<field name="data" readonly="1" nolabel="1"/>
<field name="advice" nolabel="1" height="80"/>
</group>
<group col="2" colspan="3" fill="0">
<button states="choose" icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/>
<button states="choose" icon="gtk-ok" name="act_getfile" string="Get file" type="object"/>
<button states="get" icon="gtk-close" name="act_destroy" special="cancel" string="Close" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_wizard_lang_export" model="ir.actions.act_window">
<field name="name">Export language</field>
<record id="action_wizard_lang_export" model="ir.actions.act_window">
<field name="name">Export a Translation File</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.module.lang.export</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem action="action_wizard_lang_export" id="menu_wizard_lang_export" parent="base.menu_translation"/>
<menuitem action="action_wizard_lang_export" id="menu_wizard_lang_export" parent="menu_translation_export"/>
<record id="wizard_lang_import" model="ir.actions.wizard">
<field name="name">Import language</field>
<field name="name">Import a Translation File</field>
<field name="wiz_name">module.lang.import</field>
</record>
<menuitem action="wizard_lang_import" id="menu_wizard_lang_import" parent="base.menu_translation" type="wizard"/>
<record id="wizard_lang_import" model="ir.actions.wizard">
<field name="name">Import language</field>
<field name="wiz_name">module.lang.import</field>
</record>
<menuitem action="wizard_lang_import" id="menu_wizard_lang_import" parent="base.menu_translation" type="wizard"/>
<record id="wizard_update_translations" model="ir.ui.view">
<menuitem action="wizard_lang_import" id="menu_wizard_lang_import" parent="menu_translation_export" type="wizard"/>
<record id="wizard_update_translations" model="ir.ui.view">
<field name="name">Update Translations</field>
<field name="model">wizard.module.update_translations</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form col="3" string="Update Translations">
<image name="gtk-dialog-info"/>
<group col="2" fill="0" height="500">
<field name="lang" width="300"/>
</group>
<group col="2" colspan="3" fill="0">
<button icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/>
<button icon="gtk-ok" name="act_update" string="Update" type="object"/>
</group>
</form>
</field>
<field name="arch" type="xml">
<form col="3" string="Update Translations">
<image name="gtk-dialog-info"/>
<group col="2" fill="0" height="500">
<field name="lang" width="300"/>
</group>
<label align="0.0" colspan="4" string="This wizard will detect new terms in the application so that you can update them manually."/>
<separator colspan="4"/>
<group col="2" colspan="4" fill="0">
<button icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/>
<button icon="gtk-ok" name="act_update" string="Update" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_wizard_update_translations" model="ir.actions.act_window">
<field name="name">Update Translations</field>
<record id="action_wizard_update_translations" model="ir.actions.act_window">
<field name="name">Reload Official Translations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">wizard.module.update_translations</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem action="action_wizard_update_translations" id="menu_wizard_update_translations" parent="base.menu_translation"/>
<menuitem action="action_wizard_update_translations" id="menu_wizard_update_translations" parent="menu_translation_app"/>
</data>
</terp>
@@ -44,7 +44,7 @@ class wizard_export_lang(osv.osv_memory):
lang_obj=pooler.get_pool(cr.dbname).get('res.lang')
ids=lang_obj.search(cr, uid, ['&', ('active', '=', True), ('translatable', '=', True),])
langs=lang_obj.browse(cr, uid, ids)
return [('', _('New language'))] + [(lang.code, lang.name) for lang in langs]
return [(lang.code, lang.name) for lang in langs]
def act_cancel(self, cr, uid, ids, context=None):
@@ -56,28 +56,31 @@ class wizard_export_lang(osv.osv_memory):
def act_getfile(self, cr, uid, ids, context=None):
this = self.browse(cr, uid, ids)[0]
mods = map(lambda m: m.name, this.modules)
mods = map(lambda m: m.name, this.modules) or ['all']
mods.sort()
buf=StringIO.StringIO()
tools.trans_export(this.lang, mods, buf, this.format, dbname=cr.dbname)
if this.format == 'csv':
this.advice = _("Save this document to a .CSV file and open it with your favourite spreadsheet software. The file encoding is UTF-8. You have to translate the latest column before reimporting it.")
elif this.format == 'po':
ext = this.lang and '.po' or '.pot'
this.advice = _("Save this document to a %s file and edit it with a specific software or a text editor. The file encoding is UTF-8." % (ext,))
if not this.lang:
this.format = 'pot'
this.advice = _("Save this document to a %s file and edit it with a specific software or a text editor. The file encoding is UTF-8.") % ('.'+this.format,)
elif this.format == 'tgz':
ext = this.lang and '.po' or '.pot'
this.advice = _('Save this document to a .tgz file. This archive containt UTF-8 %s files and may be uploaded to launchpad.' % (ext,))
this.advice = _('Save this document to a .tgz file. This archive containt UTF-8 %s files and may be uploaded to launchpad.') % (ext,)
this.name = "%s.%s" % (this.lang or _('new'), this.format)
out=base64.encodestring(buf.getvalue())
buf.close()
return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice}, context=context)
return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice, 'name':this.name}, context=context)
_name = "wizard.module.lang.export"
_columns = {
'lang': fields.selection(_get_languages, 'Language'), # not required: unset = new language
'name': fields.char('Filename', 16, readonly=True),
'lang': fields.selection(_get_languages, 'Language', help='To export a new language, do not select a language.'), # not required: unset = new language
'format': fields.selection( ( ('csv','CSV File'), ('po','PO File'), ('tgz', 'TGZ Archive')), 'File Format', required=True),
'modules': fields.many2many('ir.module.module', 'rel_modules_langexport', 'wiz_id', 'module_id', 'Modules', domain=[('state','=','installed')]),
'data': fields.binary('File', readonly=True),
@@ -86,7 +89,8 @@ class wizard_export_lang(osv.osv_memory):
('get','get'), # get the file
) ),
}
_defaults = { 'state': lambda *a: 'choose', }
_defaults = { 'state': lambda *a: 'choose',
}
wizard_export_lang()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1 -2
View File
@@ -142,7 +142,6 @@ class res_partner(osv.osv):
'user_id': fields.many2one('res.users', 'Dedicated Salesman', help='The internal user that is in charge of communicating with this partner if any.'),
'responsible': fields.many2one('res.users', 'Users'),
'vat': fields.char('VAT',size=32 ,help="Value Added Tax number"),
'vat_subject': fields.boolean('Subjected to the VAT'),
'bank_ids': fields.one2many('res.partner.bank', 'partner_id', 'Banks'),
'website': fields.char('Website',size=64),
'comment': fields.text('Notes'),
@@ -277,7 +276,7 @@ class res_partner_address(osv.osv):
_name = 'res.partner.address'
_order = 'id'
_columns = {
'partner_id': fields.many2one('res.partner', 'Partner', required=True, ondelete='cascade', select=True),
'partner_id': fields.many2one('res.partner', 'Partner', ondelete='cascade', select=True),
'type': fields.selection( [ ('default','Default'),('invoice','Invoice'), ('delivery','Delivery'), ('contact','Contact'), ('other','Other') ],'Address Type'),
'function': fields.many2one('res.partner.function', 'Function'),
'title': fields.selection(_contact_title_get, 'Title', size=32),
+2 -2
View File
@@ -21,6 +21,6 @@
<field name="view_type">form</field>
<field name="context">{'active_test': False}</field>
</record>
<menuitem action="res_lang_act_window" id="menu_res_lang_act_window" parent="base.menu_translation"/>
<menuitem action="res_lang_act_window" id="menu_res_lang_act_window" parent="base.menu_translation_app"/>
</data>
</terp>
</terp>
+1 -1
View File
@@ -70,7 +70,7 @@ class expression(object):
return []
ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context)
return ids+rg(ids2, table, parent)
return [(left, 'in', rg(ids2, table, parent))]
return [(left, 'in', rg(ids, table, parent))]
self.__main_table = table
+24 -2
View File
@@ -102,10 +102,10 @@ class _column(object):
def set_memory(self, cr, obj, id, name, value, user=None, context=None):
raise Exception(_('Not implemented set_memory method !'))
def get_memory(self, cr, obj, ids, name, context=None, values=None):
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None):
raise Exception(_('Not implemented get_memory method !'))
def get(self, cr, obj, ids, name, context=None, values=None):
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
raise Exception(_('undefined get method !'))
def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None):
@@ -203,6 +203,28 @@ class binary(_column):
_symbol_f = lambda symb: symb and psycopg.Binary(symb) or None
_symbol_set = (_symbol_c, _symbol_f)
_classic_read = False
def get_memory(self, cr, obj, ids, name, user=None, context=None, values=None):
if not context:
context = {}
if not values:
values = []
res = {}
for i in ids:
val = None
for v in values:
if v['id'] == i:
val = v[name]
break
res.setdefault(i, val)
if context.get('get_binary_size', True):
res[i] = tools.human_size(val)
return res
get = get_memory
class selection(_column):
_type = 'selection'
+27 -17
View File
@@ -296,15 +296,14 @@ class orm_template(object):
_table = None
def _field_create(self, cr, context={}):
cr.execute("SELECT id FROM ir_model WHERE model='%s'" % self._name)
cr.execute("SELECT id FROM ir_model_data WHERE name='%s'" % ('model_'+self._name.replace('.','_'),))
if not cr.rowcount:
# reference model in order to have a description of its fonctionnality in custom_report
cr.execute('SELECT nextval(%s)', ('ir_model_id_seq',))
id = cr.fetchone()[0]
cr.execute("INSERT INTO ir_model (id,model, name, info) VALUES (%s, %s, %s, %s)", (id, self._name, self._description, self.__doc__))
if 'module' in context:
cr.execute("INSERT INTO ir_model_data (name,date_init,date_update,module,model,res_id) VALUES (%s, now(), now(), %s, %s, %s)", \
('model_'+self._table, context['module'], 'ir.model', id)
('model_'+self._name.replace('.','_'), context['module'], 'ir.model', id)
)
cr.commit()
@@ -1113,22 +1112,26 @@ class orm_memory(orm_template):
self.unlink(ids)
return True
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
if not fields:
fields = self._columns.keys()
def read(self, cr, user, ids, fields_to_read=None, context=None, load='_classic_read'):
if not context:
context = {}
if not fields_to_read:
fields_to_read = self._columns.keys()
result = []
if self.datas:
for id in ids:
r = {'id': id}
for f in fields:
for f in fields_to_read:
if id in self.datas:
r[f] = self.datas[id].get(f, False)
if r[f] and isinstance(self._columns[f], fields.binary) and context.get('get_binary_size', True):
r[f] = len(r[f])
result.append(r)
if id in self.datas:
self.datas[id]['internal.date_access'] = time.time()
fields_post = filter(lambda x: x in self._columns and not getattr(self._columns[x], load), fields)
fields_post = filter(lambda x: x in self._columns and not getattr(self._columns[x], load), fields_to_read)
for f in fields_post:
res2 = self._columns[f].get_memory(cr, self, ids, f, user, context=context, values=False)
res2 = self._columns[f].get_memory(cr, self, ids, f, user, context=context, values=result)
for record in result:
record[f] = res2[record['id']]
return result
@@ -1686,24 +1689,31 @@ class orm(orm_template):
return result[0]
return result
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'):
def _read_flat(self, cr, user, ids, fields_to_read, context=None, load='_classic_read'):
if not context:
context = {}
if not ids:
return []
if fields == None:
fields = self._columns.keys()
if fields_to_read == None:
fields_to_read = self._columns.keys()
# construct a clause for the rules :
d1, d2 = self.pool.get('ir.rule').domain_get(cr, user, self._name)
# all inherited fields + all non inherited fields for which the attribute whose name is in load is True
fields_pre = filter(lambda x: x in self._columns and getattr(self._columns[x], '_classic_write'), fields) + self._inherits.values()
fields_pre = filter(lambda x: x in self._columns and getattr(self._columns[x], '_classic_write'), fields_to_read) + self._inherits.values()
res = []
if len(fields_pre):
fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre)
def convert_field(f):
if f in ('create_date', 'write_date'):
return "date_trunc('second', %s) as %s" % (f, f)
if isinstance(self._columns[f], fields.binary) and context.get('get_binary_size', True):
return "length(%s) as %s" % (f,f)
return '"%s"' % (f,)
#fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre)
fields_pre2 = map(convert_field, fields_pre)
for i in range(0, len(ids), cr.IN_MAX):
sub_ids = ids[i:i+cr.IN_MAX]
if d1:
@@ -1748,7 +1758,7 @@ class orm(orm_template):
del record[col]
# all fields which need to be post-processed by a simple function (symbol_get)
fields_post = filter(lambda x: x in self._columns and self._columns[x]._symbol_get, fields)
fields_post = filter(lambda x: x in self._columns and self._columns[x]._symbol_get, fields_to_read)
if fields_post:
# maybe it would be faster to iterate on the fields then on res, so that we wouldn't need
# to get the _symbol_get in each occurence
@@ -1758,7 +1768,7 @@ class orm(orm_template):
ids = map(lambda x: x['id'], res)
# all non inherited fields for which the attribute whose name is in load is False
fields_post = filter(lambda x: x in self._columns and not getattr(self._columns[x], load), fields)
fields_post = filter(lambda x: x in self._columns and not getattr(self._columns[x], load), fields_to_read)
# Compute POST fields
todo = {}
@@ -2238,9 +2248,9 @@ class orm(orm_template):
else:
cr.execute('select max(parent_right) from '+self._table)
pleft = cr.fetchone()[0] or 0
cr.execute('update '+self._table+' set parent_left=%d,parent_right=%d', (pleft+1,pleft+2))
cr.execute('update '+self._table+' set parent_left=parent_left+2 where parent_left>%d', (pleft,))
cr.execute('update '+self._table+' set parent_right=parent_right+2 where parent_right>%d', (pleft,))
cr.execute('update '+self._table+' set parent_left=%d,parent_right=%d where id=%d', (pleft+1,pleft+2,id_new))
wf_service = netsvc.LocalService("workflow")
wf_service.trg_create(user, self._name, id_new, cr)
+12
View File
@@ -672,6 +672,18 @@ def mod10r(number):
return result + str((10 - report) % 10)
def human_size(sz):
"""
Return the size in a human readable format
"""
if not sz:
return False
units = ('bytes', 'Kb', 'Mb', 'Gb')
s, i = float(sz), 0
while s >= 1024 and i < len(units)-1:
s = s / 1024
i = i + 1
return "%0.2f %s" % (s, units[i])
if __name__ == '__main__':
+4 -2
View File
@@ -324,7 +324,7 @@ def trans_generate(lang, modules, dbname=None):
_to_translate = []
def push_translation(module, type, name, id, source):
tuple = (module, type, name, id, source)
if not tuple in _to_translate:
if source and tuple not in _to_translate:
_to_translate.append(tuple)
@@ -354,7 +354,7 @@ def trans_generate(lang, modules, dbname=None):
# export arch
arch = result['arch']
if not isinstance(arch, UpdateableStr):
if arch and not isinstance(arch, UpdateableStr):
d = xml.dom.minidom.parseString(arch)
for t in trans_parse_view(d.documentElement):
push_translation(module, 'wizard_view', name, 0, t)
@@ -368,6 +368,8 @@ def trans_generate(lang, modules, dbname=None):
elif model=='ir.model.fields':
field_name = obj.name
if not field_name in pool.get(obj.model)._columns:
continue
field_def = pool.get(obj.model)._columns[field_name]
name = obj.model + "," + field_name