Skip to content

Commit

Permalink
[MERGE] forward merge 7.0 until revision 4919.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vo Minh Thu committed Apr 4, 2013
2 parents b207801 + 5a4be3d commit 307ca37
Show file tree
Hide file tree
Showing 39 changed files with 307 additions and 179 deletions.
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Depends:
python-docutils,
python-feedparser,
python-gdata,
python-imaging,
python-jinja2,
python-ldap,
python-libxslt1,
Expand Down Expand Up @@ -46,7 +47,7 @@ Depends:
Conflicts: tinyerp-server, openerp-server, openerp-web
Replaces: tinyerp-server, openerp-server, openerp-web
Recommends:
graphviz, ghostscript, postgresql, python-imaging, python-matplotlib
graphviz, ghostscript, postgresql, python-matplotlib, poppler-utils
Description: OpenERP Enterprise Resource Management
OpenERP, previously known as TinyERP, is a complete ERP and CRM. The main
features are accounting (analytic and financial), stock management, sales and
Expand Down
73 changes: 32 additions & 41 deletions debian/openerp.init
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,46 @@ DAEMON=/usr/bin/openerp-server
NAME=openerp-server
DESC=openerp-server
CONFIG=/etc/openerp/openerp-server.conf
LOGFILE=/var/log/openerp-server.log
LOGFILE=/var/log/openerp/openerp-server.log
USER=openerp

test -x ${DAEMON} || exit 0

set -e

case "${1}" in
start)
echo -n "Starting ${DESC}: "

start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- --config=${CONFIG} \
--logfile=${LOGFILE}

echo "${NAME}."
;;

stop)
echo -n "Stopping ${DESC}: "

start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid \
--oknodo

echo "${NAME}."
;;
do_start () {
echo -n "Starting ${DESC}: "
start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid --chuid ${USER} --background --make-pidfile --exec ${DAEMON} -- --config=${CONFIG} --logfile=${LOGFILE}
echo "${NAME}."
}

restart|force-reload)
echo -n "Restarting ${DESC}: "
do_stop () {
echo -n "Stopping ${DESC}: "
start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid --oknodo
echo "${NAME}."
}

start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid \
--oknodo

sleep 1

start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- --config=${CONFIG} \
--logfile=${LOGFILE}

echo "${NAME}."
;;

*)
N=/etc/init.d/${NAME}
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;
case "${1}" in
start)
do_start
;;

stop)
do_stop
;;

restart|force-reload)
echo -n "Restarting ${DESC}: "
do_stop
sleep 1
do_start
;;

*)
N=/etc/init.d/${NAME}
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0
6 changes: 3 additions & 3 deletions debian/openerp.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ case "${1}" in
chown openerp:openerp /etc/openerp/openerp-server.conf
chmod 0640 /etc/openerp/openerp-server.conf
# Creating log file
touch /var/log/openerp-server.log
chown openerp:openerp /var/log/openerp-server.log
chmod 0640 /var/log/openerp-server.log
mkdir -p /var/log/openerp/
chown openerp:openerp /var/log/openerp
chmod 0750 /var/log/openerp
# Creating local storage directory
mkdir -p /var/lib/openerp/filestore
chown openerp:openerp -R /var/lib/openerp
Expand Down
11 changes: 11 additions & 0 deletions openerp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
""" OpenERP core library.
"""

# Make sure the OpenERP server runs in UTC. This is especially necessary
# under Windows as under Linux it seems the real import of time is
# sufficiently deferred so that setting the TZ environment variable
# in openerp.cli.server was working.
import os
os.environ['TZ'] = 'UTC' # Set the timezone...
import time # ... *then* import time.
del os
del time

# The hard-coded super-user id (a.k.a. administrator, or root user).
SUPERUSER_ID = 1

Expand Down
2 changes: 1 addition & 1 deletion openerp/addons/base/ir/ir_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def run(self, cr, uid, ids, context=None):
.read(cr, uid, action.action_id.id, context=context)

if action.state=='code':
eval(action.code, cxt, mode="exec", nocopy=True) # nocopy allows to return 'action'
eval(action.code.strip(), cxt, mode="exec", nocopy=True) # nocopy allows to return 'action'
if 'action' in cxt:
return cxt['action']

