Skip to content

Commit

Permalink
[merge]merge with main branch
Browse files Browse the repository at this point in the history
bzr revid: tch@tinyerp.com-20120827092352-bm2vjzmxi84qkh5z
  • Loading branch information
41089 committed Aug 27, 2012
2 parents 7e59db5 + 0b464f0 commit 400fca9
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 117 deletions.
13 changes: 7 additions & 6 deletions openerp/addons/base/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@
'name': 'Base',
'version': '1.3',
'category': 'Hidden',
'description': """The kernel of OpenERP, needed for all installation.""",
'description': """
The kernel of OpenERP, needed for all installation.
===================================================
""",
'author': 'OpenERP SA',
'maintainer': 'OpenERP SA',
'website': 'http://www.openerp.com',
'depends': [],
'init_xml': [
'data': [
'base_data.xml',
'security/base_security.xml',
'base_menu.xml',
'res/res_security.xml',
'res/res_config.xml',
'data/res.country.state.csv'
],
'update_xml': [
'data/res.country.state.csv',
'ir/wizard/wizard_menu_view.xml',
'ir/ir.xml',
'ir/ir_filters.xml',
Expand Down Expand Up @@ -77,7 +78,7 @@
'res/res_widget_data.xml',
'publisher_warranty/publisher_warranty_data.xml',
],
'demo_xml': [
'demo': [
'base_demo.xml',
'res/res_partner_demo.xml',
'res/res_partner_demo.yml',
Expand Down
1 change: 0 additions & 1 deletion openerp/addons/base/ir/ir.xml
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@
<record model="ir.ui.view" id="view_ir_needaction_users_rel_tree">
<field name="name">ir.needaction_users_rel.tree</field>
<field name="model">ir.needaction_users_rel</field>
<field name="sequence">10</field>
<field name="arch" type="xml">
<tree string="Subscription">
<field name="user_id"/>
Expand Down
8 changes: 6 additions & 2 deletions openerp/addons/base/ir/ir_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def create(self, cr, user, vals, context=None):
res = super(ir_model,self).create(cr, user, vals, context)
if vals.get('state','base')=='manual':
self.instanciate(cr, user, vals['model'], context)
self.pool.get(vals['model']).__init__(self.pool, cr)
ctx = dict(context,
field_name=vals['name'],
field_state='manual',
Expand All @@ -198,7 +197,9 @@ class x_custom_model(osv.osv):
x_custom_model._name = model
x_custom_model._module = False
a = x_custom_model.create_instance(self.pool, cr)
if (not a._columns) or ('x_name' in a._columns.keys()):
if not a._columns:
x_name = 'id'
elif 'x_name' in a._columns.keys():
x_name = 'x_name'
else:
x_name = a._columns.keys()[0]
Expand Down Expand Up @@ -931,6 +932,9 @@ def unlink_if_refcount(to_unlink):

ir_model_relation = self.pool.get('ir.model.relation')
relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove)])
ir_module_module = self.pool.get('ir.module.module')
modules_to_remove_ids = ir_module_module.search(cr, uid, [('name', 'in', modules_to_remove)])
relation_ids = ir_model_relation.search(cr, uid, [('module', 'in', modules_to_remove_ids)])
ir_model_relation._module_data_uninstall(cr, uid, relation_ids, context)

unlink_if_refcount((model, res_id) for model, res_id in to_unlink
Expand Down
4 changes: 1 addition & 3 deletions openerp/addons/base/ir/ir_model_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def _module_data_uninstall(self, cr, uid, ids, context=None):
ids_set = set(ids)
ids.sort()
ids.reverse()
to_unlink = []
for data in self.browse(cr, uid, ids, context):
model = data.model.model
model_obj = self.pool.get(model)
Expand Down Expand Up @@ -75,5 +74,4 @@ def _module_data_uninstall(self, cr, uid, ids, context=None):
cr.execute('ALTER TABLE "%s" DROP CONSTRAINT "%s"' % (model_obj._table, name),)
_logger.info('Dropped CONSTRAINT %s@%s', name, model)

to_unlink.append(data.id)
self.unlink(cr, uid, to_unlink, context)
self.unlink(cr, uid, ids, context)
5 changes: 1 addition & 4 deletions openerp/addons/base/ir/ir_model_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def _module_data_uninstall(self, cr, uid, ids, context=None):
to_drop_table = []
ids.sort()
ids.reverse()
to_unlink = []
for data in self.browse(cr, uid, ids, context):
model = data.model
model_obj = self.pool.get(model)
Expand All @@ -53,9 +52,7 @@ def _module_data_uninstall(self, cr, uid, ids, context=None):
if cr.fetchone() and not name in to_drop_table:
to_drop_table.append(name)

to_unlink.append(data.id)

self.unlink(cr, uid, to_unlink, context)
self.unlink(cr, uid, ids, context)

# drop m2m relation tables
for table in to_drop_table:
Expand Down
18 changes: 15 additions & 3 deletions openerp/addons/base/module/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import base64
from docutils.core import publish_string
import imp
import logging
import re
import urllib
import zipimport
import base64

from openerp import modules, pooler, release, tools, addons
from openerp.tools.parse_version import parse_version
Expand Down Expand Up @@ -94,6 +96,14 @@ def get_module_info(cls, name):
'module %s', name, exc_info=True)
return info

def _get_desc(self, cr, uid, ids, field_name=None, arg=None, context=None):
res = dict.fromkeys(ids, '')
for module in self.browse(cr, uid, ids, context=context):
overrides = dict(embed_stylesheet=False, doctitle_xform=False, output_encoding='unicode')
output = publish_string(source=module.description, writer_name='html', settings_overrides=overrides)
res[module.id] = output
return res

def _get_latest_version(self, cr, uid, ids, field_name=None, arg=None, context=None):
res = dict.fromkeys(ids, '')
for m in self.browse(cr, uid, ids):
Expand Down Expand Up @@ -183,6 +193,7 @@ def _get_icon_image(self, cr, uid, ids, field_name=None, arg=None, context=None)
'shortdesc': fields.char('Module Name', size=64, readonly=True, translate=True),
'summary': fields.char('Summary', size=64, readonly=True, translate=True),
'description': fields.text("Description", readonly=True, translate=True),
'description_html': fields.function(_get_desc, string='Description HTML', type='html', method=True, readonly=True),
'author': fields.char("Author", size=128, readonly=True),
'maintainer': fields.char('Maintainer', size=128, readonly=True),
'contributors': fields.text('Contributors', readonly=True),
Expand Down Expand Up @@ -222,7 +233,7 @@ def _get_icon_image(self, cr, uid, ids, field_name=None, arg=None, context=None)
('AGPL-3', 'Affero GPL-3'),
('Other OSI approved licence', 'Other OSI Approved Licence'),
('Other proprietary', 'Other Proprietary')
], string='License', readonly=True),
], string='License', readonly=True),
'menus_by_module': fields.function(_get_views, string='Menus', type='text', multi="meta", store=True),
'reports_by_module': fields.function(_get_views, string='Reports', type='text', multi="meta", store=True),
'views_by_module': fields.function(_get_views, string='Views', type='text', multi="meta", store=True),
Expand Down Expand Up @@ -371,7 +382,8 @@ def module_uninstall(self, cr, uid, ids, context=None):
ir_model_data = self.pool.get('ir.model.data')
ir_model_constraint = self.pool.get('ir.model.constraint')
modules_to_remove = [m.name for m in self.browse(cr, uid, ids, context)]
constraint_ids = ir_model_constraint.search(cr, uid, [('module', 'in', modules_to_remove)])
modules_to_remove_ids = [m.id for m in self.browse(cr, uid, ids, context)]
constraint_ids = ir_model_constraint.search(cr, uid, [('module', 'in', modules_to_remove_ids)])
ir_model_constraint._module_data_uninstall(cr, uid, constraint_ids, context)
ir_model_data._module_data_uninstall(cr, uid, modules_to_remove, context)
self.write(cr, uid, ids, {'state': 'uninstalled'})
Expand Down
4 changes: 2 additions & 2 deletions openerp/addons/base/module/module_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<field name="model">ir.module.module</field>
<field name="arch" type="xml">
<search string="Search modules">
<field name="name" filter_domain="['|', '|', '|', ('description', 'ilike', self), ('summary', 'ilike', self), ('shortdesc', 'ilike', self), ('name',
<field name="name" filter_domain="['|', '|', ('summary', 'ilike', self), ('shortdesc', 'ilike', self), ('name',
'ilike', self)]"/>
<filter name="app" icon="terp-check" string="Apps" domain="[('application', '=', 1)]"/>
<filter name="extra" icon="terp-check" string="Extra" domain="[('application', '=', 0)]"/>
Expand Down Expand Up @@ -133,7 +133,7 @@
</group>
<notebook>
<page string="Description">
<field name="description"/>
<field name="description_html"/>
</page>
<page string="Technical Data" groups="base.group_no_one">
<group col="4">
Expand Down
1 change: 1 addition & 0 deletions openerp/addons/base/res/res_config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="res_config_view_base" model="ir.ui.view">
<field name="name">res.config.view.base</field>
<field name="model">res.config</field>
Expand Down
63 changes: 29 additions & 34 deletions openerp/addons/base/res/res_security.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<data noupdate="1">

