Skip to content

Commit

Permalink
[MIG] business_requirement: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoAlesLopez committed Apr 28, 2024
1 parent 8952617 commit 34c40fd
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 139 deletions.
4 changes: 2 additions & 2 deletions business_requirement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"category": "Business Requirements Management",
"summary": "Manage the Business Requirements (stories, scenarios, gaps\
and test cases) for your customers",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"website": "https://github.com/OCA/business-requirement",
"author": "Elico Corp, Tecnativa, Odoo Community Association (OCA)",
"depends": ["product", "portal"],
Expand Down Expand Up @@ -35,7 +35,7 @@
],
"assets": {
"web.assets_tests": [
"/business_requirement/static/src/js/business_requirement_portal_tour.js",
"/business_requirement/static/tests/tours/**/*",
],
},
"demo": ["data/business_requirement_demo.xml"],
Expand Down
113 changes: 31 additions & 82 deletions business_requirement/models/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,24 @@ class BusinessRequirement(models.Model):
_description = "Business Requirement"
_order = "name desc"

sequence = fields.Char(readonly=True, copy=False, index=True)
sequence = fields.Char(copy=False, index=True)
name = fields.Char(
readonly=True,
copy=False,
states={"draft": [("readonly", False)]},
)
description = fields.Char(
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
)
business_requirement = fields.Html(
string="Customer Story", readonly=True, states={"draft": [("readonly", False)]}
)
scenario = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
)
gap = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
)
test_case = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
)
terms_and_conditions = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
string="Customer Story",
)
scenario = fields.Html()
gap = fields.Html()
test_case = fields.Html()
terms_and_conditions = fields.Html()
category_ids = fields.Many2many(
comodel_name="business.requirement.category",
string="Categories",
relation="business_requirement_category_rel",
readonly=True,
states={"draft": [("readonly", False)]},
)
state = fields.Selection(
selection=[
Expand All @@ -61,19 +43,15 @@ class BusinessRequirement(models.Model):
],
default="draft",
copy=False,
readonly=False,
states={"draft": [("readonly", False)]},
tracking=True,
)
change_request = fields.Boolean(
string="Change Request?", readonly=True, states={"draft": [("readonly", False)]}
string="Change Request?",
)
partner_id = fields.Many2one(
comodel_name="res.partner",
string="Stakeholder",
copy=False,
readonly=True,
states={"draft": [("readonly", False)]},
)
priority = fields.Selection(
selection=[("0", "Low"), ("1", "Normal"), ("2", "High")],
Expand All @@ -84,39 +62,39 @@ class BusinessRequirement(models.Model):
comodel_name="res.users",
string="Requested by",
required=True,
readonly=True,
default=lambda self: self.env.user,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
)
confirmation_date = fields.Datetime(copy=False, readonly=True)
confirmation_date = fields.Datetime(
copy=False,
)
confirmed_user_id = fields.Many2one(
comodel_name="res.users", string="Confirmed by", copy=False, readonly=True
comodel_name="res.users",
string="Confirmed by",
copy=False,
)
responsible_user_id = fields.Many2one(
comodel_name="res.users",
string="Responsible",
copy=False,
readonly=True,
default=lambda self: self.env.user,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
)
reviewer_ids = fields.Many2many(
comodel_name="res.users",
string="Reviewers",
copy=False,
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
)
approval_date = fields.Datetime(copy=False, readonly=True)
approval_date = fields.Datetime(
copy=False,
)
approved_id = fields.Many2one(
comodel_name="res.users", string="Approved by", copy=False, readonly=True
comodel_name="res.users",
string="Approved by",
copy=False,
)
company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
default=lambda self: self.env.company,
)
to_be_reviewed = fields.Boolean()
Expand All @@ -131,10 +109,11 @@ class BusinessRequirement(models.Model):
)
origin = fields.Char(
string="Source",
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", True)]},
)
portal_published = fields.Boolean("In Portal", default=False)
portal_published = fields.Boolean(
"In Portal",
default=False,
)
user_id = fields.Many2one(
comodel_name="res.users",
string="Owner",
Expand All @@ -150,7 +129,7 @@ class BusinessRequirement(models.Model):
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get("name", "/") == "/":
if not vals.get("name"):
vals["name"] = self.env["ir.sequence"].next_by_code(
"business.requirement"
)
Expand Down Expand Up @@ -194,15 +173,12 @@ def write(self, vals):
)
return super().write(vals)

def name_get(self):
"""
Display display [Name] Description
"""
result = []
for br in self:
formatted_name = f"[{br.name}] {br.description}"
result.append((br.id, formatted_name))
return result
@api.depends("name", "description")
def _compute_display_name(self):
for business_requirement in self:
business_requirement.display_name = (
f"[{business_requirement.name}] {business_requirement.description}"
)