Expand Down
2 changes: 1 addition & 1 deletion openerp/addons/base/ir/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _file_read(self, cr, uid, location, fname, bin_size=False):
if bin_size:
r = os.path.getsize(full_path)
else:
r = open(full_path).read().encode('base64')
r = open(full_path,'rb').read().encode('base64')
except IOError:
_logger.error("_read_file reading %s",full_path)
return r
Expand Down
7 changes: 6 additions & 1 deletion openerp/addons/base/ir/ir_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import logging
import threading
import time
import psycopg2
from datetime import datetime
from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -188,6 +189,7 @@ def _acquire_job(cls, db_name):
If a job was processed, returns True, otherwise returns False.
"""
db = openerp.sql_db.db_connect(db_name)
threading.current_thread().dbname = db_name
cr = db.cursor()
jobs = []
try:
Expand Down Expand Up @@ -242,6 +244,9 @@ def _acquire_job(cls, db_name):
# we're exiting due to an exception while acquiring the lock
lock_cr.close()

if hasattr(threading.current_thread(), 'dbname'): # cron job could have removed it as side-effect
del threading.current_thread().dbname

def _try_lock(self, cr, uid, ids, context=None):
"""Try to grab a dummy exclusive write-lock to the rows with the given ids,
to make sure a following write() or unlink() will not block due
Expand Down
2 changes: 1 addition & 1 deletion openerp/addons/base/ir/ir_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ir_filters(osv.osv):
_description = 'Filters'

def _list_all_models(self, cr, uid, context=None):
cr.execute("SELECT model, name from ir_model")
cr.execute("SELECT model, name FROM ir_model ORDER BY name")
return cr.fetchall()

def copy(self, cr, uid, id, default=None, context=None):
Expand Down
14 changes: 11 additions & 3 deletions openerp/addons/base/ir/ir_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import types

import openerp
import openerp.modules.registry
from openerp import SUPERUSER_ID
from openerp import tools
from openerp.osv import fields,osv
Expand Down Expand Up @@ -168,7 +169,9 @@ def unlink(self, cr, user, ids, context=None):
if not context.get(MODULE_UNINSTALL_FLAG):
# only reload pool for normal unlink. For module uninstall the
# reload is done independently in openerp.modules.loading
cr.commit() # must be committed before reloading registry in new cursor
openerp.modules.registry.RegistryManager.new(cr.dbname)
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)

return res

Expand All @@ -194,6 +197,7 @@ def create(self, cr, user, vals, context=None):
field_state='manual',
select=vals.get('select_level', '0'))
self.pool[vals['model']]._auto_init(cr, ctx)
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return res

def instanciate(self, cr, user, model, context=None):
Expand Down Expand Up @@ -259,7 +263,6 @@ class ir_model_fields(osv.osv):
'state': lambda self,cr,uid,ctx=None: (ctx and ctx.get('manual',False)) and 'manual' or 'base',
'on_delete': 'set null',
'select_level': '0',
'size': 64,
'field_description': '',
'selectable': 1,
}
Expand Down Expand Up @@ -289,10 +292,10 @@ def _check_selection(self, cr, uid, selection, context=None):
return True

def _size_gt_zero_msg(self, cr, user, ids, context=None):
return _('Size of the field can never be less than 1 !')
return _('Size of the field can never be less than 0 !')

_sql_constraints = [
('size_gt_zero', 'CHECK (size>0)',_size_gt_zero_msg ),
('size_gt_zero', 'CHECK (size>=0)',_size_gt_zero_msg ),
]

def _drop_column(self, cr, uid, ids, context=None):
Expand All @@ -318,6 +321,9 @@ def unlink(self, cr, user, ids, context=None):

self._drop_column(cr, user, ids, context)
res = super(ir_model_fields, self).unlink(cr, user, ids, context)
if not context.get(MODULE_UNINSTALL_FLAG):
cr.commit()
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return res

def create(self, cr, user, vals, context=None):
Expand Down Expand Up @@ -349,6 +355,7 @@ def create(self, cr, user, vals, context=None):
select=vals.get('select_level', '0'),
update_custom_fields=True)
self.pool[vals['model']]._auto_init(cr, ctx)
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)

