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

How to get count of projects per partner?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
projectpythonmoduleaccountapirelationships
2 Cevaplar
9712 Görünümler
Avatar
Jairo Llopis

I have this code in my module:

from openerp import api, fields, models


class Partner(models.Model):
    _name = _inherit = "res.partner"

    @api.one
    @api.depends("project_ids")
    def _project_count(self):
        self.project_count = len(self.project_ids)

    project_count = fields.Integer(compute="_project_count")
    project_ids = fields.One2many("project.project", "partner_id")

But it yields this exception:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/openerp/http.py", line 496, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/local/lib/python2.7/dist-packages/openerp/http.py", line 513, in dispatch
    result = self._call_function(**self.params)
  File "/usr/local/lib/python2.7/dist-packages/openerp/http.py", line 279, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/http.py", line 276, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/local/lib/python2.7/dist-packages/openerp/http.py", line 723, in __call__
    return self.method(*args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/openerp/http.py", line 372, in response_wrap
    response = f(*args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 941, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 924, in _call_kw
    records = getattr(request.session.model(model), method)(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/http.py", line 825, in proxy
    result = meth(cr, request.uid, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/openerp/api.py", line 234, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/models.py", line 3085, in read
    result = BaseModel.read(records, fields, load=load)
  File "/usr/local/lib/python2.7/dist-packages/openerp/api.py", line 232, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/models.py", line 3128, in read
    values[name] = field.convert_to_read(record[name], use_name_get)
  File "/usr/local/lib/python2.7/dist-packages/openerp/models.py", line 5411, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/usr/local/lib/python2.7/dist-packages/openerp/fields.py", line 707, in __get__
    self.determine_value(record)
  File "/usr/local/lib/python2.7/dist-packages/openerp/fields.py", line 807, in determine_value
    self.compute_value(recs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/fields.py", line 767, in compute_value
    self._compute_value(records)
  File "/usr/local/lib/python2.7/dist-packages/openerp/fields.py", line 759, in _compute_value
    self.compute(records)
  File "/usr/local/lib/python2.7/dist-packages/openerp/api.py", line 232, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/api.py", line 392, in new_api
    result = [method(rec, *args, **kwargs) for rec in self]
  File "/opt/odoo/extra-addons/grupoesoc/partner_projects/partner_projects.py", line 28, in _project_count
    self.project_count = len(self.project_ids)
  File "/usr/local/lib/python2.7/dist-packages/openerp/fields.py", line 707, in __get__
    self.determine_value(record)
  File "/usr/local/lib/python2.7/dist-packages/openerp/fields.py", line 798, in determine_value
    record._prefetch_field(self)
  File "/usr/local/lib/python2.7/dist-packages/openerp/api.py", line 232, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/models.py", line 3167, in _prefetch_field
    result = records.read(list(fnames), load='_classic_write')
  File "/usr/local/lib/python2.7/dist-packages/openerp/api.py", line 232, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/models.py", line 3117, in read
    self._read_from_database(stored)
  File "/usr/local/lib/python2.7/dist-packages/openerp/api.py", line 232, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/models.py", line 3276, in _read_from_database
    res2 = self._columns[f].get(cr, self._model, ids, f, user, context=context, values=result)
  File "/usr/local/lib/python2.7/dist-packages/openerp/osv/fields.py", line 689, in get
    }, (tuple(record_ids),))
  File "/usr/local/lib/python2.7/dist-packages/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
ProgrammingError: column "partner_id" does not exist
LINE 1: SELECT id, partner_id                        FROM project_pr...
                   ^

Seems like I cannot relate it directly to project.project because the field partner_id comes from account.analytic.account, but then how can I get the relationship between res.partner and project.project?

0
Avatar
Vazgeç
Avatar
Jairo Llopis
Üretici En İyi Yanıt

The answer is to use a relationship with "account.analytic.account" and filter from there:

from openerp import api, fields, models


class Partner(models.Model):
    _name = _inherit = "res.partner"

    @api.one
    @api.depends("contract_ids")
    def _project_count(self):
        self.project_count = len(self.env["project.project"].search(
            [("analytic_account_id",
              "in",
              [c.id for c in self.contract_ids])]))

    project_count = fields.Integer(compute="_project_count")
1
Avatar
Vazgeç
Avatar
Ludo - 21South
En İyi Yanıt

Project by itself is an analytic account. Looking at the source code, it tells me the following:

    _inherits = {'account.analytic.account': "analytic_account_id",

                 "mail.alias": "alias_id"}

This means that on the project there should be an analytic_account_id field, pointing to the related analytic account. You could use that. Depending on your business needs, it could be a related field or perhaps a one2many field using using related fields to view project names.

1
Avatar
Vazgeç
Jairo Llopis
Üretici

Thanks. The problem is that not all analytic accounts are projects, but I will search from there.

Ludo - 21South

If I recall correctly, the analytic account has a field "type" which indicates what type of account it is. Project should be an option there.

Jairo Llopis
Üretici

It's true, but that field does not say if it is a project or not. I already found the solution, thanks.

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
External Python code calling (xml-rpc maybe?) Openerp Fields to work with
python module sale account
Avatar
Avatar
1
Mar 15
5790
Error when passing information through API Çözüldü
python api
Avatar
Avatar
1
Eyl 23
3173
Search a production order that is planned for today on python with an api
python api
Avatar
Avatar
3
Nis 19
3802
Java module to Odoo module conversion....
project python
Avatar
Avatar
Avatar
2
Kas 15
5497
Error In Open Erp when create new module
python module
Avatar
0
Mar 15
4703
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