コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3889 ビュー

please provide me simple example

アバター
破棄
最善の回答

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())

アバター
破棄
関連投稿 返信 ビュー 活動
0
1月 16
3159
3
2月 20
1300
0
9月 16
3596
1
5月 15
3981
1
10月 22
4210