-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] sale_order_line_price_history: Migration to 16.0
Migrate the SaleOrderLinePriceHistoryWidget to PriceHistoryWidget using the new OWL 16
- Loading branch information
1 parent
85a0d69
commit ac70f63
Showing
7 changed files
with
55 additions
and
74 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
80 changes: 28 additions & 52 deletions
80
sale_order_line_price_history/static/src/js/sale_line_price_history_widget.js
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,57 +1,33 @@ | ||
/* Copyright 2021 Tecnativa - David Vidal | ||
* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
*/ | ||
odoo.define("sale_order_line_price_history.price_history_widget", function (require) { | ||
"use strict"; | ||
/** @odoo-module **/ | ||
const {Component} = owl; | ||
// Import the registry | ||
import {registry} from "@web/core/registry"; | ||
import {standardFieldProps} from "@web/views/fields/standard_field_props"; | ||
import {useService} from "@web/core/utils/hooks"; | ||
|
||
var Widget = require("web.Widget"); | ||
var widget_registry = require("web.widget_registry"); | ||
export class PriceHistoryWidget extends Component { | ||
setup() { | ||
super.setup(); | ||
this.actionService = useService("action"); | ||
} | ||
|
||
var SaleOrderLinePriceHistoryWidget = Widget.extend({ | ||
template: "sale_order_line_price_history.price_history_widget", | ||
events: _.extend({}, Widget.prototype.events, { | ||
"click .price_history": "_onClickButton", | ||
}), | ||
|
||
init: function (parent, params) { | ||
this.data = params.data; | ||
this._super(parent); | ||
}, | ||
|
||
updateState: function (state) { | ||
var candidate = state.data[this.getParent().currentRow]; | ||
if (candidate) { | ||
this.data = candidate.data; | ||
this.renderElement(); | ||
} | ||
}, | ||
|
||
_onClickButton: function () { | ||
// When it's a new line, we can't rely on a line id for the wizard, but | ||
// we can provide the proper element to find the historic lines. | ||
this.$el.find(".price_history").prop("special_click", true); | ||
var additional_context = {}; | ||
if (this.data.id) { | ||
additional_context = {active_id: this.data.id}; | ||
} else { | ||
additional_context = { | ||
default_partner_id: this.data.order_partner_id.res_id, | ||
default_product_id: this.data.product_id.res_id, | ||
}; | ||
viewPriceHistory() { | ||
this.actionService.doAction( | ||
"sale_order_line_price_history.sale_order_line_price_history_action", | ||
{ | ||
additionalContext: { | ||
default_product_id: this.props.record.data.product_id[0], | ||
default_partner_id: this.props.record.data.order_partner_id[0], | ||
default_active_id: this.props.value, | ||
default_sale_order_line_id: this.props.value, | ||
}, | ||
} | ||
this.do_action( | ||
"sale_order_line_price_history.sale_order_line_price_history_action", | ||
{ | ||
additional_context: additional_context, | ||
} | ||
); | ||
}, | ||
}); | ||
); | ||
} | ||
} | ||
|
||
widget_registry.add( | ||
"sale_line_price_history_widget", | ||
SaleOrderLinePriceHistoryWidget | ||
); | ||
PriceHistoryWidget.template = "sale_order_line_price_history.price_history_widget"; | ||
PriceHistoryWidget.props = standardFieldProps; | ||
|
||
return SaleOrderLinePriceHistoryWidget; | ||
}); | ||
// Add the field to the correct category | ||
registry.category("fields").add("sale_line_price_history_widget", PriceHistoryWidget); |
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