From 77ea08ce09f6629886cb4f40d6a71fa5024f1171 Mon Sep 17 00:00:00 2001 From: Andrea Cometa Date: Fri, 25 Oct 2024 18:04:50 +0200 Subject: [PATCH] [IMP] moving readonly fields mgmt to view --- business_requirement/models/business.py | 45 +++++++------------- business_requirement/views/business_view.xml | 29 +++++++------ 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/business_requirement/models/business.py b/business_requirement/models/business.py index c7065a39..1ee8da50 100644 --- a/business_requirement/models/business.py +++ b/business_requirement/models/business.py @@ -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=[ @@ -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")], @@ -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( @@ -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( @@ -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() @@ -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( diff --git a/business_requirement/views/business_view.xml b/business_requirement/views/business_view.xml index f3887ea4..8ccf9167 100644 --- a/business_requirement/views/business_view.xml +++ b/business_requirement/views/business_view.xml @@ -44,16 +44,16 @@ />

- - - + - +

- - - - + + + + - + + readonly="state not in ['draft']" + /> - + - + - + @@ -104,11 +106,12 @@ - - + +