diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-07-13 13:30:30 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-07-13 13:30:30 +0300 |
| commit | a7eaf3bfc955fee567f858f570a09eaadf38ee1b (patch) | |
| tree | ec18809abeb33350fa2ca222b9339a5f9e2bcd42 | |
| parent | 990cdf4c94b69e41b6ef5eaca5c5ed13d143d18d (diff) | |
Document: fix the context logic of content nodes
Content nodes should have meaningful context and perhaps an active id
'act_id', which will be used in the report or other generation fn().
The dctx mechanism of nodes was built for that, use it.
bzr revid: p_christ@hol.gr-20100713103030-irueg85zizlp42ju
| -rw-r--r-- | addons/document/directory_content.py | 15 | ||||
| -rw-r--r-- | addons/document/nodes.py | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/addons/document/directory_content.py b/addons/document/directory_content.py index cb2da17b8fc..218cd4f710b 100644 --- a/addons/document/directory_content.py +++ b/addons/document/directory_content.py @@ -90,12 +90,19 @@ class document_directory_content(osv.osv): tname = (content.prefix or '') + (content.suffix or '') + (content.extension or '') if tname.find('/'): tname=tname.replace('/', '_') + act_id = False + if 'dctx_res_id' in node.dctx: + act_id = node.dctx['dctx_res_id'] + elif hasattr(node, 'res_id'): + act_id = node.res_id + else: + act_id = node.context.context.get('res_id',False) if not nodename: - n = nodes.node_content(tname, node, node.context,content) + n = nodes.node_content(tname, node, node.context,content, act_id=act_id) res2.append( n) else: if nodename == tname: - n = nodes.node_content(tname, node, node.context,content) + n = nodes.node_content(tname, node, node.context,content, act_id=act_id) n.fill_fields(cr) res2.append(n) return res2 @@ -110,6 +117,8 @@ class document_directory_content(osv.osv): raise Exception("Invalid content: %s" % node.extension) report = self.pool.get('ir.actions.report.xml').browse(cr, uid, node.report_id) srv = netsvc.Service._services['report.'+report.report_name] - pdf,pdftype = srv.create(cr, uid, [node.context.context['res_id']], {}, {}) + ctx = node.context.context.copy() + ctx.update(node.dctx) + pdf,pdftype = srv.create(cr, uid, [node.act_id,], {}, context=ctx) return pdf document_directory_content() diff --git a/addons/document/nodes.py b/addons/document/nodes.py index 0def3995d91..58d830a169a 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -782,7 +782,7 @@ class node_res_obj(node_class): self.res_find_all = parent.res_find_all if res_bo: self.res_id = res_bo.id - dc2 = self.context.context + dc2 = self.context.context.copy() dc2.update(self.dctx) dc2['res_model'] = res_model dc2['res_id'] = res_bo.id |
