Ir al contenido
Odoo Menú
  • Inicia sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de propiedades
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

function.field store help

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
storeerrrorfields.functionarguments
3 Respuestas
7023 Vistas
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
Descartar
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)
Mejor respuesta

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
Descartar
Avatar
Erhuvwu Akpobaro
Autor Mejor respuesta

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
Descartar
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 ?

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
To change the function field to editable?
python store fields.function odooV8
Avatar
Avatar
Avatar
3
mar 18
11287
Why in functions called by fields.function(called_function,...) the field uid is always 1?
store v7 fields.function uid
Avatar
Avatar
1
mar 15
6097
jsonb_path_query_array error Resuelto
errror
Avatar
Avatar
1
jun 24
5215
Expected singleton Error
errror
Avatar
Avatar
Avatar
5
dic 19
8133
[object with reference: name - name] v10
errror
Avatar
Avatar
2
abr 17
8356
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

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