removed bad code
bzr revid: fp@tinyerp.com-20100128132653-1tchuel2eudj82gg
This commit is contained in:
parent
c0796e7092
commit
7b3007797f
|
@ -115,8 +115,7 @@
|
|||
<field name="padding"/>
|
||||
<field name="number_increment"/>
|
||||
<field name="number_next"/>
|
||||
<field name="weight" />
|
||||
<field name="condition" colspan="4" />
|
||||
<field name="weight" />
|
||||
<separator colspan="4" string="Legend (for prefix, suffix)"/>
|
||||
<group col="8" colspan="4">
|
||||
<group>
|
||||
|
@ -151,11 +150,11 @@
|
|||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="company_id"/>
|
||||
<field name="number_next"/>
|
||||
<field name="number_increment"/>
|
||||
<field name="prefix"/>
|
||||
<field name="padding"/>
|
||||
<field name="active"/>
|
||||
<field name="number_next"/>
|
||||
<field name="number_increment"/>
|
||||
<field name="prefix"/>
|
||||
<field name="padding"/>
|
||||
<field name="active"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -341,36 +340,36 @@
|
|||
<field name="usage"/>
|
||||
<field name="view_type"/>
|
||||
<notebook colspan="4">
|
||||
<page string="General Settings">
|
||||
<field colspan="4" name="view_ids">
|
||||
<form string="Views">
|
||||
<field colspan="4" name="sequence"/>
|
||||
<field name="view_mode"/>
|
||||
<field domain="[('type', '=', view_mode)]" name="view_id"/>
|
||||
</form>
|
||||
<tree string="Views">
|
||||
<field name="sequence"/>
|
||||
<field name="view_mode"/>
|
||||
<field name="view_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field colspan="4" name="default_user_ids"/>
|
||||
<field colspan="4" name="menus"/>
|
||||
<field colspan="4" name="domain"/>
|
||||
<field colspan="4" name="context"/>
|
||||
<field name="limit"/>
|
||||
<field name="auto_refresh"/>
|
||||
<newline/>
|
||||
<field name="view_mode"/>
|
||||
<field name="filter"/>
|
||||
<field name="view_id"/>
|
||||
<field name="search_view_id"/>
|
||||
</page>
|
||||
<page string="Security">
|
||||
<separator colspan="4" string="Select Groups" />
|
||||
<field name="groups_id" nolabel="1" colspan="4" />
|
||||
</page>
|
||||
</notebook>
|
||||
<page string="General Settings">
|
||||
<field colspan="4" name="view_ids">
|
||||
<form string="Views">
|
||||
<field colspan="4" name="sequence"/>
|
||||
<field name="view_mode"/>
|
||||
<field domain="[('type', '=', view_mode)]" name="view_id"/>
|
||||
</form>
|
||||
<tree string="Views">
|
||||
<field name="sequence"/>
|
||||
<field name="view_mode"/>
|
||||
<field name="view_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field colspan="4" name="default_user_ids"/>
|
||||
<field colspan="4" name="menus"/>
|
||||
<field colspan="4" name="domain"/>
|
||||
<field colspan="4" name="context"/>
|
||||
<field name="limit"/>
|
||||
<field name="auto_refresh"/>
|
||||
<newline/>
|
||||
<field name="view_mode"/>
|
||||
<field name="filter"/>
|
||||
<field name="view_id"/>
|
||||
<field name="search_view_id"/>
|
||||
</page>
|
||||
<page string="Security">
|
||||
<separator colspan="4" string="Select Groups" />
|
||||
<field name="groups_id" nolabel="1" colspan="4" />
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -997,7 +996,7 @@
|
|||
<field eval="8" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Menu" editable="top">
|
||||
<field name="sequence"/>
|
||||
<field name="sequence"/>
|
||||
<field icon="icon" name="complete_name"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
@ -1217,13 +1216,12 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Server Action">
|
||||
<group col="6" colspan="4">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model_id" select="1"/>
|
||||
<field name="state" select="1"/>
|
||||
<field name="sequence" select="2"/>
|
||||
<field name="condition"/>
|
||||
</group>
|
||||
<group col="6" colspan="4">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model_id" select="1"/>
|
||||
<field name="state" select="1"/>
|
||||
<field name="sequence" select="2"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Python Code" attrs="{'invisible':[('state','!=','code')]}">
|
||||
<separator colspan="4" string="Python Code"/>
|
||||
|
@ -1236,7 +1234,7 @@
|
|||
<field name="trigger_name" select="2" attrs="{'required':[('state','=','trigger')]}"/>
|
||||
</page>
|
||||
<page string="Action to Launch" attrs="{'invisible':[('state','!=','client_action')]}">
|
||||
<separator colspan="4" string="Client Action Configuration"/>
|
||||
<separator colspan="4" string="Client Action Configuration"/>
|
||||
<field name="action_id" select="2" attrs="{'required':[('state','=','client_action')]}"/>
|
||||
</page>
|
||||
<page string="Email Configuration" attrs="{'invisible':[('state','!=','email')]}">
|
||||
|
@ -1256,7 +1254,7 @@
|
|||
</page>
|
||||
<page string="Create / Write" attrs="{'invisible':[('state','!=','object_create'),('state','!=','object_write')]}">
|
||||
<separator colspan="4" string="Fields Mapping"/>
|
||||
<field name="srcmodel_id" select="2" attrs="{'required':[('state','!=','dummy'), ('state','!=','sms'), ('state','!=','code'), ('state','!=','loop'),('state','!=','trigger'), ('state','!=','client_action'), ('state','!=','email'), ('state','!=','sms'), ('state','!=','other')]}"/>
|
||||
<field name="srcmodel_id" select="2" attrs="{'required':[('state','!=','dummy'), ('state','!=','sms'), ('state','!=','code'), ('state','!=','loop'),('state','!=','trigger'), ('state','!=','client_action'), ('state','!=','email'), ('state','!=','sms'), ('state','!=','other')]}"/>
|
||||
<field name="fields_lines" nolabel="1" select="2" colspan="4">
|
||||
<tree string="Field Mappings" editable="top">
|
||||
<field name="col1" domain="[('model_id','=',parent.srcmodel_id or parent.model_id)]"/>
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# 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.
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
# GNU 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/>.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from osv import fields,osv
|
||||
from tools.safe_eval import safe_eval
|
||||
import pooler
|
||||
|
||||
class ir_sequence_type(osv.osv):
|
||||
|
@ -47,17 +47,12 @@ class ir_sequence(osv.osv):
|
|||
'number_next': fields.integer('Next Number', required=True),
|
||||
'number_increment': fields.integer('Increment Number', required=True),
|
||||
'padding' : fields.integer('Number padding', required=True),
|
||||
'condition': fields.char('Condition', size=250, help="If set, sequence will only be used in case this python expression matches, and will precede other sequences."),
|
||||
'weight': fields.integer('Weight',required=True, help="If two sequences match, the highest weight will be used."),
|
||||
'company_id' : fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *a: True,
|
||||
'number_increment': lambda *a: 1,
|
||||
'number_next': lambda *a: 1,
|
||||
'padding' : lambda *a : 0,
|
||||
'weight' : lambda *a: 10,
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'ir.sequence', context=c)
|
||||
}
|
||||
|
||||
def _process(self, s):
|
||||
|
@ -76,29 +71,10 @@ class ir_sequence(osv.osv):
|
|||
}
|
||||
|
||||
def get_id(self, cr, uid, sequence_id, test='id=%s', context=None):
|
||||
if not context:
|
||||
context = {}
|
||||
try:
|
||||
cr.execute('SELECT id, number_next, prefix, suffix, padding, condition \
|
||||
FROM ir_sequence \
|
||||
WHERE '+test+' AND active=%s ORDER BY weight DESC, length(COALESCE(condition,\'\')) DESC \
|
||||
FOR UPDATE', (sequence_id, True))
|
||||
for res in cr.dictfetchall():
|
||||
if res['condition']:
|
||||
print "ir_seq: %s has condition:" %res['id'], res['condition'],
|
||||
try:
|
||||
bo = safe_eval(res['condition'],context)
|
||||
if not bo:
|
||||
print "not matched"
|
||||
continue
|
||||
except Exception,e:
|
||||
# it would be normal to have exceptions, because
|
||||
# the domain may contain errors
|
||||
print "Exception.\ne:",e
|
||||
print "Context:", context
|
||||
continue
|
||||
print "Matched!"
|
||||
|
||||
cr.execute('SELECT id, number_next, prefix, suffix, padding FROM ir_sequence WHERE '+test+' AND active=%s FOR UPDATE', (sequence_id, True))
|
||||
res = cr.dictfetchone()
|
||||
if res:
|
||||
cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=%s', (res['id'], True))
|
||||
if res['number_next']:
|
||||
return self._process(res['prefix']) + '%%0%sd' % res['padding'] % res['number_next'] + self._process(res['suffix'])
|
||||
|
@ -108,8 +84,8 @@ class ir_sequence(osv.osv):
|
|||
cr.commit()
|
||||
return False
|
||||
|
||||
def get(self, cr, uid, code, context = None):
|
||||
return self.get_id(cr, uid, code, test='code=%s',context=context)
|
||||
def get(self, cr, uid, code):
|
||||
return self.get_id(cr, uid, code, test='code=%s')
|
||||
ir_sequence()
|
||||
|
||||
|
||||
|
|
|
@ -304,6 +304,7 @@ class many2one(_column):
|
|||
for id in ids:
|
||||
res.setdefault(id, '')
|
||||
obj = obj.pool.get(self._obj)
|
||||
|
||||
# build a dictionary of the form {'id_of_distant_resource': name_of_distant_resource}
|
||||
from orm import except_orm
|
||||
try:
|
||||
|
@ -313,7 +314,6 @@ class many2one(_column):
|
|||
iids = filter(None, res.values())
|
||||
for iiid in iids:
|
||||
names[iiid] = '// Access Denied //'
|
||||
|
||||
for r in res.keys():
|
||||
if res[r] and res[r] in names:
|
||||
res[r] = (res[r], names[res[r]])
|
||||
|
|
Loading…
Reference in New Issue