Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3900 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 16
3163
3
ก.พ. 20
1300
0
ก.ย. 16
3599
Problem on Installing Odoo 9.0 แก้ไขแล้ว
1
พ.ค. 15
3992
1
ต.ค. 22
4213