Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Custom field widget not working, showing default widget instead.

Odoberať

Get notified when there's activity on this post

This question has been flagged
fieldswidget
3259 Zobrazenia
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Owl - Fields Widget
fields widget owl
Avatar
0
jan 23
2473
[Odoo 14 CE] x2many_counter widget for Many2many-fields
fields widget Many2many
Avatar
Avatar
2
mar 21
5145
Field Type Multi_Selection possible?
fields tags widget
Avatar
0
aug 20
2771
Can we override default form controls?
javascript fields widget
Avatar
Avatar
Avatar
2
mar 15
5034
[7.0] Field / widget : type = color ?
fields widget colors
Avatar
Avatar
2
mar 15
10562
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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