Adds support for document fields to Odoo. The fields can be used like any other Odoo fields.
The field arguments filename
and directory
can be a function or
a value. The filename
parameter has to be a string and the directory
an integer representing the id of the directory.
from odoo.addons.muk_dms_field.fields.dms_binary import DocumentBinary
from odoo.addons.muk_dms_field.fields.dms_many2one import DocumentMany2one
class Model(models.Model):
def _get_file_name(self):
return self.content_fname or "NewFile"
def _get_file_directory(self):
return self.env.ref("muk_dms.directory_01_demo").id
content_fname = fields.Char(
string="Filename")
content = DocumentBinary(
string="Data",
filename=_get_file_name,
directory=_get_file_directory)
file = DocumentMany2one(
comodel_name='muk_dms.file')