diff options
| author | apa-tiny <apa@tinyerp.com> | 2010-03-16 17:33:08 +0530 |
|---|---|---|
| committer | apa-tiny <apa@tinyerp.com> | 2010-03-16 17:33:08 +0530 |
| commit | 4e2d697bbcaed951ff8d6e2f4dbb40d0b9634401 (patch) | |
| tree | d1c5191015ffd025f99876c9f612be8d822dd115 /addons | |
| parent | 8ea773c793398546341f31360cde91a5f23fecef (diff) | |
| parent | d80e1e599fad0f875f895b97350ec104ea28731e (diff) | |
[MERGE]
bzr revid: apa@tinyerp.com-20100316120308-1xmdokjpg3xr3fet
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/account_view.xml | 4 | ||||
| -rw-r--r-- | addons/account/project/project_view.xml | 2 | ||||
| -rw-r--r-- | addons/account/project/wizard/wizard_account_analytic_line.py | 6 | ||||
| -rw-r--r-- | addons/base_module_record/base_module_record.py | 44 | ||||
| -rw-r--r-- | addons/document/directory_report.py | 2 | ||||
| -rw-r--r-- | addons/document/document_directory.py | 7 | ||||
| -rw-r--r-- | addons/document/nodes.py | 21 | ||||
| -rw-r--r-- | addons/event_project/wizard/project_wizard.py | 6 | ||||
| -rw-r--r-- | addons/project/project_demo.xml | 11 | ||||
| -rw-r--r-- | addons/project_caldav/__terp__.py | 30 | ||||
| -rw-r--r-- | addons/project_caldav/project_caldav_view.xml | 18 | ||||
| -rw-r--r-- | addons/project_retro_planning/project_retro_planning.py | 14 | ||||
| -rw-r--r-- | addons/project_timesheet/project_timesheet.py | 54 |
13 files changed, 115 insertions, 104 deletions
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 3ef24386c2d..d865823e9cd 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -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> diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index a2be8716c1e..5954c4e80b0 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -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"/> diff --git a/addons/account/project/wizard/wizard_account_analytic_line.py b/addons/account/project/wizard/wizard_account_analytic_line.py index e6ebd336c35..4d63aff05f5 100644 --- a/addons/account/project/wizard/wizard_account_analytic_line.py +++ b/addons/account/project/wizard/wizard_account_analytic_line.py @@ -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'} } diff --git a/addons/base_module_record/base_module_record.py b/addons/base_module_record/base_module_record.py index 91ba7b8782c..1bea209cd78 100644 --- a/addons/base_module_record/base_module_record.py +++ b/addons/base_module_record/base_module_record.py @@ -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: diff --git a/addons/document/directory_report.py b/addons/document/directory_report.py index aac65cc8e36..a7a3d80191b 100644 --- a/addons/document/directory_report.py +++ b/addons/document/directory_report.py @@ -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] diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 17c3dfb66d9..554eae43e08 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -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) diff --git a/addons/document/nodes.py b/addons/document/nodes.py index c6e2f1b10d1..2335eaf4b58 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -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) diff --git a/addons/event_project/wizard/project_wizard.py b/addons/event_project/wizard/project_wizard.py index d39c86f4d49..fe70db08e7b 100644 --- a/addons/event_project/wizard/project_wizard.py +++ b/addons/event_project/wizard/project_wizard.py @@ -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 {} diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index 7b5d565fead..f668d82bf5c 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -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> diff --git a/addons/project_caldav/__terp__.py b/addons/project_caldav/__terp__.py index 0cd26f06334..1ac69933623 100644 --- a/addons/project_caldav/__terp__.py +++ b/addons/project_caldav/__terp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,22 +15,22 @@ # 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/>. # ############################################################################## { - "name" : "Caldav task management", - "version" : "1.0", - "author" : "Tiny", - "category" : "Generic Modules/Others", - "description": """ Synchronize between Project task and Caldav Vtodo.""", - "depends" : ["project", "caldav"], - "init_xml" : ["project_caldav_data.xml"], - "demo_xml" : [], - "update_xml" : ["project_caldav_view.xml", - "project_caldav_wizard.xml"], - "active": False, - "website": "http://www.openerp.com", - "installable": True, + "name" : "Caldav task management", + "version" : "1.0", + "author" : "Tiny", + "category" : "Generic Modules/Others", + "description": """ Synchronize between Project task and Caldav Vtodo.""", + "depends" : ["project", "caldav", "base_calendar"], + "init_xml" : ["project_caldav_data.xml"], + "demo_xml" : [], + "update_xml" : ["project_caldav_view.xml", + "project_caldav_wizard.xml"], + "active": False, + "website": "http://www.openerp.com", + "installable": True, } diff --git a/addons/project_caldav/project_caldav_view.xml b/addons/project_caldav/project_caldav_view.xml index d4fc7115491..541cc3c396e 100644 --- a/addons/project_caldav/project_caldav_view.xml +++ b/addons/project_caldav/project_caldav_view.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data> - + <record id="view_project_caldav_task_form" model="ir.ui.view"> <field name="name">project.task.caldav.form</field> <field name="model">project.task</field> @@ -46,8 +46,8 @@ </page> </notebook> </field> - </record> - + </record> + <record id="view_project_caldav_task_form1" model="ir.ui.view"> <field name="name">project.task.caldav.form1</field> <field name="model">project.task</field> @@ -58,8 +58,8 @@ <field name="class" /> </field> </field> - </record> - + </record> + <record id="view_project_caldav_task_form2" model="ir.ui.view"> <field name="name">project.task.caldav.form2</field> <field name="model">project.task</field> @@ -68,8 +68,10 @@ <field name="arch" type="xml"> <field name="progress" position="after"> <group colspan="2" col="3"> - <field name="rrule_type" string="Recurrency" +<!-- <field name="rrule_type" string="Recurrency" on_change="onchange_rrule_type(rrule_type)" colspan="1" /> +--> <field name="rrule_type" string="Recurrency" + colspan="1" /> <button string="Custom" name="101" icon="gtk-save-as" type="action" context="{'model' : 'project.task'}" @@ -78,7 +80,7 @@ </field> </field> </record> - + <record id="view_project_caldav_task_form3" model="ir.ui.view"> <field name="name">project.task.caldav.form3</field> <field name="model">project.task</field> @@ -94,6 +96,6 @@ </field> </field> </record> - + </data> </openerp> diff --git a/addons/project_retro_planning/project_retro_planning.py b/addons/project_retro_planning/project_retro_planning.py index 0f35ddb4338..60c8279f16f 100644 --- a/addons/project_retro_planning/project_retro_planning.py +++ b/addons/project_retro_planning/project_retro_planning.py @@ -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: diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index fbafdb4a60a..a6743b10330 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -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/>. # ############################################################################## from osv import fields, osv @@ -58,11 +58,12 @@ class project_work(osv.osv): res['general_account_id'] = a res['product_uom_id'] = emp.product_id.uom_id.id return res - + def create(self, cr, uid, vals, *args, **kwargs): - obj = self.pool.get('hr.analytic.timesheet') + obj_timesheet = self.pool.get('hr.analytic.timesheet') + task_obj = self.pool.get('project.task') vals_line = {} - obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) + obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] @@ -71,33 +72,36 @@ class project_work(osv.osv): vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id - res = obj.on_change_account_id(cr, uid, False, acc_id) + res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] - timeline_id = obj.create(cr, uid, vals_line, {}) - + amount = vals_line['unit_amount'] + prod_id = vals_line['product_id'] + unit = False + timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context']) + # Compute based on pricetype - amount_unit=obj.on_change_unit_amount(cr, uid, line_id, - vals_line['product_id'], vals_line['unit_amount'], unit, context) - - vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) - obj.write(cr, uid,[timeline_id], vals_line, {}) + amount_unit=obj_timesheet.on_change_unit_amount(cr, uid, timeline_id, + prod_id, amount, unit, context=kwargs['context']) + + vals_line['amount'] = (-1) * vals['hours']* (amount_unit['value']['amount'] or 0.0) + obj_timesheet.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs) def write(self, cr, uid, ids, vals, context=None): vals_line = {} - - task = self.pool.get('project.task.work').browse(cr, uid, ids)[0] + obj = self.pool.get('hr.analytic.timesheet') + timesheet_obj = self.pool.get('hr.analytic.timesheet') + task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! - list_avail_ids = self.pool.get('hr.analytic.timesheet').search(cr, uid, []) + list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: - obj = self.pool.get('hr.analytic.timesheet') if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: @@ -111,13 +115,13 @@ class project_work(osv.osv): vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] - # Compute based on pricetype - amount_unit=obj.on_change_unit_amount(cr, uid, line_id, - vals_line['product_id'], vals_line['unit_amount'], unit, context) - - vals_line['amount'] = (-1) * vals['hours'] * (amount_unit or 0.0) - obj.write(cr, uid, [line_id], vals_line, {}) + unit = False + amount_unit=obj.on_change_unit_amount(cr, uid, line_id, + vals_line['product_id'], vals_line['unit_amount'], unit, context=context) + + vals_line['amount'] = (-1) * vals['hours'] * (amount_unit['value']['amount'] or 0.0) + obj.write(cr, uid, [line_id], vals_line, context=context) return super(project_work,self).write(cr, uid, ids, vals, context) @@ -147,9 +151,9 @@ class task(osv.osv): if task_obj.work_ids: work_ids = [x.id for x in task_obj.work_ids] self.pool.get('project.task.work').unlink(cr, uid, work_ids, *args, **kwargs) - + return super(task,self).unlink(cr, uid, ids, *args, **kwargs) - + def write(self, cr, uid, ids,vals,context={}): if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): vals_line = {} |
