Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
Function field Save in database
In Openerp 7 Functional field added with store in Database
I used the below code:-
def _concat_attached_file(self, cr, uid, ids, name, arg, context=None):
res = {}
attachment_obj = self.pool.get('ir.attachment')
for id in ids:
procedure_attachment = attachment_obj.search(cr, uid, [('res_model', '=', 'model_name'), ('res_id', '=', id)], context=context)
filelist = []
for val in attachment_obj.browse(cr, uid, procedure_attachment):
filelist.append(val.name)
filevalue = ', '.join(filelist)
if not filevalue:
filevalue = None
res[id] = filelist
return res
'attached_file' : fields.function(_concat_attached_file, method=True, store=True, string='Attached File Name', type='char'),
But the above functional fields generate output only with Store=False. Suppose used Store=True output not generated. I want to store the db also how to fix ?Thanks
'store'=True will store the value of the field in database. Once stored then the functional fields function will not be executed again. if 'store'=False, then every time(any change in the record) the functional field will be executed
But if the value of 'store' is a dictionary then (key of the dictionary will be a model name and value will a tuple with list of ids, list of field name and 10-i dont know ) any change/update in the model specified as the key of the dictionary and change/ update is in the ids specified in the tuple and change or update is in the field names specified in the list then the function of the functional field will be loaded and new data will be saved in database
Hi Omal Bastin, Thanks for reply I have another doubt In openerp 7 i want to shows attached file shows in list view and store in DB. After attached the file [using default options Wizard Attachments Add] method the function not called. So write method overridden and called the function. But how to shows the attachment document after attached to call function automatically [without using write method override] Thanks
Hi, goto res.company model and check how the image is saved and showed in the ERP. There you can find a better example for what your are looking for
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 10/28/13, 10:11 AM |
Seen: 5410 times |
Last updated: 3/16/15, 8:10 AM |