Purnendu Singh (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-improve_binaryfield-vja into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-improve_binaryfield-vja/+merge/127709
Hello,
Remove _rec_name.
Update the ir_attachments form view and added a on_change method to update the
name field based on attached document.
Thanks,
Purnendu Singh
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-improve_binaryfield-vja/+merge/127709
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-improve_binaryfield-vja.
=== modified file 'document/document.py'
--- document/document.py 2012-10-02 10:29:15 +0000
+++ document/document.py 2012-10-03 10:38:23 +0000
@@ -36,7 +36,6 @@
class document_file(osv.osv):
_inherit = 'ir.attachment'
- _rec_name = 'datas_fname'
def _attach_parent_id(self, cr, uid, ids=None, context=None):
@@ -149,7 +148,14 @@
_sql_constraints = [
# filename_uniq is not possible in pure SQL
]
- def _check_duplication(self, cr, uid, vals, ids=None, op='create'):
+
+ def onchange_file(self, cr, uid, ids, datas_fname=False, context=None):
+ res = {'value':{}}
+ if datas_fname:
+ res['value'].update({'name': datas_fname})
+ return res
+
+ def _check_duplication(self, cr, uid, vals, ids=[], op='create'):
name = vals.get('name', False)
parent_id = vals.get('parent_id', False)
res_model = vals.get('res_model', False)
=== modified file 'document/document_view.xml'
--- document/document_view.xml 2012-08-13 16:06:57 +0000
+++ document/document_view.xml 2012-10-03 10:38:23 +0000
@@ -228,6 +228,9 @@
<field name="priority" eval="1"/>
<field name="inherit_id" ref="base.view_attachment_form"/>
<field name="arch" type="xml">
+ <xpath expr="//field[@name='datas_fname']" position="replace">
+ <field name="datas_fname" invisible="1" on_change="onchange_file(datas_fname)"/>
+ </xpath>
<field name="url" position="after">
<field name="user_id"/>
</field>
@@ -338,15 +341,6 @@
<field name="value" eval="'ir.actions.act_window,%d'%action_document_file_directory_form"/>
</record>
- <record model="ir.ui.view" id="view_attachment_form_inherit">
- <field name="name">ir.attachment.view.inherit</field>
- <field name="model">ir.attachment</field>
- <field name="inherit_id" ref="base.view_attachment_form"/>
- <field name="arch" type="xml">
- <field name="datas_fname" position = "replace" >
- </field>
- </field>
- </record>
<record model="ir.ui.view" id="view_process_node_form_inherit1">
<field name="name">process.node.form</field>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp