Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
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

Odoo 10 copy one2many line on client side

Suscribirse

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

Se marcó esta pregunta
webclientlistviewbuttonsodoo10
4301 Vistas
Avatar
Nick Booker

I'm trying to allow a user to duplicate a line on a one2many (sales order line to be precise) on the client side.  The customer expressly doesn't want to have to save the sales order in order to do this.

I've tried to add a copy button to the right hand side of ListView:

    <t t-extend="ListView.row">
<t t-jquery=".o_list_record_delete" t-operation="after">
<td t-if="options.deletable">
<button type="button" aria-hidden="true"
class="o_icon_button o_kf_so_line_copy_button">
<i class="fa fa-copy"/>
</button>
<!-- <a class="o_kf_so_line_copy_button"><i class="fa fa-copy"/></a> -->
</td>
</t>
</t>
<t t-extend="ListView">
<!-- TODO little quirk is that striping doesn't carry into copy column. Fix this at end if time and solution otherwise works. -->
<t t-jquery='t[t-set="columns_count"]' t-operation="after">
<t t-set="columns_count" value="columns_count + (options.deletable ? 1 : 0)"/>
</t>
<t t-jquery=".o_list_record_delete" t-operation="after">
<td t-if="options.deletable" class="o_kf_so_line_copy"/>
</t>
</t>

Note a couple of attempts one using <button> and another using <a>.

Here is my javascript where I try to set up a click handler:

odoo.define('acme_flobbits_management.SOLineCopyWidgets', function (require) {
"use strict";


var core = require('web.core');
var Widget = require('web.Widget');
var utils = require('web.utils');
var ListView = require('web.ListView');
var SOLineCopyDialog = require('acme_flobbits_management.SOLineCopyDialog');
ListView.include({
reload_content: function() {
var self = this;
var reloaded = this._super();
reloaded.then(function() {
var $elements = self.$el.find('.o_kf_so_line_copy_button');
// Finding the elements OK
$elements.click(function(e) {
// But this click handler's getting ignored when it's a "span"
// Declaring as button lets it work, but then Odoo ListView gets its knickers in a twist
// list_view.js 996 will give clues for this and for how to get at the data we need!
e.preventDefault();
e.stopPropagation();
SOLineCopyDialog.createSOLineCopyDialog(self);
});
});
return reloaded;
}
});
});


Using the <button> tag, Odoo throws a wobbly on load because the javascript is looking for any button tags nested inside the td and making its own click handler that requires a 'field' data attribute, but my button doesn't bind to a field so I don't think that makes sense.

Using the <a> tag, Odoo happily lets me do it, but the click is ignored and passed through to the row, so the Sale Order Line form is popped up as if I'd clicked elsewhere on the row instead of running the javascript I've tried to connect to the <a> tag's click event.

Looking in the Firefox debugger, there is indeed no little [ev] marker next to my <a> tag in the inspector.

Q1: Firstly, am I approaching this the right way overall (by extending ListView)?  Or is there some standard way to add a column of buttons to a specific field's one2many table, only in Edit mode, and perform some client-side-only action in response to it while keeping knowledge of the record being copied and allowing the one2many view to be updated after adding what I assume will be a new (0, False, {fields}) thing to Javascript's copy of the field.

Q2: Secondly, if I am approaching this the right way, how do I:

  a) get my click handler to be registered and triggered?

  b) find out in my extended ListView whether a particular attribute of the tree in my view arch XML, e.g. <tree kf_copyable_so_line="1"/>, has been set?


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

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
How to change the position of setup button from by default left to right side inside the column ?
treeview listview buttons
Avatar
0
dic 23
2258
Can one change the form view that is displayed on a NOT editable list?
listview formview odoo10
Avatar
0
nov 19
4392
How to filter list view by related field Resuelto
filter listview odoo10
Avatar
Avatar
6
ago 18
11676
Please Help me, I cant any action on 'Validate' button?
buttons js odoo10
Avatar
0
abr 18
4330
One2many list view Buttons
listview buttons one2many_list
Avatar
0
ene 18
4972
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 ภาษาไทย 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 totalmente integrado.

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