<record model="res.groups" id="group_partner_manager">
<field name="name">Partner Manager</field>
</record>
<record model="res.groups" id="group_partner_manager">
<field name="name">Partner Manager</field>
</record>

<record model="ir.ui.menu" id="menu_config_address_book">
<field eval="[(6,0,[ref('group_system'), ref('group_partner_manager')])]" name="groups_id"/>
</record>
<record model="ir.ui.menu" id="menu_base_config">
<field eval="[(6,0,[ref('group_system'), ref('group_partner_manager')])]" name="groups_id"/>
</record>
<record model="ir.ui.menu" id="menu_base_partner">
<field eval="[(6,0,[ref('group_partner_manager')])]" name="groups_id"/>
</record>
<record model="ir.ui.menu" id="menu_config_address_book">
<field eval="[(6,0,[ref('group_system'), ref('group_partner_manager')])]" name="groups_id"/>
</record>
<record model="ir.ui.menu" id="menu_base_config">
<field eval="[(6,0,[ref('group_system'), ref('group_partner_manager')])]" name="groups_id"/>
</record>
<record model="ir.ui.menu" id="menu_base_partner">
<field eval="[(6,0,[ref('group_partner_manager')])]" name="groups_id"/>
</record>

</data>
<!-- Record Rule For Company -->
<record id="res_company_rule" model="ir.rule">
<field name="name">company rule</field>
<field model="ir.model" name="model_id" ref="model_res_company"/>
<field eval="True" name="global"/>
<!-- TODO: review this <field name="domain_force">['|', ('child_ids', 'child_of', [user.company_id.id]), ('parent_id', 'child_of', [user.company_id.id])]</field> -->
<field name="domain_force">[('id','child_of',[user.company_id.id])]</field>
</record>

