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

How to change tax computation in odoo9 with my custom module and avoid breaking things?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
accountinginheritancetaxodooodoo9
4788 Vistes
Avatar
Klo

I want to add a module that will change tax computation (def _compute_all in class account.tax) if special check box (field.Boolean) in form view is checked. I use check box since I think it gives clearer information to the user is it active or not.

I just can't get it to work. Fields (float and boolean checkbox) were added and usable but odoo just ignores my changes in tax computation (I test it in POS by adding few products with my custom tax with custom computation).


What is the proper way to do this (way that will not break stuff in the future) and that will work with other modules (basically use same data fields as original odoo-made account module)?


1. Am I even looking at the right method (def_compute_all), class(account.tax) and module (account)?

2. Where is the actual class and method that gives final result to other modules (like POS, Sales, rest of Accounting) and fields?

3. Is that code with  @api.v8 and @api.v7 just legacy, or do I have to dynamically change it too?

4. Is there any documentation on developing accounting or tax modules? I am completely lost .


original compute_all method in class AccountTax in module accounting (that might be totally wrong method to change dynamically, or even wrong class?)

def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, partner=None):
    self.ensure_one()
    if self.amount_type == 'fixed':
        return math.copysign(self.amount, base_amount) * quantity
    if (self.amount_type == 'percent' and not self.price_include) or (self.amount_type == 'division' and self.price_include):
        return base_amount * self.amount / 100
    if self.amount_type == 'percent' and self.price_include:
        return base_amount - (base_amount / (1 + self.amount / 100))
    if self.amount_type == 'division' and not self.price_include:
        return base_amount / (1 - self.amount / 100) - base_amount


my module:

class MyTaxCompute(models.Model):
    _inherit = 'account.tax'

    custom_tax = fields.Boolean(string='Custom tax computation')
    custom_tax_field1 = fields.Float(string='Tax 1')
    custom_tax_field2 = fields.Float(string='Tax 2')
    
        def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, partner=None):         if self.custom_tax:         #my code here         #res = ...         else:         res = super(MyTaxCompute, self)._compute_amount(base_amount, price_unit, quantity, product, partner)     return res


my view

<record id="view_tax_form_inherited" model="ir.ui.view">
    <field name="name">account.tax.form.inherited</field>
    <field name="model">account.tax</field>
    <field name="inherit_id" ref="account.view_tax_form"/>
    <field name="arch" type="xml">

        <xpath expr="//page/group" position="after">
<!-- my custom boolean selection field -->
            <field name="custom_tax" string="Custom tax computation"/>
<!-- my custom float fields to put tax rates in -->
            <field name="custom_tax_field1" string="Tax 1"/>
            <field name="custom_tax_field2" string="Tax 2"/>
        </xpath>
    </field>
</record> 
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
Setting up tax cloud on Odoo v10
accounting tax odoo
Avatar
2
de set. 17
3893
Accounting Sale Entries have no taxes if generated via PoS (Odoo9) Solved
accounting pos tax odoo9
Avatar
Avatar
2
de jul. 16
3706
Indian GST based pos bill
accounting tax tag GST odoo9
Avatar
Avatar
1
de maig 18
6592
How to use sales and purchase of OpenERP 7 together with accounting of Odoo 9
accounting reporting openerp7 odoo odoo9
Avatar
Avatar
1
de gen. 16
3434
Add custom filter in financial reports odoo17
accounting odoo
Avatar
Avatar
Avatar
3
de gen. 25
8133
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