qdp (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-configuration-rework into
lp:openobject-server.
Requested reviews:
Vo Minh Thu (OpenERP) (vmt-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-configuration-rework/+merge/66464
changes about usability and config wizards. Need to be tested with this branch
of addons (also ready to be merged):
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-configuration-rework/
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-configuration-rework/+merge/66464
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-configuration-rework.
=== modified file 'openerp/addons/base/__openerp__.py'
--- openerp/addons/base/__openerp__.py 2011-05-23 12:09:40 +0000
+++ openerp/addons/base/__openerp__.py 2011-06-30 13:37:48 +0000
@@ -94,7 +94,6 @@
'test/bug_lp541545.xml',
'test/test_osv_expression.yml',
'test/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules.
- 'test/test_config_users.yml',
'test/test_ir_values.yml',
],
'installable': True,
=== modified file 'openerp/addons/base/base_update.xml'
--- openerp/addons/base/base_update.xml 2011-01-06 17:38:28 +0000
+++ openerp/addons/base/base_update.xml 2011-06-30 13:37:48 +0000
@@ -180,6 +180,7 @@
</search>
</field>
</record>
+
<!--
======================
Company
@@ -192,18 +193,30 @@
<field name="arch" type="xml">
<form string="Company">
<group colspan="4" col="6">
- <field colspan="4" name="name" select="1"/>
- <field name="partner_id" readonly="1" select="1" required="0"/>
- <field name="parent_id" select="1" groups="base.group_multi_company"/>
+ <group colspan="4" col="4">
+ <field name="name" select="1"/>
+ <field name="partner_id" readonly="1" select="1" required="0"/>
+ <field name="parent_id" select="1" groups="base.group_multi_company"/>
+ </group>
+ <group colspan="2" col="2">
+ <field name="logo" nolabel="1" widget="image"/>
+ </group>
</group>
<notebook colspan="4">
<page string="General Information">
+ <separator string="Address Information" colspan="4"/>
+ <field name="street"/>
+ <field name="street2"/>
+ <field name="zip"/>
+ <field name="city"/>
+ <field name="country_id"/>
+ <field name="state_id"/>
+ <field name="phone"/>
+ <field name="email"/>
+ <separator string="Header/Footer of Reports" colspan="4"/>
<field name="rml_header1" colspan="4"/>
<field name="rml_footer1" colspan="4"/>
<field name="rml_footer2" colspan="4"/>
- <field name="currency_id"/>
- <separator colspan="4" string="Your Logo - Use a size of about 450x150 pixels."/>
- <field colspan="4" name="logo" widget="image"/>
</page>
<page string="Header/Footer" groups="base.group_extended">
<field colspan="4" name="rml_header" nolabel="1"/>
@@ -215,6 +228,9 @@
<field colspan="2" name="rml_header3" nolabel="1"/>
</page>
<page string="Configuration">
+ <separator string="Accounting" colspan="4"/>
+ <field name="currency_id" colspan="2"/>
+ <newline/>
</page>
</notebook>
</form>
@@ -233,78 +249,6 @@
</field>
</record>
- <record id="view_users_configuration_form" model="ir.ui.view">
- <field name="name">res.config.users.confirm.form</field>
- <field name="model">res.config.users</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="res_config_view_base"/>
- <field name="arch" type="xml">
- <data>
- <form position="attributes">
- <attribute name="string">Create User</attribute>
- </form>
- <xpath expr='//separator[@string="title"]' position='attributes'>
- <attribute name='string'>New User</attribute>
- </xpath>
- <xpath expr="//label[@string='description']"
- position="attributes">
- <attribute name="string">Create additional users and assign them groups that will allow them to have access to selected functionalities within the system. Click on 'Done' if you do not wish to add more users at this stage, you can always do this later.</attribute>
- </xpath>
- <xpath expr='//separator[@string="vsep"]' position='attributes'>
- <attribute name='string'></attribute>
- </xpath>
- <group string="res_config_contents" position="replace">
- <field name="name"/>
- <field name="email"/>
- <field name="login"/>
- <field name="password" password="True"/>
- <field name="context_lang"/>
- <field name="context_tz"/>
-
- <separator string="Group" colspan="4"/>
- <label align="0.0" colspan="4" string="Groups are used to define access rights on objects and the visibility of screens and menus"/>
- <field colspan="4" nolabel="1" name="groups_id"/>
- </group>
-
- <xpath expr='//button[@name="action_next"]'
- position='attributes'>
- <attribute name="name">action_add</attribute>
- <attribute name='string'>Add User</attribute>
- <attribute name='icon'>gtk-add</attribute>
- </xpath>
-
- <xpath expr='//button[@name="action_skip"]'
- position='attributes'>
- <!-- if this one is performed first, it transforms
- the action_skip into action_next, and the
- transformation of action_next to action_add,
- since it uses first-match, transforms the same
- button. And we end up with [add] [next] instead
- of [next] [add]
-
- Would probably be simpler to just replace both
- by nothing and create a pair of brand new
- buttons... but we'd have to handle the groups
- around the buttons... oh well...
- -->
- <attribute name="name">action_next</attribute>
- <attribute name='string'>Done</attribute>
- <attribute name='icon'>gtk-go-forward</attribute>
- </xpath>
- </data>
- </field>
- </record>
-
- <record id="action_config_user_form" model="ir.actions.act_window">
- <field name="name">Create Users</field>
- <field name="type">ir.actions.act_window</field>
- <field name="res_model">res.config.users</field>
- <field name="view_type">form</field>
- <field name="view_mode">form</field>
- <field name="view_id" ref="view_users_configuration_form"/>
- <field name="target">new</field>
- </record>
-
<record id="view_confirm_simple_view_form" model="ir.ui.view">
<field name="name">Configure Your Interface</field>
<field name="model">res.config.view</field>
@@ -345,17 +289,19 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
+
+ <record id="category_administration_config" model="ir.actions.todo.category">
+ <field name="name">Administration</field>
+ <field name="sequence">1</field>
+ </record>
- <record id="config_wizard_step_user" model="ir.actions.todo">
- <field name="action_id" ref="action_config_user_form"/>
- <field name="sequence">10</field>
- <field name="restart">never</field>
- <field name="state">done</field>
- </record>
<record id="config_wizard_simple_view" model="ir.actions.todo">
<field name="action_id" ref="action_config_simple_view_form"/>
- <field name="restart">always</field>
+ <field name="category_id" ref="category_administration_config"/>
+ <field name="type">special</field>
<field name="sequence">1</field>
+ <field name="state">skip</field>
</record>
+
</data>
</openerp>
=== modified file 'openerp/addons/base/ir/ir.xml'
--- openerp/addons/base/ir/ir.xml 2011-06-01 13:01:56 +0000
+++ openerp/addons/base/ir/ir.xml 2011-06-30 13:37:48 +0000
@@ -1885,7 +1885,8 @@
<tree editable="bottom" string="Config Wizard Steps">
<field name="sequence"/>
<field name="action_id"/>
- <field name="restart"/>
+ <field name="category_id"/>
+ <field name="type"/>
<field name="state" readonly="1"/>
<button name="action_launch" states="open" string="Launch" type="object" icon="gtk-execute" help="Launch Configuration Wizard"/>
<button name="action_open" states="cancel,skip,done"
@@ -1903,8 +1904,9 @@
<form string="Config Wizard Steps">
<group colspan="4" col="6">
<field name="action_id"/>
- <field name="restart"/>
+ <field name="type"/>
<field name="sequence"/>
+ <field name="category_id"/>
</group>
<separator string="Groups" colspan="4"/>
<field name="groups_id" nolabel="1" colspan="4"/>
@@ -1925,10 +1927,17 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Actions">
- <filter string="To Do" name="todo" icon="terp-camera_test" domain=" ['|',('state','=','open'),'&',('state','=','skip'),('restart','=','onskip')]" help="Todo State Or (Skip State And Onskip Restart)"/>
- <separator orientation="vertical"/>
- <field name="state"/>
- <field name="restart"/>
+ <group>
+ <filter string="To Do" name="todo" icon="terp-camera_test" domain=" [('state','=','open')]" help="Wizards to be Launched"/>
+ <separator orientation="vertical"/>
+ <field name="action_id"/>
+ <field name="category_id"/>
+ <field name="state"/>
+ </group>
+ <newline/>
+ <group expand="0" string="Group By...">
+ <filter string="Category" context="{'group_by': 'category_id'}" icon="terp-folder-orange"/>
+ </group>
</search>
</field>
</record>
@@ -1958,6 +1967,41 @@
<field name="function">power_on</field>
<field name="args">()</field>
</record>
+
+ <record id="ir_actions_todo_category_form" model="ir.ui.view">
+ <field name="name">ir.actions.todo.category.form</field>
+ <field name="model">ir.actions.todo.category</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Wizard Category">
+ <field name="name"/>
+ <field name="sequence"/>
+ <field name="wizards_ids" nolabel="1" colspan="4"/>
+ </form>
+ </field>
+ </record>
+
+ <record id="ir_actions_todo_category_tree" model="ir.ui.view">
+ <field name="name">ir.actions.todo.category.tree</field>
+ <field name="model">ir.actions.todo.category</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Wizard Category">
+ <field name="name"/>
+ <field name="sequence"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="category_sales_management_config" model="ir.actions.todo.category">
+ <field name="name">Sales Management</field>
+ <field name="sequence">5</field>
+ </record>
+
+ <record id="category_tools_customization_config" model="ir.actions.todo.category">
+ <field name="name">Tools / Customization</field>
+ <field name="sequence">5</field>
+ </record>
</data>
</openerp>
=== modified file 'openerp/addons/base/ir/ir_actions.py'
--- openerp/addons/base/ir/ir_actions.py 2011-04-01 12:48:52 +0000
+++ openerp/addons/base/ir/ir_actions.py 2011-06-30 13:37:48 +0000
@@ -800,6 +800,15 @@
}
act_window_close()
+class ir_actions_todo_category(osv.osv):
+ _name = 'ir.actions.todo.category'
+ _columns = {
+ 'name':fields.char('Name', size=64, translate=True, required=True),
+ 'sequence': fields.integer('Sequence'),
+ 'wizards_ids': fields.one2many('ir.actions.todo', 'category_id', 'Configuration Wizards'),
+ }
+ir_actions_todo_category()
+
# This model use to register action services.
TODO_STATES = [('open', 'To Do'),
('done', 'Done'),
@@ -815,14 +824,15 @@
'sequence': fields.integer('Sequence'),
'state': fields.selection(TODO_STATES, string='State', required=True),
'name':fields.char('Name', size=64),
- 'restart': fields.selection([('onskip','On Skip'),('always','Always'),('never','Never')],'Restart',required=True),
+ 'type': fields.selection([('special','Special'),('normal','Normal'),('normal_recurring','Normal Recurring')],'Type',required=True),
'groups_id':fields.many2many('res.groups', 'res_groups_action_rel', 'uid', 'gid', 'Groups'),
'note':fields.text('Text', translate=True),
+ 'category_id': fields.many2one('ir.actions.todo.category','Category'),
}
_defaults={
'state': 'open',
'sequence': 10,
- 'restart': 'onskip',
+ 'type': 'special',
}
_order="sequence,name,id"
@@ -832,8 +842,16 @@
context = {}
wizard_id = ids and ids[0] or False
wizard = self.browse(cr, uid, wizard_id, context=context)
- res = self.pool.get('ir.actions.act_window').read(cr, uid, wizard.action_id.id, ['name', 'view_type', 'view_mode', 'res_model', 'context', 'views', 'type'], context=context)
- res.update({'target':'new', 'nodestroy': True})
+ res = self.pool.get('ir.actions.act_window').read(cr, uid, wizard.action_id.id, [], context=context)
+ res.update({'nodestroy': True})
+
+ # Open Specific resouce when res_id is provided in context
+ if res.get('context', {}):
+ user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
+ ctx = eval(res['context'], {'user': user})
+ if ctx.get('res_id'):
+ res.update({'res_id': ctx.pop('res_id')})
+ res.update({'context': ctx})
return res
def action_open(self, cr, uid, ids, context=None):
=== modified file 'openerp/addons/base/module/module.py'
--- openerp/addons/base/module/module.py 2011-05-11 13:53:32 +0000
+++ openerp/addons/base/module/module.py 2011-06-30 13:37:48 +0000
@@ -285,7 +285,17 @@
return demo
def button_install(self, cr, uid, ids, context=None):
- return self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
+ self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
+ return {
+ 'name': _('Install'),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'base.module.upgrade',
+ 'target': 'new',
+ 'type': 'ir.actions.act_window',
+ 'nodestroy':True,
+ }
+
def button_install_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})
@@ -305,7 +315,15 @@
if res:
raise orm.except_orm(_('Error'), _('Some installed modules depend on the module you plan to Uninstall :\n %s') % '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res)))
self.write(cr, uid, ids, {'state': 'to remove'})
- return True
+ return {
+ 'name': _('Uninstall'),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'base.module.upgrade',
+ 'target': 'new',
+ 'type': 'ir.actions.act_window',
+ 'nodestroy':True,
+ }
def button_uninstall_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'installed'})
@@ -342,7 +360,16 @@
to_install.extend(ids2)
self.button_install(cr, uid, to_install, context=context)
- return True
+ return {
+ 'name': _('Upgrade'),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'base.module.upgrade',
+ 'target': 'new',
+ 'type': 'ir.actions.act_window',
+ 'nodestroy':True,
+ }
+# return True
def button_upgrade_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'installed'})
=== modified file 'openerp/addons/base/module/module_view.xml'
--- openerp/addons/base/module/module_view.xml 2011-01-04 10:18:47 +0000
+++ openerp/addons/base/module/module_view.xml 2011-06-30 13:37:48 +0000
@@ -112,7 +112,7 @@
<newline/>
<field name="state" readonly="1" select="1"/>
<group col="6" colspan="2">
- <button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object"/>
+ <button name="button_install" states="uninstalled" string="Install" icon="terp-gtk-jump-to-ltr" type="object"/>
<button name="button_install_cancel" states="to install" string="Cancel Install" icon="gtk-cancel" type="object"/>
<button name="button_uninstall" states="installed" string="Uninstall (beta)" icon="terp-dialog-close" type="object"/>
<button name="button_uninstall_cancel" states="to remove" string="Cancel Uninstall" icon="gtk-cancel" type="object"/>
@@ -153,9 +153,9 @@
<field name="installed_version"/>
<field name="latest_version"/>
<field name="state"/>
- <button name="button_install" states="uninstalled" string="Schedule for Installation" icon="terp-gtk-jump-to-ltr" type="object"/>
+ <button name="button_install" states="uninstalled" string="Install" icon="terp-gtk-jump-to-ltr" type="object"/>
<button name="button_install_cancel" states="to install" string="Cancel Install" icon="gtk-cancel" type="object"/>
- <button name="button_upgrade" states="installed" string="Schedule Upgrade" icon="terp-gtk-go-back-rtl" type="object"/>
+ <button name="button_upgrade" states="installed" string="Upgrade" icon="terp-gtk-go-back-rtl" type="object"/>
<button name="button_uninstall" states="installed" string="Uninstall (beta)" icon="terp-dialog-close" type="object"/>
<button name="button_uninstall_cancel" states="to remove" string="Cancel Uninstall" icon="gtk-cancel" type="object"/>
<button name="button_upgrade_cancel" states="to upgrade" string="Cancel Upgrade" icon="gtk-cancel" type="object"/>
@@ -169,7 +169,7 @@
<field name="view_mode">tree,form</field>
<field name="domain"/>
<field name="search_view_id" ref="view_module_filter"/>
- <field name="help">You can install new modules in order to activate new features, menu, reports or data in your OpenERP instance. To install some modules, click on the button "Schedule for Installation" from the form view, then click on "Apply Scheduled Upgrades" to migrate your system.</field>
+ <field name="help">You can install new modules in order to activate new features, menu, reports or data in your OpenERP instance. To install some modules, click on the button "Install" from the form view and then click on "Start Upgrade".</field>
</record>
<menuitem action="open_module_tree" id="menu_module_tree" parent="base.menu_management"/>
=== modified file 'openerp/addons/base/module/wizard/base_module_configuration.py'
--- openerp/addons/base/module/wizard/base_module_configuration.py 2010-10-10 19:33:54 +0000
+++ openerp/addons/base/module/wizard/base_module_configuration.py 2011-06-30 13:37:48 +0000
@@ -27,7 +27,7 @@
_name = "base.module.configuration"
def start(self, cr, uid, ids, context=None):
- todo_ids = self.pool.get('ir.actions.todo').search(cr, uid, ['|', '|', ('restart','=','always'), ('state', '=', 'open'), '&', ('state', '=', 'skip'), ('restart', '=', 'onskip')])
+ todo_ids = self.pool.get('ir.actions.todo').search(cr, uid, ['|', '|', ('type','=','normal_recurring'), ('state', '=', 'open'), '&', ('state', '=', 'skip'), ('type', '=', 'special')])
if not todo_ids:
# When there is no wizard todo it will display message
data_obj = self.pool.get('ir.model.data')
=== modified file 'openerp/addons/base/module/wizard/base_module_configuration_view.xml'
--- openerp/addons/base/module/wizard/base_module_configuration_view.xml 2011-01-17 16:58:40 +0000
+++ openerp/addons/base/module/wizard/base_module_configuration_view.xml 2011-06-30 13:37:48 +0000
@@ -24,7 +24,7 @@
<field name="code">action = obj.start()</field>
</record>
- <menuitem name="Reconfigure"
+ <menuitem name="Add More Features"
action="action_start_configurator"
id="menu_view_base_module_configuration" parent="base.menu_config"
type="server" icon="STOCK_EXECUTE" sequence="100" />
=== modified file 'openerp/addons/base/module/wizard/base_module_shortcut_data.xml'
--- openerp/addons/base/module/wizard/base_module_shortcut_data.xml 2011-01-11 06:27:56 +0000
+++ openerp/addons/base/module/wizard/base_module_shortcut_data.xml 2011-06-30 13:37:48 +0000
@@ -3,7 +3,7 @@
<data noupdate="1">
<record id="ir_ui_view_sc_configuration" model="ir.ui.view_sc">
- <field name="name">Reconfigure</field>
+ <field name="name">Add More Features</field>
<field name="resource">ir.ui.menu</field>
<field name="user_id" ref="base.user_root"/>
<field name="res_id" ref="menu_view_base_module_configuration"/>
=== modified file 'openerp/addons/base/module/wizard/base_module_upgrade_view.xml'
--- openerp/addons/base/module/wizard/base_module_upgrade_view.xml 2010-10-21 15:42:03 +0000
+++ openerp/addons/base/module/wizard/base_module_upgrade_view.xml 2011-06-30 13:37:48 +0000
@@ -36,7 +36,7 @@
id="menu_view_base_module_upgrade"
parent="menu_management"
sequence="3"/>
-
+
<act_window id="action_view_base_module_upgrade_window"
key2="client_action_multi" name="Apply Scheduled Upgrades"
res_model="base.module.upgrade" src_model="ir.module.module"
=== modified file 'openerp/addons/base/res/partner/partner_view.xml'
--- openerp/addons/base/res/partner/partner_view.xml 2011-04-28 16:04:34 +0000
+++ openerp/addons/base/res/partner/partner_view.xml 2011-06-30 13:37:48 +0000
@@ -3,7 +3,9 @@
<data>
<menuitem icon="terp-partner" id="menu_base_partner" name="Sales" sequence="0"
web_icon="data/sales.png"
- web_icon_hover="data/sales-hover.png"/>
+ web_icon_hover="data/sales-hover.png"
+ groups="base.group_sale_salesman"/>
+
<menuitem id="menu_address_book" name="Address Book" parent="menu_base_partner" sequence="2"/>
=== modified file 'openerp/addons/base/res/res_company.py'
--- openerp/addons/base/res/res_company.py 2011-06-06 09:43:38 +0000
+++ openerp/addons/base/res/res_company.py 2011-06-30 13:37:48 +0000
@@ -25,6 +25,12 @@
import tools
from tools.translate import _
from tools.safe_eval import safe_eval as eval
+from lxml import etree
+import tempfile
+
+import pooler
+import netsvc
+from report import report_sxw
class multi_company_default(osv.osv):
"""
@@ -68,11 +74,40 @@
multi_company_default()
-
class res_company(osv.osv):
_name = "res.company"
_description = 'Companies'
_order = 'name'
+
+ def _get_address_data(self, cr, uid, ids, name, arg, context=None):
+ result = {}
+ for company in self.browse(cr, uid, ids, context=context):
+ result[company.id] = {}
+ for field in name:
+ result[company.id][field] = False
+ if company.partner_id:
+ part_obj = self.pool.get('res.partner')
+ address_obj = self.pool.get('res.partner.address')
+ address_data = part_obj.address_get(cr, uid, [company.partner_id.id], adr_pref=['default'])
+ if address_data['default']:
+ address = address_obj.read(cr, uid, address_data['default'], [], context=context)
+ for field in name:
+ result[company.id][field] = address[field] or False
+ return result
+
+ def _set_address_data(self, cr, uid, company_id, name, value, arg, context=None):
+ company = self.browse(cr, uid, company_id, context=context)
+ if company.partner_id:
+ part_obj = self.pool.get('res.partner')
+ address_obj = self.pool.get('res.partner.address')
+ address_data = part_obj.address_get(cr, uid, [company.partner_id.id], adr_pref=['default'])
+ address = address_data['default']
+ if address:
+ address_obj.write(cr, uid, [address], {name: value or False})
+ else:
+ address_obj.create(cr, uid, {name: value or False, 'partner_id': company.partner_id.id}, context=context)
+ return True
+
_columns = {
'name': fields.char('Company Name', size=64, required=True),
'parent_id': fields.many2one('res.company', 'Parent Company', select=True),
@@ -89,6 +124,14 @@
'currency_ids': fields.one2many('res.currency', 'company_id', 'Currency'),
'user_ids': fields.many2many('res.users', 'res_company_users_rel', 'cid', 'user_id', 'Accepted Users'),
'account_no':fields.char('Account No.', size=64),
+ 'street' : fields.function(_get_address_data, fnct_inv=_set_address_data, size=128, type='char', method=True, string="Street", multi='address'),
+ 'street2' : fields.function(_get_address_data, fnct_inv=_set_address_data, size=128, type='char', method=True, string="Street2", multi='address'),
+ 'zip' : fields.function(_get_address_data, fnct_inv=_set_address_data, size=24, type='char', method=True, string="Zip", multi='address'),
+ 'city' : fields.function(_get_address_data, fnct_inv=_set_address_data, size=24, type='char', method=True, string="City", multi='address'),
+ 'state_id' : fields.function(_get_address_data, fnct_inv=_set_address_data, type='many2one', domain="[('country_id', '=', country_id)]", relation='res.country.state', method=True, string="State", multi='address'),
+ 'country_id' : fields.function(_get_address_data, fnct_inv=_set_address_data, type='many2one', relation='res.country', method=True, string="Country", multi='address'),
+ 'email' : fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', method=True, string="Email", multi='address'),
+ 'phone' : fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', method=True, string="Phone", multi='address'),
}
def _search(self, cr, uid, args, offset=0, limit=None, order=None,
@@ -139,6 +182,26 @@
ids = self.search(cr, uid, [('parent_id','child_of',[company])])
return ids
+# For Report
+
+ def createReport(cr, uid, report, ids, name=False):
+ files = []
+ for id in ids:
+ try:
+ service = netsvc.LocalService(report)
+ (result, format) = service.create(cr, uid, [id], {}, {})
+ if not name:
+ report_file = '/tmp/reports'+ str(id) + '.pdf'
+ else:
+ report_file = name
+ fp = open(report_file,'wb+')
+ fp.write(result);
+ fp.close();
+ files += [report_file]
+ except Exception,e:
+ continue
+ return files
+
def _get_partner_hierarchy(self, cr, uid, company_id, context={}):
if company_id:
parent_id = self.browse(cr, uid, company_id)['parent_id']
@@ -263,6 +326,40 @@
(osv.osv._check_recursion, 'Error! You can not create recursive companies.', ['parent_id'])
]
+ def preview_report(self, cr, uid, ids, context=None):
+ # Used new cursor as it was closed explicitly somewhere and because of this partner data was not printed
+ # Tocheck: its not closed
+ cr = pooler.get_db(cr.dbname).cursor()
+ company = self.browse(cr, uid, ids, context=context)[0]
+
+ class company_parser(report_sxw.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ super(company_parser, self).__init__(cr, uid, name, context=context)
+ self.setCompany(company)
+
+ rml = etree.XML(company.rml_header)
+ rml = rml.getchildren()[0]
+ header_xml = """<document filename="Preview Report.pdf">
+ <template pageSize="(595.0,842.0)" title="Preview Report" author="OpenERP S.A.([email protected])" allowSplitting="20">""" + etree.tostring(rml) + """
+ </template>
+ </document>
+ """
+ tempfileid, tempfilename= tempfile.mkstemp('.rml', 'openerp_')
+ fp = open(tempfilename, 'wb+')
+ fp.write(header_xml)
+ fp.close()
+
+ if netsvc.Service._services.get('report.company.report'):
+ netsvc.Service._services.pop('report.company.report')
+
+ myreport = report_sxw.report_sxw('report.company.report', 'res.company', tempfilename, parser=company_parser)
+ return {
+ 'type': 'ir.actions.report.xml',
+ 'report_name': 'company.report',
+ 'datas': {'ids': ids, 'model': 'res.company'},
+ 'nodestroy': True
+ }
+
res_company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'openerp/addons/base/res/res_config.py'
--- openerp/addons/base/res/res_config.py 2011-06-30 09:51:42 +0000
+++ openerp/addons/base/res/res_config.py 2011-06-30 13:37:48 +0000
@@ -66,6 +66,7 @@
def _next_action(self, cr, uid, context=None):
todos = self.pool.get('ir.actions.todo')
self.__logger.info('getting next %s', todos)
+ # Don't forget to change the domain in search view, if this condition is changed
active_todos = todos.search(cr, uid, [('state','=','open')],
limit=1)
if active_todos:
@@ -76,7 +77,12 @@
cr.execute("select 1 from res_groups_users_rel where uid=%s and gid IN %s",(uid, tuple(todo_groups),))
dont_skip_todo = bool(cr.fetchone())
if dont_skip_todo:
- return todos.browse(cr, uid, active_todos[0], context=None)
+ res = todos.browse(cr, uid, active_todos[0], context=None)
+ # Wizards that directly opens a form stays in Todo state even if its called,
+ # as next_action is not called, so, setting state as done 'manually'
+ if res.action_id.target == 'current':
+ res.write({'state': 'done'})
+ return res
else:
todos.write(cr, uid, active_todos[0], {'state':'skip'}, context=None)
return self._next_action(cr, uid)
@@ -100,27 +106,19 @@
next = self._next_action(cr, uid)
self.__logger.info('next action is %s', next)
if next:
- action = next.action_id
- return {
- 'view_mode': action.view_mode,
- 'view_type': action.view_type,
- 'view_id': (action.view_id.id, 'Next Setup Action') if action.view_id else False,
- 'res_model': action.res_model,
- 'type': action.type,
- 'target': action.target,
- }
+ res = next.action_launch(context=context)
+ res.update({'nodestroy': False})
+ return res
self.__logger.info('all configuration actions have been executed')
- current_user_menu = self.pool.get('res.users')\
- .browse(cr, uid, uid).menu_id
+ current_user_menu = self.pool.get('res.users').browse(cr, uid, uid).menu_id
# return the action associated with the menu
- return self.pool.get(current_user_menu.type)\
- .read(cr, uid, current_user_menu.id)
+ return self.pool.get(current_user_menu.type).read(cr, uid, current_user_menu.id)
def start(self, cr, uid, ids, context=None):
ids2 = self.pool.get('ir.actions.todo').search(cr, uid, [], context=context)
for todo in self.pool.get('ir.actions.todo').browse(cr, uid, ids2, context=context):
- if (todo.restart=='always') or (todo.restart=='onskip' and (todo.state in ('skip','cancel'))):
+ if (todo.type=='normal_recurring'):
todo.write({'state':'open'})
return self.next(cr, uid, ids, context)
=== modified file 'openerp/addons/base/res/res_currency.py'
--- openerp/addons/base/res/res_currency.py 2011-05-19 12:27:52 +0000
+++ openerp/addons/base/res/res_currency.py 2011-06-30 13:37:48 +0000
@@ -21,6 +21,7 @@
import time
import netsvc
from osv import fields, osv
+import tools
from tools.misc import currency
from tools.translate import _
@@ -77,6 +78,18 @@
r['date'] = currency_date
return res
+ def name_get(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+# We can use the following line,if we want to restrict this name_get for company setup only
+# But, its better to show currencies as name(Code).
+ if not len(ids):
+ return []
+ if isinstance(ids, (int, long)):
+ ids = [ids]
+ reads = self.read(cr, uid, ids, ['name','symbol'], context, load='_classic_write')
+ return [(x['id'], tools.ustr(x['name']) + (x['symbol'] and (' (' + tools.ustr(x['symbol']) + ')') or '')) for x in reads]
+
def round(self, cr, uid, currency, amount):
if currency.rounding == 0:
return 0.0
=== modified file 'openerp/addons/base/res/res_user.py'
--- openerp/addons/base/res/res_user.py 2011-06-19 13:09:39 +0000
+++ openerp/addons/base/res/res_user.py 2011-06-30 13:37:48 +0000
@@ -240,14 +240,14 @@
'company_ids':fields.many2many('res.company','res_company_users_rel','user_id','cid','Companies'),
'context_lang': fields.selection(_lang_get, 'Language', required=True,
- help="Sets the language for the user's user interface, when UI "
- "translations are available"),
+ help="Sets default language for the all user interface, when UI "
+ "translations are available. If you want to Add new Language, you can add it from 'Load an Official Translation' wizard from 'Administration' menu."),
'context_tz': fields.selection(_tz_get, 'Timezone', size=64,
help="The user's timezone, used to perform timezone conversions "
"between the server and the client."),
'view': fields.function(_get_interface_type, method=True, type='selection', fnct_inv=_set_interface_type,
selection=[('simple','Simplified'),('extended','Extended')],
- string='Interface', help="Choose between the simplified interface and the extended one"),
+ string='Interface', help="If you use OpenERP for the first time we strongly advise you to select the simplified interface, which has less features but is easier. You can always switch later from the users preferences."),
'user_email': fields.function(_email_get, method=True, fnct_inv=_email_set, string='Email', type="char", size=240),
'menu_tips': fields.boolean('Menu Tips', help="Check out this box if you want to always display tips on each menu action"),
'date': fields.datetime('Last Connection', readonly=True),
@@ -511,62 +511,6 @@
users()
-class config_users(osv.osv_memory):
- _name = 'res.config.users'
- _inherit = ['res.users', 'res.config']
-
- def _generate_signature(self, cr, name, email, context=None):
- return _('--\n%(name)s %(email)s\n') % {
- 'name': name or '',
- 'email': email and ' <'+email+'>' or '',
- }
-
- def create_user(self, cr, uid, new_id, context=None):
- """ create a new res.user instance from the data stored
- in the current res.config.users.
-
- If an email address was filled in for the user, sends a mail
- composed of the return values of ``get_welcome_mail_subject``
- and ``get_welcome_mail_body`` (which should be unicode values),
- with the user's data %-formatted into the mail body
- """
- base_data = self.read(cr, uid, new_id, context=context)
- partner_id = self.pool.get('res.partner').main_partner(cr, uid)
- address = self.pool.get('res.partner.address').create(
- cr, uid, {'name': base_data['name'],
- 'email': base_data['email'],
- 'partner_id': partner_id,},
- context)
- # Change the read many2one values from (id,name) to id, and
- # the one2many from ids to (6,0,ids).
- base_data.update({'menu_id' : base_data.get('menu_id') and base_data['menu_id'][0],
- 'company_id' : base_data.get('company_id') and base_data['company_id'][0],
- 'action_id' : base_data.get('action_id') and base_data['action_id'][0],
- 'signature' : self._generate_signature(cr, base_data['name'], base_data['email'], context=context),
- 'address_id' : address,
- 'groups_id' : [(6,0, base_data.get('groups_id',[]))],
- })
- new_user = self.pool.get('res.users').create(
- cr, uid, base_data, context)
- self.send_welcome_email(cr, uid, new_user, context=context)
-
- def execute(self, cr, uid, ids, context=None):
- 'Do nothing on execution, just launch the next action/todo'
- pass
- def action_add(self, cr, uid, ids, context=None):
- 'Create a user, and re-display the view'
- self.create_user(cr, uid, ids[0], context=context)
- return {
- 'view_type': 'form',
- "view_mode": 'form',
- 'res_model': 'res.config.users',
- 'view_id':self.pool.get('ir.ui.view')\
- .search(cr,uid,[('name','=','res.config.users.confirm.form')]),
- 'type': 'ir.actions.act_window',
- 'target':'new',
- }
-config_users()
-
class groups2(osv.osv): ##FIXME: Is there a reason to inherit this object ?
_inherit = 'res.groups'
_columns = {
=== modified file 'openerp/addons/base/security/base_security.xml'
--- openerp/addons/base/security/base_security.xml 2011-03-03 15:59:18 +0000
+++ openerp/addons/base/security/base_security.xml 2011-06-30 13:37:48 +0000
@@ -29,12 +29,13 @@
<field name="name">Useability / No One</field>
</record>
- <record id="group_sale_manager" model="res.groups">
+ <record id="group_sale_manager" context="{'noadmin':True}" model="res.groups">
<field name="name">Sales / Manager</field>
</record>
- <record id="group_sale_salesman" model="res.groups">
+ <record id="group_sale_salesman" context="{'noadmin':True}" model="res.groups">
<field name="name">Sales / User</field>
</record>
+
<!-- Set accesses to menu -->
<record model="ir.ui.menu" id="base.menu_administration">
<field name="groups_id" eval="[(6,0, [ref('group_system'), ref('group_erp_manager')])]"/>
=== modified file 'openerp/addons/base/security/ir.model.access.csv'
--- openerp/addons/base/security/ir.model.access.csv 2011-05-31 13:45:06 +0000
+++ openerp/addons/base/security/ir.model.access.csv 2011-06-30 13:37:48 +0000
@@ -125,3 +125,4 @@
"access_res_widget_user","res.widget.user","model_res_widget",,1,0,0,0
"access_res_log_all","res.log","model_res_log",,1,1,1,1
"access_ir_config_parameter","ir_config_parameter","model_ir_config_parameter",,1,0,0,0
+"access_ir_actions_todo_category","ir_actions_todo_category","model_ir_actions_todo_category","group_system",1,1,1,1
=== removed file 'openerp/addons/base/test/test_config_users.yml'
--- openerp/addons/base/test/test_config_users.yml 2011-05-23 11:19:53 +0000
+++ openerp/addons/base/test/test_config_users.yml 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
--
- I Create "test" user using configuration wizard.
--
- !python {model: res.config.users}: |
- defaults = {
- 'name' : 'test1',
- 'login' : 'test1',
- 'password' : 'test',
- }
- wizard_id = self.create(cr, uid, defaults)
- self.action_add(cr, uid, [wizard_id], context)
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp