Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3986 Lượt xem

please provide me simple example

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

in py 

import 

from openerp.tools import openerp,image_colorize, image_resize_image_big
then add a code in py 

photo = fields.Binary(string="Image to upload", default=lambda self:self._get_default_image())

   @api.model

  def _get_default_image(self, colorize=False):

   image = image_colorize(open(openerp.modules.get_module_resource('base','static/src/img', 'avatar.png')).read())

      return image_resize_image_big(image.encode('base64'))

in xml

<field name="photo" widget="image" />

if in case you need a any other image as default add png image in static/src/img and change the below py code

image = image_colorize(open(openerp.modules.get_module_resource('your_module','static/src/img', 'imagename.png')).read())

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 1 16
3234
3
thg 2 20
1300
0
thg 9 16
3697
1
thg 5 15
4077
1
thg 10 22
4328