2015-11-23 47 views
1

資產模塊我們有'asset.asset'字段那裏我有'image_medium'。所以我想把它做得更大。以下我已經做了這個領域更大的128px * 128px但是在保存了它的模糊之後,我的意思是我想讓它在更高的像素上。如何讓圖像場更大?

enter image description here

回答

0

與此

<field name="image" widget="image" class="oe_right oe_image_custom" style="width: 265px; height: 300px;"/> 
+0

k我應該在.py字段文件中添加 –

+0

image = fields。? –

+0

使用fields.binary – user00000341

0

嘗試這是示例圖像小型,中型和標誌型的

_columns = { 
    'brand_id': fields.many2one('model.name', 'Make', required=True), 
    'image': fields.related('brand_id', 'image', type="binary", string="Logo"), 
    'image_medium': fields.related('brand_id', 'image_medium', type="binary", string="Logo (medium)"), 
    'image_small': fields.related('brand_id', 'image_small', type="binary", string="Logo (small)"), 
} 

以及新的API,你可以做下面的代碼:

# image: all image fields are base64 encoded and PIL-supported 
image = openerp.fields.Binary("Photo", attachment=True, 
    help="This field holds the image used as photo for the employee, limited to 1024x1024px.") 
image_medium = openerp.fields.Binary("Medium-sized photo", 
    compute='_compute_images', inverse='_inverse_image_medium', store=True, attachment=True, 
    help="Medium-sized photo of the employee. It is automatically "\ 
     "resized as a 128x128px image, with aspect ratio preserved. "\ 
     "Use this field in form views or some kanban views.") 
image_small = openerp.fields.Binary("Small-sized photo", 
    compute='_compute_images', inverse='_inverse_image_small', store=True, attachment=True, 
    help="Small-sized photo of the employee. It is automatically "\ 
     "resized as a 64x64px image, with aspect ratio preserved. "\ 
     "Use this field anywhere a small image is required.") 

@api.depends('image') 
def _compute_images(self): 
    for rec in self: 
     rec.image_medium = tools.image_resize_image_medium(rec.image) 
     rec.image_small = tools.image_resize_image_small(rec.image) 

def _inverse_image_medium(self): 
    for rec in self: 
     rec.image = tools.image_resize_image_big(rec.image_medium) 

def _inverse_image_small(self): 
    for rec in self: 
     rec.image = tools.image_resize_image_big(rec.image_small) 

def _get_default_image(self, cr, uid, context=None): 
    image_path = get_module_resource('hr', 'static/src/img', 'default_image.png') 
    return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64')) 
1

在xml視圖中將字段名稱'image_medium'更改爲image
刪除類oe_avatar並添加height="300" width="300",它應該工作。

+0

是的,做完了,謝謝你 –