Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

field function and its store parameter in an inherited class

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
storeinheritance7.0function_fieldsuper
6 Antworten
8483 Ansichten
Avatar
Ludovic CHEVALIER

Hi!

I want to add a calculated field in Partner class.

To do this, I've made a module with the code below.

I made it first without trying to called parent function from super python method.

But I had this error:

NameError. name '_get_invoice_partner'  is not defined

And now I have called them with super method, I have this error:

TypeError: super(type, obj): obj must be an instance or subtype of type

Is someone could help me please?

from openerp.osv import osv

from openerp.osv import orm

from openerp.osv import fields


class Partner(osv.osv):

'''Partner'''

_inherit = 'res.partner'


def _get_invoice_partner(self, cr, uid, ids, context=None):

res = super(Partner, self)._get_invoice_partner(cr, uid, ids, context=context)

return res


def _get_partner_id(self, cr, uid, ids, context=None):

res = super(Partner, self)._get_partner_id(cr, uid, ids, context=context)

return res


def _get_last_mb_product(self, cr, uid, ids, name, args, context=None):

"""Return the last membership product buy by a user"""

name=name[0]

res ={}

member_line_obj = self.pool.get('membership.membership_line')

for partner in self.browse(cr, uid, ids, context=context):

partner_id = partner.id

line_id = member_line_obj.search(cr, uid, [

('partner', '=', partner_id),

('date_cancel', '=', False)

], limit=1, order='date_from', context=context)

if line_id:

res[partner.id] = {name: product_id}

product_id = member_line_obj.read(cr, uid, line_id[0], [name], context=context)[name][0]

return res

_columns = {

'membership_id': fields.function(

_get_last_mb_product, multi='membership_id',

string='Last membership product',

type='many2one',

obj='product.product',

store = {

'account.invoice': (_get_invoice_partner, ['state'], 10),

'membership.membership_line': (_get_partner_id, ['state'], 10, )

}, help="Last membership product"),

}

Partner()


0
Avatar
Verwerfen
Pawan

L'Heureux-Cyclage, Ludovic CHEVALIER,
Your code seems to be fine
One of the only reason seeming possible is because there is no '_get_invoice_partner' function in the main/super res.partner object, thats why it is showing error while executing that line.
Try keeping a print statement in "_get_invoice_partner" function, before calling super of it, if it executes that print statement then simply remove the super call and it should work
Hope it helps!

Ludovic CHEVALIER
Autor

Hi Pawan! Thanks for your answer. "_get_invoice_partner" function existing in Partner class in pos_membership module. I put a print statement in pos_membership "_get_invoice_partner" function and in custom module. The one of pos_membership is called before the one of custom module. If I remove the super call in my custom module, I can't define a value to res and I have this logical error: NameError: global name 'res' is not defined And if I remove the return of res variable, I have this other logical error: TypeError: 'NoneType' object is not iterable :-(

Julio Serna

you can try to use another methods that no exist in core odoo, for example you can use _get_partner_id_custom and _get_invoice_partner_custom and call inside new methods custom the original methods and after modify "res"

Avatar
Ludovic CHEVALIER
Autor Beste Antwort

Here is a code that works: http://git.heureux-cyclage.org/?p=burette/etudesetchantiersidf.git;a=blob;f=etudesetchantiersidf.py;h=4b5774ebd0d505c18dca5747449a8ad0745f7774;hb=ab989882154710b12c9ed2ed2ee74060974cd1cd

self did not return courant object (res.partner) but, 'account.invoice', 'pos.order' or 'membership.membership_line' depending which store field it is.

0
Avatar
Verwerfen
Avatar
Krupesh Laiya
Beste Antwort

Had you put membership module in depends (__openerp__.py)?

if you have membership module in depends then override the method don't use super.

0
Avatar
Verwerfen
Ludovic CHEVALIER
Autor

Thanks for the answer! Here is my dependance tree for my module (">" == "depend from"): - custom module > bikecoop_l10n_fr > pos_membership > remembership > membership I thought it was ok with this configuration to override all of thoses dependances. I've added explicitly those dependances to my custom module: - membership, remembership, pos_membership If I remove "_get_invoice_partner" and "_get_partner_id" in my custom module, when I launch OpenERP, I have this strange error message: 2015-12-29 08:38:10,542 12528 CRITICAL custom_module openerp.modules.module: Couldn't load module web 2015-12-29 08:38:10,542 12528 CRITICAL custom_module openerp.modules.module: name '_get_invoice_partner' is not defined ??? If I add those two function, I have this message error again: TypeError: super(type, obj): obj must be an instance or subtype of type Any idea?

Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
Python "super" - function does not work Gelöst
python inheritance super
Avatar
Avatar
Avatar
2
Dez. 22
13660
Add/Override parent compute method (event.booth) Odoo15 Gelöst
inheritance super v15
Avatar
Avatar
1
Dez. 22
5051
[7.0] Group by functional field (stored in db)
7.0 group_by function_field
Avatar
Avatar
1
März 15
4380
Calling super of super (grandparent class)
inheritance class super 12.0
Avatar
Avatar
Avatar
2
Juni 21
6811
Why does this inherited write function goes of twice? Gelöst
inheritance write super odoo9
Avatar
Avatar
7
Nov. 23
9757
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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