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 '12.0-port-sale_discount_display_amount-from-14.0-to-12.…
…0-pr-1651-2952' of git+ssh://github.com/sergiocorato/sale-workflow into 12.0
- Loading branch information
Showing
8 changed files
with
120 additions
and
32 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
36 changes: 36 additions & 0 deletions
36
sale_discount_display_amount/migrations/12.0.1.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,36 @@ | ||
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 = """ | ||
update sale_order_line | ||
set | ||
price_subtotal_no_discount = price_subtotal | ||
where discount = 0.0 | ||
""" | ||
cr.execute(query) | ||
|
||
query = """ | ||
update sale_order | ||
set | ||
price_subtotal_no_discount = amount_untaxed | ||
""" | ||
cr.execute(query) | ||
|
||
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")._compute_discount() |
17 changes: 17 additions & 0 deletions
17
sale_discount_display_amount/migrations/12.0.1.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", "price_subtotal_no_discount"), | ||
("sale_order_line", "price_subtotal_no_discount"), | ||
) | ||
|
||
|
||
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
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