Skip to content

Commit

Permalink
[MERGE] Forward-port saas-4 bugfixes up to ad4c6ca
Browse files Browse the repository at this point in the history
  • Loading branch information
odony committed Jun 12, 2014
2 parents 88205e2 + ad4c6ca commit f15cbd6
Show file tree
Hide file tree
Showing 21 changed files with 1,522 additions and 1,456 deletions.
11 changes: 9 additions & 2 deletions addons/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,14 @@ def name_search(self, cr, user, name, args=None, operator='ilike', context=None,
pass
if name:
if operator not in expression.NEGATIVE_TERM_OPERATORS:
ids = self.search(cr, user, ['|', ('code', '=like', name+"%"), '|', ('shortcut', '=', name), ('name', operator, name)]+args, limit=limit)
plus_percent = lambda n: n+'%'
code_op, code_conv = {
'ilike': ('=ilike', plus_percent),
'like': ('=like', plus_percent),
}.get(operator, (operator, lambda n: n))

ids = self.search(cr, user, ['|', ('code', code_op, code_conv(name)), '|', ('shortcut', '=', name), ('name', operator, name)]+args, limit=limit)

if not ids and len(name.split()) >= 2:
#Separating code and name of account for searching
operand1,operand2 = name.split(' ',1) #name can contain spaces e.g. OpenERP S.A.
Expand Down Expand Up @@ -2918,7 +2925,7 @@ class account_fiscal_position_template(osv.osv):
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Account Mapping'),
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Tax Mapping'),
'note': fields.text('Notes', translate=True),
'note': fields.text('Notes'),
}

def generate_fiscal_position(self, cr, uid, chart_temp_id, tax_template_ref, acc_template_ref, company_id, context=None):
Expand Down
3 changes: 3 additions & 0 deletions addons/account/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,9 @@ def _auto_init(self, cr, context=None):
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'account_move_line_journal_id_period_id_index\'')
if not cr.fetchone():
cr.execute('CREATE INDEX account_move_line_journal_id_period_id_index ON account_move_line (journal_id, period_id)')
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('account_move_line_date_id_index',))
if not cr.fetchone():
cr.execute('CREATE INDEX account_move_line_date_id_index ON account_move_line (date DESC, id desc)')
return res

def _check_no_view(self, cr, uid, ids, context=None):
Expand Down
2 changes: 1 addition & 1 deletion addons/account/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class account_fiscal_position(osv.osv):
'company_id': fields.many2one('res.company', 'Company'),
'account_ids': fields.one2many('account.fiscal.position.account', 'position_id', 'Account Mapping'),
'tax_ids': fields.one2many('account.fiscal.position.tax', 'position_id', 'Tax Mapping'),
'note': fields.text('Notes', translate=True),
'note': fields.text('Notes'),
}

_defaults = {
Expand Down
2 changes: 1 addition & 1 deletion addons/account_voucher/voucher_payment_receipt_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
<field name="writeoff_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="payment_option" required="1" attrs="{'invisible':[('writeoff_amount','=',0)]}"/>
<field name="writeoff_acc_id"
attrs="{'invisible':['|', ('payment_option','!=','with_writeoff'), ('writeoff_amount','=',0)], 'required':[('payment_option','=','with_writeoff')]}"
attrs="{'invisible':['|', ('payment_option','!=','with_writeoff'), ('writeoff_amount','=',0)], 'required':[('payment_option','=','with_writeoff'), ('writeoff_amount','!=',0)]}"
domain="[('type','=','other')]"/>
<field name="comment"
attrs="{'invisible':['|', ('payment_option','!=','with_writeoff'), ('writeoff_amount','=',0)]}"/>
Expand Down
24 changes: 17 additions & 7 deletions addons/base_action_rule/base_action_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def _register_hook(self, cr, ids=None):
""" Wrap the methods `create` and `write` of the models specified by
the rules given by `ids` (or all existing rules if `ids` is `None`.)
"""
updated = False
if ids is None:
ids = self.search(cr, SUPERUSER_ID, [])
for action_rule in self.browse(cr, SUPERUSER_ID, ids):
Expand All @@ -223,20 +224,21 @@ def _register_hook(self, cr, ids=None):
model_obj.create = self._wrap_create(model_obj.create, model)
model_obj.write = self._wrap_write(model_obj.write, model)
model_obj.base_action_ruled = True
return True
updated = True
return updated

def create(self, cr, uid, vals, context=None):
res_id = super(base_action_rule, self).create(cr, uid, vals, context=context)
self._register_hook(cr, [res_id])
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
if self._register_hook(cr, [res_id]):
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return res_id

def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)):
ids = [ids]
super(base_action_rule, self).write(cr, uid, ids, vals, context=context)
self._register_hook(cr, ids)
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
if self._register_hook(cr, ids):
openerp.modules.registry.RegistryManager.signal_registry_change(cr.dbname)
return True

