Skip to content

Commit

Permalink
[IMP] moving readonly fields mgmt to view
Browse files Browse the repository at this point in the history
  • Loading branch information
scigghia committed Oct 25, 2024
1 parent cc54f32 commit 77ea08c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 42 deletions.
45 changes: 16 additions & 29 deletions business_requirement/models/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,34 @@ class BusinessRequirement(models.Model):

sequence = fields.Char(readonly=True, copy=False, index=True)
name = fields.Char(
readonly=True,
readonly=False,
copy=False,
states={"draft": [("readonly", False)]},
default='/'
)
description = fields.Char(
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
readonly=False,
)
business_requirement = fields.Html(
string="Customer Story", readonly=True, states={"draft": [("readonly", False)]}
string="Customer Story", readonly=False
)
scenario = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
readonly=False,
)
gap = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
readonly=False,
)
test_case = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
readonly=False,
)
terms_and_conditions = fields.Html(
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
readonly=False,
)
category_ids = fields.Many2many(
comodel_name="business.requirement.category",
string="Categories",
relation="business_requirement_category_rel",
readonly=True,
states={"draft": [("readonly", False)]},
readonly=False,
)
state = fields.Selection(
selection=[
Expand All @@ -62,18 +56,16 @@ 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?", readonly=False
)
partner_id = fields.Many2one(
comodel_name="res.partner",
string="Stakeholder",
copy=False,
readonly=True,
states={"draft": [("readonly", False)]},
readonly=False,
)
priority = fields.Selection(
selection=[("0", "Low"), ("1", "Normal"), ("2", "High")],
Expand All @@ -84,9 +76,8 @@ class BusinessRequirement(models.Model):
comodel_name="res.users",
string="Requested by",
required=True,
readonly=True,
readonly=False,
default=lambda self: self.env.user,
states={"draft": [("readonly", False)], "confirmed": [("readonly", False)]},
)
confirmation_date = fields.Datetime(copy=False, readonly=True)
confirmed_user_id = fields.Many2one(
Expand All @@ -96,16 +87,14 @@ class BusinessRequirement(models.Model):
comodel_name="res.users",
string="Responsible",
copy=False,
readonly=True,
readonly=False,
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)]},
readonly=False,
)
approval_date = fields.Datetime(copy=False, readonly=True)
approved_id = fields.Many2one(
Expand All @@ -115,8 +104,7 @@ class BusinessRequirement(models.Model):
comodel_name="res.company",
string="Company",
required=True,
readonly=True,
states={"draft": [("readonly", False)]},
readonly=False,
default=lambda self: self.env.company,
)
to_be_reviewed = fields.Boolean()
Expand All @@ -131,8 +119,7 @@ class BusinessRequirement(models.Model):
)
origin = fields.Char(
string="Source",
readonly=True,
states={"draft": [("readonly", False)], "confirmed": [("readonly", True)]},
readonly=False,
)
portal_published = fields.Boolean("In Portal", default=False)
user_id = fields.Many2one(
Expand Down
29 changes: 16 additions & 13 deletions business_requirement/views/business_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
/>
</div>
<h1>
<field name="name" class="oe_inline" readonly="1" /> -
<field name="description" default_focus="1" />
<field name="name" class="oe_inline" readonly="state not in ['draft']" /> -
<field name="description" default_focus="1" readonly="state not in ['draft']" />
</h1>
<group col="4">
<field name="responsible_user_id" required="1" />
<field name="partner_id" />
<field name="origin" />
<field name="category_ids" widget="many2many_tags" />
<field name="responsible_user_id" required="1" readonly="state not in ['draft', 'confirmed']" />
<field name="partner_id" readonly="state not in ['draft']" />
<field name="origin" readonly="state not in ['draft']" />
<field name="category_ids" widget="many2many_tags" readonly="state not in ['draft']" />
<field name="to_be_reviewed" />
<field name="reviewer_ids" widget="many2many_tags" />
<field name="reviewer_ids" widget="many2many_tags" readonly="state not in ['draft', 'confirmed']" />
<field
name="priority"
groups="base.group_user"
Expand All @@ -67,22 +67,24 @@
name="business_requirement"
nolabel="1"
colspan="2"
/>
readonly="state not in ['draft']"
/>
</group>
<group string="Scenario">
<field name="scenario" nolabel="1" colspan="2" />
<field name="scenario" nolabel="1" colspan="2" readonly="state not in ['draft', 'confirmed']" />
</group>
<group string="Gap">
<field name="gap" nolabel="1" colspan="2" />
<field name="gap" nolabel="1" colspan="2" readonly="state not in ['draft', 'confirmed']" />
</group>
<group string="Test Case">
<field name="test_case" nolabel="1" colspan="2" />
<field name="test_case" nolabel="1" colspan="2" readonly="state not in ['draft', 'confirmed']" />
</group>
<group string="Terms and Conditions">
<field
name="terms_and_conditions"
nolabel="1"
colspan="2"
readonly="state not in ['draft', 'confirmed']"
/>
</group>
</page>
Expand All @@ -104,11 +106,12 @@
</page>
<page string="Other" name="other">
<group col="4">
<field name="requested_user_id" />
<field name="change_request" />
<field name="requested_user_id" readonly="state not in ['draft', 'confirmed']" />
<field name="change_request" readonly="state not in ['draft']" />
<field
name="company_id"
groups="base.group_multi_company"
readonly="state not in ['draft']"
/>
</group>
</page>
Expand Down

0 comments on commit 77ea08c

Please sign in to comment.