İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Custom field widget not working, showing default widget instead.

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
fieldswidget
3274 Görünümler
Avatar
Pablo A

Odoo 14 instance.

I am working on a custom field widget to hold , preview, and ultimately transform the bitmap representation of the rendered qweb template in ir.ui.view model.
Nothing too fancy but i am unable to actually test and see how it works because it doesn't work at all, when i load my module and head to the form, instead of showing my custom widget it shows the upload widget for the image field. I want it to show my widget instead of the upload button.

This is what my model be looking like:

class View(models.Model):

"""

This class extends 'ir.ui.view' to add bitmap-related functionality to views.

"""


_inherit = "ir.ui.view"


enable_bitmap = fields.Boolean(string='Enable Bitmap Field', help="Enable or disable the bitmap functionality.")

bitmap_image = fields.Binary(string='Bitmap Image', attachment=True, widget="bitmap_canvas", help="Binary field to store the generated bitmap image.")

bitmap_width = fields.Float(string="Bitmap Width (mm)", help="Width of the generated bitmap in millimeters.")

bitmap_height = fields.Float(string="Bitmap Height (mm)", help="Height of the generated bitmap in millimeters.")

dpi = fields.Integer(string="DPI", default=300)

bitmap_enabled = fields.Boolean(compute='_compute_bitmap_enabled', store=False, help="Computed field to determine if bitmap functionality is enabled.")

html_raw_qweb = fields.Html(compute='_compute_html_raw_qweb', store=False, help="HTML content generated from Arch Base XML.")


def get_html_as_text(self):

"""

Retrieve HTML content from 'html_raw_qweb' field as text.


:return: HTML content as text.

:rtype: str

"""

self.ensure_one()

return self.html_raw_qweb


@api.depends('arch_base')

def _compute_html_raw_qweb(self):

"""

Compute 'html_raw_qweb' field based on 'arch_base' and 'enable_bitmap' values.


- If 'enable_bitmap' is True and 'arch_base' is provided, perform the action.

- Render HTML content from 'arch_base' XML.

- Update 'html_raw_qweb' field with the rendered HTML.

- Otherwise, set 'html_raw_qweb' to False.

"""

for view in self:

if view.arch_base and view.enable_bitmap:

view.html_raw_qweb = self.env['ir.ui.view']._render_template(view.arch_base, values={})

else:

view.html_raw_qweb = False


def store_bitmap(self, bitmap_data):

"""

Store the provided bitmap data in the 'bitmap_image' field.


:param bytes bitmap_data: Bitmap image data to store.

"""
 ## code to store the thingy

?xml version="1.0" encoding="utf-8"?>

odoo>

record model="ir.ui.view" id="ir_ui_view_xml_view_inherit">

field name="name">ir.ui.view.inherit

field name="model">ir.ui.view

field name="inherit_id" ref="base.view_view_form" />

field name="arch" type="xml">

xpath expr="//field[@name='active']" position="after">

field name="enable_bitmap" widget="boolean_toggle" />

field name="bitmap_image" attrs="{'invisible': [('enable_bitmap', '=', False)]}"

widget="bitmap_canvas" />

field name="bitmap_width" attrs="{'invisible': [('enable_bitmap', '=', False)]}" />

field name="bitmap_height" attrs="{'invisible': [('enable_bitmap', '=', False)]}" />

field name="dpi" attrs="{'invisible': [('enable_bitmap', '=', False)]}" />

/xpath>

/field>

/record>

/odoo>

(i intentionally broke the < at the start to display as raw text in this box)


If only i could load my custom xml and js for the widget i could test if this approach works but i'm unable too, anyone sees what could it be that causes my widget not to be shown? this is my first time writing a custom field widget.
Also if you see something that would not work on my functions i would appreciate the feedback, but i would really just need this to render my widget to start testing.

0
Avatar
Vazgeç
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
Owl - Fields Widget
fields widget owl
Avatar
0
Oca 23
2481
[Odoo 14 CE] x2many_counter widget for Many2many-fields
fields widget Many2many
Avatar
Avatar
2
Mar 21
5149
Field Type Multi_Selection possible?
fields tags widget
Avatar
0
Ağu 20
2777
Can we override default form controls?
javascript fields widget
Avatar
Avatar
Avatar
2
Mar 15
5047
[7.0] Field / widget : type = color ?
fields widget colors
Avatar
Avatar
2
Mar 15
10568
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now