Skip to content

Commit 4778f55

Browse files
committed
[MIG] agreement_serviceprofile: Migration to 16.0
1 parent 35c9508 commit 4778f55

File tree

9 files changed

+49
-47
lines changed

9 files changed

+49
-47
lines changed

Diff for: agreement_serviceprofile/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Agreement Service Profile",
66
"summary": "Adds an Agreement Service Profile object",
7-
"version": "14.0.1.1.1",
7+
"version": "16.0.1.0.0",
88
"category": "Contract",
99
"author": "Pavlov Media, "
1010
"Open Source Integrators, "
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from openupgradelib import openupgrade
2+
3+
4+
@openupgrade.migrate()
5+
def migrate(env, version):
6+
openupgrade.logged_query(
7+
env.cr,
8+
"""UPDATE product_template SET detailed_type = 'serviceprofile'
9+
WHERE is_service_profile IS TRUE""",
10+
)

Diff for: agreement_serviceprofile/models/agreement_serviceprofile.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@ def _default_stage_id(self):
3232
product_id = fields.Many2one(
3333
"product.template",
3434
"Service Product",
35-
domain="[('is_serviceprofile', '=', True), ('type', '=', 'service')]",
35+
domain="[('detailed_type', '=', 'serviceprofile'), ('type', '=', 'service')]",
3636
)
3737
product_variant_id = fields.Many2one(
3838
"product.product",
3939
"Service Product Variant",
40-
domain="[('is_serviceprofile', '=', True), ('type', '=', 'service')]",
40+
domain="[('detailed_type', '=', 'serviceprofile'), ('type', '=', 'service')]",
4141
)
4242
use_product_variant = fields.Boolean(default=False)
4343
partner_id = fields.Many2one(related="agreement_id.partner_id", string="Partner")
4444

4545
# Used for Kanban grouped_by view
4646
@api.model
4747
def _read_group_stage_ids(self, stages, domain, order):
48-
stage_ids = self.env["agreement.stage"].search(
49-
[("stage_type", "=", "serviceprofile")]
50-
)
48+
stage_ids = stages.search([("stage_type", "=", "serviceprofile")], order=order)
5149
return stage_ids

Diff for: agreement_serviceprofile/models/product.py

+10-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,20 @@
11
# Copyright (C) 2019 - TODAY, Open Source Integrators
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33

4-
from odoo import api, fields, models
4+
from odoo import fields, models
55

66

77
class ProductTemplate(models.Model):
88
_inherit = "product.template"
99

