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

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
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

Custom Fields Value Disappear when perform action & Passing Custom Field Value to Account Invoice Line ?

Odebírat

Get notified when there's activity on this post

This question has been flagged
fieldscustomsale.order.lineaccount.invoice.lineodoo10
3 Odpovědi
7017 Zobrazení
Avatar
Vootipong Limpanitivat

Hi, Everyone

     i have been able to create a custom in sale order line there are two field 1.totalweight and priceperunit i use a help of @api.onchange so when ever the value that it depends on it will change automatically. below is my .py code

class customSaleField(models.Model):
 _inherit = 'sale.order.line'

 TotalWeight = fields.Float(string='Total Weight',readonly=True,store=True)
 PricePerUnit = fields.Float(string='Price Per Unit',readonly=True,store=True)

@api.onchange('product_uom_qty')
 def on_change_weight(self):
  weight = self.product_uom_qty * self.product_id.weight
  value = {
   'value' : {
    'TotalWeight' : weight
   }
  }
  return value
  
 @api.onchange('price_subtotal','TotalWeight')
 def on_change_PricePerUnit(self):

  try:
   PricePerUnit = self.price_subtotal / self.TotalWeight
  except ZeroDivisionError:
   PricePerUnit = 0
   
  value = {
   'value' : {
    'PricePerUnit' : PricePerUnit
   }
  }
  return value

however,when i press "confirm sale" or "save" or perform any action the value in custom fields are disappear

Secondly, how do i actually pass these values,field to account ?? after the user press click on "create invoice"


0
Avatar
Zrušit
Avatar
Jignesh Mehta
Nejlepší odpověď

Hello Vootipong Limpanitivat,


Try to remove readonly attribute from field.

May be because of readonly attribute, method is not affected. I faced many time in the past.


@api.onchange('product_uom_qty')
def on_change_weight(self):
    if self.product_uom_qty:
        self.TotalWeight = self.product_uom_qty * self.product_id.weight

@api.onchange('price_subtotal','TotalWeight')
def on_change_PricePerUnit(self):
    if self.price_subtotal:
        self.PricePerUnit = self.price_subtotal / self.TotalWeight


For Passing values to account, refer this method under sale module which is def create_invoices


Hope it will helps you.

Thanks,

0
Avatar
Zrušit
Vootipong Limpanitivat
Autor

Sir, it works !! it really works !

So i have to inherited and override those function ?

Jignesh Mehta

Yes. For passing values you need to override those function called as def create_invoices. If any sale order line id passes in the invoice line then you will pass it easily. Check that method and override it.

Vootipong Limpanitivat
Autor

hi , i have found the answer relate to this here is the link

https://www.odoo.com/forum/help-1/question/how-to-transfer-data-from-sale-order-to-invoice-when-clicking-on-create-invoice-85740

the answer were posted by Peter Alabaster

so i manage to change to odoo 10

the out come are like this

def _prepare_invoice(self):

res = super(customSaleField,self)._prepare_invoice(self)

if line.product_id:

if line.TotalWeight:

res['TotalWeight'] = line.TotalWeight

if line.PricePerUnit

res['PricePerUnit'] = line.PricePerUnit

return res

??

Vootipong Limpanitivat
Autor

i dont know am on the right way or not please she some light please

Avatar
Mohammed Amal N
Nejlepší odpověď

Hi,

I think store is used to store computed field to db.

If you need to save it from an onchange function try writing it from onchange

example

self.weight = self.product_uom_qty * self.product_id.weight


0
Avatar
Zrušit
Vootipong Limpanitivat
Autor

still not working

@api.onchange('product_uom_qty')

def on_change_weight(self):

self.TotalWeight = self.product_uom_qty * self.product_id.weight

weight= self.product_uom_qty * self.product_id.weight

value = {

'value' : {

'TotalWeight' : weight

}

}

return value

@api.onchange('price_subtotal','TotalWeight')

def on_change_PricePerUnit(self):

try:

self.PricePerUnit = self.price_subtotal / self.TotalWeight

PPU = self.price_subtotal / self.TotalWeight

except ZeroDivisionError:

self.PricePerUnit = 0

PPU = 0

value = {

'value' : {

'PricePerUnit' : PPU

}

}

return value

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
[Odoo 10]Passing Custom FIeld Value from Sale Order Line to Account Invoice Line Vyřešeno
fields sale.order.line account.invoice.line odoo10
Avatar
Avatar
3
zář 24
13386
[odoo10] how to remove unnecessary columns Vyřešeno
fields odoo10
Avatar
Avatar
2
zář 18
6792
Remove Calendar from Date field
fields odoo10
Avatar
Avatar
1
dub 18
4064
How to trigger "onclick" event while clicking on mobile/phone number in Odoo 10
fields odoo10
Avatar
0
led 18
4876
Odoo 10 use compute field with another field data
fields odoo10
Avatar
0
zář 17
3873
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 ภาษาไทย 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