Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Custom Field "Service Fee %" in Sales Order Line

Subscriure's

Get notified when there's activity on this post

This question has been flagged
sale.order.linestudio18.0automation-rules
4 Respostes
1598 Vistes
Avatar
Zulfikri

Hi,

i need custom that named "Service Fee %" in sales order line like image below,


i noticed the service fee that i input didn't automatically change the total amount(field : subtotal) of in sales order line, i think i need an automation rule so the total amount change when i input the service fee. So, i did like this

BUT, when i make new sales order and input the quantity, price, etc and save it. Seem like an error appear and my Odoo frezeed. Any solution of this or the best approach for this case? 

0
Avatar
Descartar
Avatar
D Enterprise
Best Answer

Hii,

Solution (No Code, No Studio)

1. Stop updating price_subtotal — it's a computed field.

2. Do this instead:

  • Create a new float field: x_service_fee_percent on sale.order.line
  • Create a new monetary field: x_adjusted_subtotal on sale.order.line (linked to currency_id)
  • Automation Rule (Safe Calculation)
  • Go to Settings → Technical → Automation → Automated Actions → Create:
    • Model: Sale Order Line
    • Trigger: On Creation & Update
    • Trigger Fields: x_service_fee_percent, price_unit, product_uom_qty, discount
    • Action To Do: Update the Record
  • Field to update:
  • x_adjusted_subtotal → Use this expression:

add this code in automation rule:

((record.price_unit * record.product_uom_qty) * (1 - (record.discount or 0)/100.0)) * (1 + (record.x_service_fee_percent or 0)/100.0)
i hope it is usefull

1
Avatar
Descartar
Zulfikri
Autor

Hi, Thank you so much that work really well, but i still have an issue. Please check my new reply, i hope u can help

Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello @Zulfikri,

 

Add the Action named 'Execute Python code' in Your Automated Action as shown in below image.

 



After that add below Python code in your automated action.

 

# Step-by-step safe evaluation of subtotal with service fee

 

# Step 1: Get quantity

qty = record.product_uom_qty or 0.0

 

# Step 2: Get unit price

price = record.price_unit or 0.0

 

# Step 3: Get service fee (as percentage, e.g. 0.10 = 10%)

fee = record.x_studio_service_fee or 0.0

 

# Step 4: Compute multiplier

multiplier = 1.0 + fee

 

# Step 5: Calculate total with service fee

total_with_fee = qty * price * multiplier

 

# Step 6: Store in custom field

record.write({'x_studio_service_fee' : total_with_fee})

 

If you have any questions or need further assistance, feel free to reach out.


Thanks & Regards,

Email:  odoo@aktivsoftware.com           

Skype: kalpeshmaheshwari

0
Avatar
Descartar
Zulfikri
Autor

Hi, thank you so much, i have tried something like that, seems like it only make an change visually, am i right?. I still cant change the total on the bottom of the order line, invoice, and for the journal item as well

Avatar
Zulfikri
Autor Best Answer

Hi Desk Enterprise,

Thank you so much that work really well, but i still have an issue. How to change the "Total" (which I marked with a red box) below the sales order line so it can updated based on "Total Amount" that we already customized?


0
Avatar
Descartar
D Enterprise

Override price_subtotal (Recommended for direct integration)
Instead of using x_adjusted_subtotal, override the standard field price_subtotal with your formula.
Update your Automation Rule:
Model: Sale Order Line

Trigger: On Update & Create

Trigger Fields: x_service_fee_percent, price_unit, discount, product_uom_qty

Action: Update the Record

Update Field: price_subtotal

Value:
((record.price_unit * record.product_uom_qty) * (1 - (record.discount or 0)/100.0)) * (1 + (record.x_service_fee_percent or 0)/100.0)
i hope this is solve the error

Avatar
Piyush H
Best Answer

Dear Zulfikri,

here's how to implement this entirely through the Odoo interface:

Method 1: Using Studio (Recommended)
  1. Install Studio
    • Go to Settings → Apps → Search for "Studio" → Install
  2. Add the Service Fee % Field
    • Open any Sales Order
    • Click the "Edit Form" button (pencil icon) in top-right
    • Click "+" to add a new field
    • Field Name: x_service_fee_percent
    • Field Label: "Service Fee %"
    • Field Type: Float
    • Widget: Percentage (or Monetary if you prefer currency format)
    • Save the field
  3. Create an Automated Action
    • Go to Settings → Technical → Automation → Automated Actions
    • Create a new record:
      • Name: "Update Subtotal with Service Fee"
      • Model: Sales Order Line
      • Trigger: On Update
      • Apply On: [Your specific domain if needed, or leave blank]
    • In "Actions To Do" tab:
      • Add Action → Execute Python Code
      • Paste this (simplified version that won't cause recursion):

python

for line in records:
    price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
    fees = line.x_service_fee_percent or 0.0
    line.price_subtotal = price * line.product_uom_qty * (1 + fees / 100.0)
Method 2: Using Only Standard Features

If you can't use Studio, try this workaround:

  1. Create a Discount Field Workaround
    • Go to Settings → Technical → Database Structure → Fields
    • Create a new field:
      • Model: sale.order.line
      • Field Name: x_service_fee_percent
      • Field Type: Float
      • Label: "Service Fee %"
  2. Modify the Sales Order Line View
    • Go to Settings → Technical → User Interface → Views
    • Find the sale.order.line form view
    • Click "Edit" and add your field after price_unit
  3. Use a Computed Field (Still no-code)
    • In the same Fields section, edit your x_service_fee_percent field
    • Check "Computed"
    • For the compute method, use:
      python
      def _compute_service_fee(self):
          for line in self:
              line.x_service_fee_percent = line.price_subtotal * 0.10  # Example 10% fee
Important Notes
  1. Performance Warning: No-code solutions may be less efficient than proper code implementations
  2. Backup First: Always backup your database before making structural changes
  3. Testing: Try this in a test environment first

Alternative: Consider using the "Margin" field that already exists in Sales if it meets your needs

🚀 Did This Solve Your Problem?

If this answer helped you save time, money, or frustration, consider:

✅ Upvoting (👍) to help others find it faster

✅ Marking as "Best Answer" if it resolved your issue

Your feedback keeps the Odoo community strong! 💪

(Need further customization? Drop a comment—I’m happy to refine the solution!)

0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
How to set default view to list view globally
configuration studio 18.0
Avatar
Avatar
1
d’abr. 25
1713
Sale order to purchase order with all line of Sale order
sale.order.line purchase_order studio
Avatar
Avatar
Avatar
2
de des. 23
2473
Odoo 18: Create/Override Odoo studio
create studio path components 18.0
Avatar
0
de set. 25
531
Carry over data and content from CRM card to Project card
opportunities project crm studio won 18.0
Avatar
Avatar
1
de nov. 25
269
debit and credit in currency
studio
Avatar
Avatar
1
de nov. 25
2133
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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