10-
is_serviceprofile = fields.Boolean(
11-
string="Create Service Profiles",
12-
help="""If True, this product will create a service profile on the
13-
agreement when the sales order is confirmed.""",
10+
detailed_type = fields.Selection(
11+
selection_add=[
12+
("serviceprofile", "Service Profile"),
13+
],
14+
ondelete={"serviceprofile": "set service"},
1415
)
1516

16-
@api.onchange("is_serviceprofile")
17-
def onchange_type(self):
18-
if self.is_serviceprofile:
19-
self.type = "service"
20-
21-
22-
class ProductProduct(models.Model):
23-
_inherit = "product.product"
24-
25-
is_serviceprofile = fields.Boolean(
26-
string="Create Service Profiles",
27-
help="""If True, this product will create a service profile on the
28-
agreement when the sales order is confirmed.""",
29-
)
30-
31-
@api.onchange("is_serviceprofile")
32-
def onchange_type(self):
33-
if self.is_serviceprofile:
34-
self.type = "service"
17+
def _detailed_type_mapping(self):
18+
type_mapping = super()._detailed_type_mapping()
19+
type_mapping["serviceprofile"] = "service"
20+
return type_mapping

Diff for: agreement_serviceprofile/static/description/index.html

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
/*
1010
:Author: David Goodger ([email protected])
11-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1516
1617
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1718
customize this style sheet.
@@ -274,7 +275,7 @@
274275
margin-left: 2em ;
275276
margin-right: 2em }
276277

277-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
278279
pre.code, code { background-color: #eeeeee }
279280
pre.code .comment, code .comment { color: #5C6576 }
280281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
300301
span.pre {
301302
white-space: pre }
302303

303-
span.problematic {
304+
span.problematic, pre.problematic {
304305
color: red }
305306

306307
span.section-subtitle {
@@ -431,7 +432,9 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
431432
<div class="section" id="maintainers">
432433
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
433434
<p>This module is maintained by the OCA.</p>
434-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
435+
<a class="reference external image-reference" href="https://odoo-community.org">
436+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
437+
</a>
435438
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
436439
mission is to support the collaborative development of Odoo features and
437440
promote its widespread use.</p>

Diff for: agreement_serviceprofile/tests/test_product.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ def setUp(self):
1414
# TEST 01: Test onchange_type product.template
1515
def test_product_template_onchange_type(self):
1616
product_01 = self.test_product1
17-
product_01.is_serviceprofile = True
18-
product_01.onchange_type()
17+
product_01.detailed_type = "serviceprofile"
18+
product_01.flush_recordset()
1919
self.assertEqual(product_01.type, "service")
2020

2121
# TEST 02: Test onchange_type product.product
2222
def test_product_product_onchange_type(self):
2323
product_02 = self.test_product2
24-
product_02.is_serviceprofile = True
25-
product_02.onchange_type()
24+
product_02.detailed_type = "serviceprofile"
2625
self.assertEqual(product_02.type, "service")

Diff for: agreement_serviceprofile/views/agreement.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
<field name="use_product_variant" />
2828
<field
2929
name="product_variant_id"
30-
context="{'default_is_serviceprofile': True, 'default_type': 'service'}"
30+
context="{'default_detailed_type': 'serviceprofile', 'default_type': 'service'}"
3131
attrs="{'invisible': [('use_product_variant', '=', False)], 'required': [('use_product_variant','!=', False)]}"
3232
/>
3333
<field
3434
name="product_id"
35-
context="{'default_is_serviceprofile': True, 'default_type': 'service'}"
35+
context="{'default_detailed_type': 'serviceprofile', 'default_type': 'service'}"
3636
attrs="{'invisible': [('use_product_variant', '!=', False)], 'required': [('use_product_variant','=', False)]}"
3737
/>
3838
</group>

Diff for: agreement_serviceprofile/views/agreement_serviceprofile.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@
5353
<group>
5454
<field
5555
name="product_id"
56-
context="{'default_is_serviceprofile': True, 'default_type': 'service'}"
56+
context="{'default_detailed_type': 'serviceprofile', 'default_type': 'service'}"
5757
attrs="{'invisible': [('use_product_variant', '!=', False)], 'required': [('use_product_variant','=', False)]}"
5858
/>
5959
<field
6060
name="product_variant_id"
61-
context="{'default_is_serviceprofile': True, 'default_type': 'service'}"
61+
context="{'default_detailed_type': 'serviceprofile', 'default_type': 'service'}"
6262
attrs="{'invisible': [('use_product_variant', '=', False)], 'required': [('use_product_variant','!=', False)]}"
6363
/>
6464
<field name="use_product_variant" />
6565
</group>
6666
</group>
6767
<group string="Notes">
68-
<field name="notes" nolabel="1" widget="html" />
68+
<field name="notes" nolabel="1" widget="html" colspan="2" />
6969
</group>
7070
</sheet>
7171
<div class="oe_chatter">

Diff for: agreement_serviceprofile/views/product.xml

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
<field name="inherit_id" ref="product.product_template_form_view" />
1010
<field name="arch" type="xml">
1111
<xpath expr="//notebook" position="inside">
12-
<page id="agreement" string="Service">
12+
<page
13+
id="agreement"
14+
string="Service"
15+
attrs="{'invisible': [('detailed_type', '!=', 'serviceprofile')]}"
16+
>
1317
<group>
1418
<group id="agreement_left">
15-
<field name="is_serviceprofile" />
1619
</group>
1720
<group id="agreement_right" />
1821
</group>
@@ -28,10 +31,13 @@
2831
<field name="inherit_id" ref="product.product_normal_form_view" />
2932
<field name="arch" type="xml">
3033
<xpath expr="//notebook" position="inside">
31-
<page id="agreement" string="Service">
34+
<page
35+
id="agreement"
36+
string="Service"
37+
attrs="{'invisible': [('detailed_type', '!=', 'serviceprofile')]}"
38+
>
3239
<group>
3340
<group id="agreement_left">
34-
<field name="is_serviceprofile" />
3541
</group>
3642
<group id="agreement_right" />
3743
</group>

0 commit comments

Comments
 (0)