forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '14.0-sale_discount_display_amount-add_discount_subtotal…
…_with_migr' of git+ssh://github.com/sergiocorato/sale-workflow into 14.0
- Loading branch information
Showing
7 changed files
with
55 additions
and
2 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
21 changes: 21 additions & 0 deletions
21
sale_discount_display_amount/migrations/14.0.2.2.0/post-compute-subtotal-columns.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,21 @@ | ||
import logging | ||
|
||
from odoo import SUPERUSER_ID | ||
from odoo.api import Environment | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def migrate(cr, version): | ||
_logger.info("Compute discount columns") | ||
env = Environment(cr, SUPERUSER_ID, {}) | ||
|
||
query = """ | ||
select distinct order_id from sale_order_line where discount > 0.0; | ||
""" | ||
|
||
cr.execute(query) | ||
order_ids = cr.fetchall() | ||
|
||
orders = env["sale.order"].search([("id", "in", order_ids)]) | ||
orders.mapped("order_line")._update_discount_display_fields() |
17 changes: 17 additions & 0 deletions
17
sale_discount_display_amount/migrations/14.0.2.2.0/pre-add-subtotal-columns.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,17 @@ | ||
import logging | ||
|
||
from odoo.tools.sql import column_exists, create_column | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
COLUMNS = ( | ||
("sale_order", "discount_subtotal"), | ||
("sale_order_line", "discount_subtotal"), | ||
) | ||
|
||
|
||
def migrate(cr, version): | ||
for table, column in COLUMNS: | ||
if not column_exists(cr, table, column): | ||
_logger.info("Create discount column %s in database", column) | ||
create_column(cr, table, column, "numeric") |
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