Merge with trunk-server
bzr revid: ysa@tinyerp.com-20101228101718-q4zrv5bsefkaaykw
This commit is contained in:
commit
e8ba5b489a
|
@ -18,3 +18,6 @@ bin/python2.6
|
|||
build/
|
||||
bin/yolk
|
||||
bin/pil*.py
|
||||
.project
|
||||
.pydevproject
|
||||
.settings
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
OpenERP v6.0 is published under the GNU AFFERO GENERAL PUBLIC LICENSE,
|
||||
Version 3 (AGPLv3), as included below. Some external libraries and
|
||||
contributions bundled with OpenERP may be published under other
|
||||
AGPLv3-compatible licenses. For these, please refer to the relevant
|
||||
source files and/or license files, in the source code tree.
|
||||
|
||||
**************************************************************************
|
||||
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
|
@ -225,6 +225,10 @@ def zip_directory(directory, b64enc=True, src=True):
|
|||
|
||||
archname = StringIO()
|
||||
archive = PyZipFile(archname, "w", ZIP_DEFLATED)
|
||||
|
||||
# for Python 2.5, ZipFile.write() still expects 8-bit strings (2.6 converts to utf-8)
|
||||
directory = tools.ustr(directory).encode('utf-8')
|
||||
|
||||
archive.writepy(directory)
|
||||
_zippy(archive, directory, src=src)
|
||||
archive.close()
|
||||
|
@ -599,8 +603,19 @@ class MigrationManager(object):
|
|||
|
||||
log = logging.getLogger('init')
|
||||
|
||||
def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs):
|
||||
|
||||
def load_module_graph(cr, graph, status=None, perform_checks=True, skip_cleanup=False, **kwargs):
|
||||
"""Migrates+Updates or Installs all module nodes from ``graph``
|
||||
:param graph: graph of module nodes to load
|
||||
:param status: status dictionary for keeping track of progress
|
||||
:param perform_checks: whether module descriptors should be checked for validity (prints warnings
|
||||
for same cases, and even raise osv_except if certificate is invalid)
|
||||
:param skip_cleanup: whether the auto-cleanup of records should be executed (unlinks any object that
|
||||
appears to be from one of the updated modules, but have not been loaded during
|
||||
last loading (i.e. records that seem to have been removed from the module).
|
||||
This is best left disabled when loading stand-alone modules that could contain
|
||||
records from dependent modules (i.e. other modules have put records in their
|
||||
namespace)
|
||||
"""
|
||||
def process_sql_file(cr, fp):
|
||||
queries = fp.read().split(';')
|
||||
for query in queries:
|
||||
|
@ -649,8 +664,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs):
|
|||
try:
|
||||
_load_data(cr, module_name, id_map, mode, 'test')
|
||||
except Exception, e:
|
||||
logger.notifyChannel('ERROR', netsvc.LOG_TEST, e)
|
||||
pass
|
||||
logging.getLogger('test').exception('Tests failed to execute in module %s', module_name)
|
||||
finally:
|
||||
if tools.config.options['test_commit']:
|
||||
cr.commit()
|
||||
|
@ -763,7 +777,9 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs):
|
|||
for model in cr.dictfetchall():
|
||||
pool.get('ir.model').instanciate(cr, 1, model['model'], {})
|
||||
|
||||
pool.get('ir.model.data')._process_end(cr, 1, package_todo)
|
||||
if not skip_cleanup:
|
||||
# Cleanup orphan records
|
||||
pool.get('ir.model.data')._process_end(cr, 1, package_todo)
|
||||
cr.commit()
|
||||
|
||||
return has_updates
|
||||
|
@ -807,7 +823,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
|||
if not graph:
|
||||
logger.notifyChannel('init', netsvc.LOG_CRITICAL, 'module base cannot be loaded! (hint: verify addons-path)')
|
||||
raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)'))
|
||||
has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
|
||||
has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report, skip_cleanup=True)
|
||||
|
||||
if update_module:
|
||||
modobj = pool.get('ir.module.module')
|
||||
|
@ -857,7 +873,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
|||
cr.execute("""select model,name from ir_model where id NOT IN (select distinct model_id from ir_model_access)""")
|
||||
for (model, name) in cr.fetchall():
|
||||
model_obj = pool.get(model)
|
||||
if not isinstance(model_obj, osv.osv.osv_memory):
|
||||
if model_obj and not isinstance(model_obj, osv.osv.osv_memory):
|
||||
logger.notifyChannel('init', netsvc.LOG_WARNING, 'object %s (%s) has no access rules!' % (model, name))
|
||||
|
||||
# Temporary warning while we remove access rights on osv_memory objects, as they have
|
||||
|
@ -873,6 +889,8 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
|||
obj = pool.get(model)
|
||||
if obj:
|
||||
obj._check_removed_columns(cr, log=True)
|
||||
else:
|
||||
logger.notifyChannel('init', netsvc.LOG_WARNING, "Model %s is referenced but not present in the orm pool!" % model)
|
||||
|
||||
if report.get_report():
|
||||
logger.notifyChannel('init', netsvc.LOG_INFO, report)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
import ir
|
||||
import module
|
||||
import res
|
||||
import maintenance
|
||||
import publisher_warranty
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
{
|
||||
'name': 'Base',
|
||||
'version': '1.2',
|
||||
'version': '1.3',
|
||||
'category': 'Generic Modules/Base',
|
||||
'description': """The kernel of OpenERP, needed for all installation.""",
|
||||
'author': 'OpenERP SA',
|
||||
|
@ -71,20 +71,22 @@
|
|||
|
||||
'res/ir_property_view.xml',
|
||||
'security/base_security.xml',
|
||||
'maintenance/maintenance_view.xml',
|
||||
'publisher_warranty/publisher_warranty_view.xml',
|
||||
|
||||
'security/ir.model.access.csv',
|
||||
'res/res_widget_view.xml',
|
||||
'res/res_widget_data.xml',
|
||||
'publisher_warranty/publisher_warranty_data.xml',
|
||||
],
|
||||
'demo_xml': [
|
||||
'base_demo.xml',
|
||||
'res/partner/partner_demo.xml',
|
||||
'res/partner/crm_demo.xml',
|
||||
'res/res_widget_demo.xml',
|
||||
],
|
||||
'test': [
|
||||
'test/base_test.xml',
|
||||
#'test/base_test.yml'
|
||||
'test/base_test.yml',
|
||||
'test/test_context.xml',
|
||||
'test/bug_lp541545.xml',
|
||||
],
|
||||
|
|
|
@ -161,7 +161,8 @@ CREATE TABLE res_groups (
|
|||
|
||||
CREATE TABLE res_groups_users_rel (
|
||||
uid integer NOT NULL references res_users on delete cascade,
|
||||
gid integer NOT NULL references res_groups on delete cascade
|
||||
gid integer NOT NULL references res_groups on delete cascade,
|
||||
UNIQUE("uid","gid")
|
||||
);
|
||||
|
||||
create index res_groups_users_rel_uid_idx on res_groups_users_rel (uid);
|
||||
|
@ -288,6 +289,7 @@ CREATE TABLE ir_module_module (
|
|||
description text,
|
||||
demo boolean default False,
|
||||
web boolean DEFAULT FALSE,
|
||||
license character varying(32),
|
||||
primary key(id)
|
||||
);
|
||||
ALTER TABLE ir_module_module add constraint name_uniq unique (name);
|
||||
|
|
|
@ -989,7 +989,7 @@
|
|||
<field name="name">Zambia</field>
|
||||
<field name="code">zm</field>
|
||||
</record>
|
||||
<!-- DEPRECATED, News name of Zaire is Democratic Republic of the Congo ! -->
|
||||
<!-- DEPRECATED, New name of Zaire is Democratic Republic of the Congo ! -->
|
||||
<record id="zr" model="res.country">
|
||||
<field name="name">Zaire</field>
|
||||
<field name="code">zr</field>
|
||||
|
@ -1044,7 +1044,7 @@
|
|||
</record>
|
||||
|
||||
<assert id="main_company" model="res.company">
|
||||
<test expr="currency_id.code == 'eur'.upper()"/>
|
||||
<test expr="currency_id.name == 'eur'.upper()"/>
|
||||
<test expr="name">OpenERP S.A.</test>
|
||||
</assert>
|
||||
|
||||
|
@ -1170,7 +1170,7 @@
|
|||
<field name="currency_id" ref="COP"/>
|
||||
<field eval="time.strftime('%Y-01-01')" name="name"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="CZK" model="res.currency">
|
||||
<field name="name">Kč</field>
|
||||
<field name="code">CZK</field>
|
||||
|
@ -1213,7 +1213,7 @@
|
|||
<field name="currency_id" ref="HUF"/>
|
||||
<field eval="time.strftime('%Y-01-01')" name="name"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="IDR" model="res.currency">
|
||||
<field name="name">Rs</field>
|
||||
<field name="code">IDR</field>
|
||||
|
@ -1290,7 +1290,7 @@
|
|||
<field name="currency_id" ref="PLN"/>
|
||||
<field eval="time.strftime('%Y-01-01')" name="name"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="SEK" model="res.currency">
|
||||
<field name="name">kr</field>
|
||||
<field name="code">SEK</field>
|
||||
|
@ -1304,7 +1304,7 @@
|
|||
<field name="currency_id" ref="SEK"/>
|
||||
<field eval="time.strftime('%Y-01-01')" name="name"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="GBP" model="res.currency">
|
||||
<field name="name">GBP</field>
|
||||
<field name="code">GBP</field>
|
||||
|
@ -1326,7 +1326,7 @@
|
|||
<field name="rounding">0.01</field>
|
||||
<field name="accuracy">4</field>
|
||||
<field name="company_id" ref="main_company"/>
|
||||
</record>
|
||||
</record>
|
||||
<record id="rateARS" model="res.currency.rate">
|
||||
<field name="rate">5.0881</field>
|
||||
<field name="currency_id" ref="ARS"/>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<menuitem icon="terp-administration" id="menu_administration" name="Administration" sequence="50"/>
|
||||
<menuitem icon="terp-administration" id="menu_administration"
|
||||
name="Administration" sequence="50"
|
||||
web_icon="data/administration.png"
|
||||
web_icon_hover="data/administration-hover.png"/>
|
||||
|
||||
<menuitem icon="terp-administration" id="menu_administration_shortcut" parent="menu_administration" name="Custom Shortcuts" sequence="50"/>
|
||||
<menuitem id="next_id_4" name="Low Level Objects"
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -34,6 +34,7 @@ import ir_exports
|
|||
import workflow
|
||||
import ir_rule
|
||||
import wizard
|
||||
import ir_config_parameter
|
||||
import osv_memory_autovacuum
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -819,20 +819,17 @@
|
|||
<filter icon="terp-stock_zoom"
|
||||
string="Search"
|
||||
domain="[('type', '=', 'search')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="gtk-indent"
|
||||
string="Tree"
|
||||
domain="[('type', '=', 'tree')]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="gtk-new"
|
||||
string="Form"
|
||||
domain="[('type', '=','form')]"/>
|
||||
<newline/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
<field name="model"/>
|
||||
<field name="inherit_id"/>
|
||||
<field name="xml_id"/>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Object" icon="terp-stock_align_left_24" domain="[]" context="{'group_by':'model'}"/>
|
||||
|
@ -1047,8 +1044,8 @@
|
|||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Model Description">
|
||||
<field name="name"/>
|
||||
<field name="model"/>
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
<field name="osv_memory"/>
|
||||
</tree>
|
||||
|
@ -1379,6 +1376,12 @@
|
|||
<field name="action" colspan="4" />
|
||||
<field name="icon" on_change="onchange_icon(icon)" colspan="2"/>
|
||||
<field name="icon_pict" widget="picture" nolabel="1" colspan="2"/>
|
||||
<group col="4" colspan="8" groups="base.group_extended">
|
||||
<field name="web_icon" groups="base.group_extended" />
|
||||
<field name="web_icon_hover" groups="base.group_extended" />
|
||||
<field name="web_icon_data" widget="image" groups="base.group_extended"/>
|
||||
<field name="web_icon_hover_data" widget="image" groups="base.group_extended"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Groups">
|
||||
|
@ -1406,6 +1409,7 @@
|
|||
<field name="res_model">ir.ui.menu</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="edit_menu"/>
|
||||
<field name="context">{'ir.ui.menu.full_list':True}</field>
|
||||
<field name="search_view_id" ref="edit_menu_access_search"/>
|
||||
<field name="help">Manage and customize the items available and displayed in your OpenERP system menu. You can delete an item by clicking on the box at the beginning of each line and then delete it through the button that appeared. Items can be assigned to specific groups in order to make them accessible to some users within the system.</field>
|
||||
</record>
|
||||
|
@ -1678,7 +1682,7 @@
|
|||
<field name="name">Property multi-company</field>
|
||||
<field model="ir.model" name="model_id" ref="model_ir_property"/>
|
||||
<field eval="True" name="global"/>
|
||||
<field name="domain_force">['|',('company_id','child_of',user.company_id.id),('company_id','=',False)]</field>
|
||||
<field name="domain_force">['|',('company_id','=',user.company_id.id),('company_id','=',False)]</field>
|
||||
</record>
|
||||
|
||||
<!--server action view-->
|
||||
|
|
|
@ -26,6 +26,7 @@ import time
|
|||
from tools.config import config
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import logging
|
||||
import re
|
||||
import copy
|
||||
import os
|
||||
|
@ -35,6 +36,7 @@ from report.report_sxw import report_sxw, report_rml
|
|||
class actions(osv.osv):
|
||||
_name = 'ir.actions.actions'
|
||||
_table = 'ir_actions'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Action Name', required=True, size=64),
|
||||
'type': fields.char('Action Type', required=True, size=32,readonly=True),
|
||||
|
@ -97,6 +99,7 @@ class report_xml(osv.osv):
|
|||
_name = 'ir.actions.report.xml'
|
||||
_table = 'ir_act_report_xml'
|
||||
_sequence = 'ir_actions_id_seq'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True, translate=True),
|
||||
'model': fields.char('Object', size=64, required=True),
|
||||
|
@ -143,19 +146,24 @@ class act_window(osv.osv):
|
|||
_name = 'ir.actions.act_window'
|
||||
_table = 'ir_act_window'
|
||||
_sequence = 'ir_actions_id_seq'
|
||||
_order = 'name'
|
||||
|
||||
def _check_model(self, cr, uid, ids, context={}):
|
||||
def _check_model(self, cr, uid, ids, context=None):
|
||||
for action in self.browse(cr, uid, ids, context):
|
||||
if not self.pool.get(action.res_model):
|
||||
return False
|
||||
if action.src_model and not self.pool.get(action.src_model):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _invalid_model_msg(self, cr, uid, ids, context=None):
|
||||
return _('Invalid model name in the action definition.')
|
||||
|
||||
_constraints = [
|
||||
(_check_model, 'Invalid model name in the action definition.', ['res_model','src_model'])
|
||||
(_check_model, _invalid_model_msg, ['res_model','src_model'])
|
||||
]
|
||||
|
||||
def _views_get_fnc(self, cr, uid, ids, name, arg, context={}):
|
||||
def _views_get_fnc(self, cr, uid, ids, name, arg, context=None):
|
||||
res={}
|
||||
for act in self.browse(cr, uid, ids):
|
||||
res[act.id]=[(view.view_id.id, view.view_mode) for view in act.view_ids]
|
||||
|
@ -171,30 +179,34 @@ class act_window(osv.osv):
|
|||
res[act.id].append((False, t))
|
||||
return res
|
||||
|
||||
def _search_view(self, cr, uid, ids, name, arg, context={}):
|
||||
def _search_view(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
def encode(s):
|
||||
if isinstance(s, unicode):
|
||||
return s.encode('utf8')
|
||||
return s
|
||||
for act in self.browse(cr, uid, ids):
|
||||
for act in self.browse(cr, uid, ids, context=context):
|
||||
fields_from_fields_get = self.pool.get(act.res_model).fields_get(cr, uid, context=context)
|
||||
search_view_id = False
|
||||
if act.search_view_id:
|
||||
search_view_id = act.search_view_id.id
|
||||
else:
|
||||
res_view = self.pool.get('ir.ui.view').search(cr, uid, [('model','=',act.res_model),('type','=','search'),('inherit_id','=',False)])
|
||||
res_view = self.pool.get('ir.ui.view').search(cr, uid,
|
||||
[('model','=',act.res_model),('type','=','search'),
|
||||
('inherit_id','=',False)], context=context)
|
||||
if res_view:
|
||||
search_view_id = res_view[0]
|
||||
if search_view_id:
|
||||
field_get = self.pool.get(act.res_model).fields_view_get(cr, uid, search_view_id, 'search', context)
|
||||
field_get = self.pool.get(act.res_model).fields_view_get(cr, uid, search_view_id,
|
||||
'search', context)
|
||||
fields_from_fields_get.update(field_get['fields'])
|
||||
field_get['fields'] = fields_from_fields_get
|
||||
res[act.id] = str(field_get)
|
||||
else:
|
||||
def process_child(node, new_node, doc):
|
||||
for child in node.childNodes:
|
||||
if child.localName=='field' and child.hasAttribute('select') and child.getAttribute('select')=='1':
|
||||
if child.localName=='field' and child.hasAttribute('select') \
|
||||
and child.getAttribute('select')=='1':
|
||||
if child.childNodes:
|
||||
fld = doc.createElement('field')
|
||||
for attr in child.attributes.keys():
|
||||
|
@ -218,7 +230,7 @@ class act_window(osv.osv):
|
|||
res[act.id] = str(form_arch)
|
||||
return res
|
||||
|
||||
def _get_help_status(self, cr, uid, ids, name, arg, context={}):
|
||||
def _get_help_status(self, cr, uid, ids, name, arg, context=None):
|
||||
activate_tips = self.pool.get('res.users').browse(cr, uid, uid).menu_tips
|
||||
return dict([(id, activate_tips) for id in ids])
|
||||
|
||||
|
@ -272,6 +284,19 @@ class act_window(osv.osv):
|
|||
'multi': False,
|
||||
}
|
||||
|
||||
def for_xml_id(self, cr, uid, module, xml_id, context=None):
|
||||
""" Returns the act_window object created for the provided xml_id
|
||||
|
||||
:param module: the module the act_window originates in
|
||||
:param xml_id: the namespace-less id of the action (the @id
|
||||
attribute from the XML file)
|
||||
:return: A read() view of the ir.actions.act_window
|
||||
"""
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
data_id = dataobj._get_id (cr, 1, module, xml_id)
|
||||
res_id = dataobj.browse(cr, uid, data_id, context).res_id
|
||||
return self.read(cr, uid, res_id, [], context)
|
||||
|
||||
act_window()
|
||||
|
||||
class act_window_view(osv.osv):
|
||||
|
@ -302,6 +327,7 @@ class act_wizard(osv.osv):
|
|||
_inherit = 'ir.actions.actions'
|
||||
_table = 'ir_act_wizard'
|
||||
_sequence = 'ir_actions_id_seq'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Wizard Info', size=64, required=True, translate=True),
|
||||
'type': fields.char('Action Type', size=32, required=True),
|
||||
|
@ -320,6 +346,7 @@ class act_url(osv.osv):
|
|||
_name = 'ir.actions.url'
|
||||
_table = 'ir_act_url'
|
||||
_sequence = 'ir_actions_id_seq'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Action Name', size=64, translate=True),
|
||||
'type': fields.char('Action Type', size=32, required=True),
|
||||
|
@ -336,7 +363,7 @@ class act_url(osv.osv):
|
|||
}
|
||||
act_url()
|
||||
|
||||
def model_get(self, cr, uid, context={}):
|
||||
def model_get(self, cr, uid, context=None):
|
||||
wkf_pool = self.pool.get('workflow')
|
||||
ids = wkf_pool.search(cr, uid, [])
|
||||
osvs = wkf_pool.read(cr, uid, ids, ['osv'])
|
||||
|
@ -381,7 +408,7 @@ server_object_lines()
|
|||
#
|
||||
class actions_server(osv.osv):
|
||||
|
||||
def _select_signals(self, cr, uid, context={}):
|
||||
def _select_signals(self, cr, uid, context=None):
|
||||
cr.execute("SELECT distinct w.osv, t.signal FROM wkf w, wkf_activity a, wkf_transition t \
|
||||
WHERE w.id = a.wkf_id AND t.act_from = a.id OR t.act_to = a.id AND t.signal!='' \
|
||||
AND t.signal NOT IN (null, NULL)")
|
||||
|
@ -393,13 +420,13 @@ class actions_server(osv.osv):
|
|||
res.append(line)
|
||||
return res
|
||||
|
||||
def _select_objects(self, cr, uid, context={}):
|
||||
def _select_objects(self, cr, uid, context=None):
|
||||
model_pool = self.pool.get('ir.model')
|
||||
ids = model_pool.search(cr, uid, [('name','not ilike','.')])
|
||||
res = model_pool.read(cr, uid, ids, ['model', 'name'])
|
||||
return [(r['model'], r['name']) for r in res] + [('','')]
|
||||
|
||||
def change_object(self, cr, uid, ids, copy_object, state, context={}):
|
||||
def change_object(self, cr, uid, ids, copy_object, state, context=None):
|
||||
if state == 'object_copy':
|
||||
model_pool = self.pool.get('ir.model')
|
||||
model = copy_object.split(',')[0]
|
||||
|
@ -414,7 +441,7 @@ class actions_server(osv.osv):
|
|||
_name = 'ir.actions.server'
|
||||
_table = 'ir_act_server'
|
||||
_sequence = 'ir_actions_id_seq'
|
||||
_order = 'sequence'
|
||||
_order = 'sequence,name'
|
||||
_columns = {
|
||||
'name': fields.char('Action Name', required=True, size=64, help="Easy to Refer action by name e.g. One Sales Order -> Many Invoices", translate=True),
|
||||
'condition' : fields.char('Condition', size=256, required=True, help="Condition that is to be tested before action is executed, e.g. object.list_price > object.cost_price"),
|
||||
|
@ -470,7 +497,7 @@ class actions_server(osv.osv):
|
|||
}
|
||||
|
||||
def get_email(self, cr, uid, action, context):
|
||||
logger = netsvc.Logger()
|
||||
logger = logging.getLogger('Workflow')
|
||||
obj_pool = self.pool.get(action.model_id.model)
|
||||
id = context.get('active_id')
|
||||
obj = obj_pool.browse(cr, uid, id)
|
||||
|
@ -486,12 +513,12 @@ class actions_server(osv.osv):
|
|||
try:
|
||||
obj = getattr(obj, field)
|
||||
except Exception:
|
||||
logger.notifyChannel('Workflow', netsvc.LOG_ERROR, 'Failed to parse : %s' % (field))
|
||||
logger.exception('Failed to parse: %s', field)
|
||||
|
||||
return obj
|
||||
|
||||
def get_mobile(self, cr, uid, action, context):
|
||||
logger = netsvc.Logger()
|
||||
logger = logging.getLogger('Workflow')
|
||||
obj_pool = self.pool.get(action.model_id.model)
|
||||
id = context.get('active_id')
|
||||
obj = obj_pool.browse(cr, uid, id)
|
||||
|
@ -507,7 +534,7 @@ class actions_server(osv.osv):
|
|||
try:
|
||||
obj = getattr(obj, field)
|
||||
except Exception:
|
||||
logger.notifyChannel('Workflow', netsvc.LOG_ERROR, 'Failed to parse : %s' % (field))
|
||||
logger.exception('Failed to parse: %s', field)
|
||||
|
||||
return obj
|
||||
|
||||
|
@ -543,7 +570,7 @@ class actions_server(osv.osv):
|
|||
|
||||
# FIXME: refactor all the eval() calls in run()!
|
||||
def run(self, cr, uid, ids, context=None):
|
||||
logger = netsvc.Logger()
|
||||
logger = logging.getLogger(self._name)
|
||||
if context is None:
|
||||
context = {}
|
||||
for action in self.browse(cr, uid, ids, context):
|
||||
|
@ -591,18 +618,19 @@ class actions_server(osv.osv):
|
|||
pass
|
||||
|
||||
if not address:
|
||||
logger.notifyChannel('email', netsvc.LOG_INFO, 'Partner Email address not Specified!')
|
||||
logger.info('Partner Email address not Specified!')
|
||||
continue
|
||||
if not user:
|
||||
logger.info('Email-From address not Specified at server!')
|
||||
raise osv.except_osv(_('Error'), _("Please specify server option --email-from !"))
|
||||
|
||||
subject = self.merge_message(cr, uid, action.subject, action, context)
|
||||
body = self.merge_message(cr, uid, action.message, action, context)
|
||||
|
||||
if tools.email_send(user, [address], subject, body, debug=False, subtype='html') == True:
|
||||
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (address))
|
||||
logger.info('Email successfully sent to: %s', address)
|
||||
else:
|
||||
logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (address))
|
||||
logger.warning('Failed to send email to: %s', address)
|
||||
|
||||
if action.state == 'trigger':
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
@ -616,7 +644,7 @@ class actions_server(osv.osv):
|
|||
#TODO: set the user and password from the system
|
||||
# for the sms gateway user / password
|
||||
# USE smsclient module from extra-addons
|
||||
logger.notifyChannel('sms', netsvc.LOG_ERROR, 'SMS Facility has not been implemented yet. Use smsclient module!')
|
||||
logger.warning('SMS Facility has not been implemented yet. Use smsclient module!')
|
||||
|
||||
if action.state == 'other':
|
||||
res = []
|
||||
|
@ -771,7 +799,7 @@ class ir_actions_todo(osv.osv):
|
|||
'sequence': 10,
|
||||
'restart': 'onskip',
|
||||
}
|
||||
_order="sequence,id"
|
||||
_order="sequence,name,id"
|
||||
|
||||
def action_launch(self, cr, uid, ids, context=None):
|
||||
""" Launch Action of Wizard"""
|
||||
|
|
|
@ -24,16 +24,29 @@ from osv.orm import except_orm
|
|||
import tools
|
||||
|
||||
class ir_attachment(osv.osv):
|
||||
def check(self, cr, uid, ids, mode, context=None):
|
||||
def check(self, cr, uid, ids, mode, context=None, values=None):
|
||||
"""Restricts the access to an ir.attachment, according to referred model
|
||||
In the 'document' module, it is overriden to relax this hard rule, since
|
||||
more complex ones apply there.
|
||||
"""
|
||||
if not ids:
|
||||
return
|
||||
ima = self.pool.get('ir.model.access')
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
cr.execute('select distinct res_model from ir_attachment where id IN %s', (tuple(ids),))
|
||||
for obj in cr.fetchall():
|
||||
if obj[0]:
|
||||
ima.check(cr, uid, obj[0], mode, context=context)
|
||||
res_ids = {}
|
||||
if ids:
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
cr.execute('SELECT DISTINCT res_model, res_id FROM ir_attachment WHERE id = ANY (%s)', (ids,))
|
||||
for rmod, rid in cr.fetchall():
|
||||
if not (rmod and rid):
|
||||
continue
|
||||
res_ids.setdefault(rmod,[]).append(rid)
|
||||
if values:
|
||||
if 'res_model' in values and 'res_id' in values:
|
||||
res_ids.setdefault(values['res_model'],[]).append(values['res_id'])
|
||||
|
||||
for model, mids in res_ids.items():
|
||||
self.pool.get(model).check_access_rule(cr, uid, mids, mode, context=context)
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False):
|
||||
|
@ -64,7 +77,7 @@ class ir_attachment(osv.osv):
|
|||
return super(ir_attachment, self).read(cr, uid, ids, fields_to_read, context, load)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
self.check(cr, uid, ids, 'write', context=context)
|
||||
self.check(cr, uid, ids, 'write', context=context, values=vals)
|
||||
return super(ir_attachment, self).write(cr, uid, ids, vals, context)
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
@ -76,15 +89,12 @@ class ir_attachment(osv.osv):
|
|||
return super(ir_attachment, self).unlink(cr, uid, ids, context)
|
||||
|
||||
def create(self, cr, uid, values, context=None):
|
||||
if 'res_model' in values and values['res_model'] != '':
|
||||
self.pool.get('ir.model.access').check(cr, uid, values['res_model'], 'create', context=context)
|
||||
self.check(cr, uid, [], mode='create', context=context, values=values)
|
||||
return super(ir_attachment, self).create(cr, uid, values, context)
|
||||
|
||||
def action_get(self, cr, uid, context=None):
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
data_id = dataobj._get_id(cr, 1, 'base', 'action_attachment')
|
||||
res_id = dataobj.browse(cr, uid, data_id, context).res_id
|
||||
return self.pool.get('ir.actions.act_window').read(cr, uid, res_id, [], context)
|
||||
return self.pool.get('ir.actions.act_window').for_xml_id(
|
||||
cr, uid, 'base', 'action_attachment', context=context)
|
||||
|
||||
def _name_get_resname(self, cr, uid, ids, object,method, context):
|
||||
data = {}
|
||||
|
@ -114,11 +124,11 @@ class ir_attachment(osv.osv):
|
|||
'url': fields.char('Url', size=512, oldname="link"),
|
||||
'type': fields.selection(
|
||||
[ ('url','URL'), ('binary','Binary'), ],
|
||||
'Type', help="Binary File or external URL", required=True),
|
||||
'Type', help="Binary File or external URL", required=True, change_default=True),
|
||||
|
||||
'create_date': fields.datetime('Date Created', readonly=True),
|
||||
'create_uid': fields.many2one('res.users', 'Owner', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'company_id': fields.many2one('res.company', 'Company', change_default=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
"""
|
||||
A module to store some configuration parameters relative to a whole database.
|
||||
"""
|
||||
|
||||
from osv import osv,fields
|
||||
import uuid
|
||||
import datetime
|
||||
from tools import misc
|
||||
|
||||
"""
|
||||
A dictionary holding some configuration parameters to be initialized when the database is created.
|
||||
"""
|
||||
_default_parameters = {
|
||||
"database.uuid": lambda: str(uuid.uuid1()),
|
||||
"database.create_date": lambda: datetime.datetime.now().strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
}
|
||||
|
||||
class ir_config_parameter(osv.osv):
|
||||
""" An osv to old configuration parameters for a given database.
|
||||
|
||||
To be short, it's just a global dictionary of strings stored in a table. """
|
||||
|
||||
_name = 'ir.config_parameter'
|
||||
|
||||
_columns = {
|
||||
# The key of the configuration parameter.
|
||||
'key': fields.char('Key', size=256, required=True, select=1),
|
||||
# The value of the configuration parameter.
|
||||
'value': fields.text('Value', required=True),
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
('key_uniq', 'unique (key)', 'Key must be unique.')
|
||||
]
|
||||
|
||||
def init(self, cr):
|
||||
"""
|
||||
Initializes the parameters listed in _default_parameters.
|
||||
"""
|
||||
for key, func in _default_parameters.iteritems():
|
||||
ids = self.search(cr, 1, [('key','=',key)])
|
||||
if not ids:
|
||||
self.set_param(cr, 1, key, func())
|
||||
|
||||
def get_param(self, cr, uid, key, context=None):
|
||||
""" Get the value of a parameter.
|
||||
|
||||
@param key: The key of the parameter.
|
||||
@type key: string
|
||||
@return: The value of the parameter, False if it does not exist.
|
||||
@rtype: string
|
||||
"""
|
||||
ids = self.search(cr, uid, [('key','=',key)], context=context)
|
||||
if not ids:
|
||||
return False
|
||||
param = self.browse(cr, uid, ids[0], context=context)
|
||||
value = param.value
|
||||
return value
|
||||
|
||||
def set_param(self, cr, uid, key, value, context=None):
|
||||
""" Set the value of a parameter.
|
||||
|
||||
@param key: The key of the parameter.
|
||||
@type key: string
|
||||
@param value: The value of the parameter.
|
||||
@type value: string
|
||||
@return: Return the previous value of the parameter of False if it did
|
||||
not existed.
|
||||
@rtype: string
|
||||
"""
|
||||
ids = self.search(cr, uid, [('key','=',key)], context=context)
|
||||
if ids:
|
||||
param = self.browse(cr, uid, ids[0], context=context)
|
||||
old = param.value
|
||||
self.write(cr, uid, ids, {'value': value}, context=context)
|
||||
return old
|
||||
else:
|
||||
self.create(cr, uid, {'key': key, 'value': value}, context=context)
|
||||
return False
|
||||
|
||||
ir_config_parameter()
|
|
@ -2,20 +2,19 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
# Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
@ -43,6 +42,7 @@ _intervalTypes = {
|
|||
|
||||
class ir_cron(osv.osv, netsvc.Agent):
|
||||
_name = "ir.cron"
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=60, required=True),
|
||||
'user_id': fields.many2one('res.users', 'User', required=True),
|
||||
|
@ -124,7 +124,7 @@ class ir_cron(osv.osv, netsvc.Agent):
|
|||
cr.commit()
|
||||
|
||||
|
||||
cr.execute('select min(nextcall) as min_next_call from ir_cron where numbercall<>0 and active and nextcall>=now()')
|
||||
cr.execute('select min(nextcall) as min_next_call from ir_cron where numbercall<>0 and active')
|
||||
next_call = cr.dictfetchone()['min_next_call']
|
||||
if next_call:
|
||||
next_call = time.mktime(time.strptime(next_call, '%Y-%m-%d %H:%M:%S'))
|
||||
|
@ -145,7 +145,8 @@ class ir_cron(osv.osv, netsvc.Agent):
|
|||
|
||||
def restart(self, dbname):
|
||||
self.cancel(dbname)
|
||||
self._poolJobs(dbname)
|
||||
# Reschedule cron processing job asap, but not in the current thread
|
||||
self.setAlarm(self._poolJobs, time.time(), dbname, dbname)
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
res = super(ir_cron, self).create(cr, uid, vals, context=context)
|
||||
|
|
|
@ -24,6 +24,7 @@ from osv import fields,osv
|
|||
|
||||
class ir_exports(osv.osv):
|
||||
_name = "ir.exports"
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Export Name', size=128),
|
||||
'resource': fields.char('Resource', size=128, select=True),
|
||||
|
@ -35,6 +36,7 @@ ir_exports()
|
|||
|
||||
class ir_exports_line(osv.osv):
|
||||
_name = 'ir.exports.line'
|
||||
_order = 'id'
|
||||
_columns = {
|
||||
'name': fields.char('Field Name', size=64),
|
||||
'export_id': fields.many2one('ir.exports', 'Export', select=True, ondelete='cascade'),
|
||||
|
|
|
@ -43,7 +43,7 @@ def _get_fields_type(self, cr, uid, context=None):
|
|||
class ir_model(osv.osv):
|
||||
_name = 'ir.model'
|
||||
_description = "Objects"
|
||||
_rec_name = 'name'
|
||||
_order = 'model'
|
||||
|
||||
def _is_osv_memory(self, cr, uid, ids, field_name, arg, context=None):
|
||||
models = self.browse(cr, uid, ids, context=context)
|
||||
|
@ -75,12 +75,14 @@ class ir_model(osv.osv):
|
|||
fnct_search=_search_osv_memory,
|
||||
help="Indicates whether this object model lives in memory only, i.e. is not persisted (osv.osv_memory)")
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'model': lambda *a: 'x_',
|
||||
'state': lambda self,cr,uid,ctx={}: (ctx and ctx.get('manual',False)) and 'manual' or 'base',
|
||||
'state': lambda self,cr,uid,ctx=None: (ctx and ctx.get('manual',False)) and 'manual' or 'base',
|
||||
}
|
||||
def _check_model_name(self, cr, uid, ids):
|
||||
for model in self.browse(cr, uid, ids):
|
||||
|
||||
def _check_model_name(self, cr, uid, ids, context=None):
|
||||
for model in self.browse(cr, uid, ids, context=context):
|
||||
if model.state=='manual':
|
||||
if not model.model.startswith('x_'):
|
||||
return False
|
||||
|
@ -88,8 +90,10 @@ class ir_model(osv.osv):
|
|||
return False
|
||||
return True
|
||||
|
||||
def _model_name_msg(self, cr, uid, ids, context=None):
|
||||
return _('The Object name must start with x_ and not contain any special character !')
|
||||
_constraints = [
|
||||
(_check_model_name, 'The Object name must start with x_ and not contain any special character !', ['model']),
|
||||
(_check_model_name, _model_name_msg, ['model']),
|
||||
]
|
||||
|
||||
# overridden to allow searching both on model name (model field)
|
||||
|
@ -180,9 +184,12 @@ class ir_model_fields(osv.osv):
|
|||
'field_description': lambda *a: '',
|
||||
'selectable': lambda *a: 1,
|
||||
}
|
||||
_order = "id"
|
||||
_order = "name"
|
||||
def _size_gt_zero_msg(self, cr, user, ids, context=None):
|
||||
return _('Size of the field can never be less than 1 !')
|
||||
|
||||
_sql_constraints = [
|
||||
('size_gt_zero', 'CHECK (size>0)', 'Size of the field can never be less than 1 !'),
|
||||
('size_gt_zero', 'CHECK (size>0)',_size_gt_zero_msg ),
|
||||
]
|
||||
def unlink(self, cr, user, ids, context=None):
|
||||
for field in self.browse(cr, user, ids, context):
|
||||
|
@ -369,6 +376,7 @@ ir_model_access()
|
|||
class ir_model_data(osv.osv):
|
||||
_name = 'ir.model.data'
|
||||
__logger = logging.getLogger('addons.base.'+_name)
|
||||
_order = 'module,model,name'
|
||||
_columns = {
|
||||
'name': fields.char('XML Identifier', required=True, size=128, select=1),
|
||||
'model': fields.char('Object', required=True, size=64, select=1),
|
||||
|
@ -381,8 +389,8 @@ class ir_model_data(osv.osv):
|
|||
_defaults = {
|
||||
'date_init': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'date_update': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'noupdate': lambda *a: False,
|
||||
'module': lambda *a: ''
|
||||
'noupdate': False,
|
||||
'module': ''
|
||||
}
|
||||
_sql_constraints = [
|
||||
('module_name_uniq', 'unique(name, module)', 'You cannot have multiple records with the same id for the same module !'),
|
||||
|
@ -394,6 +402,12 @@ class ir_model_data(osv.osv):
|
|||
self.doinit = True
|
||||
self.unlink_mark = {}
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
super(ir_model_data, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_model_data_module_name_index\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX ir_model_data_module_name_index ON ir_model_data (module, name)')
|
||||
|
||||
@tools.cache()
|
||||
def _get_id(self, cr, uid, module, xml_id):
|
||||
"""Returns the id of the ir.model.data record corresponding to a given module and xml_id (cached) or raise a ValueError if not found"""
|
||||
|
@ -441,18 +455,19 @@ class ir_model_data(osv.osv):
|
|||
action_id = False
|
||||
|
||||
if xml_id:
|
||||
cr.execute('select id,res_id from ir_model_data where module=%s and name=%s', (module,xml_id))
|
||||
cr.execute('''SELECT imd.id, imd.res_id, md.id
|
||||
FROM ir_model_data imd LEFT JOIN %s md ON (imd.res_id = md.id)
|
||||
WHERE imd.module=%%s AND imd.name=%%s''' % model_obj._table,
|
||||
(module, xml_id))
|
||||
results = cr.fetchall()
|
||||
for action_id2,res_id2 in results:
|
||||
cr.execute('select id from '+model_obj._table+' where id=%s', (res_id2,))
|
||||
result3 = cr.fetchone()
|
||||
if not result3:
|
||||
for imd_id2,res_id2,real_id2 in results:
|
||||
if not real_id2:
|
||||
self._get_id.clear_cache(cr.dbname, uid, module, xml_id)
|
||||
self.get_object_reference.clear_cache(cr.dbname, uid, module, xml_id)
|
||||
cr.execute('delete from ir_model_data where id=%s', (action_id2,))
|
||||
cr.execute('delete from ir_model_data where id=%s', (imd_id2,))
|
||||
res_id = False
|
||||
else:
|
||||
res_id,action_id = res_id2,action_id2
|
||||
res_id,action_id = res_id2,imd_id2
|
||||
|
||||
if action_id and res_id:
|
||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
||||
|
|
|
@ -28,6 +28,7 @@ from tools.safe_eval import safe_eval as eval
|
|||
|
||||
class ir_rule(osv.osv):
|
||||
_name = 'ir.rule'
|
||||
_order = 'name'
|
||||
_MODES = ['read', 'write', 'create', 'unlink']
|
||||
|
||||
def _domain_force_get(self, cr, uid, ids, field_name, arg, context={}):
|
||||
|
@ -47,7 +48,7 @@ class ir_rule(osv.osv):
|
|||
res[rule.id] = False
|
||||
return res
|
||||
|
||||
def _check_model_obj(self, cr, uid, ids, context={}):
|
||||
def _check_model_obj(self, cr, uid, ids, context=None):
|
||||
return not any(isinstance(self.pool.get(rule.model_id.model), osv.osv_memory) for rule in self.browse(cr, uid, ids, context))
|
||||
|
||||
_columns = {
|
||||
|
|
|
@ -2,20 +2,19 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
# Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
@ -26,6 +25,7 @@ import pooler
|
|||
|
||||
class ir_sequence_type(osv.osv):
|
||||
_name = 'ir.sequence.type'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Name',size=64, required=True),
|
||||
'code': fields.char('Code',size=32, required=True),
|
||||
|
@ -38,6 +38,7 @@ def _code_get(self, cr, uid, context={}):
|
|||
|
||||
class ir_sequence(osv.osv):
|
||||
_name = 'ir.sequence'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Name',size=64, required=True),
|
||||
'code': fields.selection(_code_get, 'Code',size=64, required=True),
|
||||
|
@ -74,17 +75,22 @@ class ir_sequence(osv.osv):
|
|||
|
||||
def get_id(self, cr, uid, sequence_id, test='id', context=None):
|
||||
assert test in ('code','id')
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.id
|
||||
seq_id = self.search(cr, uid, [(test,'=',sequence_id),('active','=',True),('company_id','=',company_id)])
|
||||
if not seq_id:
|
||||
seq_id = self.search(cr, uid, [(test,'=',sequence_id),('active','=',True),('company_id','=',False)])
|
||||
if seq_id:
|
||||
sequece_data = self.browse(cr, uid, seq_id[0], context)
|
||||
self.write(cr, uid, sequece_data.id, {'number_next': sequece_data.number_next + sequece_data.number_increment})
|
||||
if sequece_data.number_next:
|
||||
return self._process(sequece_data.prefix) + '%%0%sd' % sequece_data.padding % sequece_data.number_next + self._process(sequece_data.suffix)
|
||||
company_id = self.pool.get('res.users').read(cr, uid, uid, ['company_id'], context=context)['company_id'][0] or None
|
||||
cr.execute('''SELECT id, number_next, prefix, suffix, padding
|
||||
FROM ir_sequence
|
||||
WHERE %s=%%s
|
||||
AND active=true
|
||||
AND (company_id = %%s or company_id is NULL)
|
||||
ORDER BY company_id, id
|
||||
FOR UPDATE NOWAIT''' % test,
|
||||
(sequence_id, company_id))
|
||||
res = cr.dictfetchone()
|
||||
if res:
|
||||
cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=true', (res['id'],))
|
||||
if res['number_next']:
|
||||
return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix'])
|
||||
else:
|
||||
return self._process(sequece_data.prefix) + self._process(sequece_data.suffix)
|
||||
return self._process(res['prefix']) + self._process(res['suffix'])
|
||||
return False
|
||||
|
||||
def get(self, cr, uid, code):
|
||||
|
|
|
@ -57,7 +57,7 @@ class ir_translation(osv.osv):
|
|||
_columns = {
|
||||
'name': fields.char('Field Name', size=128, required=True),
|
||||
'res_id': fields.integer('Resource ID', select=True),
|
||||
'lang': fields.selection(_get_language, string='Language', size=5),
|
||||
'lang': fields.selection(_get_language, string='Language', size=16),
|
||||
'type': fields.selection(TRANSLATION_TYPE, string='Type', size=16, select=True),
|
||||
'src': fields.text('Source'),
|
||||
'value': fields.text('Translation Value'),
|
||||
|
@ -138,7 +138,7 @@ class ir_translation(osv.osv):
|
|||
and source. All values passed to this method should be unicode (not byte strings),
|
||||
especially ``source``.
|
||||
|
||||
:param name: identification of the term to translate, such as field name
|
||||
:param name: identification of the term to translate, such as field name (optional if source is passed)
|
||||
:param types: single string defining type of term to translate (see ``type`` field on ir.translation), or sequence of allowed types (strings)
|
||||
:param lang: language code of the desired translation
|
||||
:param source: optional source term to translate (should be unicode)
|
||||
|
@ -153,19 +153,22 @@ class ir_translation(osv.osv):
|
|||
if isinstance(types, basestring):
|
||||
types = (types,)
|
||||
if source:
|
||||
cr.execute('select value ' \
|
||||
'from ir_translation ' \
|
||||
'where lang=%s ' \
|
||||
'and type in %s ' \
|
||||
'and name=%s ' \
|
||||
'and src=%s',
|
||||
(lang or '', types, tools.ustr(name), source))
|
||||
query = """SELECT value
|
||||
FROM ir_translation
|
||||
WHERE lang=%s
|
||||
AND type in %s
|
||||
AND src=%s"""
|
||||
params = (lang or '', types, source)
|
||||
if name:
|
||||
query += " AND name=%s"
|
||||
params += (tools.ustr(name),)
|
||||
cr.execute(query, params)
|
||||
else:
|
||||
cr.execute('select value ' \
|
||||
'from ir_translation ' \
|
||||
'where lang=%s ' \
|
||||
'and type in %s ' \
|
||||
'and name=%s',
|
||||
cr.execute("""SELECT value
|
||||
FROM ir_translation
|
||||
WHERE lang=%s
|
||||
AND type in %s
|
||||
AND name=%s""",
|
||||
(lang or '', types, tools.ustr(name)))
|
||||
res = cr.fetchone()
|
||||
trad = res and res[0] or u''
|
||||
|
|
|
@ -19,9 +19,13 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
import base64
|
||||
import re
|
||||
|
||||
import tools
|
||||
import addons
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
def one_in(setA, setB):
|
||||
"""Check the presence of an element of setA in setB
|
||||
|
@ -31,25 +35,6 @@ def one_in(setA, setB):
|
|||
return True
|
||||
return False
|
||||
|
||||
def cond(C, X, Y):
|
||||
if C: return X
|
||||
return Y
|
||||
|
||||
class many2many_unique(fields.many2many):
|
||||
def set(self, cr, obj, id, name, values, user=None, context=None):
|
||||
if not values:
|
||||
return
|
||||
val = values[:]
|
||||
for act in values:
|
||||
if act[0]==4:
|
||||
cr.execute('SELECT * FROM '+self._rel+' \
|
||||
WHERE '+self._id1+'=%s AND '+self._id2+'=%s', (id, act[1]))
|
||||
if cr.fetchall():
|
||||
val.remove(act)
|
||||
return super(many2many_unique, self).set(cr, obj, id, name, val, user=user,
|
||||
context=context)
|
||||
|
||||
|
||||
class ir_ui_menu(osv.osv):
|
||||
_name = 'ir.ui.menu'
|
||||
|
||||
|
@ -67,8 +52,10 @@ class ir_ui_menu(osv.osv):
|
|||
# radical but this doesn't frequently happen
|
||||
self._cache = {}
|
||||
|
||||
def create_shortcut(self, cr, uid, values, context={}):
|
||||
def create_shortcut(self, cr, uid, values, context=None):
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
if context is None:
|
||||
context = {}
|
||||
new_context = context.copy()
|
||||
for key in context:
|
||||
if key.startswith('default_'):
|
||||
|
@ -91,22 +78,15 @@ class ir_ui_menu(osv.osv):
|
|||
self._cache[key] = True
|
||||
return action_id
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False):
|
||||
|
||||
ids = super(ir_ui_menu, self).search(cr, uid, args, offset=0,
|
||||
limit=None, order=order, context=context, count=False)
|
||||
|
||||
if not ids:
|
||||
if count:
|
||||
return 0
|
||||
return []
|
||||
|
||||
|
||||
def _filter_visible_menus(self, cr, uid, ids, context=None):
|
||||
"""Filters the give menu ids to only keep the menu items that should be
|
||||
visible in the menu hierarchy of the current user.
|
||||
Uses a cache for speeding up the computation.
|
||||
"""
|
||||
modelaccess = self.pool.get('ir.model.access')
|
||||
user_groups = set(self.pool.get('res.users').read(cr, 1, uid, ['groups_id'])['groups_id'])
|
||||
result = []
|
||||
for menu in self.browse(cr, uid, ids):
|
||||
for menu in self.browse(cr, uid, ids, context=context):
|
||||
# this key works because user access rights are all based on user's groups (cfr ir_model_access.check)
|
||||
key = (cr.dbname, menu.id, tuple(user_groups))
|
||||
if key in self._cache:
|
||||
|
@ -147,6 +127,25 @@ class ir_ui_menu(osv.osv):
|
|||
|
||||
result.append(menu.id)
|
||||
self._cache[key] = True
|
||||
return result
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
ids = super(ir_ui_menu, self).search(cr, uid, args, offset=0,
|
||||
limit=None, order=order, context=context, count=False)
|
||||
|
||||
if not ids:
|
||||
if count:
|
||||
return 0
|
||||
return []
|
||||
|
||||
# menu filtering is done only on main menu tree, not other menu lists
|
||||
if context.get('ir.ui.menu.full_list'):
|
||||
result = ids
|
||||
else:
|
||||
result = self._filter_visible_menus(cr, uid, ids, context=context)
|
||||
|
||||
if offset:
|
||||
result = result[long(offset):]
|
||||
|
@ -172,6 +171,10 @@ class ir_ui_menu(osv.osv):
|
|||
parent_path = ''
|
||||
return parent_path + menu.name
|
||||
|
||||
def create(self, *args, **kwargs):
|
||||
self.clear_cache()
|
||||
return super(ir_ui_menu, self).create(*args, **kwargs)
|
||||
|
||||
def write(self, *args, **kwargs):
|
||||
self.clear_cache()
|
||||
return super(ir_ui_menu, self).write(*args, **kwargs)
|
||||
|
@ -251,30 +254,42 @@ class ir_ui_menu(osv.osv):
|
|||
return {}
|
||||
return {'type': {'icon_pict': 'picture'}, 'value': {'icon_pict': ('stock', (icon,'ICON_SIZE_MENU'))}}
|
||||
|
||||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select distinct parent_id from ir_ui_menu where id IN %s',(tuple(ids),))
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
return False
|
||||
level -= 1
|
||||
return True
|
||||
|
||||
|
||||
def read_image(self, path):
|
||||
path_info = path.split(',')
|
||||
icon_path = addons.get_module_resource(path_info[0],path_info[1])
|
||||
icon = tools.file_open(icon_path,'rb').read()
|
||||
return base64.encodestring(icon)
|
||||
|
||||
def _get_image_icon(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for menu in self.browse(cr, uid, ids, context=context):
|
||||
res[menu.id] = {
|
||||
'web_icon_data': False,
|
||||
'web_icon_hover_data': False,
|
||||
}
|
||||
if not menu.parent_id:
|
||||
if menu.web_icon_hover:
|
||||
res[menu.id]['web_icon_hover_data'] = self.read_image(menu.web_icon_hover)
|
||||
if menu.web_icon:
|
||||
res[menu.id]['web_icon_data'] = self.read_image(menu.web_icon)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Menu', size=64, required=True, translate=True),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'child_id' : fields.one2many('ir.ui.menu', 'parent_id','Child IDs'),
|
||||
'parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', select=True),
|
||||
'groups_id': many2many_unique('res.groups', 'ir_ui_menu_group_rel',
|
||||
'groups_id': fields.many2many('res.groups', 'ir_ui_menu_group_rel',
|
||||
'menu_id', 'gid', 'Groups', help="If you have groups, the visibility of this menu will be based on these groups. "\
|
||||
"If this field is empty, OpenERP will compute visibility based on the related object's read access."),
|
||||
'complete_name': fields.function(_get_full_name, method=True,
|
||||
string='Complete Name', type='char', size=128),
|
||||
'icon': fields.selection(tools.icons, 'Icon', size=64),
|
||||
'icon_pict': fields.function(_get_icon_pict, method=True, type='char', size=32),
|
||||
'web_icon': fields.char('Icon File', size=128),
|
||||
'web_icon_hover':fields.char('Icon Over File', size=128),
|
||||
'web_icon_data': fields.function(_get_image_icon, string='Web Icons', type='binary', method=True, readonly=True, store=True, multi='icon'),
|
||||
'web_icon_hover_data':fields.function(_get_image_icon, string='Web Icons Over', type='binary', method=True, readonly=True, store=True,multi='icon'),
|
||||
'action': fields.function(_action, fnct_inv=_action_inv,
|
||||
method=True, type='reference', string='Action',
|
||||
selection=[
|
||||
|
@ -285,13 +300,17 @@ class ir_ui_menu(osv.osv):
|
|||
('ir.actions.server', 'ir.actions.server'),
|
||||
]),
|
||||
}
|
||||
|
||||
def _rec_message(self, cr, uid, ids, context=None):
|
||||
return _('Error ! You can not create recursive Menu.')
|
||||
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive Menu.', ['parent_id'])
|
||||
(osv.osv._check_recursion, _rec_message , ['parent_id'])
|
||||
]
|
||||
_defaults = {
|
||||
'icon' : lambda *a: 'STOCK_OPEN',
|
||||
'icon_pict': lambda *a: ('stock', ('STOCK_OPEN','ICON_SIZE_MENU')),
|
||||
'sequence' : lambda *a: 10,
|
||||
'icon' : 'STOCK_OPEN',
|
||||
'icon_pict': ('stock', ('STOCK_OPEN','ICON_SIZE_MENU')),
|
||||
'sequence' : 10,
|
||||
}
|
||||
_order = "sequence,id"
|
||||
ir_ui_menu()
|
||||
|
|
|
@ -28,7 +28,7 @@ import netsvc
|
|||
import os
|
||||
import logging
|
||||
|
||||
def _check_xml(self, cr, uid, ids, context={}):
|
||||
def _check_xml(self, cr, uid, ids, context=None):
|
||||
logger = logging.getLogger('init')
|
||||
for view in self.browse(cr, uid, ids, context):
|
||||
eview = etree.fromstring(view.arch.encode('utf8'))
|
||||
|
@ -44,17 +44,23 @@ def _check_xml(self, cr, uid, ids, context={}):
|
|||
class view_custom(osv.osv):
|
||||
_name = 'ir.ui.view.custom'
|
||||
_columns = {
|
||||
'ref_id': fields.many2one('ir.ui.view', 'Original View'),
|
||||
'user_id': fields.many2one('res.users', 'User'),
|
||||
'ref_id': fields.many2one('ir.ui.view', 'Original View', select=True),
|
||||
'user_id': fields.many2one('res.users', 'User', select=True),
|
||||
'arch': fields.text('View Architecture', required=True),
|
||||
}
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
super(view_custom, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_custom_user_id_ref_id\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX ir_ui_view_custom_user_id_ref_id ON ir_ui_view_custom (user_id, ref_id)')
|
||||
view_custom()
|
||||
|
||||
class view(osv.osv):
|
||||
_name = 'ir.ui.view'
|
||||
_columns = {
|
||||
'name': fields.char('View Name',size=64, required=True),
|
||||
'model': fields.char('Object', size=64, required=True),
|
||||
'model': fields.char('Object', size=64, required=True, select=True),
|
||||
'priority': fields.integer('Sequence', required=True),
|
||||
'type': fields.selection((
|
||||
('tree','Tree'),
|
||||
|
@ -64,9 +70,9 @@ class view(osv.osv):
|
|||
('calendar', 'Calendar'),
|
||||
('diagram','Diagram'),
|
||||
('gantt', 'Gantt'),
|
||||
('search','Search')), 'View Type', required=True),
|
||||
('search','Search')), 'View Type', required=True, select=True),
|
||||
'arch': fields.text('View Architecture', required=True),
|
||||
'inherit_id': fields.many2one('ir.ui.view', 'Inherited View', ondelete='cascade'),
|
||||
'inherit_id': fields.many2one('ir.ui.view', 'Inherited View', ondelete='cascade', select=True),
|
||||
'field_parent': fields.char('Child Field',size=64),
|
||||
'xml_id': fields.function(osv.osv.get_xml_id, type='char', size=128, string="XML ID",
|
||||
method=True, help="ID of the view defined in xml file"),
|
||||
|
@ -75,11 +81,17 @@ class view(osv.osv):
|
|||
'arch': '<?xml version="1.0"?>\n<tree string="My view">\n\t<field name="name"/>\n</tree>',
|
||||
'priority': 16
|
||||
}
|
||||
_order = "priority"
|
||||
_order = "priority,name"
|
||||
_constraints = [
|
||||
(_check_xml, 'Invalid XML for View Architecture!', ['arch'])
|
||||
]
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
super(view, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_model_type_inherit_id\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX ir_ui_view_model_type_inherit_id ON ir_ui_view (model, type, inherit_id)')
|
||||
|
||||
def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'):
|
||||
|
||||
if not isinstance(ids, (list, tuple)):
|
||||
|
@ -195,15 +207,21 @@ class view_sc(osv.osv):
|
|||
'name': fields.char('Shortcut Name', size=64, required=True),
|
||||
'res_id': fields.many2one('ir.ui.menu','Resource Ref.', ondelete='cascade'),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'user_id': fields.many2one('res.users', 'User Ref.', required=True, ondelete='cascade'),
|
||||
'resource': fields.char('Resource Name', size=64, required=True)
|
||||
'user_id': fields.many2one('res.users', 'User Ref.', required=True, ondelete='cascade', select=True),
|
||||
'resource': fields.char('Resource Name', size=64, required=True, select=True)
|
||||
}
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
super(view_sc, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_sc_user_id_resource\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX ir_ui_view_sc_user_id_resource ON ir_ui_view_sc (user_id, resource)')
|
||||
|
||||
def get_sc(self, cr, uid, user_id, model='ir.ui.menu', context={}):
|
||||
ids = self.search(cr, uid, [('user_id','=',user_id),('resource','=',model)], context=context)
|
||||
return self.read(cr, uid, ids, ['res_id','name'], context=context)
|
||||
|
||||
_order = 'sequence'
|
||||
_order = 'sequence,name'
|
||||
_defaults = {
|
||||
'resource': lambda *a: 'ir.ui.menu',
|
||||
'user_id': lambda obj, cr, uid, context: uid,
|
||||
|
|
|
@ -26,8 +26,7 @@ from tools.translate import _
|
|||
|
||||
EXCLUDED_FIELDS = set((
|
||||
'report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml',
|
||||
'report_sxw_content_data', 'report_rml_content_data', 'search_view',
|
||||
'search_view_id'))
|
||||
'report_sxw_content_data', 'report_rml_content_data', 'search_view', ))
|
||||
|
||||
class ir_values(osv.osv):
|
||||
_name = 'ir.values'
|
||||
|
@ -72,21 +71,21 @@ class ir_values(osv.osv):
|
|||
'name': fields.char('Name', size=128),
|
||||
'model_id': fields.many2one('ir.model', 'Object', size=128,
|
||||
help="This field is not used, it only helps you to select a good model."),
|
||||
'model': fields.char('Object Name', size=128),
|
||||
'model': fields.char('Object Name', size=128, select=True),
|
||||
'action_id': fields.many2one('ir.actions.actions', 'Action',
|
||||
help="This field is not used, it only helps you to select the right action."),
|
||||
'value': fields.text('Value'),
|
||||
'value_unpickle': fields.function(_value_unpickle, fnct_inv=_value_pickle,
|
||||
method=True, type='text', string='Value'),
|
||||
'object': fields.boolean('Is Object'),
|
||||
'key': fields.selection([('action','Action'),('default','Default')], 'Type', size=128),
|
||||
'key2' : fields.char('Event Type',help="The kind of action or button in the client side that will trigger the action.", size=128),
|
||||
'key': fields.selection([('action','Action'),('default','Default')], 'Type', size=128, select=True),
|
||||
'key2' : fields.char('Event Type',help="The kind of action or button in the client side that will trigger the action.", size=128, select=True),
|
||||
'meta': fields.text('Meta Datas'),
|
||||
'meta_unpickle': fields.function(_value_unpickle, fnct_inv=_value_pickle,
|
||||
method=True, type='text', string='Metadata'),
|
||||
'res_id': fields.integer('Object ID', help="Keep 0 if the action must appear on all resources."),
|
||||
'user_id': fields.many2one('res.users', 'User', ondelete='cascade'),
|
||||
'company_id': fields.many2one('res.company', 'Company')
|
||||
'res_id': fields.integer('Object ID', help="Keep 0 if the action must appear on all resources.", select=True),
|
||||
'user_id': fields.many2one('res.users', 'User', ondelete='cascade', select=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', select=True)
|
||||
}
|
||||
_defaults = {
|
||||
'key': lambda *a: 'action',
|
||||
|
@ -94,11 +93,11 @@ class ir_values(osv.osv):
|
|||
'company_id': lambda *a: False
|
||||
}
|
||||
|
||||
def _auto_init(self, cr, context={}):
|
||||
def _auto_init(self, cr, context=None):
|
||||
super(ir_values, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_values_key_model_key2_index\'')
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_values_key_model_key2_res_id_user_id_idx\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX ir_values_key_model_key2_index ON ir_values (key, model, key2)')
|
||||
cr.execute('CREATE INDEX ir_values_key_model_key2_res_id_user_id_idx ON ir_values (key, model, key2, res_id, user_id)')
|
||||
|
||||
def set(self, cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=False, preserve_user=False, company=False):
|
||||
if isinstance(value, unicode):
|
||||
|
|
|
@ -26,6 +26,7 @@ import netsvc
|
|||
class workflow(osv.osv):
|
||||
_name = "workflow"
|
||||
_table = "wkf"
|
||||
_order = "name"
|
||||
# _log_access = False
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
|
@ -115,6 +116,7 @@ workflow()
|
|||
class wkf_activity(osv.osv):
|
||||
_name = "workflow.activity"
|
||||
_table = "wkf_activity"
|
||||
_order = "name"
|
||||
# _log_access = False
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True),
|
||||
|
@ -171,15 +173,15 @@ class wkf_instance(osv.osv):
|
|||
_log_access = False
|
||||
_columns = {
|
||||
'wkf_id': fields.many2one('workflow', 'Workflow', ondelete='cascade', select=True),
|
||||
'res_id': fields.integer('Resource ID', select=True),
|
||||
'res_type': fields.char('Resource Object', size=64, select=True),
|
||||
'state': fields.char('State', size=32, select=True),
|
||||
'res_id': fields.integer('Resource ID'),
|
||||
'res_type': fields.char('Resource Object', size=64),
|
||||
'state': fields.char('State', size=32),
|
||||
}
|
||||
def _auto_init(self, cr, context={}):
|
||||
def _auto_init(self, cr, context=None):
|
||||
super(wkf_instance, self)._auto_init(cr, context)
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_id_res_type_state_index\'')
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_type_res_id_state_index\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX wkf_instance_res_id_res_type_state_index ON wkf_instance (res_id, res_type, state)')
|
||||
cr.execute('CREATE INDEX wkf_instance_res_type_res_id_state_index ON wkf_instance (res_type, res_id, state)')
|
||||
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_id_wkf_id_index\'')
|
||||
if not cr.fetchone():
|
||||
cr.execute('CREATE INDEX wkf_instance_res_id_wkf_id_index ON wkf_instance (res_id, wkf_id)')
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import pooler
|
||||
import time
|
||||
import netsvc
|
||||
|
||||
from tools.misc import debug
|
||||
from tools.misc import ustr
|
||||
from tools.translate import _
|
||||
import tools.maintenance as tm
|
||||
|
||||
class maintenance_contract_module(osv.osv):
|
||||
_name ="maintenance.contract.module"
|
||||
_description = "maintenance contract modules"
|
||||
_columns = {
|
||||
'name' : fields.char('Name', size=128, required=True),
|
||||
'version': fields.char('Version', size=64,),
|
||||
}
|
||||
|
||||
maintenance_contract_module()
|
||||
|
||||
class maintenance_contract(osv.osv):
|
||||
_name = "maintenance.contract"
|
||||
_description = "Maintenance Contract"
|
||||
|
||||
def _get_valid_contracts(self, cr, uid):
|
||||
return [contract for contract in self.browse(cr, uid, self.search(cr, uid, [])) if contract.state == 'valid']
|
||||
|
||||
def status(self, cr, uid):
|
||||
covered_modules, uncovered_modules = set(), set()
|
||||
|
||||
status = 'none'
|
||||
for contract in self._get_valid_contracts(cr, uid):
|
||||
covered_modules.update([m.name for m in contract.module_ids])
|
||||
|
||||
if covered_modules:
|
||||
modobj = self.pool.get('ir.module.module')
|
||||
modids = modobj.search(cr, uid, [('state', '=', 'installed')])
|
||||
uncovered_modules = set(m.name for m in modobj.browse(cr, uid, modids)) - covered_modules
|
||||
status = ['full', 'partial'][len(uncovered_modules) > 0]
|
||||
|
||||
return {
|
||||
'status': status,
|
||||
'uncovered_modules': list(uncovered_modules),
|
||||
}
|
||||
|
||||
def send(self, cr, uid, tb, explanations, remarks=None):
|
||||
status = self.status(cr, uid)
|
||||
if status['status'] != 'full':
|
||||
raise osv.except_osv(_('Error'), _("Your can't submit bug reports due to uncovered modules: %s") % (', '.join(status['uncovered_modules']),))
|
||||
|
||||
dbmsg = _('This error occurs on database %s') % (cr.dbname,)
|
||||
if not remarks:
|
||||
remarks = dbmsg
|
||||
else:
|
||||
remarks += '\n\n-----\n' + dbmsg
|
||||
|
||||
valid_contracts = self._get_valid_contracts(cr, uid)
|
||||
|
||||
crm_case_id = None
|
||||
rc = None
|
||||
try:
|
||||
for contract in valid_contracts:
|
||||
rc = tm.remote_contract(contract.name, contract.password)
|
||||
if rc.id:
|
||||
break
|
||||
rc = None
|
||||
|
||||
if not rc:
|
||||
raise osv.except_osv(_('Error'), _('Unable to find a valid contract'))
|
||||
|
||||
origin = 'client'
|
||||
crm_case_id = rc.submit(rc.id, tb, explanations, remarks or '', origin)
|
||||
|
||||
except tm.RemoteContractException, rce:
|
||||
netsvc.Logger().notifyChannel('maintenance', netsvc.LOG_INFO, rce)
|
||||
except osv.except_osv:
|
||||
raise
|
||||
except:
|
||||
pass
|
||||
|
||||
cid = rc and rc.name or valid_contracts[0].name
|
||||
try:
|
||||
# as backup, put it also in another database...
|
||||
import urllib
|
||||
args = urllib.urlencode({
|
||||
'contract_id': cid,
|
||||
'crm_case_id': crm_case_id or 0,
|
||||
'explanation': explanations,
|
||||
'remark': remarks or '',
|
||||
'tb': tb,
|
||||
})
|
||||
uo = urllib.urlopen('http://www.openerp.com/scripts/maintenance.php', args)
|
||||
submit_result = uo.read()
|
||||
debug(submit_result)
|
||||
uo.close()
|
||||
except:
|
||||
if not crm_case_id:
|
||||
# TODO schedule a retry (ir.cron)
|
||||
return False
|
||||
return True
|
||||
|
||||
def _valid_get(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
for contract in self.browse(cr, uid, ids, context=context):
|
||||
res[contract.id] = ("unvalid", "valid")[contract.date_stop >= time.strftime('%Y-%m-%d')]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Contract ID', size=256, required=True, readonly=True),
|
||||
'password' : fields.char('Password', size=64, invisible=True, required=True, readonly=True),
|
||||
'date_start' : fields.date('Starting Date', readonly=True),
|
||||
'date_stop' : fields.date('Ending Date', readonly=True),
|
||||
'module_ids' : fields.many2many('maintenance.contract.module', 'maintenance_contract_module_rel', 'contract_id', 'module_id', 'Covered Modules', readonly=True),
|
||||
'state' : fields.function(_valid_get, method=True, string="State", type="selection", selection=[('valid', 'Valid'),('unvalid', 'Unvalid')], readonly=True),
|
||||
'kind' : fields.selection([('full', 'Full'),('partial', 'Partial')], 'Kind', required=True, readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'password' : lambda obj,cr,uid,context={} : '',
|
||||
}
|
||||
_sql_constraints = [
|
||||
('uniq_name', 'unique(name)', "Your maintenance contract is already subscribed in the system !")
|
||||
]
|
||||
|
||||
maintenance_contract()
|
||||
|
||||
|
||||
class maintenance_contract_wizard(osv.osv_memory):
|
||||
_name = 'maintenance.contract.wizard'
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Contract ID', size=256, required=True ),
|
||||
'password' : fields.char('Password', size=64, required=True),
|
||||
'state' : fields.selection([('draft', 'Draft'),('validated', 'Validated'),('unvalidated', 'Unvalidated')], 'States'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state' : lambda *a: 'draft',
|
||||
}
|
||||
|
||||
def action_validate(self, cr, uid, ids, context=None):
|
||||
if not ids:
|
||||
return False
|
||||
|
||||
module_proxy = self.pool.get('ir.module.module')
|
||||
module_ids = module_proxy.search(cr, uid, [('state', '=', 'installed')])
|
||||
modules = module_proxy.read(cr, uid, module_ids, ['name', 'installed_version'])
|
||||
|
||||
contract = self.read(cr, uid, ids, ['name', 'password'])[0]
|
||||
|
||||
try:
|
||||
contract_info = tm.remote_contract(contract['name'], contract['password'], modules)
|
||||
except tm.RemoteContractException, rce:
|
||||
raise osv.except_osv(_('Error'), ustr(rce))
|
||||
|
||||
is_ok = contract_info['status'] in ('partial', 'full')
|
||||
if is_ok:
|
||||
module_ids = []
|
||||
if contract_info['modules_with_contract']:
|
||||
for name, version in contract_info['modules_with_contract']:
|
||||
contract_module = self.pool.get('maintenance.contract.module')
|
||||
res = contract_module.search(cr, uid, [('name', '=', name),('version', '=', version)])
|
||||
if not res:
|
||||
id = contract_module.create(cr, uid, { 'name' : name, 'version' : version } )
|
||||
else:
|
||||
id = res[0]
|
||||
module_ids.append(id)
|
||||
|
||||
self.pool.get('maintenance.contract').create(
|
||||
cr,
|
||||
uid, {
|
||||
'name' : contract['name'],
|
||||
'password' : contract['password'],
|
||||
'date_start' : contract_info['date_from'],
|
||||
'date_stop' : contract_info['date_to'],
|
||||
'kind' : contract_info['status'],
|
||||
'module_ids' : [(6,0,module_ids)],
|
||||
}
|
||||
)
|
||||
|
||||
return self.write(cr, uid, ids, {'state' : ('unvalidated', 'validated')[is_ok] }, context=context)
|
||||
|
||||
maintenance_contract_wizard()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="0">
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,131 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="maintenance_contract_tree_view" model="ir.ui.view">
|
||||
<field name="name">maintenance.contract.tree</field>
|
||||
<field name="model">maintenance.contract</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Maintenance Contract">
|
||||
<field name="name"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="maintenance_contract_form_view" model="ir.ui.view">
|
||||
<field name="name">maintenance.contract.form</field>
|
||||
<field name="model">maintenance.contract</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Maintenance Contract">
|
||||
<group col="6" colspan="4">
|
||||
<field name="name"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
</group>
|
||||
<separator string="Covered Modules" colspan="4"/>
|
||||
<field name="module_ids" nolabel="1" colspan="4">
|
||||
<tree string="Covered Modules">
|
||||
<field name="name" />
|
||||
<field name="version" />
|
||||
</tree>
|
||||
</field>
|
||||
<field name="state" colspan="4"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="maintenance_contract_search_view" model="ir.ui.view">
|
||||
<field name="name">maintenance.contract.search</field>
|
||||
<field name="model">maintenance.contract</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Maintenance Contract">
|
||||
<field name="name"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="maintenance_contract_view_calendar" model="ir.ui.view">
|
||||
<field name="name">maintenance.contract.calendar</field>
|
||||
<field name="model">maintenance.contract</field>
|
||||
<field name="type">calendar</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="Maintenance Contract" date_start="date_start" color="state">
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_maintenance_contract_form" model="ir.actions.act_window">
|
||||
<field name="name">Maintenance Contracts</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">maintenance.contract</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,calendar</field>
|
||||
<field name="search_view_id" ref="maintenance_contract_search_view"/>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
name="Maintenance"
|
||||
id="maintenance"
|
||||
parent="base.menu_administration" groups="base.group_extended"/>
|
||||
|
||||
<menuitem
|
||||
action="action_maintenance_contract_form"
|
||||
id="menu_maintenance_contract"
|
||||
parent="maintenance"/>
|
||||
|
||||
<record id="maintenance_contract_add_wizard" model="ir.ui.view">
|
||||
<field name="name">maintenance.contract.add.wizard</field>
|
||||
<field name="model">maintenance.contract.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add Maintenance Contract" col="2">
|
||||
<group col="1">
|
||||
<separator string="Add Maintenance Contract" />
|
||||
<group states="draft">
|
||||
<field name="name" width="250" />
|
||||
<newline />
|
||||
<field name="password" password="True" />
|
||||
<field name="state" invisible="1" />
|
||||
</group>
|
||||
<group states="validated">
|
||||
<label string="Maintenance contract added !"/>
|
||||
</group>
|
||||
<group states="unvalidated">
|
||||
<label string="Could you check your contract information ?" />
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<button type="object" string="_Cancel" icon="gtk-cancel" special="cancel" states="draft"/>
|
||||
<button type="object" string="_Validate" icon="gtk-apply" name="action_validate" states="draft"/>
|
||||
<button type="object" string="_Close" icon="gtk-close" special="cancel" states="validated,unvalidated"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_maintenance_contract_add_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Add Maintenance Contract</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">maintenance.contract.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
action="action_maintenance_contract_add_wizard"
|
||||
id="menu_maintenance_contract_add"
|
||||
parent="maintenance" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -27,7 +27,6 @@ import urllib
|
|||
import zipimport
|
||||
|
||||
import addons
|
||||
import netsvc
|
||||
import pooler
|
||||
import release
|
||||
import tools
|
||||
|
@ -41,7 +40,7 @@ class module_category(osv.osv):
|
|||
_name = "ir.module.category"
|
||||
_description = "Module Category"
|
||||
|
||||
def _module_nbr(self,cr,uid, ids, prop, unknow_none,context):
|
||||
def _module_nbr(self,cr,uid, ids, prop, unknow_none, context):
|
||||
cr.execute('SELECT category_id, COUNT(*) \
|
||||
FROM ir_module_module \
|
||||
WHERE category_id IN %(ids)s \
|
||||
|
@ -58,7 +57,7 @@ class module_category(osv.osv):
|
|||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char("Name", size=128, required=True),
|
||||
'name': fields.char("Name", size=128, required=True, select=True),
|
||||
'parent_id': fields.many2one('ir.module.category', 'Parent Category', select=True),
|
||||
'child_ids': fields.one2many('ir.module.category', 'parent_id', 'Child Categories'),
|
||||
'module_nr': fields.function(_module_nbr, method=True, string='Number of Modules', type='integer')
|
||||
|
@ -71,24 +70,25 @@ class module(osv.osv):
|
|||
_description = "Module"
|
||||
__logger = logging.getLogger('base.' + _name)
|
||||
|
||||
def get_module_info(self, name):
|
||||
@classmethod
|
||||
def get_module_info(cls, name):
|
||||
info = {}
|
||||
try:
|
||||
info = addons.load_information_from_description_file(name)
|
||||
if 'version' in info:
|
||||
info['version'] = release.major_version + '.' + info['version']
|
||||
except Exception:
|
||||
self.__logger.debug('Error when trying to fetch informations for '
|
||||
cls.__logger.debug('Error when trying to fetch informations for '
|
||||
'module %s', name, exc_info=True)
|
||||
return info
|
||||
|
||||
def _get_latest_version(self, cr, uid, ids, field_name=None, arg=None, context={}):
|
||||
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):
|
||||
res[m.id] = self.get_module_info(m.name).get('version', '')
|
||||
return res
|
||||
|
||||
def _get_views(self, cr, uid, ids, field_name=None, arg=None, context={}):
|
||||
def _get_views(self, cr, uid, ids, field_name=None, arg=None, context=None):
|
||||
res = {}
|
||||
model_data_obj = self.pool.get('ir.model.data')
|
||||
view_obj = self.pool.get('ir.ui.view')
|
||||
|
@ -97,39 +97,46 @@ class module(osv.osv):
|
|||
mlist = self.browse(cr, uid, ids, context=context)
|
||||
mnames = {}
|
||||
for m in mlist:
|
||||
mnames[m.name] = m.id
|
||||
# skip uninstalled modules below,
|
||||
# no data to find anyway
|
||||
if m.state in ('installed', 'to upgrade', 'to remove'):
|
||||
mnames[m.name] = m.id
|
||||
res[m.id] = {
|
||||
'menus_by_module':'',
|
||||
'reports_by_module':'',
|
||||
'views_by_module': ''
|
||||
'menus_by_module':[],
|
||||
'reports_by_module':[],
|
||||
'views_by_module': []
|
||||
}
|
||||
|
||||
if not mnames:
|
||||
return res
|
||||
|
||||
view_id = model_data_obj.search(cr,uid,[('module','in', mnames.keys()),
|
||||
('model','in',('ir.ui.view','ir.actions.report.xml','ir.ui.menu'))])
|
||||
for data_id in model_data_obj.browse(cr,uid,view_id,context):
|
||||
# We use try except, because views or menus may not exist
|
||||
try:
|
||||
key = data_id['model']
|
||||
key = data_id.model
|
||||
res_mod_dic = res[mnames[data_id.module]]
|
||||
if key=='ir.ui.view':
|
||||
try:
|
||||
v = view_obj.browse(cr,uid,data_id.res_id)
|
||||
aa = v.inherit_id and '* INHERIT ' or ''
|
||||
res[mnames[data_id.module]]['views_by_module'] += aa + v.name + ' ('+v.type+')\n'
|
||||
except Exception:
|
||||
self.__logger.debug(
|
||||
'Unknown error while browsing ir.ui.view[%s]',
|
||||
data_id.res_id, exc_info=True)
|
||||
v = view_obj.browse(cr,uid,data_id.res_id)
|
||||
aa = v.inherit_id and '* INHERIT ' or ''
|
||||
res_mod_dic['views_by_module'].append(aa + v.name + '('+v.type+')')
|
||||
elif key=='ir.actions.report.xml':
|
||||
res[mnames[data_id.module]]['reports_by_module'] += report_obj.browse(cr,uid,data_id.res_id).name + '\n'
|
||||
res_mod_dic['reports_by_module'].append(report_obj.browse(cr,uid,data_id.res_id).name)
|
||||
elif key=='ir.ui.menu':
|
||||
try:
|
||||
m = menu_obj.browse(cr,uid,data_id.res_id)
|
||||
res[mnames[data_id.module]]['menus_by_module'] += m.complete_name + '\n'
|
||||
except Exception:
|
||||
self.__logger.debug(
|
||||
'Unknown error while browsing ir.ui.menu[%s]',
|
||||
data_id.res_id, exc_info=True)
|
||||
except KeyError:
|
||||
res_mod_dic['menus_by_module'].append(menu_obj.browse(cr,uid,data_id.res_id).complete_name)
|
||||
except KeyError, e:
|
||||
self.__logger.warning(
|
||||
'Data not found for reference %s[%s:%s.%s]', data_id.model,
|
||||
data_id.res_id, data_id.model, data_id.name, exc_info=True)
|
||||
pass
|
||||
except Exception, e:
|
||||
self.__logger.warning('Unknown error while browsing %s[%s]',
|
||||
data_id.model, data_id.res_id, exc_info=True)
|
||||
pass
|
||||
for key, value in res.iteritems():
|
||||
for k, v in res[key].iteritems() :
|
||||
res[key][k] = "\n".join(sorted(v))
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
|
@ -180,16 +187,21 @@ class module(osv.osv):
|
|||
}
|
||||
|
||||
_defaults = {
|
||||
'state': lambda *a: 'uninstalled',
|
||||
'demo': lambda *a: False,
|
||||
'license': lambda *a: 'AGPL-3',
|
||||
'state': 'uninstalled',
|
||||
'demo': False,
|
||||
'license': 'AGPL-3',
|
||||
'web': False,
|
||||
}
|
||||
_order = 'name'
|
||||
|
||||
def _name_uniq_msg(self, cr, uid, ids, context=None):
|
||||
return _('The name of the module must be unique !')
|
||||
def _certificate_uniq_msg(self, cr, uid, ids, context=None):
|
||||
return _('The certificate ID of the module must be unique !')
|
||||
|
||||
_sql_constraints = [
|
||||
('name_uniq', 'unique (name)', 'The name of the module must be unique !'),
|
||||
('certificate_uniq', 'unique (certificate)', 'The certificate ID of the module must be unique !')
|
||||
('name_uniq', 'UNIQUE (name)',_name_uniq_msg ),
|
||||
('certificate_uniq', 'UNIQUE (certificate)',_certificate_uniq_msg )
|
||||
]
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
@ -231,6 +243,19 @@ class module(osv.osv):
|
|||
if tools.find_in_path(binary) is None:
|
||||
raise Exception('Unable to find %r in path' % (binary,))
|
||||
|
||||
@classmethod
|
||||
def check_external_dependencies(cls, module_name, newstate='to install'):
|
||||
terp = cls.get_module_info(module_name)
|
||||
try:
|
||||
cls._check_external_dependencies(terp)
|
||||
except Exception, e:
|
||||
if newstate == 'to install':
|
||||
msg = _('Unable to install module "%s" because an external dependency is not met: %s')
|
||||
elif newstate == 'to upgrade':
|
||||
msg = _('Unable to upgrade module "%s" because an external dependency is not met: %s')
|
||||
else:
|
||||
msg = _('Unable to process module "%s" because an external dependency is not met: %s')
|
||||
raise orm.except_orm(_('Error'), msg % (module_name, e.args[0]))
|
||||
|
||||
def state_update(self, cr, uid, ids, newstate, states_to_update, context=None, level=100):
|
||||
if level<1:
|
||||
|
@ -248,17 +273,7 @@ class module(osv.osv):
|
|||
od = self.browse(cr, uid, ids2)[0]
|
||||
mdemo = od.demo or mdemo
|
||||
|
||||
terp = self.get_module_info(module.name)
|
||||
try:
|
||||
self._check_external_dependencies(terp)
|
||||
except Exception, e:
|
||||
if newstate == 'to install':
|
||||
msg = _('Unable to install module "%s" because an external dependency is not met: %s')
|
||||
elif newstate == 'to upgrade':
|
||||
msg = _('Unable to upgrade module "%s" because an external dependency is not met: %s')
|
||||
else:
|
||||
msg = _('Unable to process module "%s" because an external dependency is not met: %s')
|
||||
raise orm.except_orm(_('Error'), msg % (module.name, e.args[0]))
|
||||
self.check_external_dependencies(module.name, newstate)
|
||||
if not module.dependencies_id:
|
||||
mdemo = module.demo
|
||||
if module.state in states_to_update:
|
||||
|
@ -266,14 +281,14 @@ class module(osv.osv):
|
|||
demo = demo or mdemo
|
||||
return demo
|
||||
|
||||
def button_install(self, cr, uid, ids, context={}):
|
||||
def button_install(self, cr, uid, ids, context=None):
|
||||
return self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
|
||||
|
||||
def button_install_cancel(self, cr, uid, ids, context={}):
|
||||
def button_install_cancel(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})
|
||||
return True
|
||||
|
||||
def button_uninstall(self, cr, uid, ids, context={}):
|
||||
def button_uninstall(self, cr, uid, ids, context=None):
|
||||
for module in self.browse(cr, uid, ids):
|
||||
cr.execute('''select m.state,m.name
|
||||
from
|
||||
|
@ -289,7 +304,7 @@ class module(osv.osv):
|
|||
self.write(cr, uid, ids, {'state': 'to remove'})
|
||||
return True
|
||||
|
||||
def button_uninstall_cancel(self, cr, uid, ids, context={}):
|
||||
def button_uninstall_cancel(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'installed'})
|
||||
return True
|
||||
|
||||
|
@ -305,6 +320,7 @@ class module(osv.osv):
|
|||
if mod.state not in ('installed','to upgrade'):
|
||||
raise orm.except_orm(_('Error'),
|
||||
_("Can not upgrade module '%s'. It is not installed.") % (mod.name,))
|
||||
self.check_external_dependencies(mod.name, 'to upgrade')
|
||||
iids = depobj.search(cr, uid, [('name', '=', mod.name)], context=context)
|
||||
for dep in depobj.browse(cr, uid, iids, context=context):
|
||||
if dep.module_id.state=='installed' and dep.module_id not in todo:
|
||||
|
@ -325,7 +341,7 @@ class module(osv.osv):
|
|||
self.button_install(cr, uid, to_install, context=context)
|
||||
return True
|
||||
|
||||
def button_upgrade_cancel(self, cr, uid, ids, context={}):
|
||||
def button_upgrade_cancel(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {'state': 'installed'})
|
||||
return True
|
||||
def button_update_translations(self, cr, uid, ids, context=None):
|
||||
|
@ -341,8 +357,8 @@ class module(osv.osv):
|
|||
'maintainer': terp.get('maintainer', False),
|
||||
'contributors': ', '.join(terp.get('contributors', [])) or False,
|
||||
'website': terp.get('website', ''),
|
||||
'license': terp.get('license', 'GPL-2'),
|
||||
'certificate': terp.get('certificate') or None,
|
||||
'license': terp.get('license', 'AGPL-3'),
|
||||
'certificate': terp.get('certificate') or False,
|
||||
'web': terp.get('web') or False,
|
||||
}
|
||||
|
||||
|
@ -350,34 +366,40 @@ class module(osv.osv):
|
|||
def update_list(self, cr, uid, context={}):
|
||||
res = [0, 0] # [update, add]
|
||||
|
||||
# iterate through installed modules and mark them as being so
|
||||
known_mods = self.browse(cr, uid, self.search(cr, uid, []))
|
||||
known_mods_names = dict([(m.name, m) for m in known_mods])
|
||||
|
||||
# iterate through detected modules and update/create them in db
|
||||
for mod_name in addons.get_modules():
|
||||
ids = self.search(cr, uid, [('name','=',mod_name)])
|
||||
mod = known_mods_names.get(mod_name)
|
||||
terp = self.get_module_info(mod_name)
|
||||
values = self.get_values_from_terp(terp)
|
||||
|
||||
if ids:
|
||||
id = ids[0]
|
||||
mod = self.browse(cr, uid, id)
|
||||
if mod:
|
||||
updated_values = {}
|
||||
for key in values:
|
||||
old = getattr(mod, key)
|
||||
updated = isinstance(values[key], basestring) and tools.ustr(values[key]) or values[key]
|
||||
if not old == updated:
|
||||
updated_values[key] = values[key]
|
||||
if terp.get('installable', True) and mod.state == 'uninstallable':
|
||||
self.write(cr, uid, id, {'state': 'uninstalled'})
|
||||
updated_values['state'] = 'uninstalled'
|
||||
if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''):
|
||||
self.write(cr, uid, id, {'url': ''})
|
||||
res[0] += 1
|
||||
self.write(cr, uid, id, values)
|
||||
cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s', (id,))
|
||||
if updated_values:
|
||||
self.write(cr, uid, mod.id, updated_values)
|
||||
else:
|
||||
mod_path = addons.get_module_path(mod_name)
|
||||
if not mod_path:
|
||||
continue
|
||||
if not terp or not terp.get('installable', True):
|
||||
continue
|
||||
|
||||
ids = self.search(cr, uid, [('name','=',mod_name)])
|
||||
id = self.create(cr, uid, dict(name=mod_name, state='uninstalled', **values))
|
||||
mod = self.browse(cr, uid, id)
|
||||
res[1] += 1
|
||||
self._update_dependencies(cr, uid, id, terp.get('depends', []))
|
||||
self._update_category(cr, uid, id, terp.get('category', 'Uncategorized'))
|
||||
|
||||
self._update_dependencies(cr, uid, mod, terp.get('depends', []))
|
||||
self._update_category(cr, uid, mod, terp.get('category', 'Uncategorized'))
|
||||
|
||||
return res
|
||||
|
||||
|
@ -409,40 +431,52 @@ class module(osv.osv):
|
|||
self.write(cr, uid, mod.id, self.get_values_from_terp(terp))
|
||||
cr.execute('DELETE FROM ir_module_module_dependency ' \
|
||||
'WHERE module_id = %s', (mod.id,))
|
||||
self._update_dependencies(cr, uid, mod.id, terp.get('depends',
|
||||
self._update_dependencies(cr, uid, mod, terp.get('depends',
|
||||
[]))
|
||||
self._update_category(cr, uid, mod.id, terp.get('category',
|
||||
self._update_category(cr, uid, mod, terp.get('category',
|
||||
'Uncategorized'))
|
||||
# Import module
|
||||
zimp = zipimport.zipimporter(fname)
|
||||
zimp.load_module(mod.name)
|
||||
return res
|
||||
|
||||
def _update_dependencies(self, cr, uid, id, depends=[]):
|
||||
for d in depends:
|
||||
cr.execute('INSERT INTO ir_module_module_dependency (module_id, name) values (%s, %s)', (id, d))
|
||||
def _update_dependencies(self, cr, uid, mod_browse, depends=None):
|
||||
if depends is None:
|
||||
depends = []
|
||||
existing = set(x.name for x in mod_browse.dependencies_id)
|
||||
needed = set(depends)
|
||||
for dep in (needed - existing):
|
||||
cr.execute('INSERT INTO ir_module_module_dependency (module_id, name) values (%s, %s)', (mod_browse.id, dep))
|
||||
for dep in (existing - needed):
|
||||
cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s and name = %s', (mod_browse.id, dep))
|
||||
|
||||
def _update_category(self, cr, uid, mod_browse, category='Uncategorized'):
|
||||
current_category = mod_browse.category_id
|
||||
current_category_path = []
|
||||
while current_category:
|
||||
current_category_path.insert(0, current_category.name)
|
||||
current_category = current_category.parent_id
|
||||
|
||||
def _update_category(self, cr, uid, id, category='Uncategorized'):
|
||||
categs = category.split('/')
|
||||
p_id = None
|
||||
while categs:
|
||||
if p_id is not None:
|
||||
cr.execute('select id from ir_module_category where name=%s and parent_id=%s', (categs[0], p_id))
|
||||
else:
|
||||
cr.execute('select id from ir_module_category where name=%s and parent_id is NULL', (categs[0],))
|
||||
c_id = cr.fetchone()
|
||||
if not c_id:
|
||||
cr.execute('select nextval(\'ir_module_category_id_seq\')')
|
||||
c_id = cr.fetchone()[0]
|
||||
cr.execute('insert into ir_module_category (id, name, parent_id) values (%s, %s, %s)', (c_id, categs[0], p_id))
|
||||
else:
|
||||
c_id = c_id[0]
|
||||
p_id = c_id
|
||||
categs = categs[1:]
|
||||
self.write(cr, uid, [id], {'category_id': p_id})
|
||||
if categs != current_category_path:
|
||||
p_id = None
|
||||
while categs:
|
||||
if p_id is not None:
|
||||
cr.execute('SELECT id FROM ir_module_category WHERE name=%s AND parent_id=%s', (categs[0], p_id))
|
||||
else:
|
||||
cr.execute('SELECT id FROM ir_module_category WHERE name=%s AND parent_id is NULL', (categs[0],))
|
||||
c_id = cr.fetchone()
|
||||
if not c_id:
|
||||
cr.execute('INSERT INTO ir_module_category (name, parent_id) VALUES (%s, %s) RETURNING id', (categs[0], p_id))
|
||||
c_id = cr.fetchone()[0]
|
||||
else:
|
||||
c_id = c_id[0]
|
||||
p_id = c_id
|
||||
categs = categs[1:]
|
||||
self.write(cr, uid, [mod_browse.id], {'category_id': p_id})
|
||||
|
||||
def update_translations(self, cr, uid, ids, filter_lang=None, context={}):
|
||||
logger = netsvc.Logger()
|
||||
def update_translations(self, cr, uid, ids, filter_lang=None, context=None):
|
||||
logger = logging.getLogger('i18n')
|
||||
if not filter_lang:
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
lang_obj = pool.get('res.lang')
|
||||
|
@ -459,16 +493,19 @@ class module(osv.osv):
|
|||
# unable to find the module. we skip
|
||||
continue
|
||||
for lang in filter_lang:
|
||||
if len(lang) > 5:
|
||||
raise osv.except_osv(_('Error'), _('You Can Not Load Translation For language Due To Invalid Language/Country Code'))
|
||||
iso_lang = tools.get_iso_codes(lang)
|
||||
f = os.path.join(modpath, 'i18n', iso_lang + '.po')
|
||||
if not os.path.exists(f) and iso_lang.find('_') != -1:
|
||||
f = os.path.join(modpath, 'i18n', iso_lang.split('_')[0] + '.po')
|
||||
f = addons.get_module_resource(mod.name, 'i18n', iso_lang + '.po')
|
||||
# Implementation notice: we must first search for the full name of
|
||||
# the language derivative, like "en_UK", and then the generic,
|
||||
# like "en".
|
||||
if (not f) and '_' in iso_lang:
|
||||
f = addons.get_module_resource(mod.name, 'i18n', iso_lang.split('_')[0] + '.po')
|
||||
iso_lang = iso_lang.split('_')[0]
|
||||
if os.path.exists(f):
|
||||
logger.notifyChannel("i18n", netsvc.LOG_INFO, 'module %s: loading translation file for language %s' % (mod.name, iso_lang))
|
||||
if f:
|
||||
logger.info('module %s: loading translation file for language %s', mod.name, iso_lang)
|
||||
tools.trans_load(cr.dbname, f, lang, verbose=False, context=context)
|
||||
elif iso_lang != 'en':
|
||||
logger.warning('module %s: no translation for language %s', mod.name, iso_lang)
|
||||
|
||||
def check(self, cr, uid, ids, context=None):
|
||||
logger = logging.getLogger('init')
|
||||
|
@ -485,13 +522,13 @@ class module(osv.osv):
|
|||
raise osv.except_osv(_('Error'), _('Module %s: Invalid Quality Certificate') % (mod.name,))
|
||||
|
||||
def list_web(self, cr, uid, context=None):
|
||||
""" list_web(cr, uid, context) -> [module_name]
|
||||
""" list_web(cr, uid, context) -> [(module_name, module_version)]
|
||||
Lists all the currently installed modules with a web component.
|
||||
|
||||
Returns a list of addon names.
|
||||
Returns a list of a tuple of addon names and addon versions.
|
||||
"""
|
||||
return [
|
||||
module['name']
|
||||
(module['name'], module['installed_version'])
|
||||
for module in self.browse(cr, uid,
|
||||
self.search(cr, uid,
|
||||
[('web', '=', True),
|
||||
|
@ -524,6 +561,7 @@ class module(osv.osv):
|
|||
'to web client', names)
|
||||
return [
|
||||
{'name': module.name,
|
||||
'version': module.installed_version,
|
||||
'depends': list(self._web_dependencies(
|
||||
cr, uid, module, context=context)),
|
||||
'content': addons.zip_directory(
|
||||
|
@ -537,7 +575,7 @@ class module_dependency(osv.osv):
|
|||
_name = "ir.module.module.dependency"
|
||||
_description = "Module dependency"
|
||||
|
||||
def _state(self, cr, uid, ids, name, args, context={}):
|
||||
def _state(self, cr, uid, ids, name, args, context=None):
|
||||
result = {}
|
||||
mod_obj = self.pool.get('ir.module.module')
|
||||
for md in self.browse(cr, uid, ids):
|
||||
|
|
|
@ -73,6 +73,7 @@ class ir_module_reference_print(report_sxw.rml_parse):
|
|||
def _fields_find(self, obj):
|
||||
modobj = self.pool.get(obj)
|
||||
res = modobj.fields_get(self.cr, self.uid).items()
|
||||
res.sort()
|
||||
return res
|
||||
|
||||
report_sxw.report_sxw('report.ir.module.reference', 'ir.module.module',
|
||||
|
|
|
@ -38,7 +38,9 @@ class base_language_install(osv.osv_memory):
|
|||
'state': 'init',
|
||||
'overwrite': False
|
||||
}
|
||||
def lang_install(self, cr, uid, ids, context):
|
||||
def lang_install(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
language_obj = self.browse(cr, uid, ids)[0]
|
||||
lang = language_obj.lang
|
||||
if lang:
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
import pooler
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class base_module_upgrade(osv.osv_memory):
|
||||
""" Module Upgrade """
|
||||
|
@ -80,7 +81,7 @@ class base_module_upgrade(osv.osv_memory):
|
|||
res = mod_obj.read(cr, uid, ids, ['name','state'], context)
|
||||
return {'module_info': '\n'.join(map(lambda x: x['name']+' : '+x['state'], res))}
|
||||
|
||||
def upgrade_module(self, cr, uid, ids, context):
|
||||
def upgrade_module(self, cr, uid, ids, context=None):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
mod_obj = self.pool.get('ir.module.module')
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
|
|
|
@ -35,7 +35,7 @@ class base_update_translations(osv.osv_memory):
|
|||
lang_obj=pooler.get_pool(cr.dbname).get('res.lang')
|
||||
ids=lang_obj.search(cr, uid, [('code', '=', lang_code)])
|
||||
if not ids:
|
||||
raise osv.except_osv(_('No language with code "%s" exists') % lang_code)
|
||||
raise osv.except_osv(_('Error!'), _('No language with code "%s" exists') % lang_code)
|
||||
lang = lang_obj.browse(cr, uid, ids[0])
|
||||
return lang.name
|
||||
def act_cancel(self, cr, uid, ids, context=None):
|
||||
|
@ -51,12 +51,14 @@ class base_update_translations(osv.osv_memory):
|
|||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
res = super(base_update_translations, self).default_get(cr, uid, fields, context=context)
|
||||
|
||||
if context.get('active_model') != "res.lang":
|
||||
return res
|
||||
|
||||
record_id = context and context.get('active_id', False) or False
|
||||
record_id = context.get('active_id', False) or False
|
||||
if record_id:
|
||||
lang = self.pool.get('res.lang').browse(cr, uid, record_id).code
|
||||
res.update(lang=lang)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import maintenance
|
||||
import publisher_warranty
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,334 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 OpenERP S.A. (<http://www.openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
"""
|
||||
Module to handle publisher warranty contracts as well as notifications from
|
||||
OpenERP.
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import sys
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
import pooler
|
||||
import release
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
from tools.safe_eval import safe_eval
|
||||
from tools.config import config
|
||||
from tools import misc
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
"""
|
||||
Time interval that will be used to determine up to which date we will
|
||||
check the logs to see if a message we just received was already logged.
|
||||
@type: datetime.timedelta
|
||||
"""
|
||||
_PREVIOUS_LOG_CHECK = datetime.timedelta(days=365)
|
||||
|
||||
class publisher_warranty_contract(osv.osv):
|
||||
"""
|
||||
Osv representing a publisher warranty contract.
|
||||
"""
|
||||
_name = "publisher_warranty.contract"
|
||||
|
||||
def _get_valid_contracts(self, cr, uid):
|
||||
"""
|
||||
Return the list of the valid contracts encoded in the system.
|
||||
|
||||
@return: A list of contracts
|
||||
@rtype: list of publisher_warranty.contract browse records
|
||||
"""
|
||||
return [contract for contract in self.browse(cr, uid, self.search(cr, uid, []))
|
||||
if contract.state == 'valid']
|
||||
|
||||
def status(self, cr, uid):
|
||||
""" Method called by the client to check availability of publisher warranty contract. """
|
||||
|
||||
contracts = self._get_valid_contracts(cr, uid)
|
||||
return {
|
||||
'status': "full" if contracts else "none" ,
|
||||
'uncovered_modules': list(),
|
||||
}
|
||||
|
||||
def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None):
|
||||
""" Method called by the client to send a problem to the publisher warranty server. """
|
||||
|
||||
if not remarks:
|
||||
remarks = ""
|
||||
|
||||
valid_contracts = self._get_valid_contracts(cr, uid)
|
||||
valid_contract = valid_contracts[0]
|
||||
|
||||
try:
|
||||
origin = 'client'
|
||||
dbuuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid')
|
||||
db_create_date = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date')
|
||||
user = self.pool.get("res.users").browse(cr, uid, uid)
|
||||
user_name = user.name
|
||||
email = user.email
|
||||
|
||||
msg = {'contract_name': valid_contract.name,
|
||||
'tb': tb,
|
||||
'explanations': explanations,
|
||||
'remarks': remarks,
|
||||
'origin': origin,
|
||||
'dbname': cr.dbname,
|
||||
'dbuuid': dbuuid,
|
||||
'db_create_date': db_create_date,
|
||||
'issue_name': issue_name,
|
||||
'email': email,
|
||||
'user_name': user_name,
|
||||
}
|
||||
|
||||
|
||||
add_arg = {"timeout":30} if sys.version_info >= (2,6) else {}
|
||||
uo = urllib2.urlopen(config.get("publisher_warranty_url"),
|
||||
urllib.urlencode({'arg0': msg, "action": "send",}),**add_arg)
|
||||
try:
|
||||
submit_result = uo.read()
|
||||
finally:
|
||||
uo.close()
|
||||
|
||||
result = safe_eval(submit_result)
|
||||
|
||||
crm_case_id = result
|
||||
|
||||
if not crm_case_id:
|
||||
return False
|
||||
|
||||
except osv.except_osv:
|
||||
raise
|
||||
except Exception:
|
||||
_logger.warning("Error sending problem report", exc_info=1)
|
||||
raise osv.except_osv("Connection error", "An error occured during the connection " +
|
||||
"with the publisher warranty server.")
|
||||
|
||||
return True
|
||||
|
||||
def check_validity(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Check the validity of a publisher warranty contract. This method just call get_logs() but checks
|
||||
some more things, so it can be called from a user interface.
|
||||
"""
|
||||
contract_id = ids[0]
|
||||
contract = self.browse(cr, uid, contract_id)
|
||||
state = contract.state
|
||||
validated = state != "unvalidated"
|
||||
|
||||
self.get_logs(cr, uid, ids, cron_mode=False, context=context)
|
||||
|
||||
contract = self.browse(cr, uid, contract_id)
|
||||
validated2 = contract.state != "unvalidated"
|
||||
if not validated and not validated2:
|
||||
raise osv.except_osv(_("Contract validation error"),
|
||||
_("Please check your publisher warranty contract name and validity."))
|
||||
return True
|
||||
|
||||
def get_logs(self, cr, uid, ids, cron_mode=True, context=None):
|
||||
"""
|
||||
Send a message to OpenERP's publisher warranty server to check the validity of
|
||||
the contracts, get notifications, etc...
|
||||
|
||||
@param cron_mode: If true, catch all exceptions (appropriate for usage in a cron).
|
||||
@type cron_mode: boolean
|
||||
"""
|
||||
try:
|
||||
try:
|
||||
result = get_sys_logs(cr, uid)
|
||||
except Exception:
|
||||
if cron_mode: # we don't want to see any stack trace in cron
|
||||
return False
|
||||
_logger.debug("Exception while sending a get logs messages", exc_info=1)
|
||||
raise osv.except_osv(_("Error"), _("Error during communication with the publisher warranty server."))
|
||||
|
||||
contracts = result["contracts"]
|
||||
for contract in contracts:
|
||||
c_id = self.search(cr, uid, [("name","=",contract)])[0]
|
||||
date_from = contracts[contract][0]
|
||||
date_to = contracts[contract][1]
|
||||
state = contracts[contract][2]
|
||||
self.write(cr, uid, c_id, {
|
||||
"date_start": date_from,
|
||||
"date_stop": date_to,
|
||||
"state": state,
|
||||
})
|
||||
|
||||
limit_date = (datetime.datetime.now() - _PREVIOUS_LOG_CHECK).strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
for message in result["messages"]:
|
||||
ids = self.pool.get("res.log").search(cr, uid, [("res_model", "=", "publisher_warranty.contract"),
|
||||
("create_date", ">=", limit_date),
|
||||
("name", "=", message)])
|
||||
if ids:
|
||||
continue
|
||||
self.pool.get('res.log').create(cr, uid,
|
||||
{
|
||||
'name': message,
|
||||
'res_model': "publisher_warranty.contract",
|
||||
"read": True,
|
||||
"user_id": False,
|
||||
},
|
||||
context=context
|
||||
)
|
||||
except Exception:
|
||||
if cron_mode:
|
||||
return False # we don't want to see any stack trace in cron
|
||||
else:
|
||||
raise
|
||||
return True
|
||||
|
||||
def get_last_user_messages(self, cr, uid, limit, context=None):
|
||||
"""
|
||||
Get the messages to be written in the web client.
|
||||
@return: A list of html messages with ids, can be False or empty.
|
||||
@rtype: list of tuples(int,string)
|
||||
"""
|
||||
ids = self.pool.get('res.log').search(cr, uid, [("res_model", "=", "publisher_warranty.contract")]
|
||||
, order="create_date desc", limit=limit)
|
||||
if not ids:
|
||||
return []
|
||||
messages = [(x.id, x.name) for x in self.pool.get('res.log').browse(cr, uid, ids)]
|
||||
|
||||
return messages
|
||||
|
||||
def del_user_message(self, cr, uid, id, context=None):
|
||||
"""
|
||||
Delete a message.
|
||||
"""
|
||||
self.pool.get('res.log').unlink(cr, uid, [id])
|
||||
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Serial Key', size=384, required=True),
|
||||
'date_start' : fields.date('Starting Date', readonly=True),
|
||||
'date_stop' : fields.date('Ending Date', readonly=True),
|
||||
'state' : fields.selection([('unvalidated', 'Unvalidated'), ('valid', 'Valid')
|
||||
, ('terminated', 'Terminated'), ('canceled', 'Canceled')], string="State", readonly=True),
|
||||
'kind' : fields.char('Kind', size=64, readonly=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': 'unvalidated',
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
('uniq_name', 'unique(name)', "Your publisher warranty contract is already subscribed in the system !")
|
||||
]
|
||||
|
||||
publisher_warranty_contract()
|
||||
|
||||
class maintenance_contract(osv.osv_memory):
|
||||
""" Old osv we only keep for compatibility with the clients. """
|
||||
|
||||
_name = "maintenance.contract"
|
||||
|
||||
def status(self, cr, uid):
|
||||
return self.pool.get("publisher_warranty.contract").status(cr, uid)
|
||||
|
||||
def send(self, cr, uid, tb, explanations, remarks=None, issue_name=None):
|
||||
return self.pool.get("publisher_warranty.contract").send(cr, uid, tb,
|
||||
explanations, remarks, issue_name)
|
||||
|
||||
maintenance_contract()
|
||||
|
||||
class publisher_warranty_contract_wizard(osv.osv_memory):
|
||||
"""
|
||||
A wizard osv to help people entering a publisher warranty contract.
|
||||
"""
|
||||
_name = 'publisher_warranty.contract.wizard'
|
||||
_inherit = "ir.wizard.screen"
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Serial Key', size=256, required=True ),
|
||||
'state' : fields.selection([("draft", "Draft"), ("finished", "Finished")])
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
"state": "draft",
|
||||
}
|
||||
|
||||
def action_validate(self, cr, uid, ids, context=None):
|
||||
if not ids:
|
||||
return False
|
||||
|
||||
wiz = self.browse(cr, uid, ids[0])
|
||||
c_name = wiz.name
|
||||
|
||||
contract_osv = self.pool.get("publisher_warranty.contract")
|
||||
contracts = contract_osv.search(cr, uid, [("name","=",c_name)])
|
||||
if contracts:
|
||||
raise osv.except_osv(_("Error"), _("That contract is already registered in the system."))
|
||||
|
||||
contract_id = contract_osv.create(cr, uid, {
|
||||
"name": c_name,
|
||||
"state": "unvalidated",
|
||||
})
|
||||
|
||||
contract_osv.check_validity(cr, uid, [contract_id])
|
||||
|
||||
self.write(cr, uid, ids, {"state": "finished"})
|
||||
|
||||
return True
|
||||
|
||||
|
||||
publisher_warranty_contract_wizard()
|
||||
|
||||
def get_sys_logs(cr, uid):
|
||||
"""
|
||||
Utility method to send a publisher warranty get logs messages.
|
||||
"""
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
||||
dbuuid = pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid')
|
||||
db_create_date = pool.get('ir.config_parameter').get_param(cr, uid, 'database.create_date')
|
||||
nbr_users = pool.get("res.users").search(cr, uid, [], count=True)
|
||||
contractosv = pool.get('publisher_warranty.contract')
|
||||
contracts = contractosv.browse(cr, uid, contractosv.search(cr, uid, []))
|
||||
user = pool.get("res.users").browse(cr, uid, uid)
|
||||
msg = {
|
||||
"dbuuid": dbuuid,
|
||||
"nbr_users": nbr_users,
|
||||
"dbname": cr.dbname,
|
||||
"db_create_date": db_create_date,
|
||||
"version": release.version,
|
||||
"contracts": [c.name for c in contracts],
|
||||
"language": user.context_lang,
|
||||
}
|
||||
|
||||
add_arg = {"timeout":30} if sys.version_info >= (2,6) else {}
|
||||
arguments = {'arg0': msg, "action": "update",}
|
||||
arguments_raw = urllib.urlencode(arguments)
|
||||
url = config.get("publisher_warranty_url")
|
||||
uo = urllib2.urlopen(url, arguments_raw, **add_arg)
|
||||
try:
|
||||
submit_result = uo.read()
|
||||
finally:
|
||||
uo.close()
|
||||
|
||||
result = safe_eval(submit_result) if submit_result else {}
|
||||
|
||||
return result
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="ir_cron_ping_scheduler" model="ir.cron">
|
||||
<field name="name">Update System Logs</field>
|
||||
<field eval="True" name="active" />
|
||||
<field name="user_id" ref="base.user_root" />
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">weeks</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall" />
|
||||
<field eval="'publisher_warranty.contract'" name="model" />
|
||||
<field eval="'get_logs'" name="function" />
|
||||
<field eval="'(None,)'" name="args" />
|
||||
<field name="priority">1000</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -0,0 +1,146 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="publisher_warranty_contract_tree_view" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.tree</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Publisher Warranty Contracts">
|
||||
<field name="name"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
<field name="state" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="publisher_warranty_contract_form_view" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.form</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Publisher Warranty Contract">
|
||||
<group col="2" colspan="4">
|
||||
<group col="2">
|
||||
<field name="name"/>
|
||||
</group>
|
||||
<group col="2">
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
</group>
|
||||
<group col="2">
|
||||
<field name="state"/>
|
||||
<field name="kind"/>
|
||||
</group>
|
||||
<group col="2">
|
||||
<button name="check_validity" string="Validate" type="object"
|
||||
attrs="{'invisible':[('state','in',['valid', 'terminated', 'canceled'])]}"/>
|
||||
<button name="check_validity" string="Refresh Validation Dates" type="object"
|
||||
attrs="{'invisible':[('state','in',['unvalidated'])]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="publisher_warranty_contract_search_view" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.search</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Publisher Warranty Contract">
|
||||
<field name="name"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="publisher_warranty_contract_view_calendar" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.calendar</field>
|
||||
<field name="model">publisher_warranty.contract</field>
|
||||
<field name="type">calendar</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="Maintenance Contract" date_start="date_start" color="state">
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_publisher_warranty_contract_form" model="ir.actions.act_window">
|
||||
<field name="name">Contracts</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">publisher_warranty.contract</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,calendar</field>
|
||||
<field name="search_view_id" ref="publisher_warranty_contract_search_view"/>
|
||||
</record>
|
||||
|
||||
<menuitem name="Publisher Warranty" id="publisher_warranty"
|
||||
parent="base.menu_administration" groups="base.group_extended"/>
|
||||
|
||||
<menuitem action="action_publisher_warranty_contract_form" id="menu_publisher_warranty_contract"
|
||||
parent="publisher_warranty" sequence="2"/>
|
||||
|
||||
|
||||
<record id="publisher_warranty_contract_add_wizard" model="ir.ui.view">
|
||||
<field name="name">publisher_warranty.contract.add.wizard</field>
|
||||
<field name="model">publisher_warranty.contract.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Register a Contract">
|
||||
<group col="8">
|
||||
<group colspan="3" col="1">
|
||||
<field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/>
|
||||
<newline/>
|
||||
<label width="220" string="This wizard helps you register a publisher warranty contract in your OpenERP system. After the contract has been registered, you will be able to send issues directly to OpenERP."/>
|
||||
<label width="220"/>
|
||||
<label width="220" string=""/>
|
||||
<field name="state" invisible="1"/>
|
||||
</group>
|
||||
<separator orientation="vertical" rowspan="5"/>
|
||||
<group colspan="4">
|
||||
<separator string="Register a Contract" colspan="4"/>
|
||||
<group states="draft" col="4">
|
||||
<label string="Please enter the serial key provided in your contract document:" colspan="4"/>
|
||||
<field name="name" colspan="4"/>
|
||||
</group>
|
||||
<group states="finished" col="4">
|
||||
<label string="Publisher warranty contract successfully registered!" colspan="4"/>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="8" col="8" states="draft">
|
||||
<separator string="" colspan="8"/>
|
||||
<label colspan="6" width="220"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="action_validate" string="Register" type="object" icon="gtk-apply"/>
|
||||
</group>
|
||||
<group colspan="8" col="8" states="finished">
|
||||
<separator string="" colspan="8"/>
|
||||
<label colspan="6" width="220"/>
|
||||
<button special="cancel" string="Close" icon="gtk-ok"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_publisher_warranty_contract_add_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Register a Contract</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">publisher_warranty.contract.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
action="action_publisher_warranty_contract_add_wizard"
|
||||
id="menu_publisher_warranty_contract_add"
|
||||
parent="publisher_warranty" sequence="1"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -25,6 +25,7 @@ from osv import fields, osv
|
|||
class Bank(osv.osv):
|
||||
_description='Bank'
|
||||
_name = 'res.bank'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128, required=True),
|
||||
'code': fields.char('Code', size=64),
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<field name="help">Manage bank records you want to be used in the system.</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_res_bank_form" groups="group_extended,group_system" id="menu_action_res_bank_form"
|
||||
parent="base.menu_config_address_book" sequence="5"/>
|
||||
<menuitem action="action_res_bank_form" id="menu_action_res_bank_form"
|
||||
parent="base.menu_config_address_book" sequence="5"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<filter icon="terp-project"
|
||||
string="Generic"
|
||||
help="Parameters that are used by all resources."
|
||||
default="1"
|
||||
domain="[('res_id','=',False)]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="name"/>
|
||||
|
|
|
@ -29,6 +29,7 @@ from osv import fields,osv
|
|||
class res_partner_canal(osv.osv):
|
||||
_name = "res.partner.canal"
|
||||
_description = "Channels"
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Channel Name',size=64, required=True),
|
||||
'active': fields.boolean('Active'),
|
||||
|
|
|
@ -29,6 +29,7 @@ from tools.translate import _
|
|||
class res_payterm(osv.osv):
|
||||
_description = 'Payment term'
|
||||
_name = 'res.payterm'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Payment Term (short name)', size=64),
|
||||
}
|
||||
|
@ -47,36 +48,44 @@ class res_partner_category(osv.osv):
|
|||
res.append((record['id'], name))
|
||||
return res
|
||||
|
||||
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
|
||||
if not args:
|
||||
args=[]
|
||||
if not context:
|
||||
context={}
|
||||
if name:
|
||||
# Be sure name_search is symetric to name_get
|
||||
name = name.split(' / ')[-1]
|
||||
ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit, context=context)
|
||||
else:
|
||||
ids = self.search(cr, uid, args, limit=limit, context=context)
|
||||
return self.name_get(cr, uid, ids, context)
|
||||
|
||||
|
||||
def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
|
||||
res = self.name_get(cr, uid, ids, context=context)
|
||||
return dict(res)
|
||||
|
||||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select distinct parent_id from res_partner_category where id IN %s',(tuple(ids),))
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
return False
|
||||
level -= 1
|
||||
return True
|
||||
|
||||
_description='Partner Categories'
|
||||
_name = 'res.partner.category'
|
||||
_columns = {
|
||||
'name': fields.char('Category Name', required=True, size=64, translate=True),
|
||||
'parent_id': fields.many2one('res.partner.category', 'Parent Category', select=True),
|
||||
'parent_id': fields.many2one('res.partner.category', 'Parent Category', select=True, ondelete='cascade'),
|
||||
'complete_name': fields.function(_name_get_fnc, method=True, type="char", string='Full Name'),
|
||||
'child_ids': fields.one2many('res.partner.category', 'parent_id', 'Child Categories'),
|
||||
'active' : fields.boolean('Active', help="The active field allows you to hide the category without removing it."),
|
||||
'parent_left' : fields.integer('Left parent', select=True),
|
||||
'parent_right' : fields.integer('Right parent', select=True),
|
||||
}
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error ! You can not create recursive categories.', ['parent_id'])
|
||||
(osv.osv._check_recursion, 'Error ! You can not create recursive categories.', ['parent_id'])
|
||||
]
|
||||
_defaults = {
|
||||
'active' : lambda *a: 1,
|
||||
}
|
||||
_order = 'parent_id,name'
|
||||
_parent_store = True
|
||||
_parent_order = 'name'
|
||||
_order = 'parent_left'
|
||||
res_partner_category()
|
||||
|
||||
class res_partner_title(osv.osv):
|
||||
|
@ -149,7 +158,7 @@ class res_partner(osv.osv):
|
|||
def do_share(self, cr, uid, ids, *args):
|
||||
return True
|
||||
|
||||
def _check_ean_key(self, cr, uid, ids):
|
||||
def _check_ean_key(self, cr, uid, ids, context=None):
|
||||
for partner_o in pooler.get_pool(cr.dbname).get('res.partner').read(cr, uid, ids, ['ean13',]):
|
||||
thisean=partner_o['ean13']
|
||||
if thisean and thisean!='':
|
||||
|
@ -264,6 +273,7 @@ res_partner()
|
|||
class res_partner_address(osv.osv):
|
||||
_description ='Partner Addresses'
|
||||
_name = 'res.partner.address'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'partner_id': fields.many2one('res.partner', 'Partner Name', ondelete='set null', select=True, help="Keep empty for a private address, not related to partner."),
|
||||
'type': fields.selection( [ ('default','Default'),('invoice','Invoice'), ('delivery','Delivery'), ('contact','Contact'), ('other','Other') ],'Address Type', help="Used to select automatically the right address according to the context in sales and purchases documents."),
|
||||
|
@ -337,6 +347,7 @@ res_partner_address()
|
|||
class res_partner_bank_type(osv.osv):
|
||||
_description='Bank Account Type'
|
||||
_name = 'res.partner.bank.type'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True, translate=True),
|
||||
'code': fields.char('Code', size=64, required=True),
|
||||
|
@ -347,6 +358,7 @@ res_partner_bank_type()
|
|||
class res_partner_bank_type_fields(osv.osv):
|
||||
_description='Bank type fields'
|
||||
_name = 'res.partner.bank.type.field'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Field Name', size=64, required=True, translate=True),
|
||||
'bank_type_id': fields.many2one('res.partner.bank.type', 'Bank Type', required=True, ondelete='cascade'),
|
||||
|
@ -362,7 +374,7 @@ class res_partner_bank(osv.osv):
|
|||
_name = "res.partner.bank"
|
||||
_rec_name = "acc_number"
|
||||
_description = __doc__
|
||||
_order = 'sequence'
|
||||
_order = 'sequence,name'
|
||||
|
||||
def _bank_type_get(self, cr, uid, context=None):
|
||||
bank_type_obj = self.pool.get('res.partner.bank.type')
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<menuitem icon="terp-partner" id="menu_base_partner" name="Sales" sequence="0"/>
|
||||
<menuitem icon="terp-partner" id="menu_base_partner" name="Sales" sequence="0"
|
||||
web_icon="data/sales.png"
|
||||
web_icon_hover="data/sales-hover.png"/>
|
||||
|
||||
<menuitem id="menu_address_book" name="Address Book" parent="menu_base_partner" sequence="2"/>
|
||||
|
||||
|
@ -314,7 +316,7 @@
|
|||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
<newline/>
|
||||
</page>
|
||||
<page string="History" groups="base.group_extended">
|
||||
<page string="History" groups="base.group_extended" invisible="True">
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field colspan="4" name="comment" nolabel="1"/>
|
||||
|
@ -337,7 +339,7 @@
|
|||
<field name="name" select="1"/>
|
||||
<field name="address" select="1"/>
|
||||
<field name="country" select="1"/>
|
||||
<field name="category_id" select="1"/>
|
||||
<field name="category_id" select="1" groups="base.group_extended"/>
|
||||
<field name="user_id" select="1">
|
||||
<filter string="My Partners" icon="terp-personal+" domain="[('user_id','=',uid)]"/>
|
||||
</field>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
import netsvc
|
||||
import tools
|
||||
from osv import fields, osv
|
||||
import re
|
||||
|
||||
class partner_wizard_spam(osv.osv_memory):
|
||||
""" Mass Mailing """
|
||||
|
@ -51,14 +52,22 @@ class partner_wizard_spam(osv.osv_memory):
|
|||
event_pool = self.pool.get('res.partner.event')
|
||||
active_ids = context and context.get('active_ids', [])
|
||||
partners = partner_pool.browse(cr, uid, active_ids, context)
|
||||
type_ = 'plain'
|
||||
if re.search('(<(pre)|[pubi].*>)', data.text):
|
||||
type_ = 'html'
|
||||
for partner in partners:
|
||||
for adr in partner.address:
|
||||
if adr.email:
|
||||
name = adr.name or partner.name
|
||||
to = '%s <%s>' % (name, adr.email)
|
||||
to = '"%s" <%s>' % (name, adr.email)
|
||||
#TODO: add some tests to check for invalid email addresses
|
||||
#CHECKME: maybe we should use res.partner/email_send
|
||||
tools.email_send(data.email_from, [to], data.subject, data.text,subtype='html')
|
||||
tools.email_send(data.email_from,
|
||||
[to],
|
||||
data.subject,
|
||||
data.text,
|
||||
subtype=type_,
|
||||
openobject_id="res.partner-%s"%partner.id)
|
||||
nbr += 1
|
||||
event_pool.create(cr, uid,
|
||||
{'name': 'Email(s) sent through mass mailing',
|
||||
|
|
|
@ -72,6 +72,7 @@ multi_company_default()
|
|||
class res_company(osv.osv):
|
||||
_name = "res.company"
|
||||
_description = 'Companies'
|
||||
_order = 'name'
|
||||
_columns = {
|
||||
'name': fields.char('Company Name', size=64, required=True),
|
||||
'parent_id': fields.many2one('res.company', 'Parent Company', select=True),
|
||||
|
@ -184,16 +185,6 @@ class res_company(osv.osv):
|
|||
except:
|
||||
return False
|
||||
|
||||
def _check_recursion(self, cr, uid, ids):
|
||||
level = 100
|
||||
while len(ids):
|
||||
cr.execute('select distinct parent_id from res_company where id IN %s',(tuple(ids),))
|
||||
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||
if not level:
|
||||
return False
|
||||
level -= 1
|
||||
return True
|
||||
|
||||
def _get_logo(self, cr, uid, ids):
|
||||
return open(os.path.join(
|
||||
tools.config['root_path'], '..', 'pixmaps', 'openerp-header.png'),
|
||||
|
@ -203,16 +194,16 @@ class res_company(osv.osv):
|
|||
return """
|
||||
<header>
|
||||
<pageTemplate>
|
||||
<frame id="first" x1="22.0" y1="22.0" width="1080" height="700"/>
|
||||
<frame id="first" x1="28.0" y1="28.0" width="786" height="525"/>
|
||||
<pageGraphics>
|
||||
<fill color="black"/>
|
||||
<stroke color="black"/>
|
||||
<setFont name="DejaVu Sans" size="8"/>
|
||||
<drawString x="25" y="725"> [[ formatLang(time.strftime("%Y-%m-%d"), date=True) ]] [[ time.strftime("%H:%M") ]]</drawString>
|
||||
<drawString x="25" y="555"> [[ formatLang(time.strftime("%Y-%m-%d"), date=True) ]] [[ time.strftime("%H:%M") ]]</drawString>
|
||||
<setFont name="DejaVu Sans Bold" size="10"/>
|
||||
<drawString x="490" y="725">[[ company.partner_id.name ]]</drawString>
|
||||
<drawString x="382" y="555">[[ company.partner_id.name ]]</drawString>
|
||||
<stroke color="#000000"/>
|
||||
<lines>25 720 1085 720</lines>
|
||||
<lines>25 550 818 550</lines>
|
||||
</pageGraphics>
|
||||
</pageTemplate>
|
||||
</header>"""
|
||||
|
@ -220,16 +211,16 @@ class res_company(osv.osv):
|
|||
return """
|
||||
<header>
|
||||
<pageTemplate>
|
||||
<frame id="first" x1="1.3cm" y1="1.5cm" width="18.4cm" height="26.5cm"/>
|
||||
<frame id="first" x1="28.0" y1="28.0" width="539" height="772"/>
|
||||
<pageGraphics>
|
||||
<fill color="black"/>
|
||||
<stroke color="black"/>
|
||||
<setFont name="DejaVu Sans" size="8"/>
|
||||
<drawString x="1.3cm" y="28.3cm"> [[ formatLang(time.strftime("%Y-%m-%d"), date=True) ]] [[ time.strftime("%H:%M") ]]</drawString>
|
||||
<drawString x="1.0cm" y="28.3cm"> [[ formatLang(time.strftime("%Y-%m-%d"), date=True) ]] [[ time.strftime("%H:%M") ]]</drawString>
|
||||
<setFont name="DejaVu Sans Bold" size="10"/>
|
||||
<drawString x="9.8cm" y="28.3cm">[[ company.partner_id.name ]]</drawString>
|
||||
<drawString x="9.3cm" y="28.3cm">[[ company.partner_id.name ]]</drawString>
|
||||
<stroke color="#000000"/>
|
||||
<lines>1.3cm 28.1cm 20cm 28.1cm</lines>
|
||||
<lines>1.0cm 28.1cm 20.1cm 28.1cm</lines>
|
||||
</pageGraphics>
|
||||
</pageTemplate>
|
||||
</header>"""
|
||||
|
@ -280,7 +271,7 @@ class res_company(osv.osv):
|
|||
}
|
||||
|
||||
_constraints = [
|
||||
(_check_recursion, 'Error! You can not create recursive companies.', ['parent_id'])
|
||||
(osv.osv._check_recursion, 'Error! You can not create recursive companies.', ['parent_id'])
|
||||
]
|
||||
|
||||
res_company()
|
||||
|
|
|
@ -24,6 +24,7 @@ from operator import attrgetter
|
|||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
from tools import ustr
|
||||
import pooler
|
||||
|
||||
|
||||
|
@ -379,9 +380,8 @@ class res_config_installer(osv.osv_memory):
|
|||
continue
|
||||
fields[module.name].update(
|
||||
readonly=True,
|
||||
help=fields[module.name].get('help', '') +
|
||||
help= ustr(fields[module.name].get('help', '')) +
|
||||
_('\n\nThis addon is already installed on your system'))
|
||||
|
||||
return fields
|
||||
|
||||
def execute(self, cr, uid, ids, context=None):
|
||||
|
@ -393,7 +393,7 @@ class res_config_installer(osv.osv_memory):
|
|||
cr, uid,
|
||||
modules.search(cr, uid, [('name','in',to_install)]),
|
||||
'to install', ['uninstalled'], context=context)
|
||||
cr.commit() #TOFIX: after remove this statement, installation wizard is fail
|
||||
cr.commit() #TOFIX: after remove this statement, installation wizard is fail
|
||||
pooler.restart_pool(cr.dbname, update_module=True)
|
||||
res_config_installer()
|
||||
|
||||
|
@ -418,9 +418,9 @@ class ir_actions_configuration_wizard(osv.osv_memory):
|
|||
# if the next one is also an old-style extension, you never know...
|
||||
if next.note:
|
||||
return next.note
|
||||
return "Click 'Continue' to configure the next addon..."
|
||||
return "Your database is now fully configured.\n\n"\
|
||||
"Click 'Continue' and enjoy your OpenERP experience..."
|
||||
return _("Click 'Continue' to configure the next addon...")
|
||||
return _("Your database is now fully configured.\n\n"\
|
||||
"Click 'Continue' and enjoy your OpenERP experience...")
|
||||
|
||||
_columns = {
|
||||
'note': fields.text('Next Wizard', readonly=True),
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group colspan="4" col="8">
|
||||
<group colspan="3" width="220" height="250">
|
||||
<field name="config_logo" widget="image" width="220" height="130" nolabel="1" colspan="1"/>
|
||||
<group colspan="1" width="220" height="250">
|
||||
<field name="config_logo" widget="image" width="220" height="130" nolabel="1"/>
|
||||
<newline/>
|
||||
<label align="0.0" string="description" width="200" colspan="2"/>
|
||||
</group>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue