İç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

field color depending on value...

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
viewsformwidgetWidgets
9274 Görünümler
Avatar
Fatih Piristine

I needed something like monetary field to show unit of value.  1kg 0.3IU etc. so far ok. this is done.

when I tried to add colors into foreground. I loose state and can't push color attributes in to field.

i only have style= but nothing else. code is below, any advice appreciated. thanks.

widgets.js

(function() {

var instance = openerp;
var _t = instance.web._t;


instance.web.form.FieldNutrient = instance.web.form.FieldFloat.extend({
template: "FieldNutrient",
widget_class: 'oe_form_field_float oe_form_field_nutrient',
init: function() {
this._super.apply(this, arguments);

_nutrient = {
'value': this.get_value(),
'unit': null,
'digits': [16, 2],
'position': 'after',
'range': 0.05,
'color_low': '#c02c2c',
'color_high': '#c02c2c',
'color_ok': '#078B01',
'color': 'color:#078B01'
};

if (this.options.unit) {
_nutrient.unit = this.options.unit;
}

if (this.options.position) {
_nutrient.position = this.options.position;
}

if (this.options.digits) {
if (this.options.digits.length === 1) {
this.digits = _nutrient.digits = [16, this.options.digits];
} else {
this.digits = _nutrient.digits = this.options.digits;
}
}

this.set({"nutrient": _nutrient});
this.on("change:nutrient", this, this.get_color);
this.get_color();
},
start: function() {
var tmp = this._super();
this.on("change:nutrient", this, this.reinitialize);
return tmp;
},
get_color: function() {
_nutrient = this.get('nutrient');

if (_nutrient.value < 0) {
this.color = _nutrient.color = ''.concat('color:', _nutrient.color_low);
} else {
this.color = _nutrient.color = ''.concat('color:', _nutrient.color_ok);
}

this.set({"nutrient": _nutrient});
},
,
render_value: function() {
var show_value = this.format_value(this.get('value'), '');
if (!this.get("effective_readonly")) {
this.$el.find('input').val(show_value);
} else {
if (this.password) {
show_value = new Array(show_value.length + 1).join('*');
}
var char_content = this.$(".oe_form_char_content").text(show_value);
if (this.color) {
var _nutrient = this.get('nutrient');
_nutrient.value = this.get('value');
this.set({'nutrient': _nutrient});
this.get_color();
char_content.parent().css('color', this.color);
}
}
},
parse_value: function(val, def) {
return instance.web.parse_value(val, {type: "float", digits: this.digits}, def);
},
format_value: function(val, def) {
return instance.web.format_value(val, {type: "float", digits: this.digits}, def);
}
});

instance.web.form.widgets = instance.web.form.widgets.extend({
'nutrient': 'instance.web.form.FieldNutrient'
});

})();


widgets.xml

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-name="FieldNutrient" t-extend="FieldChar">
<t t-jquery="t:first" t-operation="before">
<t t-if="widget.get('nutrient') and widget.get('nutrient').unit and widget.get('nutrient').position === 'before'">
<t t-esc="widget.get('nutrient').unit"/>
</t>
</t>
<t t-jquery="t:last" t-operation="after">
<t t-if="widget.get('nutrient') and widget.get('nutrient').position and widget.get('nutrient').position === 'after'">
<t t-esc="widget.get('nutrient').unit"/>
</t>
</t>
</t>

</templates>


form_view.xml where field is called. widget parameters coming from options, hard-coded.

definition of fields:

dry_matter: float

amount_ingr_dry: float, computed

diff_ingry_dry: float, computed

<tr>
<td><label for="dry_matter"/></td>
<td><field name="dry_matter" class="oe_text_right" readonly="1" widget='nutrient' options="{'unit': 'kg', 'digits': [16,2], 'position': 'after'}"/></td>
<td><field name="amount_ingr_dry" class="oe_text_right" widget='nutrient' options="{'unit': 'kg', 'digits': [16,2], 'position': 'after'}"/></td>
<td><field name="diff_ingr_dry" class="oe_text_right" widget='nutrient' options="{'unit': 'kg', 'digits': [16,2], 'position': 'after'}"/></td>
</tr>


any ideas?


edit: ok i got the colors and units as needed. but left unit optional for now. added new column next to it to make it more readable.     


next one. to refer need value in widget, compare it with diff to get the colors properly defined by range. green red orange blue etc etc.


1
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
Display model creation view of another model
views form
Avatar
Avatar
2
Şub 23
2735
Split View Odoo
views widget
Avatar
Avatar
1
Oca 19
6392
Resolve "handle" widget issue.
widget Widgets
Avatar
0
Nis 16
4606
Why is my custom form view not being read by Odoo?
views form
Avatar
Avatar
2
Eyl 15
6590
When inherit view original view also changed ?
views form
Avatar
Avatar
1
Mar 15
4709
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