Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] sale_margin_tax #213

Open
wants to merge 6 commits into
base: 16.0
Choose a base branch
from

Commits on Jun 4, 2024

  1. [ADD] sale_margin_tax

    len-foss committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    201e2f2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d1d61fb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8b3c631 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a05e555 View commit details
    Browse the repository at this point in the history
  5. [REF] sale_margin_tax: refactor for correct accounting

    When accounting for margin tax sales, the purchase price
    and margin (that form the base for the tax lines) need to be split.
    This is because a different tax grid should be applied on both line.
    However, Odoo does not provide a way to split the base as it does to
    split the tax. Furthermore, adding a 'margin' line type does not work
    because the functions that apply the repartition lines etc are basically
    impossible to override (they do not provide any hook,
    and the arbitrary compute order would make any tentative very brittle).
    To avoid these difficulty, another line is created on a "margin" product
    (a service), so that both the purchase and the margin can be accounted
    as base lines.
    
    This provide the advantage that no further override of basic accounting
    functions are needed, and that the tax rate of the margin tax is always
    either the initial rate (say 21) or 0.
    
    The downside is that it makes so statistics harder.
    Since the margin line and the product lines are linked by a many2one,
    it is still possible to extract the relevant info, just a bit harder.
    
    This refactoring also merges the margin behaviour from invoice and sale
    into a mixin to avoid desync of the essentially duplicated code
    (if only both line/tax fields had the same name...).
    This solved a bug where an invoice would think to be margin-based but
    without finding a witness margin tax.
    
    Last, this now handles the case where the margin is negative,
    in which case no tax is due.
    len-foss committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    a39f40c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    76768c6 View commit details
    Browse the repository at this point in the history