Skip to content

Commit 321af49

Browse files
bosdbosd
authored andcommitted
[MIG] product_contract: Migration to 19.0
1 parent 07af5e2 commit 321af49

14 files changed

Lines changed: 102 additions & 60 deletions

File tree

product_contract/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Recurring - Product Contract
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github
24-
:target: https://github.com/OCA/contract/tree/18.0/product_contract
24+
:target: https://github.com/OCA/contract/tree/19.0/product_contract
2525
:alt: OCA/contract
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/contract-18-0/contract-18-0-product_contract
27+
:target: https://translation.odoo-community.org/projects/contract-19-0/contract-19-0-product_contract
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -68,7 +68,7 @@ Bug Tracker
6868
Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/issues>`_.
6969
In case of trouble, please check there if your issue has already been reported.
7070
If you spotted it first, help us to smash it by providing a detailed and welcomed
71-
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20product_contract%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
71+
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20product_contract%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7272

7373
Do not contact contributors directly about support or help with technical issues.
7474

@@ -115,6 +115,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
115115

116116
|maintainer-sbejaoui|
117117

118-
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/18.0/product_contract>`_ project on GitHub.
118+
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/19.0/product_contract>`_ project on GitHub.
119119

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

product_contract/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{
66
"name": "Recurring - Product Contract",
7-
"version": "18.0.1.1.2",
7+
"version": "19.0.1.0.0",
88
"category": "Contract Management",
99
"license": "AGPL-3",
1010
"author": "LasLabs, ACSONE SA/NV, Odoo Community Association (OCA)",

product_contract/migrations/18.0.1.0.0/post-migration.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

product_contract/migrations/18.0.1.0.0/pre-migrate.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

product_contract/models/contract.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from odoo import api, fields, models
55
from odoo.exceptions import AccessError
6-
from odoo.tools.translate import _
76

87

98
class ContractContract(models.Model):
@@ -26,7 +25,7 @@ def action_view_sales_orders(self):
2625
self.ensure_one()
2726
orders = self.contract_line_ids.mapped("sale_order_line_id.order_id")
2827
action = {
29-
"name": _("Sales Orders"),
28+
"name": self.env._("Sales Orders"),
3029
"view_mode": "list,form",
3130
"res_model": "sale.order",
3231
"type": "ir.actions.act_window",

product_contract/models/product_template.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2018 ACSONE SA/NV.
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

5-
from odoo import _, api, fields, models
5+
from odoo import api, fields, models
66
from odoo.exceptions import ValidationError
77

88

@@ -154,10 +154,21 @@ class ProductTemplate(models.Model):
154154

155155
def write(self, vals):
156156
if "is_contract" in vals and vals["is_contract"] is False:
157-
for company in self.env["res.company"].search([]):
158-
self.with_company(company).write(
159-
{"property_contract_template_id": False}
157+
# Get only the IDs to avoid loading all company records into memory
158+
# Use a reasonable batch size to avoid performance issues
159+
offset = 0
160+
batch_size = 100
161+
while True:
162+
company_batch = self.env["res.company"].search_read(
163+
[], ["id"], offset=offset, limit=batch_size, order="id"
160164
)
165+
if not company_batch:
166+
break
167+
for company_data in company_batch:
168+
self.with_company(company_data["id"]).write(
169+
{"property_contract_template_id": False}
170+
)
171+
offset += batch_size
161172
return super().write(vals)
162173

163174
@api.constrains("is_contract", "type")
@@ -166,4 +177,4 @@ def _check_contract_product_type(self):
166177
Contract product should be service type
167178
"""
168179
if any([product.is_contract and product.type != "service" for product in self]):
169-
raise ValidationError(_("Contract product should be service type"))
180+
raise ValidationError(self.env._("Contract product should be service type"))

product_contract/models/sale_order.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2018 ACSONE SA/NV.
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

5-
from odoo import _, api, fields, models
5+
from odoo import api, fields, models
66
from odoo.exceptions import ValidationError
77

88

@@ -22,7 +22,7 @@ def _check_contact_is_not_terminated(self):
2222
"cancel",
2323
) and rec.order_line.filtered("contract_id.is_terminated"):
2424
raise ValidationError(
25-
_("You can't upsell or downsell a terminated contract")
25+
self.env._("You can't upsell or downsell a terminated contract")
2626
)
2727

2828
@api.depends("order_line.contract_id", "state")

product_contract/models/sale_order_line.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from dateutil.relativedelta import relativedelta
66

7-
from odoo import _, api, fields, models
7+
from odoo import api, fields, models
88
from odoo.exceptions import ValidationError
99

1010
MONTH_NB_MAPPING = {
@@ -27,7 +27,7 @@ def _check_contact_is_not_terminated(self):
2727
and rec.contract_id.is_terminated
2828
):
2929
raise ValidationError(
30-
_("You can't upsell or downsell a terminated contract")
30+
self.env._("You can't upsell or downsell a terminated contract")
3131
)
3232

3333
def _get_contract_line_qty(self):
@@ -63,7 +63,7 @@ def _prepare_contract_line_values(
6363
"product_id": self.product_id.id,
6464
"name": self.name.split(":\n")[0],
6565
"quantity": self._get_contract_line_qty(),
66-
"uom_id": self.product_uom.id,
66+
"uom_id": self.product_uom_id.id,
6767
"price_unit": self.price_unit,
6868
"discount": self.discount,
6969
"date_end": self.date_end,
@@ -123,7 +123,7 @@ def _check_contract_sale_partner(self):
123123
if rec.contract_id:
124124
if rec.order_id.partner_id != rec.contract_id.partner_id:
125125
raise ValidationError(
126-
_(
126+
self.env._(
127127
"Sale Order and contract should be "
128128
"linked to the same partner"
129129
)
@@ -138,7 +138,7 @@ def _check_contract_sale_contract_template(self):
138138
and rec.contract_template_id != rec.contract_id.contract_template_id
139139
):
140140
raise ValidationError(
141-
_("Contract product has different contract template")
141+
self.env._("Contract product has different contract template")
142142
)
143143

144144
def _compute_invoice_status(self):
@@ -271,7 +271,7 @@ def _get_contract_name(self, date_text, recurring_rule_label, invoicing_type_lab
271271

272272
def _get_contract_name_format(self):
273273
self.ensure_one()
274-
return _(
274+
return self.env._(
275275
"""{product}:
276276
- Recurrency: {recurring_rule}
277277
- Invoicing Type: {invoicing_type}

product_contract/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Recurring - Product Contract</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:34494a98ca456e25a227778a7bf16f4107e7ca5893c8e264d62de0558186fa64
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/18.0/product_contract"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-18-0/contract-18-0-product_contract"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/19.0/product_contract"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-19-0/contract-19-0-product_contract"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module adds support for products to be linked to contract
379379
templates.</p>
380380
<p>A contract is created on <tt class="docutils literal">sale.order</tt> confirmation for each different
@@ -417,7 +417,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
417417
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/contract/issues">GitHub Issues</a>.
418418
In case of trouble, please check there if your issue has already been reported.
419419
If you spotted it first, help us to smash it by providing a detailed and welcomed
420-
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20product_contract%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
420+
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20product_contract%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
421421
<p>Do not contact contributors directly about support or help with technical issues.</p>
422422
</div>
423423
<div class="section" id="credits">
@@ -454,7 +454,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
454454
promote its widespread use.</p>
455455
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
456456
<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>
457-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/18.0/product_contract">OCA/contract</a> project on GitHub.</p>
457+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/19.0/product_contract">OCA/contract</a> project on GitHub.</p>
458458
<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>
459459
</div>
460460
</div>

product_contract/static/src/xml/sale_product_field.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<templates xml:space="preserve">
33

44
<t t-inherit="sale.SaleProductField" t-inherit-mode="extension">
5-
<xpath expr="//button[@t-if='hasExternalButton']" position="before">
5+
<xpath expr="//button[@t-on-click='onEditConfiguration']" position="before">
66
<t t-if="isConfigurableContract">
77
<button
88
type="button"

0 commit comments

Comments
 (0)