-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by LoisRForgeFlow
- Loading branch information
Showing
16 changed files
with
806 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
==================== | ||
Repair Type Sequence | ||
==================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:8e7d37690be266473425c4c06979f3c361d035030453f337cd7ffe0070481a53 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Alpha | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frepair-lightgray.png?logo=github | ||
:target: https://github.com/OCA/repair/tree/16.0/repair_type_sequence | ||
:alt: OCA/repair | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/repair-16-0/repair-16-0-repair_type_sequence | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/repair&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module introduces a sequence to the repair type that will be influence the numbering in the repair orders. | ||
|
||
.. IMPORTANT:: | ||
This is an alpha version, the data model and design can change at any time without warning. | ||
Only for development or testing purpose, do not use in production. | ||
`More details on development status <https://odoo-community.org/page/development-status>`_ | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/repair/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/repair/issues/new?body=module:%20repair_type_sequence%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* ForgeFlow S.L. | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Aaron Henriquez [email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
.. |maintainer-AaronHForgeFlow| image:: https://github.com/AaronHForgeFlow.png?size=40px | ||
:target: https://github.com/AaronHForgeFlow | ||
:alt: AaronHForgeFlow | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-AaronHForgeFlow| | ||
|
||
This module is part of the `OCA/repair <https://github.com/OCA/repair/tree/16.0/repair_type_sequence>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 ForgeFlow S.L. (https://forgeflow.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Repair Type Sequence", | ||
"summary": """ | ||
Adds sequence to repair orders defined in the repairs's | ||
type""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "ForgeFlow S.L.," "Odoo Community Association (OCA)", | ||
"maintainers": ["AaronHForgeFlow"], | ||
"website": "https://github.com/OCA/repair", | ||
"depends": ["repair_type"], | ||
"development_status": "Alpha", | ||
"data": ["views/repair_type_views.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * repair_type_sequence | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model.fields,field_description:repair_type_sequence.field_repair_type__sequence_id | ||
msgid "Entry Sequence" | ||
msgstr "" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model.fields,field_description:repair_type_sequence.field_repair_type__sequence_number_next | ||
msgid "Next Number" | ||
msgstr "" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model,name:repair_type_sequence.model_repair_order | ||
msgid "Repair Order" | ||
msgstr "" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model,name:repair_type_sequence.model_repair_type | ||
msgid "Repair Type" | ||
msgstr "" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model.fields,field_description:repair_type_sequence.field_repair_type__sequence_prefix | ||
msgid "Sequence Prefix" | ||
msgstr "" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model.fields,help:repair_type_sequence.field_repair_type__sequence_number_next | ||
msgid "The next sequence number will be used for the next rorder." | ||
msgstr "" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model.fields,help:repair_type_sequence.field_repair_type__sequence_prefix | ||
msgid "The rorder's sequence will be created using this prefix." | ||
msgstr "" | ||
|
||
#. module: repair_type_sequence | ||
#: model:ir.model.fields,help:repair_type_sequence.field_repair_type__sequence_id | ||
msgid "" | ||
"This field contains the information related to the numbering of the rorders " | ||
"belonging to this rtype." | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import repair_type | ||
from . import repair_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2023 ForgeFlow S.L. (https://forgeflow.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class RepairOrder(models.Model): | ||
_inherit = "repair.order" | ||
|
||
@api.model | ||
def create(self, vals): | ||
rorder = super(RepairOrder, self).create(vals) | ||
if rorder.repair_type_id: | ||
sequence_id = ( | ||
self.env["repair.type"].browse(vals["repair_type_id"]).sequence_id | ||
) | ||
if sequence_id: | ||
rorder.name = sequence_id._next() | ||
return rorder | ||
|
||
def write(self, vals): | ||
res = False | ||
for rec in self: | ||
new_rtype_id = vals.get("repair_type_id", False) | ||
new_rtype = self.env["repair.type"].browse(new_rtype_id) | ||
if new_rtype and new_rtype.sequence_id: | ||
vals["name"] = new_rtype.sequence_id._next() | ||
res = super(RepairOrder, rec).write(vals) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Copyright 2023 ForgeFlow S.L. (https://forgeflow.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class RepairType(models.Model): | ||
_inherit = "repair.type" | ||
|
||
sequence_prefix = fields.Char( | ||
help="The rorder's sequence will be created using this prefix.", | ||
) | ||
sequence_id = fields.Many2one( | ||
"ir.sequence", | ||
string="Entry Sequence", | ||
help="This field contains the information related to the " | ||
"numbering of the rorders belonging to this rtype.", | ||
copy=False, | ||
) | ||
sequence_number_next = fields.Integer( | ||
string="Next Number", | ||
help="The next sequence number will be used for the next rorder.", | ||
compute="_compute_seq_number_next", | ||
inverse="_inverse_seq_number_next", | ||
) | ||
|
||
@api.model | ||
def _create_sequence(self, vals): | ||
"""Create new no_gap entry sequence""" | ||
seq = { | ||
"name": vals.get("name", False) or self.name, | ||
"implementation": "no_gap", | ||
"prefix": (vals.get("sequence_prefix", False) or self.sequence_prefix), | ||
"padding": 4, | ||
"number_increment": 1, | ||
"use_date_range": False, | ||
} | ||
seq = self.env["ir.sequence"].create(seq) | ||
seq_date_range = seq._get_current_sequence() | ||
seq_date_range.number_next = vals.get("sequence_number_next", 1) | ||
return seq | ||
|
||
# do not depend on 'sequence_id.date_range_ids', because | ||
# sequence_id._get_current_sequence() may invalidate it! | ||
@api.depends("sequence_id.use_date_range", "sequence_id.number_next_actual") | ||
def _compute_seq_number_next(self): | ||
"""Compute 'sequence_number_next' according to the current sequence | ||
in use, an ir.sequence or an ir.sequence.date_range. | ||
""" | ||
for rtype in self: | ||
if rtype.sequence_id: | ||
sequence = rtype.sequence_id._get_current_sequence() | ||
rtype.sequence_number_next = sequence.number_next_actual | ||
else: | ||
rtype.sequence_number_next = 1 | ||
|
||
def _inverse_seq_number_next(self): | ||
""" | ||
Inverse 'sequence_number_next' to edit the current sequence next number | ||
""" | ||
for rtype in self: | ||
if rtype.sequence_id and rtype.sequence_number_next: | ||
sequence = rtype.sequence_id._get_current_sequence() | ||
sequence.sudo().number_next = rtype.sequence_number_next | ||
|
||
@api.model | ||
def create(self, vals): | ||
if not vals.get("sequence_id", False): | ||
if vals.get("sequence_prefix", False): | ||
vals["sequence_id"] = self.sudo()._create_sequence(vals).id | ||
else: | ||
vals["sequence_prefix"] = ( | ||
self.env["ir.sequence"].browse(vals["sequence_id"]).prefix | ||
) | ||
result = super(RepairType, self).create(vals) | ||
self._compute_rorder_code() | ||
return result | ||
|
||
def write(self, vals): | ||
if not vals.get("sequence_id", False): | ||
if vals.get("sequence_prefix", False): | ||
vals["sequence_id"] = self.sudo()._create_sequence(vals).id | ||
else: | ||
vals["sequence_prefix"] = ( | ||
self.env["ir.sequence"].browse(vals["sequence_id"]).prefix | ||
) | ||
result = super(RepairType, self).write(vals) | ||
self._compute_rorder_code() | ||
return result | ||
|
||
@api.onchange("sequence_id") | ||
def _onchange_sequence_id(self): | ||
if self.sequence_id: | ||
self.sequence_prefix = self.sequence_id.prefix | ||
|
||
def _compute_rorder_code(self): | ||
for rtype in self: | ||
if rtype.sequence_id: | ||
rtype_rorders = rtype.env["repair.order"].search( | ||
[("repair_type_id", "=", rtype.id)] | ||
) | ||
for rorder in rtype_rorders: | ||
if not rorder.name and rorder.repair_type_id.sequence_id: | ||
rorder.name = rorder.repair_type_id.sequence_id._next() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Aaron Henriquez [email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module introduces a sequence to the repair type that will be influence the numbering in the repair orders. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.