-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][IMP] custom_mrp_descarga: Add new fields in sale report.
- Loading branch information
Berezi
committed
Jan 30, 2025
1 parent
2fcd6d0
commit bca293c
Showing
8 changed files
with
219 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
custom_mrp_descarga/migrations/14.0.1.1.0/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2025 Berezi Amubieta - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
import logging | ||
|
||
from openupgradelib import openupgrade | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
cr = env.cr | ||
if not openupgrade.column_exists(cr, "sale_order_line", "lot_average_price"): | ||
cr.execute( | ||
""" | ||
ALTER TABLE sale_order_line | ||
ADD COLUMN lot_average_price float; | ||
""" | ||
) | ||
cr.execute( | ||
""" | ||
UPDATE sale_order_line | ||
SET lot_average_price = (SELECT stock_production_lot.average_price | ||
FROM stock_production_lot | ||
WHERE stock_production_lot.id = sale_order_line.lot_id) | ||
""" | ||
) | ||
if not openupgrade.column_exists(cr, "sale_order_line", "lot_cost"): | ||
cr.execute( | ||
""" | ||
ALTER TABLE sale_order_line | ||
ADD COLUMN lot_cost float; | ||
""" | ||
) | ||
cr.execute( | ||
""" | ||
UPDATE sale_order_line | ||
SET lot_cost = (SELECT stock_production_lot.average_price * product_uom_qty | ||
FROM stock_production_lot | ||
WHERE stock_production_lot.id = sale_order_line.lot_id) | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2022 Berezi Amubieta - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import api, fields, models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
lot_average_price = fields.Float( | ||
digits="MRP Price Decimal Precision", | ||
related="lot_id.average_price", | ||
store=True, | ||
) | ||
lot_cost = fields.Float(compute="_compute_lot_cost", store=True) | ||
|
||
@api.depends("lot_average_price", "product_uom_qty") | ||
def _compute_lot_cost(self): | ||
for line in self: | ||
line.lot_cost = line.lot_average_price * line.product_uom_qty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import mrp_production_summary_xlsx | ||
from . import mrp_production_quartering_summary_xlsx | ||
from . import sale_report |
Oops, something went wrong.