[MERGE] merged with lp:~openerp/openobject-addons/trunk/

bzr revid: hmo@tinyerp.com-20100316115803-60obpd8tuaonnjh9
This commit is contained in:
Harry (Open ERP) 2010-03-16 17:28:03 +05:30
commit a294aaf52b
10 changed files with 61 additions and 56 deletions

View File

@ -668,7 +668,7 @@
<field eval="True" name="object"/>
</record>
<wizard id="action_move_journal_line_form" menu="False" model="account.move.line" name="account.move.journal" string="Making Entries by Line"/>
<wizard id="action_move_journal_line_form" menu="False" model="account.move.line" name="account.move.journal" string="Entries by Line"/>
<menuitem icon="STOCK_JUSTIFY_FILL" action="action_move_journal_line_form" id="menu_action_move_journal_line_form" parent="account.menu_finance_entries" type="wizard" sequence="5"/>
<!--
@ -974,7 +974,7 @@
<menuitem action="action_move_line_form" id="menu_action_move_line_form" parent="next_id_29"/>
<record id="action_move_line_form_encode_by_move" model="ir.actions.act_window">
<field name="name">Making Entries by Move</field>
<field name="name">Entries by Move</field>
<field name="res_model">account.move</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>

View File

@ -202,7 +202,7 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_account_analytic_line_tree"/>
</record>
<wizard id="action_account_analytic_line" menu="False" model="account.analytic.line" name="account.analytic.line" string="Making Entries by Line"/>
<wizard id="action_account_analytic_line" menu="False" model="account.analytic.line" name="account.analytic.line" string="Entries by Line"/>
<menuitem id="next_id_41" name="Analytic Entries" parent="account.menu_finance_entries"/>
<menuitem type="wizard" icon="STOCK_JUSTIFY_FILL" action="action_account_analytic_line" id="account_entries_analytic_entries" parent="next_id_41"/>

View File

@ -39,7 +39,7 @@ def _action_open_window(self, cr, uid, data, context):
id = mod_obj.read(cr, uid, result, ['res_id'])
return {
'name': _('Analytic Entries'),
'name': _('Analytic Entries by line'),
'view_type': 'form',
"view_mode": 'tree,form',
'res_model': 'account.analytic.line',
@ -71,11 +71,11 @@ class account_analytic_line(wizard.interface):
}
states = {
'init': {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Entries','gtk-ok')]}
},
'open': {
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}

View File

@ -111,15 +111,19 @@ class base_module_record(osv.osv):
return obj.module+'.'+obj.name, obj.noupdate
def _create_record(self, cr, uid, doc, model, data, record_id, noupdate=False):
data_pool = self.pool.get('ir.model.data')
model_pool = self.pool.get(model)
record = doc.createElement('record')
record.setAttribute("id", record_id)
record.setAttribute("model", model)
record_list = [record]
lids = self.pool.get('ir.model.data').search(cr, uid, [('model','=',model)])
res = self.pool.get('ir.model.data').read(cr, uid, lids[:1], ['module'])
lids = data_pool.search(cr, uid, [('model','=',model)])
res = data_pool.read(cr, uid, lids[:1], ['module'])
if res:
self.depends[res[0]['module']]=True
fields = self.pool.get(model).fields_get(cr, uid)
fields = model_pool.fields_get(cr, uid)
for key,val in data.items():
if not (val or (fields[key]['type']=='boolean')):
continue
@ -142,9 +146,11 @@ class base_module_record(osv.osv):
id,update = self._get_id(cr, uid, fields[key]['relation'], val)
noupdate = noupdate or update
if not id:
relation_pool = self.pool.get(fields[key]['relation'])
field.setAttribute("model", fields[key]['relation'])
fld_nm = self.pool.get(fields[key]['relation'])._rec_name
name = self.pool.get(fields[key]['relation']).read(cr, uid, val,[fld_nm])[fld_nm] or False
fld_nm = relation_pool._rec_name
name = relation_pool.read(cr, uid, val,[fld_nm])[fld_nm] or False
field.setAttribute("search", str([(str(fld_nm) ,'=', name)]))
else:
field.setAttribute("ref", id)
@ -152,10 +158,10 @@ class base_module_record(osv.osv):
elif fields[key]['type'] in ('one2many',):
for valitem in (val or []):
if valitem[0] in (0,1):
if key in self.pool.get(model)._columns:
fname = self.pool.get(model)._columns[key]._fields_id
if key in model_pool._columns:
fname = model_pool._columns[key]._fields_id
else:
fname = self.pool.get(model)._inherit_fields[key][2]._fields_id
fname = model_pool._inherit_fields[key][2]._fields_id
valitem[2][fname] = record_id
newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1])
if not newid:
@ -190,14 +196,18 @@ class base_module_record(osv.osv):
def _create_yaml_record(self, cr, uid, model, data, record_id):
record={'model': model, 'id': str(record_id)}
lids = self.pool.get('ir.model.data').search(cr, uid, [('model','=',model)])
res = self.pool.get('ir.model.data').read(cr, uid, lids[:1], ['module'])
model_pool = self.pool.get(model)
data_pool = self.pool.get('ir.model.data')
lids = data_pool.search(cr, uid, [('model','=',model)])
res = data_pool.read(cr, uid, lids[:1], ['module'])
attrs={}
if res:
self.depends[res[0]['module']]=True
fields = self.pool.get(model).fields_get(cr, uid)
fields = model_pool.fields_get(cr, uid)
defaults={}
defaults[model] = self.pool.get(model).default_get(cr, uid, data)
defaults[model] = model_pool.default_get(cr, uid, data)
for key,val in data.items():
if ((key in defaults[model]) and (val == defaults[model][key])) and not(fields[key].get('required',False)):
continue
@ -210,19 +220,19 @@ class base_module_record(osv.osv):
elif fields[key]['type'] in ('integer','float'):
attrs[key] = val
elif fields[key]['type'] in ('many2one',):
if type(val) in (type(''),type(u'')):
if type(val) in (type(''), type(u'')):
id = val
else:
id,update = self._get_id(cr, uid, fields[key]['relation'], val)
id, update = self._get_id(cr, uid, fields[key]['relation'], val)
attrs[key] = str(id)
elif fields[key]['type'] in ('one2many',):
items=[[]]
for valitem in (val or []):
if valitem[0] in (0,1):
if key in self.pool.get(model)._columns:
fname = self.pool.get(model)._columns[key]._fields_id
if key in model_pool._columns:
fname = model_pool._columns[key]._fields_id
else:
fname = self.pool.get(model)._inherit_fields[key][2]._fields_id
fname = model_pool._inherit_fields[key][2]._fields_id
valitem[2][fname] = record_id
newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1])
if not newid:

View File

@ -45,7 +45,7 @@ class ir_action_report_xml(osv.osv):
res[data.get('id')] = False
return res
def _model_search(self, cr, uid, obj, name, args):
def _model_search(self, cr, uid, obj, name, args, context={}):
if not len(args):
return []
model_id= args[0][2]

View File

@ -64,8 +64,7 @@ class document_directory(osv.osv):
def _get_root_directory(self, cr,uid, context=None):
objid=self.pool.get('ir.model.data')
try:
mid = objid._get_id(cr, uid, 'document', 'dir_root')
return False # TODO: check why not display root dir
mid = objid._get_id(cr, uid, 'document', 'dir_root')
if not mid:
return False
except Exception, e:
@ -199,8 +198,8 @@ class document_directory(osv.osv):
path.append(duri[0])
duri = duri[1:]
did = nid[0]
return (nodes.node_dir(path, nparent,ncontext,self.browse(cr,uid,did, context)), duri)
root_node = did and self.browse(cr,uid,did, context) or False
return (nodes.node_dir(path, nparent,ncontext, root_node), duri)
nid = self.search(cr,uid,[('parent_id','=',did),('name','=',duri[0]),('type','=','ressource')], context=context)

View File

@ -49,18 +49,17 @@ class node_context(object):
context """
cached_roots = {}
def __init__(self, cr, uid, context=None):
# we don't cache the cr!
def __init__(self, cr, uid, context=None):
self.dbname = cr.dbname
self.uid = uid
self.context = context
self._dirobj = pooler.get_pool(cr.dbname).get('document.directory')
assert self._dirobj
self.rootdir = self._dirobj._get_root_directory(cr,uid,context)
self.rootdir = False #self._dirobj._get_root_directory(cr,uid,context)
def get_uri(self, cr, uri):
""" Although this fn passes back to doc.dir, it is needed since
it is a potential caching point """
it is a potential caching point """
(ndir, duri) = self._dirobj._locate_child(cr,self.uid, self.rootdir,uri, None, self)
while duri:
ndir = ndir.child(cr, duri[0])
@ -168,23 +167,23 @@ class node_dir(node_class):
our_type = 'collection'
def __init__(self,path, parent, context, dirr, dctx=None):
super(node_dir,self).__init__(path, parent,context)
self.dir_id = dirr.id
self.dir_id = dirr and dirr.id or False
#todo: more info from dirr
self.mimetype = 'application/x-directory'
# 'httpd/unix-directory'
self.create_date = dirr.create_date
self.domain = dirr.domain
self.res_model = dirr.ressource_type_id and dirr.ressource_type_id.model or False
self.create_date = dirr and dirr.create_date or False
self.domain = dirr and dirr.domain or []
self.res_model = dirr and dirr.ressource_type_id and dirr.ressource_type_id.model or False
# TODO: the write date should be MAX(file.write)..
self.write_date = dirr.write_date or dirr.create_date
self.write_date = dirr and (dirr.write_date or dirr.create_date) or False
self.content_length = 0
if dctx:
self.dctx.update(dctx)
dc2 = self.context.context
dc2.update(self.dctx)
dc2['dir_id'] = self.dir_id
self.displayname = dirr.name
if dirr.dctx_ids:
self.displayname = dirr and dirr.name or False
if dirr and dirr.dctx_ids:
for dfld in dirr.dctx_ids:
try:
self.dctx['dctx_' + dfld.field] = safe_eval(dfld.expr,dc2)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -43,7 +43,7 @@ def _create_duplicate(self, cr, uid, data, context):
event_obj=pooler.get_pool(cr.dbname).get('event.event')
project_obj = pooler.get_pool(cr.dbname).get('project.project')
duplicate_project_id= project_obj.copy(cr, uid,data['form']['project_id'], {'active': True})
project_obj.write(cr, uid, [duplicate_project_id], {'name': "copy of " + project_obj.browse(cr, uid, duplicate_project_id, context).name , 'date_start':time.strftime('%Y-%m-%d'),'date_end': event_obj.browse(cr, uid, [data['id']])[0].date_begin[0:10] })
project_obj.write(cr, uid, [duplicate_project_id], {'name': "copy of " + project_obj.browse(cr, uid, duplicate_project_id, context).name , 'date_start':time.strftime('%Y-%m-%d'),'date': event_obj.browse(cr, uid, [data['id']])[0].date_begin[0:10] })
event_obj.write(cr, uid, [data['id']], {'project_id': duplicate_project_id })
return {}

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--
Resource: project.project
-->
<record id="base.main_company" model="res.company">
<field name="project_time_mode_id" ref="product.uom_hour"></field>
</record>
<!-- Task Types -->
<record id="project_tt_specification" model="project.task.type">
<field name="sequence">1</field>
@ -26,7 +26,7 @@
<field name="sequence">4</field>
<field name="name">Merge</field>
</record>
<!-- Projects -->
<record id="project_project_9" model="project.project">
<field name="warn_manager">1</field>
@ -39,7 +39,6 @@
<field name="priority">10</field>
<field name="parent_id" ref="project_project_9"/>
<field name="name">Study + Prototype</field>
<field model="account.analytic.account" name="category_id" search="[('name','=', 'Seagate P1')]"/>
<field name="manager" ref="base.user_root"/>
<field eval="[(6, 0, [ref('project_tt_specification'),ref('project_tt_development')])]" name="type_ids"/>
</record>
@ -47,7 +46,6 @@
<field name="priority">20</field>
<field name="parent_id" ref="project_project_9"/>
<field name="name">Specific Developements</field>
<field model="account.analytic.account" name="category_id" search="[('name','=', 'Seagate P1')]"/>
<field name="manager" ref="base.user_root"/>
<field eval="[(6, 0, [ref('project_tt_specification'), ref('project_tt_development')])]" name="type_ids"/>
</record>
@ -55,11 +53,10 @@
<field name="priority">30</field>
<field name="parent_id" ref="project_project_9"/>
<field name="name">Install, data import, configuration</field>
<field model="account.analytic.account" name="category_id" search="[('name','=', 'Seagate P1')]"/>
<field name="manager" ref="base.user_root"/>
<field eval="[(6, 0, [ref('project_tt_development')])]" name="type_ids"/>
</record>
<!-- Tasks -->
<record id="project_task_116" model="project.task">
<field name="planned_hours">38.0</field>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -29,12 +29,12 @@ class project_project(osv.osv):
_description = 'project.project'
def write(self, cr, uid, ids,vals, *args, **kwargs):
if 'date_end' in vals and vals['date_end']:
if 'date' in vals and vals['date']:
data_project = self.browse(cr,uid,ids)
for prj in data_project:
c= date(*time.strptime(vals['date_end'],'%Y-%m-%d')[:3])
if prj.date_end:
d= date(*time.strptime(prj.date_end,'%Y-%m-%d')[:3])
c= date(*time.strptime(vals['date'],'%Y-%m-%d')[:3])
if prj.date:
d= date(*time.strptime(prj.date,'%Y-%m-%d')[:3])
for task in prj.tasks:
start_dt = (datetime(*time.strptime(task.date_start,'%Y-%m-%d %H:%M:%S')[:6])+(c-d)).strftime('%Y-%m-%d %H:%M:%S')
if task.date_deadline:
@ -42,7 +42,7 @@ class project_project(osv.osv):
self.pool.get('project.task').write(cr,uid,task.id,{'date_start':start_dt, 'date_deadline':deadline_dt})
else:
self.pool.get('project.task').write(cr,uid,task.id,{'date_start':start_dt})
return super(project_project,self).write(cr, uid, ids,vals, *args, **kwargs)
return super(project_project,self).write(cr, uid, ids, vals, *args, **kwargs)
project_project()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: