TIP: You can type at any time to perform a new search.
Invoice Margin
invoice_margin · OCA/account-invoicing
Security findings
Migration considerations
- Imports from the old `openerp` namespace: renamed to `odoo` since Odoo 10.0. migration-openerp-import · source
- Imports from the old `openerp.addons.decimal_precision` namespace: renamed to `odoo` since Odoo 10.0. migration-openerp-import · source
- Imports from the old `openerp` namespace: renamed to `odoo` since Odoo 10.0. migration-openerp-import · source
- Imports from the old `openerp.addons.decimal_precision` namespace: renamed to `odoo` since Odoo 10.0. migration-openerp-import · source
- For a target of Odoo 10.0+: use the `__manifest__.py` manifest name instead of `__openerp__.py`. The filename alone does not establish module age or compatibility. migration-openerp-manifest · source
- Raw `cr.execute()` INSERT/UPDATE/DELETE bypasses the ORM (no compute/constrains/tracking/mail): `UPDATE account_invoice_line SET purchase_price = line_standard_price.standard_price FROM ( SELECT ail.id line_id, (SELECT cost FROM product_price_history pph WHERE( ai.date_invoice is null OR date_trunc('day', pph.datetime) <= ai.date_invoice) AND pph.product_template_id = pp.product_tmpl_id AND pph.company_id = ail.company_id ORDER BY datetime desc LIMIT 1) standard_price FROM account_invoice_line ail INNER JOIN account_invoice ai ON ai.id = ail.invoice_id INNER JOIN product_product pp ON pp.id = ail.product_id ) line_standard_price WHERE account_invoice_line.id = line_standard_price.line_id;` - re-check the table/column names still match after upgrading. migration-raw-sql-write · source
- Raw `cr.execute()` INSERT/UPDATE/DELETE bypasses the ORM (no compute/constrains/tracking/mail): `UPDATE account_invoice_line SET margin = price_subtotal - (purchase_price * quantity), margin_percent = CASE WHEN price_subtotal = 0 then 0 ELSE 100 * (price_subtotal - (purchase_price * quantity)) / price_subtotal END;` - re-check the table/column names still match after upgrading. migration-raw-sql-write · source
- Raw `cr.execute()` INSERT/UPDATE/DELETE bypasses the ORM (no compute/constrains/tracking/mail): `UPDATE account_invoice ai SET margin = invoice_margin.margin, margin_percent = invoice_margin.margin_percent FROM ( SELECT ai.id invoice_id, sum(ail.margin) margin, CASE WHEN sum(ail.price_subtotal) = 0 THEN 0 ELSE sum(ail.margin) / sum(ail.price_subtotal) * 100 END margin_percent FROM account_invoice ai INNER JOIN account_invoice_line ail ON ail.invoice_id = ai.id GROUP BY ai.id ) invoice_margin WHERE ai.id = invoice_margin.invoice_id;` - re-check the table/column names still match after upgrading. migration-raw-sql-write · source
Migration review checklist, not a compatibility verdict. No target version is selected: apply version-specific advice only when migrating to that version or later.
- Repository
- OCA/account-invoicing · module folder · Try on Runboat
- Module version
- 2.0.0
- Category
- Invoicing
- Folder size
- 0.15 MB
- License
- AGPL-3
- Application
- No
- Auto-installable
- No
- Website
- None
- Last tracking update
- 2026-08-07 07:03:02
- Authors
- Odoo Community Association (OCA), GRAP
- Maintainers
- Odoo Community Association (OCA), GRAP
- Committers
- GitHub, Sylvain LE GAL, OCA Transbot, OCA-git-bot
Code Analysis
Views touched (2)
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
view_account_invoice_form |
account.invoice | form | Inherits account.invoice_form | |
view_account_invoice_tree |
account.invoice | tree | Inherits account.invoice_tree |
HTTP endpoints (0)
No HTTP endpoints found for this module.
Models touched (2)
New fields (2)
-
marginFloatcompute='_compute_margin'digits_compute=dp.get_precision('Product Price')help='It gives profitability by calculating the difference between the Unit Price and the cost price.'multi='margin'store=True args: 'Margin' -
margin_percentFloatcompute='_compute_margin'digits_compute=dp.get_precision('PoS Order Margin Percent')multi='margin'store=True args: 'Margin (%)'
No public methods.
New fields (3)
-
marginFloatcompute='_compute_multi_margin'digits_compute=dp.get_precision('Product Price')multi='multi_margin'store=True args: 'Margin' -
margin_percentFloatcompute='_compute_multi_margin'digits_compute=dp.get_precision('Product Price')multi='multi_margin'store=True args: 'Margin (%)' -
purchase_priceFloatcopy=Falsedigits_compute=dp.get_precision('Product Price')string='Cost Price'
-
create(self, vals)@api.model -
product_id_change(self, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, company_id=None)@api.multi