return res

Expand Down Expand Up @@ -465,6 +472,7 @@ def write(self, cr, user, ids, vals, context=None):
for col_name, col_prop, val in patch_struct[1]:
setattr(obj._columns[col_name], col_prop, val)
obj._auto_init(cr, ctx)
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return res

class ir_model_constraint(Model):
Expand Down
2 changes: 1 addition & 1 deletion openerp/addons/base/ir/ir_model_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
'readonly': [('ttype','not in', ['many2one','one2many','many2many'])]}"/>
<field name="relation_field" attrs="{'required': [('ttype','=','one2many')], 'readonly': [('ttype','!=','one2many')]}"/>
<field name="selection" attrs="{'required': [('ttype','in',['selection','reference'])], 'readonly': [('ttype','not in',['selection','reference'])]}"/>
<field name="size" attrs="{'required': [('ttype','in',['char','reference'])], 'readonly': [('ttype','not in',['char','reference'])]}"/>
<field name="size" attrs="{'invisible': [('ttype','not in',['char','text','reference'])]}"/>
<field name="domain" attrs="{'readonly': [('relation','=','')]}"/>
<field name="serialization_field_id" attrs="{'readonly': [('state','=','base')]}" domain="[('ttype','=','serialized'), ('model_id', '=', model_id)]"/>
<field name="on_delete" attrs="{'readonly': [('ttype','!=','many2one')]}"/>
Expand Down
3 changes: 2 additions & 1 deletion openerp/addons/base/ir/ir_ui_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def _type_field(self, cr, uid, ids, name, args, context=None):
}
_defaults = {
'arch': '<?xml version="1.0"?>\n<tree string="My view">\n\t<field name="name"/>\n</tree>',
'priority': 16
'priority': 16,
'type': 'tree',
}
_order = "priority,name"

Expand Down
2 changes: 0 additions & 2 deletions openerp/addons/base/module/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ def all_depencies_satisfied(m):
if to_install_ids:
self.button_install(cr, uid, to_install_ids, context=context)

openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return dict(ACTION_DICT, name=_('Install'))

def button_immediate_install(self, cr, uid, ids, context=None):
Expand Down Expand Up @@ -500,7 +499,6 @@ def button_uninstall(self, cr, uid, ids, context=None):
raise orm.except_orm(_('Error'), _("The `base` module cannot be uninstalled"))
dep_ids = self.downstream_dependencies(cr, uid, ids, context=context)
self.write(cr, uid, ids + dep_ids, {'state': 'to remove'})
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return dict(ACTION_DICT, name=_('Uninstall'))

