mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX] product_contract: Make configuration tab compatible with sale_product_configurator
Before: 1. Create a contract product 2. Add variants and select Product Configurator 3. Add the product on a Sale Order 4. Try to edit the variants with the configurator You will not be able to open the product configurator After: The product configurator will be opened first and then the contract configurator.
This commit is contained in:
@@ -65,8 +65,8 @@ To use this module, you need to:
|
|||||||
Known issues / Roadmap
|
Known issues / Roadmap
|
||||||
======================
|
======================
|
||||||
|
|
||||||
- There's no support right now for computing the start date for the
|
- There's no support right now for computing the start date for the
|
||||||
following recurrent types: daily, weekly and monthlylastday.
|
following recurrent types: daily, weekly and monthlylastday.
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
@@ -90,16 +90,16 @@ Authors
|
|||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- Ted Salmon <tsalmon@laslabs.com>
|
- Ted Salmon <tsalmon@laslabs.com>
|
||||||
- Souheil Bejaoui <souheil.bejaoui@acsone.eu>
|
- Souheil Bejaoui <souheil.bejaoui@acsone.eu>
|
||||||
- `Tecnativa <https://www.tecnativa.com>`__:
|
- `Tecnativa <https://www.tecnativa.com>`__:
|
||||||
|
|
||||||
- Ernesto Tejeda
|
- Ernesto Tejeda
|
||||||
- Pedro M. Baeza
|
- Pedro M. Baeza
|
||||||
- Carlos Roca
|
- Carlos Roca
|
||||||
- Sergio Teruel
|
- Sergio Teruel
|
||||||
|
|
||||||
- David Jaen <david.jaen.revert@gmail.com>
|
- David Jaen <david.jaen.revert@gmail.com>
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
-----------
|
-----------
|
||||||
@@ -117,10 +117,13 @@ promote its widespread use.
|
|||||||
.. |maintainer-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px
|
.. |maintainer-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px
|
||||||
:target: https://github.com/sbejaoui
|
:target: https://github.com/sbejaoui
|
||||||
:alt: sbejaoui
|
:alt: sbejaoui
|
||||||
|
.. |maintainer-CarlosRoca13| image:: https://github.com/CarlosRoca13.png?size=40px
|
||||||
|
:target: https://github.com/CarlosRoca13
|
||||||
|
:alt: CarlosRoca13
|
||||||
|
|
||||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|
||||||
|
|
||||||
|maintainer-sbejaoui|
|
|maintainer-sbejaoui| |maintainer-CarlosRoca13|
|
||||||
|
|
||||||
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/17.0/product_contract>`_ project on GitHub.
|
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/17.0/product_contract>`_ project on GitHub.
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,6 @@
|
|||||||
"installable": True,
|
"installable": True,
|
||||||
"application": False,
|
"application": False,
|
||||||
"external_dependencies": {"python": ["dateutil"]},
|
"external_dependencies": {"python": ["dateutil"]},
|
||||||
"maintainers": ["sbejaoui"],
|
"maintainers": ["sbejaoui", "CarlosRoca13"],
|
||||||
"assets": {"web.assets_backend": ["product_contract/static/src/js/*"]},
|
"assets": {"web.assets_backend": ["product_contract/static/src/js/*"]},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -420,24 +420,26 @@ class SaleOrderLine(models.Model):
|
|||||||
"date_start", "date_end", "recurring_rule_type", "recurring_invoicing_type"
|
"date_start", "date_end", "recurring_rule_type", "recurring_invoicing_type"
|
||||||
)
|
)
|
||||||
def _compute_name(self):
|
def _compute_name(self):
|
||||||
res = super()._compute_name()
|
# This method is used for adding new dependencies
|
||||||
|
return super()._compute_name()
|
||||||
|
|
||||||
|
def _get_sale_order_line_multiline_description_sale(self):
|
||||||
|
self.ensure_one()
|
||||||
ICP = self.env["ir.config_parameter"].sudo()
|
ICP = self.env["ir.config_parameter"].sudo()
|
||||||
for line in self:
|
description = ""
|
||||||
if line.is_contract:
|
if self.is_contract:
|
||||||
description = ""
|
if str2bool(ICP.get_param("product_contract.show_recurrency")) and (
|
||||||
if str2bool(ICP.get_param("product_contract.show_recurrency")) and (
|
recurring_rule_label
|
||||||
recurring_rule_label
|
:= self._get_product_contract_recurring_rule_label()
|
||||||
:= line._get_product_contract_recurring_rule_label()
|
):
|
||||||
):
|
description += "\n\t" + recurring_rule_label
|
||||||
description += "\n\t" + recurring_rule_label
|
if str2bool(ICP.get_param("product_contract.show_invoicing_type")) and (
|
||||||
if str2bool(ICP.get_param("product_contract.show_invoicing_type")) and (
|
invoicing_type_label
|
||||||
invoicing_type_label
|
:= self._get_product_contract_invoicing_type_label()
|
||||||
:= line._get_product_contract_invoicing_type_label()
|
):
|
||||||
):
|
description += "\n\t" + invoicing_type_label
|
||||||
description += "\n\t" + invoicing_type_label
|
if str2bool(ICP.get_param("product_contract.show_date")) and (
|
||||||
if str2bool(ICP.get_param("product_contract.show_date")) and (
|
date_text := self._get_product_contract_date_text()
|
||||||
date_text := line._get_product_contract_date_text()
|
):
|
||||||
):
|
description += "\n\t" + date_text
|
||||||
description += "\n\t" + date_text
|
return super()._get_sale_order_line_multiline_description_sale() + description
|
||||||
line.name = f"{line.product_id.display_name}{description}"
|
|
||||||
return res
|
|
||||||
|
|||||||
@@ -459,8 +459,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
|
||||||
<p><a class="reference external image-reference" href="https://github.com/sbejaoui"><img alt="sbejaoui" src="https://github.com/sbejaoui.png?size=40px" /></a></p>
|
<p><a class="reference external image-reference" href="https://github.com/sbejaoui"><img alt="sbejaoui" src="https://github.com/sbejaoui.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/CarlosRoca13"><img alt="CarlosRoca13" src="https://github.com/CarlosRoca13.png?size=40px" /></a></p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/17.0/product_contract">OCA/contract</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/17.0/product_contract">OCA/contract</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ import {SaleOrderLineProductField} from "@sale/js/sale_product_field";
|
|||||||
import {patch} from "@web/core/utils/patch";
|
import {patch} from "@web/core/utils/patch";
|
||||||
|
|
||||||
patch(SaleOrderLineProductField.prototype, {
|
patch(SaleOrderLineProductField.prototype, {
|
||||||
|
setup() {
|
||||||
|
super.setup(...arguments);
|
||||||
|
this.lastContractContext = false;
|
||||||
|
},
|
||||||
|
|
||||||
get extraLines() {
|
get extraLines() {
|
||||||
var res = super.extraLines;
|
var res = super.extraLines;
|
||||||
if (
|
if (
|
||||||
@@ -26,6 +31,16 @@ patch(SaleOrderLineProductField.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_editProductConfiguration() {
|
||||||
|
if (
|
||||||
|
this.props.record.data.is_configurable_product &&
|
||||||
|
this.props.record.data.is_contract
|
||||||
|
) {
|
||||||
|
this.lastContractContext = this.contractContext;
|
||||||
|
}
|
||||||
|
super._editProductConfiguration(...arguments);
|
||||||
|
},
|
||||||
|
|
||||||
_editLineConfiguration() {
|
_editLineConfiguration() {
|
||||||
super._editLineConfiguration(...arguments);
|
super._editLineConfiguration(...arguments);
|
||||||
if (this.props.record.data.is_contract) {
|
if (this.props.record.data.is_contract) {
|
||||||
@@ -34,7 +49,13 @@ patch(SaleOrderLineProductField.prototype, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get isConfigurableLine() {
|
get isConfigurableLine() {
|
||||||
return super.isConfigurableLine || this.props.record.data.is_contract;
|
// When a product is configurable it will be added again when the variants are selected.
|
||||||
|
// So the configuration will be catched with _onProductUpdate hook.
|
||||||
|
return (
|
||||||
|
super.isConfigurableLine ||
|
||||||
|
(this.props.record.data.is_contract &&
|
||||||
|
!this.props.record.data.is_configurable_product)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
get contractContext() {
|
get contractContext() {
|
||||||
@@ -54,7 +75,13 @@ patch(SaleOrderLineProductField.prototype, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async _openContractConfigurator(isNew = false) {
|
async _openContractConfigurator(isNew = false) {
|
||||||
const actionContext = this.contractContext;
|
const actionContext = Object.assign(
|
||||||
|
{},
|
||||||
|
this.lastContractContext || this.contractContext
|
||||||
|
);
|
||||||
|
if (this.lastContractContext) {
|
||||||
|
this.lastContractContext = false;
|
||||||
|
}
|
||||||
this.action.doAction("product_contract.product_contract_configurator_action", {
|
this.action.doAction("product_contract.product_contract_configurator_action", {
|
||||||
additionalContext: actionContext,
|
additionalContext: actionContext,
|
||||||
onClose: async (closeInfo) => {
|
onClose: async (closeInfo) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user