<data noupdate="1">
<!-- Record Rule For User -->
<record id="res_users_rule" model="ir.rule">
<field name="name">user rule</field>
<field model="ir.model" name="model_id" ref="model_res_users"/>
<field eval="True" name="global"/>
<field name="domain_force">[('company_ids','child_of',[user.company_id.id])]</field>
</record>

<!-- Record Rule For Company -->

<record id="res_company_rule" model="ir.rule">
<field name="name">company rule</field>
<field model="ir.model" name="model_id" ref="model_res_company"/>
<field eval="True" name="global"/>
<!-- TODO: review this <field name="domain_force">['|', ('child_ids', 'child_of', [user.company_id.id]), ('parent_id', 'child_of', [user.company_id.id])]</field> -->
<field name="domain_force">[('id','child_of',[user.company_id.id])]</field>
</record>

<!-- Record Rule For User -->
<record id="res_users_rule" model="ir.rule">
<field name="name">user rule</field>
<field model="ir.model" name="model_id" ref="model_res_users"/>
<field eval="True" name="global"/>
<field name="domain_force">[('company_ids','child_of',[user.company_id.id])]</field>
</record>

</data>
</data>
</openerp>
86 changes: 43 additions & 43 deletions openerp/addons/base/security/base_security.xml
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="0">