def onchange_model_id(self, cr, uid, ids, model_id, context=None):
Expand Down Expand Up @@ -266,7 +268,10 @@ def _check(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
action_ids = self.search(cr, uid, action_dom, context=context)
for action in self.browse(cr, uid, action_ids, context=context):
now = datetime.now()
last_run = get_datetime(action.last_run) if action.last_run else False
if action.last_run:
last_run = get_datetime(action.last_run)
else:
last_run = datetime.utcfromtimestamp(0)

# retrieve all the records that satisfy the action's condition
model = self.pool[action.model_id.model]
Expand Down Expand Up @@ -297,11 +302,16 @@ def _check(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
if not record_dt:
continue
action_dt = self._check_delay(cr, uid, action, record, record_dt, context=context)
if last_run and (last_run <= action_dt < now) or (action_dt < now):
if last_run <= action_dt < now:
try:
context = dict(context or {}, action=True)
self._process(cr, uid, action, [record.id], context=context)
except Exception:
import traceback
_logger.error(traceback.format_exc())

action.write({'last_run': now.strftime(DEFAULT_SERVER_DATETIME_FORMAT)})

if automatic:
# auto-commit for batch processing
cr.commit()
2 changes: 1 addition & 1 deletion addons/base_action_rule/base_action_rule_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field eval="False" name="doall"/>
<field eval="'base.action.rule'" name="model"/>
<field eval="'_check'" name="function"/>
<field eval="'()'" name="args"/>
<field eval="'(True,)'" name="args"/>
</record>

</data>
Expand Down
30 changes: 30 additions & 0 deletions addons/gamification/models/goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,36 @@ def number_following(self, cr, uid, model_name="mail.thread", context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return self.pool.get('mail.followers').search(cr, uid, [('res_model', '=', model_name), ('partner_id', '=', user.partner_id.id)], count=True, context=context)

def _check_domain_validity(self, cr, uid, ids, context=None):
# take admin as should always be present
superuser = self.pool['res.users'].browse(cr, uid, SUPERUSER_ID, context=context)
for definition in self.browse(cr, uid, ids, context=context):
if definition.computation_mode not in ('count', 'sum'):
continue

obj = self.pool[definition.model_id.model]
try:
domain = safe_eval(definition.domain, {'user': superuser})
# demmy search to make sure the domain is valid
obj.search(cr, uid, domain, context=context, count=True)
except (ValueError, SyntaxError), e:
msg = e.message or (e.msg + '\n' + e.text)
raise osv.except_osv(_('Error!'),_("The domain for the definition %s seems incorrect, please check it.\n\n%s" % (definition.name, msg)))
return True

def create(self, cr, uid, vals, context=None):
res_id = super(gamification_goal_definition, self).create(cr, uid, vals, context=context)
if vals.get('computation_mode') in ('count', 'sum'):
self._check_domain_validity(cr, uid, [res_id], context=context)

return res_id

def write(self, cr, uid, ids, vals, context=None):
res = super(gamification_goal_definition, self).write(cr, uid, ids, vals, context=context)
if vals.get('computation_mode', 'count') in ('count', 'sum') and (vals.get('domain') or vals.get('model_id')):
self._check_domain_validity(cr, uid, ids, context=context)

return res


class gamification_goal(osv.Model):
Expand Down
2 changes: 1 addition & 1 deletion addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
</page>
<page string="Attendances" groups="base.group_hr_attendance">
<group>
<field context="{'employee_id': employee_id, 'user_id':user_id}" name="attendances_ids" nolabel="1">
<field context="{'default_employee_id': employee_id, 'user_id':user_id}" name="attendances_ids" nolabel="1">
<tree string="Attendances" editable="bottom">
<field name="name"/>
<field name="action"/>
Expand Down
Loading

0 comments on commit f15cbd6

Please sign in to comment.