Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

function.field store help

Odebírat

Get notified when there's activity on this post

This question has been flagged
storeerrrorfields.functionarguments
3 Odpovědi
7033 Zobrazení
Avatar
Erhuvwu Akpobaro

Hey guys ,


I have field.function that shows the right value i want however when i try to display this value in the point of sake(through my own customization) nothing shows , i believe this is because my field.function is not stored :


class cm_product_template(osv.osv):

     _name = 'product.template'

     _inherit = "product.template"


    def _get_invoice_company(self, cr, uid, ids, field, parameter, context=None):

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

           context = context or {}

           invoice = {}

           #period_obj3 = self.pool.get('product.template')

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

               prod_temp_id = auto1.id

               print prod_temp_id

               # cr.execute("SELECT id FROM pp_feature WHERE plan = %d" %(featurename) )

               cr.execute("""SELECT f.name FROM product_template pt INNER JOIN product_product pp on pp.product_tmpl_id = pt.id INNER JOIN account_analytic_invoice_line aal on aal.product_id = pp.id INNER JOIN account_analytic_account aaa on aaa.id = aal.analytic_account_id INNER JOIN res_company f on f.id = aaa.invcompany_id WHERE pp.product_tmpl_id = %s""", % (prod_temp_id,) )

               # res = cr.fetchall()

               res = cr.fetchone()

               print res

               invoice.update({prod_temp_id : res and res[0] or False })

    return invoice


    _columns = {

        'cm_property_ids': fields.one2many('cm.property', 'product_template_id', 'Products') ,

        'invoice_company':fields.function(_get_invoice_company , type='integer' , store=True, method=True ,string='Invoice Company')

        }


# example od function you can use in defaults
    def _get_default_invoice_company(self, cr, uid, context=None):

        context = context or {}

        # do your treatment here

        company_id = False

        return company_id


     _defaults = {

        'invoice_company': _get_default_invoice_company ,

        }

When i add store=True i get this error :  

File "/opt/odoo/odoo/openerp/models.py", line 2399, in _set_default_value_on_column

default = default(self, cr, SUPERUSER_ID, context)

TypeError: _get_invoice_company() takes at least 6 arguments (4 given)


I am confused why i cant store the function value field in the database  any ideas to get passed this ?


1
Avatar
Zrušit
Erhuvwu Akpobaro
Autor

Hi , the field invoice company is a a new inherited field on the produced template page , I want this field to automatically show a value on on already creates products and new products . thanks for the help on removing the default field however I get this error now : Value Error : expected singleton prod_temp_Id = auto.id Is the function trying to store multiple values ?

Cyril Gaspard (GEM)

I modify your code, but you will have again an error because your request finish with : INNER JOIN accoun$ ????

Erhuvwu Akpobaro
Autor

My aplogies the right sql query is : cr.execute("SELECT f.name FROM product_template pt INNER JOIN product_product pp on pp.product_tmpl_id = pt.id INNER JOIN account_analytic_invoice_line aal on aal.product_id = pp.id inner join account_analytic_account aaa on aaa.id = aal.analytic_account_id inner join res_company f on f.id = aaa.invcompany_id WHERE pp.product_tmpl_id = %d" %(prod_temp_id) )

Cyril Gaspard (GEM)

I update your function, should work, for use of a function in _defaults, I gave you an example of function to call, see function _get_default_invoice_company which is the only prototype of function you can use in this case (in body function, you can't use ids), bye

Avatar
Cyril Gaspard (GEM)
Nejlepší odpověď

remove :

_defaults = {

'invoice_company':_get_invoice_company ,

}

what do you want to do exactly with your field invoice_company, your code is very strange ...

1
Avatar
Zrušit
Avatar
Erhuvwu Akpobaro
Autor Nejlepší odpověď

Hi , the field invoice company is a a new inherited field on the produced template page , I want this field to automatically show a value on on already creates products and new products . thanks for the help on removing the default field however I get this error now : Value Error : expected singleton prod_temp_Id = auto.id 

Is the function trying to store multiple values ?

1
Avatar
Zrušit
Cyril Gaspard (GEM)

I upvote for you, you have now enough karma to upvote, edit previous post ..., bye

Erhuvwu Akpobaro
Autor

Do you how to edit the point of sale module/interface ?

Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
To change the function field to editable?
python store fields.function odooV8
Avatar
Avatar
Avatar
3
bře 18
11288
Why in functions called by fields.function(called_function,...) the field uid is always 1?
store v7 fields.function uid
Avatar
Avatar
1
bře 15
6097
jsonb_path_query_array error Vyřešeno
errror
Avatar
Avatar
1
čvn 24
5228
Expected singleton Error
errror
Avatar
Avatar
Avatar
5
pro 19
8133
[object with reference: name - name] v10
errror
Avatar
Avatar
2
dub 17
8356
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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