Skip to content

Commit

Permalink
Merge PR #1193 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Feb 12, 2025
2 parents 2184bf6 + ae36c61 commit ab1d958
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 37 deletions.
27 changes: 15 additions & 12 deletions product_contract/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand All @@ -90,16 +90,16 @@ Authors
Contributors
------------

- Ted Salmon <[email protected]>
- Souheil Bejaoui <[email protected]>
- `Tecnativa <https://www.tecnativa.com>`__:
- Ted Salmon <[email protected]>
- Souheil Bejaoui <[email protected]>
- `Tecnativa <https://www.tecnativa.com>`__:

- Ernesto Tejeda
- Pedro M. Baeza
- Carlos Roca
- Sergio Teruel
- Ernesto Tejeda
- Pedro M. Baeza
- Carlos Roca
- Sergio Teruel

- David Jaen <[email protected]>
- David Jaen <[email protected]>

Maintainers
-----------
Expand All @@ -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 <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.

Expand Down
2 changes: 1 addition & 1 deletion product_contract/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"]},
}
42 changes: 22 additions & 20 deletions product_contract/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,24 +420,26 @@ def _compute_product_contract_description(self):
"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
4 changes: 2 additions & 2 deletions product_contract/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</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>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> <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>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>
Expand Down
31 changes: 29 additions & 2 deletions product_contract/static/src/js/sale_product_field.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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) {
Expand All @@ -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() {
Expand All @@ -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) => {
Expand Down

0 comments on commit ab1d958

Please sign in to comment.