Skip to content
Snippets Groups Projects
Commit ca36c2ff authored by nouraellm's avatar nouraellm
Browse files

[FIX] sale_margin: speed up module installation


- Due to hefty data the RAM limit gets exhausted.
- The process gets killed due to computed field margin on sale.order.line

To solve the problem:
- We add column margin to DB schema.

Task id: #2950878

closes odoo/odoo#100453

Signed-off-by: default avatarVictor Feyens (vfe) <vfe@odoo.com>
parent 90f83914
No related branches found
No related tags found
No related merge requests found
......@@ -2,11 +2,18 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
from odoo.tools.sql import column_exists, create_column
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
def _auto_init(self):
if not column_exists(self.env.cr, "sale_order_line", "margin"):
# By creating the column 'margin' manually we steer clear of hefty data computation.
create_column(self.env.cr, "sale_order_line", "margin", "NUMERIC")
return super()._auto_init()
margin = fields.Float(compute='_product_margin', digits='Product Price', store=True)
purchase_price = fields.Float(string='Cost', digits='Product Price')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment