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
    • Sociale 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

Odoo11 - onChange - Update copy/duplicate field to other model.

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
many2manycopyduplicateonchange_eventodoo11
1 Beantwoorden
8846 Weergaven
Avatar
Gabriel
Hello everyone,
 I have two models product_template  and sale_order_line.
In the product_template template I have some fields that are characteristic
of this product this field calls product characteristic

class productCharacteristcs (models.Model):
   _inherit = 'product.template'
   caractheristic_product = fields.Many2many (comodel_name = 'caracteristic.product.')
In my model sale_order_line there is this same field, but now it is 
related to another table, which may or may not be different for each sale. 
​
saleProductCharacteristcs (models.Model):
   _inherit = 'sale.order.line
   sale_caractheristic_product = fields.Many2many (comodel_name = 'sale.caracteristic.product.')

I would like the event onchange to automatically populate sale.order.line but 
based on the product information and change as i like

I found information like this: self.update ({ 'attendance_line': [(0, 0, {values})], }) But I tried here and unfortunately it was unsuccessful


0
Avatar
Annuleer
Avatar
Waleed Ali Mohsen
Beste antwoord

Hi, if I understand you correctly, you can try the below:

You already in sale.order.line model and you want to use onchange for sale_caractheristic_product field to populate sale line data

So you can use the below:

@api.onchange('sale_caractheristic_product ')
def _onchange_sale_caractheristic_product (self):
//Do you check here to retrieve the required data //Set values to sale line  
self.product_id = 
self.product_uom_qty =
..
etc
0
Avatar
Annuleer
Gabriel
Auteur

Hi, unffortily wont work.

What i want to do is, grab product caracteristics and use it on sale_product_caracteristc,.

If i change sale_product_caracterist i wont it change on product_caracteristcs.

Waleed Ali Mohsen

You will use something like that:

self.update({'move_line_ids': [(0, 0, {

'product_id': self.product1.id,

'product_uom_id': self.uom_unit.id,

'qty_done': 2,

'product_uom_qty': 0,

'lot_id': False,

'package_id': False,

'result_package_id': False,

'location_id': move1.location_id.id,

'location_dest_id': move1.location_dest_id.id,

})]})

Gabriel
Auteur

Hi, that was perfect.. but i need one last help :/

I'm trying insert multiples lines, when i use a for, like

for x in move_line_ids:

It will just show the last line, the cursor pass over the first,secound, etc, but only show the last one.

Some Tip?

Waleed Ali Mohsen

Yes, it will show only the last one so you have to have a loop and append all line into list and then assigned it to your ids in update method as below:

You can do something like this:

update = []

for record in data.order_line:

update.append((0, 0, {

'product_id': record.product_id.id,

'product_uom': record.product_uom.id,

'order_id': record.order_id.id,

'name': record.name,

'product_qty': record.product_uom_qty,

'price_unit': record.price_unit,

'taxes_id': False,

'product_subtotal': record.price_subtotal,

'analytic_account_id': record.order_id.analytic_account_id.id,

}))

self.update({'new_order_line_ids': update})

Gabriel
Auteur

Last 2 question i promisse...

If a field, integer, its not show in the many2many table widget, it wont be update corret? even if i got:

update.append((0, 0, {

'product_id': record.product_id.id, -- Show field in the table

'numeric_field': record.product_id.numeric_field.id, -- Not show field in the widget table

}))

If inside the order_line_id i got a field many2one i wont be able to update that to?

update.append((0, 0, {

'product_id': record.product_id.id,

'attributes': record.product_id.ids, -- this field is many2many

}))

Even if this case i use something like

'attributes': ((0,0{'id':1})),

I promisse i will compile every information and make a anser in the end :P

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
Add column to a many2many rel table Opgelost
many2many odoo11
Avatar
Avatar
1
nov. 19
6080
Why my custom copy button functionality is not working?
copy duplicate
Avatar
0
apr. 15
4304
how to format mapped() result Opgelost
many2many mapping odoo11
Avatar
Avatar
2
jun. 20
12474
Problem with M2M Fields Opgelost
many2many problem odoo11
Avatar
Avatar
Avatar
2
nov. 18
7049
Copying Many2many field values to another Many2many field
fields many2many copy
Avatar
0
mei 16
6854
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