-
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] product_contract: Add contract configurator instead of making t…
…ree not editable Before this changes, when trying to edit a line of sale order, it was opening the form of the line. But following the way to work of odoo with sale event, we have make a new contract configurator that will be opened when selecting a product of type contract.
- Loading branch information
1 parent
7f7d947
commit 88d2cb9
Showing
10 changed files
with
367 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models | ||
from . import wizards |
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,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_product_contract_configurator,access.product.contract.configurator,model_product_contract_configurator,sales_team.group_sale_salesman,1,1,1,0 |
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
50 changes: 50 additions & 0 deletions
50
product_contract/static/src/js/contract_configurator_controller.esm.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** @odoo-module **/ | ||
|
||
import {formView} from "@web/views/form/form_view"; | ||
import {registry} from "@web/core/registry"; | ||
import {useService} from "@web/core/utils/hooks"; | ||
|
||
export class ProductContractConfiguratorController extends formView.Controller { | ||
setup() { | ||
super.setup(); | ||
this.action = useService("action"); | ||
} | ||
|
||
async onRecordSaved(record) { | ||
await super.onRecordSaved(...arguments); | ||
const { | ||
product_uom_qty, | ||
contract_id, | ||
recurring_rule_type, | ||
recurring_invoicing_type, | ||
date_start, | ||
date_end, | ||
contract_line_id, | ||
is_auto_renew, | ||
auto_renew_interval, | ||
auto_renew_rule_type, | ||
} = record.data; | ||
return this.action.doAction({ | ||
type: "ir.actions.act_window_close", | ||
infos: { | ||
productContractConfiguration: { | ||
product_uom_qty, | ||
contract_id, | ||
recurring_rule_type, | ||
recurring_invoicing_type, | ||
date_start, | ||
date_end, | ||
contract_line_id, | ||
is_auto_renew, | ||
auto_renew_interval, | ||
auto_renew_rule_type, | ||
}, | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
registry.category("views").add("product_contract_configurator_form", { | ||
...formView, | ||
Controller: ProductContractConfiguratorController, | ||
}); |
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,54 @@ | ||
/** @odoo-module **/ | ||
|
||
import {SaleOrderLineProductField} from "@sale/js/sale_product_field"; | ||
import {patch} from "@web/core/utils/patch"; | ||
|
||
patch(SaleOrderLineProductField.prototype, { | ||
async _onProductUpdate() { | ||
super._onProductUpdate(...arguments); | ||
if (this.props.record.data.is_contract) { | ||
this._openContractConfigurator(true); | ||
} | ||
}, | ||
|
||
_editLineConfiguration() { | ||
super._editLineConfiguration(...arguments); | ||
if (this.props.record.data.is_contract) { | ||
this._openContractConfigurator(); | ||
} | ||
}, | ||
|
||
get isConfigurableLine() { | ||
return super.isConfigurableLine || this.props.record.data.is_contract; | ||
}, | ||
|
||
async _openContractConfigurator(isNew = false) { | ||
const actionContext = { | ||
default_product_id: this.props.record.data.product_id[0], | ||
default_partner_id: this.props.record.model.root.data.partner_id[0], | ||
default_company_id: this.props.record.model.root.data.company_id[0], | ||
default_product_uom_qty: this.props.record.data.product_uom_qty, | ||
default_contract_id: this.props.record.data.contract_id[0], | ||
default_recurring_rule_type: this.props.record.data.recurring_rule_type, | ||
default_recurring_invoicing_type: | ||
this.props.record.data.recurring_invoicing_type, | ||
default_date_start: this.props.record.data.date_start, | ||
default_date_end: this.props.record.data.date_end, | ||
default_is_auto_renew: this.props.record.data.is_auto_renew, | ||
default_auto_renew_interval: this.props.record.data.auto_renew_interval, | ||
default_auto_renew_rule_type: this.props.record.data.auto_renew_rule_type, | ||
}; | ||
this.action.doAction("product_contract.product_contract_configurator_action", { | ||
additionalContext: actionContext, | ||
onClose: async (closeInfo) => { | ||
if (closeInfo && !closeInfo.special) { | ||
this.props.record.update(closeInfo.productContractConfiguration); | ||
} else if (isNew) { | ||
this.props.record.update({ | ||
[this.props.name]: undefined, | ||
}); | ||
} | ||
}, | ||
}); | ||
}, | ||
}); |
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 @@ | ||
from . import product_contract_configurator |
Oops, something went wrong.