diff --git a/product_contract/README.rst b/product_contract/README.rst index 6cef5817e..0d7c5dd75 100644 --- a/product_contract/README.rst +++ b/product_contract/README.rst @@ -65,8 +65,8 @@ To use this module, you need to: Known issues / Roadmap ====================== -- There's no support right now for computing the start date for the - following recurrent types: daily, weekly and monthlylastday. +- There's no support right now for computing the start date for the + following recurrent types: daily, weekly and monthlylastday. Bug Tracker =========== @@ -90,16 +90,16 @@ Authors Contributors ------------ -- Ted Salmon -- Souheil Bejaoui -- `Tecnativa `__: +- Ted Salmon +- Souheil Bejaoui +- `Tecnativa `__: - - Ernesto Tejeda - - Pedro M. Baeza - - Carlos Roca - - Sergio Teruel + - Ernesto Tejeda + - Pedro M. Baeza + - Carlos Roca + - Sergio Teruel -- David Jaen +- David Jaen Maintainers ----------- @@ -117,10 +117,13 @@ promote its widespread use. .. |maintainer-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px :target: https://github.com/sbejaoui :alt: sbejaoui +.. |maintainer-CarlosRoca13| image:: https://github.com/CarlosRoca13.png?size=40px + :target: https://github.com/CarlosRoca13 + :alt: CarlosRoca13 -Current `maintainer `__: +Current `maintainers `__: -|maintainer-sbejaoui| +|maintainer-sbejaoui| |maintainer-CarlosRoca13| This module is part of the `OCA/contract `_ project on GitHub. diff --git a/product_contract/__manifest__.py b/product_contract/__manifest__.py index 25b0fe40c..4986f29e6 100644 --- a/product_contract/__manifest__.py +++ b/product_contract/__manifest__.py @@ -21,6 +21,6 @@ "installable": True, "application": False, "external_dependencies": {"python": ["dateutil"]}, - "maintainers": ["sbejaoui"], + "maintainers": ["sbejaoui", "CarlosRoca13"], "assets": {"web.assets_backend": ["product_contract/static/src/js/*"]}, } diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index c841099c4..8c0e3b7c1 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -420,24 +420,26 @@ class SaleOrderLine(models.Model): "date_start", "date_end", "recurring_rule_type", "recurring_invoicing_type" ) 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() - for line in self: - if line.is_contract: - description = "" - if str2bool(ICP.get_param("product_contract.show_recurrency")) and ( - recurring_rule_label - := line._get_product_contract_recurring_rule_label() - ): - description += "\n\t" + recurring_rule_label - if str2bool(ICP.get_param("product_contract.show_invoicing_type")) and ( - invoicing_type_label - := line._get_product_contract_invoicing_type_label() - ): - description += "\n\t" + invoicing_type_label - if str2bool(ICP.get_param("product_contract.show_date")) and ( - date_text := line._get_product_contract_date_text() - ): - description += "\n\t" + date_text - line.name = f"{line.product_id.display_name}{description}" - return res + description = "" + if self.is_contract: + if str2bool(ICP.get_param("product_contract.show_recurrency")) and ( + recurring_rule_label + := self._get_product_contract_recurring_rule_label() + ): + description += "\n\t" + recurring_rule_label + if str2bool(ICP.get_param("product_contract.show_invoicing_type")) and ( + invoicing_type_label + := self._get_product_contract_invoicing_type_label() + ): + description += "\n\t" + invoicing_type_label + if str2bool(ICP.get_param("product_contract.show_date")) and ( + date_text := self._get_product_contract_date_text() + ): + description += "\n\t" + date_text + return super()._get_sale_order_line_multiline_description_sale() + description diff --git a/product_contract/static/description/index.html b/product_contract/static/description/index.html index f1a2bfe7c..1a72fdcc5 100644 --- a/product_contract/static/description/index.html +++ b/product_contract/static/description/index.html @@ -459,8 +459,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

Current maintainer:

-

sbejaoui

+

Current maintainers:

+

sbejaoui CarlosRoca13

This module is part of the OCA/contract project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/product_contract/static/src/js/sale_product_field.esm.js b/product_contract/static/src/js/sale_product_field.esm.js index 4e60db39c..1c51b2ee6 100644 --- a/product_contract/static/src/js/sale_product_field.esm.js +++ b/product_contract/static/src/js/sale_product_field.esm.js @@ -4,6 +4,11 @@ import {SaleOrderLineProductField} from "@sale/js/sale_product_field"; import {patch} from "@web/core/utils/patch"; patch(SaleOrderLineProductField.prototype, { + setup() { + super.setup(...arguments); + this.lastContractContext = false; + }, + get extraLines() { var res = super.extraLines; 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() { super._editLineConfiguration(...arguments); if (this.props.record.data.is_contract) { @@ -34,7 +49,13 @@ patch(SaleOrderLineProductField.prototype, { }, 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() { @@ -54,7 +75,13 @@ patch(SaleOrderLineProductField.prototype, { }, 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", { additionalContext: actionContext, onClose: async (closeInfo) => {