<!--
Users Groups
[Note] Field 'category_id' is set later in base/module/module_data.xml
-->
<record model="res.groups" id="group_erp_manager">
<field name="name">Access Rights</field>
</record>
<record model="res.groups" id="group_system">
<field name="name">Configuration</field>
<field name="implied_ids" eval="[(4, ref('group_erp_manager'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<data noupdate="1">

<record model="res.groups" id="group_user">
<field name="name">Employee</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<!--
Users Groups
Note that the field 'category_id' is set later in
base/module/module_data.xml
-->
<record model="res.groups" id="group_erp_manager">
<field name="name">Access Rights</field>
</record>
<record model="res.groups" id="group_system">
<field name="name">Configuration</field>
<field name="implied_ids" eval="[(4, ref('group_erp_manager'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>

<record model="res.groups" id="group_multi_company">
<field name="name">Multi Companies</field>
</record>

<record model="res.groups" id="group_multi_currency">
<field name="name">Multi Currencies</field>
</record>
<record model="res.groups" id="group_user">
<field name="name">Employee</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>

<record model="res.groups" id="group_no_one">
<field name="name">Technical Features</field>
</record>
<record model="res.groups" id="group_multi_company">
<field name="name">Multi Companies</field>
</record>

<record id="group_sale_salesman" model="res.groups">
<field name="name">User</field>
</record>
<record id="group_sale_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('group_sale_salesman'))]"/>
</record>
<record model="res.groups" id="group_multi_currency">
<field name="name">Multi Currencies</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')])]"/>
</record>
<record model="res.groups" id="group_no_one">
<field name="name">Technical Features</field>
</record>

</data>
<record id="group_sale_salesman" model="res.groups">
<field name="name">User</field>
</record>
<record id="group_sale_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('group_sale_salesman'))]"/>
</record>

<data noupdate="1">
<!-- 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')])]"/>
</record>

<record model="ir.rule" id="res_widget_user_rule">
<field name="name">res.widget.user rule</field>
Expand All @@ -58,8 +55,11 @@
<record model="ir.rule" id="res_partner_rule">
<field name="name">res.partner company</field>
<field name="model_id" ref="model_res_partner"/>
<!-- Show partners from ancestors and descendants companies (or company-less), this is usually a better
default for multicompany setups. -->
<!--
Show partners from ancestors and descendants companies
(or company-less), this is usually a better default for
multicompany setups.
-->
<field name="domain_force">['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
</record>

Expand Down
1 change: 0 additions & 1 deletion openerp/import_xml.rng
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
<rng:optional> <rng:attribute name="string"/> </rng:optional>
<rng:optional> <rng:attribute name="sequence"/> </rng:optional>
<rng:optional> <rng:attribute name="groups"/> </rng:optional>
<rng:optional> <rng:attribute name="type"/> </rng:optional>
<rng:optional> <rng:attribute name="menu"/> </rng:optional>
<rng:empty />
</rng:element>
Expand Down
2 changes: 2 additions & 0 deletions openerp/tests/addons/test_impex/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import openerp

from openerp.tests import common
from openerp.tools.misc import mute_logger

def ok(n):
""" Successful import of ``n`` records
Expand Down Expand Up @@ -221,6 +222,7 @@ def test_negatives(self):
-1, -42, -(2**31 - 1), -(2**31), -12345678
], values(self.read()))

@mute_logger('openerp.sql_db')
def test_out_of_range(self):
self.assertEqual(
self.import_(['value'], [[str(2**31)]]),
Expand Down
Loading

0 comments on commit 400fca9

Please sign in to comment.