Skip to content

Commit

Permalink
[MIG] maintenance_equipment_usage: Migration to 17.0
Browse files Browse the repository at this point in the history
TT52302
  • Loading branch information
victoralmau committed Dec 19, 2024
1 parent be8862c commit 9c2407b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion maintenance_equipment_usage/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Maintenance Equipment Usage",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Maintenance",
"website": "https://github.com/OCA/maintenance",
"author": "César Fernández, Tecnativa, Odoo Community Association (OCA)",
Expand Down
18 changes: 0 additions & 18 deletions maintenance_equipment_usage/models/maintenance_equipment_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,39 @@ class MaintenanceEquipmentUsage(models.Model):
comodel_name="res.users",
string="User",
required=True,
readonly=True,
states={"draft": [("readonly", False)], "reserved": [("readonly", False)]},
tracking=True,
)
picking_user_id = fields.Many2one(
comodel_name="res.users",
string="Picked up by",
readonly=True,
states={"draft": [("readonly", False)], "reserved": [("readonly", False)]},
tracking=True,
)
return_user_id = fields.Many2one(
comodel_name="res.users",
string="Returned by",
states={
"in_use": [("required", True)],
"returned": [("readonly", True)],
"cancel": [("readonly", True)],
},
tracking=True,
)
date_picking = fields.Datetime(
string="Picking Date",
copy=False,
index=True,
readonly=True,
states={"draft": [("readonly", False)], "reserved": [("readonly", False)]},
tracking=True,
)
date_return = fields.Datetime(
string="Return Date",
copy=False,
index=True,
states={"returned": [("readonly", True)], "cancel": [("readonly", True)]},
tracking=True,
)
equipment_id = fields.Many2one(
comodel_name="maintenance.equipment",
string="Equipment",
required=True,
readonly=True,
states={"draft": [("readonly", False)], "reserved": [("readonly", False)]},
tracking=True,
)
partner_id = fields.Many2one(
comodel_name="res.partner",
string="Location",
readonly=True,
states={"draft": [("readonly", False)], "reserved": [("readonly", False)]},
tracking=True,
)
state = fields.Selection(
Expand All @@ -88,8 +72,6 @@ class MaintenanceEquipmentUsage(models.Model):
required=True,
index=True,
default=lambda self: self.env.company.id,
readonly=True,
states={"draft": [("readonly", False)], "reserved": [("readonly", False)]},
tracking=True,
)
notes = fields.Text()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ class TestMaintenanceEquipmentUsage(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.user = new_test_user(
cls.env,
login="test_basic_user",
)
cls.user = new_test_user(cls.env, login="test_basic_user")
cls.equipment = cls.env["maintenance.equipment"].create(
{"name": "Test equipment"}
)
cls.equipment_usage = cls._create_equipment_usage(cls)
cls.equipment_usage = cls._create_equipment_usage()

def _create_equipment_usage(self):
equipment_usage_form = Form(self.env["maintenance.equipment.usage"])
equipment_usage_form.equipment_id = self.equipment
equipment_usage_form.user_id = self.user
@classmethod
def _create_equipment_usage(cls):
equipment_usage_form = Form(cls.env["maintenance.equipment.usage"])
equipment_usage_form.equipment_id = cls.equipment
equipment_usage_form.user_id = cls.user
return equipment_usage_form.save()

def test_maintenance_equipment_full_process(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
<header>
<button
name="action_pick"
states="draft,reserved"
invisible="state not in ('draft','reserved')"
string="Pick"
type="object"
class="oe_highlight"
/>
<button
name="action_return"
states="in_use"
invisible="state!='in_use'"
string="Return"
type="object"
class="oe_highlight"
/>
<button
name="action_cancel"
states="draft,reserved,in_use"
invisible="state not in ('draft','reserved','in_use')"
string="Cancel"
type="object"
/>
Expand All @@ -51,13 +51,23 @@
</div>
<group>
<group>
<field name="user_id" />
<field name="equipment_id" />
<field
name="user_id"
readonly="state not in ('draft','reserved')"
/>
<field
name="equipment_id"
readonly="state not in ('draft','reserved')"
/>
</group>
<group>
<field name="partner_id" />
<field
name="partner_id"
readonly="state not in ('draft','reserved')"
/>
<field
name="company_id"
readonly="state not in ('draft','reserved')"
groups="base.group_multi_company"
/>
</group>
Expand All @@ -67,16 +77,26 @@
<field name="create_date" invisible="1" />
<field
name="picking_user_id"
attrs="{'required': [('create_date', '!=', False)]}"
readonly="state not in ('draft','reserved')"
required="create_date"
/>
<field
name="return_user_id"
states="in_use,returned,cancel"
required="state=='in_use'"
readonly="state in ('returned','cancel')"
invisible="state not in ('in_use','returned','cancel')"
/>
</group>
<group>
<field name="date_picking" />
<field name="date_return" states="in_use,returned,cancel" />
<field
name="date_picking"
readonly="state not in ('draft','reserved')"
/>
<field
name="date_return"
readonly="state in ('returned','cancel')"
invisible="state not in ('in_use','returned','cancel')"
/>
</group>
</group>
<separator string="Notes" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<span
groups="maintenance.group_equipment_manager"
class="label label-primary"
attrs="{'invisible': [('in_use', '=', False)]}"
invisible="not in_use"
>In use</span>
</xpath>
</field>
Expand All @@ -38,7 +38,7 @@
<span
groups="maintenance.group_equipment_manager"
class="label label-primary"
attrs="{'invisible': [('in_use', '=', False)]}"
invisible="not in_use"
>In use</span>
</xpath>
</field>
Expand Down

0 comments on commit 9c2407b

Please sign in to comment.