Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Odoo 10 copy one2many line on client side

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
webclientlistviewbuttonsodoo10
4307 Weergaven
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
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How to change the position of setup button from by default left to right side inside the column ?
treeview listview buttons
Avatar
0
dec. 23
2260
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 Opgelost
filter listview odoo10
Avatar
Avatar
6
aug. 18
11678
Please Help me, I cant any action on 'Validate' button?
buttons js odoo10
Avatar
0
apr. 18
4331
One2many list view Buttons
listview buttons one2many_list
Avatar
0
jan. 18
4976
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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