As it sometimes is, a while after I posted a question, I figured it out by myself. Will post for further references. Magical line is:
self.tax_totals = {'groups_by_subtotal': {'Untaxed Amount':[{'tax_group_id': 5, 'tax_group_amount':10.67}]}}
5 - is id of tax, 10.67 is amount of tax.
Bellow is explanation from Gemini:
=========
tax_totals = fields.Binary(
string="Invoice Totals",
compute='_compute_tax_totals',
inverse='_inverse_tax_totals',
help='Edit Tax amounts if you encounter rounding issues.',
exportable=False,
)
In this case, tax_totals = fields.Binary(...) with inverse='_inverse_tax_totals' is used for a special purpose related to handling tax totals and potential rounding issues on invoices (or similar documents). It's not a typical Many2one relationship, so the way inverse works is slightly different.
Understanding the Context
The tax_totals field stores a serialized representation (usually JSON) of the tax breakdown for the invoice. This data is computed dynamically based on the invoice lines and tax configuration. The purpose of having an inverse function here is to allow users to manually adjust the tax totals in the UI, and then have Odoo recalculate the invoice lines to match those adjusted totals.
How it Works
-
compute='_compute_tax_totals': This means the tax_totals value is calculated by the _compute_tax_totals method. This method generates the JSON representation of the tax breakdown.
-
inverse='_inverse_tax_totals': This is where the manual adjustment comes in. When a user modifies the tax totals in the UI (which is typically presented as a table or a form), the _inverse_tax_totals method is called.
-
_inverse_tax_totals(self): This method receives the modified tax totals (from the UI) and its task is to:
- Parse the modified JSON data.
- Attempt to adjust the invoice lines (amounts, quantities, or potentially even tax rates) in a way that results in the desired tax totals.
- Handle potential rounding issues and inconsistencies.
Hi I want to migrate from source to destination db. total tax edited records are contained in some records when I migrate from source total tax is some of tax line ids I tried with these I added the tax amount in binary for the creation but it's not working how can I adda that in my migration