Skip to content

Commit 877c2f7

Browse files
[MIG] contract: Migration to 19.0
1 parent 2d7286e commit 877c2f7

16 files changed

+87
-190
lines changed

contract/README.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Recurring - Contracts Management
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/contract
24+
:target: https://github.com/OCA/contract/tree/19.0/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-contract
27+
:target: https://translation.odoo-community.org/projects/contract-19-0/contract-19-0-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|
@@ -98,9 +98,9 @@ Usage
9898

9999
|image2|
100100

101-
.. |image| image:: https://raw.githubusercontent.com/OCA/contract/18.0/contract/static/src/screenshots/portal-my.png
102-
.. |image1| image:: https://raw.githubusercontent.com/OCA/contract/18.0/contract/static/src/screenshots/portal-list.png
103-
.. |image2| image:: https://raw.githubusercontent.com/OCA/contract/18.0/contract/static/src/screenshots/portal-detail.png
101+
.. |image| image:: https://raw.githubusercontent.com/OCA/contract/19.0/contract/static/src/screenshots/portal-my.png
102+
.. |image1| image:: https://raw.githubusercontent.com/OCA/contract/19.0/contract/static/src/screenshots/portal-list.png
103+
.. |image2| image:: https://raw.githubusercontent.com/OCA/contract/19.0/contract/static/src/screenshots/portal-detail.png
104104

