Skip to content

Commit

Permalink
fix state (#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
danila12 authored Jul 11, 2024
1 parent cf64335 commit d5d4d24
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ addon | version | maintainers | summary | price
[deltatech_service_consumable](deltatech_service_consumable/) | 14.0.1.1.3 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Service Consumable | Free
[deltatech_service_equipment](deltatech_service_equipment/) | 14.0.1.2.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Service Equipment Management | Free
[deltatech_service_equipment_base](deltatech_service_equipment_base/) | 14.0.1.1.3 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Service Equipment Management | Free
[deltatech_service_maintenance](deltatech_service_maintenance/) | 14.0.1.0.8 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Services Maintenance | Free
[deltatech_service_maintenance](deltatech_service_maintenance/) | 14.0.1.0.9 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Services Maintenance | Free
[deltatech_service_maintenance_agreement](deltatech_service_maintenance_agreement/) | 14.0.1.0.4 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Services Maintenance | Free
[deltatech_service_maintenance_plan](deltatech_service_maintenance_plan/) | 14.0.1.0.6 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Services Maintenance Plan | Free
[deltatech_sms](deltatech_sms/) | 14.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Send SMS to custom endpoint | Free
Expand Down
2 changes: 1 addition & 1 deletion deltatech_service_maintenance/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Deltatech Services Maintenance
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:db844b4f79e8c19bb5fabd0b6cf7a51526519c8b1dec193efe3c0e7cc660023d
!! source digest: sha256:23b816926a33b01ce8ca46721b20bd7ed353f128fdb84792123fffa032fce016
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down
2 changes: 1 addition & 1 deletion deltatech_service_maintenance/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Deltatech Services Maintenance",
"summary": "Services Maintenance",
"version": "14.0.1.0.8",
"version": "14.0.1.0.9",
"author": "Terrabit, Dorin Hongu",
"website": "https://www.terrabit.ro",
"category": "Services/Maintenance",
Expand Down
6 changes: 6 additions & 0 deletions deltatech_service_maintenance/i18n/ro.po
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,12 @@ msgstr "Lucru efectuat"
msgid "You must have an agreement."
msgstr ""

#. module: deltatech_service_maintenance
#: code:addons/deltatech_service_maintenance/models/service_warranty.py:0
#, python-format
msgid "Your user cannot change the state directly"
msgstr "Acest utilizator nu poate modifica direct status-ul"

#. module: deltatech_service_maintenance
#: model:service.operating.parameter,name:deltatech_service_maintenance.equi_work_again
msgid "the defect was fixed equipment works"
Expand Down
27 changes: 13 additions & 14 deletions deltatech_service_maintenance/models/service_warranty.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class ServiceWarranty(models.Model):
string="Status",
tracking=True,
)
state_editable = fields.Boolean(compute="_compute_state_editable")
equipment_id = fields.Many2one(
"service.equipment", string="Equipment", index=True, readonly=True, states={"new": [("readonly", False)]}
)
Expand All @@ -51,13 +50,6 @@ class ServiceWarranty(models.Model):
copy=True,
)

def _compute_state_editable(self):
for warranty in self:
if self.env.user.has_group("deltatech_service.group_warranty_manager"):
warranty.state_editable = True
else:
warranty.state_editable = False

@api.onchange("equipment_id")
def onchange_equipment_id(self):
if self.equipment_id:
Expand Down Expand Up @@ -150,31 +142,38 @@ def new_delivery_button(self):
@api.onchange("user_id")
def set_assigned(self):
if self.state == "new" and self.user_id:
self.state = "assigned"
self.with_context(change_ok=True).write({"state": "assigned"})
if self.name == "/":
self.name = self.env["ir.sequence"].next_by_code("service.warranty")

def set_new(self):
if self.state == "assigned":
self.state = "new"
self.with_context(change_ok=True).write({"state": "new"})
self.user_id = False
if self.name == "/":
self.name = self.env["ir.sequence"].next_by_code("service.warranty")

def set_in_progress(self):
if self.state == "assigned" and self.user_id:
self.state = "progress"
self.with_context(change_ok=True).write({"state": "progress"})
if self.name == "/":
self.name = self.env["ir.sequence"].next_by_code("service.warranty")

def request_approval(self):
self.state = "approval_requested"
self.with_context(change_ok=True).write({"state": "approval_requested"})

def approve(self):
self.state = "approved"
self.with_context(change_ok=True).write({"state": "approved"})

def set_done(self):
self.state = "done"
self.with_context(change_ok=True).write({"state": "done"})

@api.onchange("state")
def check_if_ok(self):
if not self.env.user.has_group("deltatech_service.group_warranty_manager") and not self.env.context.get(
"change_ok", False
):
raise UserError(_("Your user cannot change the state directly"))


class ServiceWarrantyItem(models.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h1 class="title">Deltatech Services Maintenance</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:db844b4f79e8c19bb5fabd0b6cf7a51526519c8b1dec193efe3c0e7cc660023d
!! source digest: sha256:23b816926a33b01ce8ca46721b20bd7ed353f128fdb84792123fffa032fce016
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/dhongu/deltatech/tree/14.0/deltatech_service_maintenance"><img alt="dhongu/deltatech" src="https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github" /></a></p>
<dl class="docutils">
Expand Down

0 comments on commit d5d4d24

Please sign in to comment.