def button_uninstall_cancel(self, cr, uid, ids, context=None):
Expand Down
6 changes: 3 additions & 3 deletions openerp/addons/base/res/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def _get_header(self,cr,uid,ids):
<frame id="first" x1="1.3cm" y1="3.0cm" height="%s" width="19.0cm"/>
<stylesheet>
<paraStyle name="main_footer" fontName="DejaVu Sans" fontSize="8.0" alignment="CENTER"/>
<paraStyle name="main_header" fontName="DejaVu Sans" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="main_header" fontName="DejaVu Sans" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
</stylesheet>
<pageGraphics>
<!-- You Logo - Change X,Y,Width and Height -->
Expand Down Expand Up @@ -344,8 +344,8 @@ def _get_header(self,cr,uid,ids):
</pageTemplate>
</header>"""

_header_a4 = _header_main % ('23.0cm', '27.6cm', '27.7cm', '27.7cm', '27.8cm', '27.3cm', '25.3cm', '25.0cm', '25.0cm', '24.6cm', '24.6cm', '24.5cm', '24.5cm')
_header_letter = _header_main % ('21.3cm', '25.9cm', '26.0cm', '26.0cm', '26.1cm', '25.6cm', '23.6cm', '23.3cm', '23.3cm', '22.9cm', '22.9cm', '22.8cm', '22.8cm')
_header_a4 = _header_main % ('21.7cm', '27.7cm', '27.7cm', '27.7cm', '27.8cm', '27.3cm', '25.3cm', '25.0cm', '25.0cm', '24.6cm', '24.6cm', '24.5cm', '24.5cm')
_header_letter = _header_main % ('20cm', '26.0cm', '26.0cm', '26.0cm', '26.1cm', '25.6cm', '23.6cm', '23.3cm', '23.3cm', '22.9cm', '22.9cm', '22.8cm', '22.8cm')

def onchange_paper_format(self, cr, uid, ids, paper_format, context=None):
if paper_format == 'us_letter':
Expand Down
2 changes: 1 addition & 1 deletion openerp/addons/base/res/res_currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _current_rate(self, cr, uid, ids, name, arg, context=None):
id, rate = cr.fetchall()[0]
res[id] = rate
else:
res[id] = 0
raise osv.except_osv(_('Error!'),_("No currency rate associated for currency %d for the given period" % (id)))
return res
_name = "res.currency"
_description = "Currency"
Expand Down
39 changes: 26 additions & 13 deletions openerp/addons/base/res/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,30 @@ def write(self, cr, uid, ids, vals, context=None):

def create(self, cr, uid, vals, context=None):
if context is None:
context={}
context = {}
# Update parent and siblings records
if vals.get('parent_id') and vals.get('use_parent_address'):
domain_siblings = [('parent_id', '=', vals['parent_id']), ('use_parent_address', '=', True)]
update_ids = [vals['parent_id']] + self.search(cr, uid, domain_siblings, context=context)
self.update_address(cr, uid, update_ids, vals, context)
return super(res_partner,self).create(cr, uid, vals, context=context)
if vals.get('parent_id'):
if 'use_parent_address' in vals:
use_parent_address = vals['use_parent_address']
else:
use_parent_address = self.default_get(cr, uid, ['use_parent_address'], context=context)['use_parent_address']

if use_parent_address:
domain_siblings = [('parent_id', '=', vals['parent_id']), ('use_parent_address', '=', True)]
update_ids = [vals['parent_id']] + self.search(cr, uid, domain_siblings, context=context)
self.update_address(cr, uid, update_ids, vals, context)

# add missing address keys
onchange_values = self.onchange_address(cr, uid, [], use_parent_address,
vals['parent_id'], context=context).get('value') or {}
vals.update(dict((key, value)
for key, value in onchange_values.iteritems()
if key in ADDRESS_FIELDS and key not in vals))

return super(res_partner, self).create(cr, uid, vals, context=context)

def update_address(self, cr, uid, ids, vals, context=None):
addr_vals = dict((key, vals[key]) for key in POSTAL_ADDRESS_FIELDS if vals.get(key))
addr_vals = dict((key, vals[key]) for key in POSTAL_ADDRESS_FIELDS if key in vals)
if addr_vals:
return super(res_partner, self).write(cr, uid, ids, addr_vals, context)

Expand All @@ -411,10 +425,10 @@ def _parse_partner_name(self, text, context=None):
""" Supported syntax:
- 'Raoul <[email protected]>': will find name and email address
- otherwise: default, everything is set as the name """
match = re.search(r'([^\s,<@]+@[^>\s,]+)', text)
if match:
email = match.group(1)
name = text[:text.index(email)].replace('"','').replace('<','').strip()
emails = tools.email_split(text)
if emails:
email = emails[0]
name = text[:text.index(email)].replace('"', '').replace('<', '').strip()
else:
name, email = text, ''
return name, email
Expand Down Expand Up @@ -457,8 +471,7 @@ def name_search(self, cr, uid, name, args=None, operator='ilike', context=None,
OR partner.name || ' (' || COALESCE(company.name,'') || ')'
''' + operator + ' %(name)s ' + limit_str, query_args)
ids = map(lambda x: x[0], cr.fetchall())
if args:
ids = self.search(cr, uid, [('id', 'in', ids)] + args, limit=limit, context=context)
ids = self.search(cr, uid, [('id', 'in', ids)] + args, limit=limit, context=context)
if ids:
return self.name_get(cr, uid, ids, context)
return super(res_partner,self).name_search(cr, uid, name, args, operator=operator, context=context, limit=limit)
Expand Down
Loading

0 comments on commit 307ca37

Please sign in to comment.