From 990cdf4c94b69e41b6ef5eaca5c5ed13d143d18d Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 13 Jul 2010 13:30:24 +0300 Subject: Document: dynamic content file for static dirs. A dynamic content definition *can* be attached to a static directory, in which case the content should be generated based on the dctx dictionary of the dir. bzr revid: p_christ@hol.gr-20100713103024-l3nylpvx4ib6s4ii --- addons/document/directory_content.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/document/directory_content.py') diff --git a/addons/document/directory_content.py b/addons/document/directory_content.py index 2d434712f56..cb2da17b8fc 100644 --- a/addons/document/directory_content.py +++ b/addons/document/directory_content.py @@ -58,7 +58,9 @@ class document_directory_content(osv.osv): 'suffix': fields.char('Suffix', size=16), 'report_id': fields.many2one('ir.actions.report.xml', 'Report'), 'extension': fields.selection(_extension_get, 'Document Type', required=True, size=4), - 'include_name': fields.boolean('Include Record Name', help="Check this field if you want that the name of the file start by the record name."), + 'include_name': fields.boolean('Include Record Name', + help="Check this field if you want that the name of the file to contain the record name." \ + "\nIf set, the directory will have to be a resource one."), 'directory_id': fields.many2one('document.directory', 'Directory'), } _defaults = { -- cgit v1.2.3 From a7eaf3bfc955fee567f858f570a09eaadf38ee1b Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 13 Jul 2010 13:30:30 +0300 Subject: 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 --- addons/document/directory_content.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'addons/document/directory_content.py') 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() -- cgit v1.2.3 From 6eebca04d623827763cd328616d3cb133f151ce9 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 13 Jul 2010 13:30:53 +0300 Subject: Document API: node_content.open_data(), for FTP A crude way to get the data of a content node, using StringIO. bzr revid: p_christ@hol.gr-20100713103053-hklth9rugddm6ajl --- addons/document/directory_content.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/document/directory_content.py') diff --git a/addons/document/directory_content.py b/addons/document/directory_content.py index 218cd4f710b..bec4f25e45d 100644 --- a/addons/document/directory_content.py +++ b/addons/document/directory_content.py @@ -122,3 +122,5 @@ class document_directory_content(osv.osv): pdf,pdftype = srv.create(cr, uid, [node.act_id,], {}, context=ctx) return pdf document_directory_content() + +#eof \ No newline at end of file -- cgit v1.2.3