@api.model
def name_search(self, name, args=None, operator="ilike", limit=100):
Expand All @@ -222,20 +198,6 @@ def name_search(self, name, args=None, operator="ilike", limit=100):
@api.returns("mail.message", lambda value: value.id)
def message_post(
self,
body="",
subject=None,
message_type="notification",
email_from=None,
author_id=None,
parent_id=False,
subtype_xmlid=None,
subtype_id=None,
partner_ids=None,
channel_ids=None,
attachments=None,
attachment_ids=None,
add_sign=True,
record_name=False,
**kwargs,
):
context = self._context or {}
Expand All @@ -245,23 +207,10 @@ def message_post(
br_rec = self.env[context.get("default_model")].browse(
context["default_res_id"]
)
subject = f"Re: {br_rec.name}-{br_rec.description}"
kwargs["subject"] = f"Re: {br_rec.name}-{br_rec.description}"
message = super(
BusinessRequirement, self.with_context(mail_create_nosubscribe=True)
).message_post(
body=body,
subject=subject,
message_type=message_type,
email_from=email_from,
author_id=author_id,
parent_id=parent_id,
subtype_xmlid=subtype_xmlid,
subtype_id=subtype_id,
partner_ids=partner_ids,
attachments=attachments,
attachment_ids=attachment_ids,
add_sign=add_sign,
record_name=record_name,
**kwargs,
)
return message
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @odoo-module */

import {registry} from "@web/core/registry";

registry.category("web_tour.tours").add("business_requirement_portal_tour", {
test: true,
url: "/my",
steps: () => [
{
content: "Go /my/business_requirements url",
trigger: 'a[href*="/my/business_requirements"]',
},
{
content: "Go to BR item",
trigger: ".tr_br_link:eq(0)",
},
],
});
12 changes: 6 additions & 6 deletions business_requirement/tests/test_br.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from odoo.tests import common


class BusinessRequirementTestBase(common.SavepointCase):
class BusinessRequirementTestBase(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand All @@ -27,14 +27,14 @@ def test_message_post(self):
)
self.assertEqual(self.message.subject, f"Re: {self.br.name}-test")

def test_br_name_search(self):
br_vals = {"name": " test", "description": "test"}
self.br.create(br_vals)
self.assertTrue(self.br.name_search(name="test"))
def test_br_display_name(self):
br_vals = {"name": "test", "description": "test"}
self.br.write(br_vals)
self.assertEqual(self.br.display_name, "[test] test")

def test_create_name_sequence(self):
name = self.env["ir.sequence"].next_by_code("business.requirement")
br_vals = {"name": "/", "description": "test"}
br_vals = {"name": False, "description": "test"}
len_seq = name[2:]
seq = "BR" + str(int(len_seq) + 1).zfill(int(len(len_seq)))
res = self.BR.create(br_vals)
Expand Down
2 changes: 1 addition & 1 deletion business_requirement/tests/test_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def setUp(self):
super().setUp()

def test_tour(self):
self.start_tour("/", "business_requirement_portal_tour", login="portal")
self.start_tour("/my", "business_requirement_portal_tour", login="portal")
2 changes: 1 addition & 1 deletion business_requirement/views/br_portal_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<t t-else="">Business Requirements</t>
</li>
<li t-if="business_requirement" class="breadcrumb-item active">
<t t-esc="business_requirement.name" />
<t t-out="business_requirement.name" />
</li>
</xpath>
</template>
Expand Down
8 changes: 4 additions & 4 deletions business_requirement/views/br_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</td>
<td>
<span
t-esc="', '.join([cate.name for cate in o.category_ids])"
t-out="', '.join([cate.name for cate in o.category_ids])"
/>
</td>
</tr>
Expand All @@ -54,7 +54,7 @@
<strong>Date</strong>
</td>
<td>
<span t-field="o.date" t-field-options='{"widget": "date"}' />
<span t-field="o.date" t-options='{"widget": "date"}' />
<t t-if="o.user_id">(<span t-field="o.user_id.name" />)</t>
</td>
</tr>
Expand All @@ -65,7 +65,7 @@
<td>
<span
t-field="o.confirmation_date"
t-field-options='{"widget": "date"}'
t-options='{"widget": "date"}'
/>
<t t-if="o.confirmed_user_id">(<span
t-field="o.confirmed_user_id.name"
Expand All @@ -79,7 +79,7 @@
<td>
<span
t-field="o.approval_date"
t-field-options='{"widget": "date"}'
t-options='{"widget": "date"}'
/>
<t t-if="o.approved_id">(<span
t-field="o.approved_id.name"
Expand Down
Loading

0 comments on commit 34c40fd

Please sign in to comment.