105105
Known issues / Roadmap
106106
======================
@@ -114,7 +114,7 @@ Bug Tracker
114114
Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/issues>`_.
115115
In case of trouble, please check there if your issue has already been reported.
116116
If you spotted it first, help us to smash it by providing a detailed and welcomed
117-
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
117+
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
118118

119119
Do not contact contributors directly about support or help with technical issues.
120120

@@ -158,6 +158,10 @@ Contributors
158158

159159
- Antoni Marroig <[email protected]>
160160

161+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
162+
163+
- Bhavesh Heliconia
164+
161165
Maintainers
162166
-----------
163167

@@ -171,6 +175,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
171175
mission is to support the collaborative development of Odoo features and
172176
promote its widespread use.
173177

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

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

contract/__manifest__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
# Copyright 2020 Tecnativa - Víctor Martínez
1010
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
1111

12+
1213
{
1314
"name": "Recurring - Contracts Management",
14-
"version": "18.0.2.0.6",
15+
"version": "19.0.1.0.0",
1516
"category": "Contract Management",
1617
"license": "AGPL-3",
1718
"author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)",
@@ -29,7 +30,6 @@
2930
"data/template_mail_notification.xml",
3031
"data/mail_message_subtype.xml",
3132
"data/ir_ui_menu.xml",
32-
"wizards/contract_manually_create_invoice.xml",
3333
"views/contract_tag.xml",
3434
"views/contract_template.xml",
3535
"views/contract_template_line.xml",
@@ -38,6 +38,7 @@
3838
"views/res_partner_view.xml",
3939
"views/res_config_settings.xml",
4040
"views/contract_portal_templates.xml",
41+
"wizards/contract_manually_create_invoice.xml",
4142
],
4243
"assets": {
4344
"web.assets_frontend": ["contract/static/src/scss/frontend.scss"],

contract/migrations/18.0.2.0.0/end-migrate.py

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

contract/migrations/18.0.2.0.0/pre-migrate.py

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

contract/models/contract.py

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

1414
from odoo import Command, api, fields, models
1515
from odoo.exceptions import ValidationError
16-
from odoo.osv import expression
1716

1817
_logger = logging.getLogger(__name__)
1918

@@ -237,7 +236,6 @@ def _onchange_contract_template_id(self):
237236
(
238237
field.compute,
239238
field.related,
240-
field.automatic,
241239
field.readonly,
242240
field.company_dependent,
243241
field.name in self.NO_SYNC,
@@ -661,7 +659,7 @@ def _cron_recurring_create(self, date_ref=False, create_type="invoice"):
661659
if not date_ref:
662660
date_ref = fields.Date.context_today(self)
663661
domain = self._get_contracts_to_invoice_domain(date_ref)
664-
domain = expression.AND(
662+
domain = fields.Domain.AND(
665663
[
666664
domain,
667665
[("generation_type", "=", create_type)],

contract/models/contract_line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ContractLine(models.Model):
2727
string="Contract",
2828
required=True,
2929
index=True,
30-
auto_join=True,
30+
bypass_search_access=True,
3131
ondelete="cascade",
3232
)
3333
currency_id = fields.Many2one(related="contract_id.currency_id")

contract/models/contract_template_line.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ class ContractTemplateLine(models.Model):
4242
readonly=False,
4343
)
4444
quantity = fields.Float(default=1.0, required=True)
45-
product_uom_category_id = fields.Many2one(
46-
comodel_name="uom.category",
47-
related="product_id.uom_id.category_id",
48-
readonly=True,
49-
)
45+
allowed_uom_ids = fields.Many2many("uom.uom", compute="_compute_allowed_uom_ids")
5046
uom_id = fields.Many2one(
5147
comodel_name="uom.uom",
5248
compute="_compute_uom_id",
5349
store=True,
5450
readonly=False,
5551
string="Unit of Measure",
56-
domain="[('category_id', '=', product_uom_category_id)]",
52+
domain="[('id', 'in', allowed_uom_ids)]",
5753
)
5854

5955
# === Pricing ===
@@ -153,13 +149,22 @@ def _compute_name(self):
153149
)
154150
line.name = product.get_product_multiline_description_sale()
155151

156-
@api.depends("product_id")
152+
@api.depends("product_id", "product_id.uom_id", "product_id.uom_ids")
153+
def _compute_allowed_uom_ids(self):
154+
for option in self:
155+
option.allowed_uom_ids = (
156+
option.product_id.uom_id | option.product_id.uom_ids
157+
)
158+
159+
@api.depends("product_id", "allowed_uom_ids")
157160
def _compute_uom_id(self):
158161
for line in self:
159-
if not line.uom_id or (
160-
line.product_id.uom_id.category_id.id != line.uom_id.category_id.id
161-
):
162+
if line.product_id and line.product_id.uom_id in line.allowed_uom_ids:
162163
line.uom_id = line.product_id.uom_id
164+
elif line.allowed_uom_ids:
165+
line.uom_id = line.allowed_uom_ids[0]
166+
else:
167+
line.uom_id = False
163168

164169
@api.depends("contract_id.contract_type")
165170
def _compute_automatic_price(self):

contract/models/res_partner.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,32 @@ def _get_partner_contract_domain(self):
2828

2929
def _compute_contract_count(self):
3030
contract_model = self.env["contract.contract"]
31-
fetch_data = contract_model.read_group(
32-
self._get_partner_contract_domain(),
33-
["partner_id", "contract_type"],
34-
["partner_id", "contract_type"],
35-
lazy=False,
31+
fetch_data = contract_model.formatted_read_group(
32+
domain=[("partner_id", "in", self.ids)],
33+
groupby=["partner_id", "contract_type"],
34+
aggregates=["__count"],
3635
)
37-
result = [
38-
[data["partner_id"][0], data["contract_type"], data["__count"]]
39-
for data in fetch_data
40-
]
4136
for partner in self:
4237
partner_child_ids = partner.child_ids.ids + partner.ids
4338
partner.sale_contract_count = sum(
44-
r[2] for r in result if r[0] in partner_child_ids and r[1] == "sale"
39+
d["__count"]
40+
for d in fetch_data
41+
if d["partner_id"][0] in partner_child_ids
42+
and d["contract_type"] == "sale"
4543
)
4644
partner.purchase_contract_count = sum(
47-
r[2] for r in result if r[0] in partner_child_ids and r[1] == "purchase"
45+
d["__count"]
46+
for d in fetch_data
47+
if d["partner_id"][0] in partner_child_ids
48+
and d["contract_type"] == "purchase"
4849
)
4950

5051
def act_show_contract(self):
5152
"""This opens contract view
5253
@return: the contract view
5354
"""
5455
self.ensure_one()
55-
contract_type = self._context.get("contract_type")
56+
contract_type = self.env.context.get("contract_type")
5657

5758
res = self._get_act_window_contract_xml(contract_type)
5859
action_context = {k: v for k, v in self.env.context.items() if k != "group_by"}

contract/readme/CONTRIBUTORS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525
- [APSL](https://www.apsl.tech):
2626

2727
> - Antoni Marroig \<<[email protected]>\>
28+
29+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
30+
> - Bhavesh Heliconia

contract/static/description/index.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Recurring - Contracts Management</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:9113fca91ae857348dfcda39b18ae300714b6e728492df9b1df80bfcf95f3ce6
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/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-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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/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-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 enables contracts management with recurring invoicing
379379
functions. Also you can print and send by email contract report.</p>
380380
<p>It works for customer contract and supplier contracts.</p>
@@ -441,9 +441,9 @@ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
441441
<ul class="simple">
442442
<li>Contracts appear in portal to following users in every contract:</li>
443443
</ul>
444-
<p><img alt="image" src="https://raw.githubusercontent.com/OCA/contract/18.0/contract/static/src/screenshots/portal-my.png" /></p>
445-
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/contract/18.0/contract/static/src/screenshots/portal-list.png" /></p>
446-
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/contract/18.0/contract/static/src/screenshots/portal-detail.png" /></p>
444+
<p><img alt="image" src="https://raw.githubusercontent.com/OCA/contract/19.0/contract/static/src/screenshots/portal-my.png" /></p>
445+
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/contract/19.0/contract/static/src/screenshots/portal-list.png" /></p>
446+
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/contract/19.0/contract/static/src/screenshots/portal-detail.png" /></p>
447447
</div>
448448
<div class="section" id="known-issues-roadmap">
449449
<h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
@@ -457,7 +457,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
457457
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/contract/issues">GitHub Issues</a>.
458458
In case of trouble, please check there if your issue has already been reported.
459459
If you spotted it first, help us to smash it by providing a detailed and welcomed
460-
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20contract%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
460+
<a class="reference external" href="https://github.com/OCA/contract/issues/new?body=module:%20contract%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
461461
<p>Do not contact contributors directly about support or help with technical issues.</p>
462462
</div>
463463
<div class="section" id="credits">
@@ -506,6 +506,13 @@ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
506506
</ul>
507507
</blockquote>
508508
</li>
509+
<li><p class="first"><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></p>
510+
<blockquote>
511+
<ul class="simple">
512+
<li>Bhavesh Heliconia</li>
513+
</ul>
514+
</blockquote>
515+
</li>
509516
</ul>
510517
</div>
511518
<div class="section" id="maintainers">
@@ -517,7 +524,7 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
517524
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
518525
mission is to support the collaborative development of Odoo features and
519526
promote its widespread use.</p>
520-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/18.0/contract">OCA/contract</a> project on GitHub.</p>
527+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/19.0/contract">OCA/contract</a> project on GitHub.</p>
521528
<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>
522529
</div>
523530
</div>

0 commit comments

Comments
 (0)