diff --git a/hr_expense_sequence/README.rst b/hr_expense_sequence/README.rst new file mode 100644 index 000000000..ee1113e58 --- /dev/null +++ b/hr_expense_sequence/README.rst @@ -0,0 +1,90 @@ +=================== +HR expense sequence +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d3fd164c3e14e8a99ac971c425ac485f0405f37a1a095a4a7881c40eeb504cf5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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%2Fhr--expense-lightgray.png?logo=github + :target: https://github.com/OCA/hr-expense/tree/18.0/hr_expense_sequence + :alt: OCA/hr-expense +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/hr-expense-18-0/hr-expense-18-0-hr_expense_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/hr-expense&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the possibility to define a sequence for the expense +report's reference. This reference is then set as default when you +create a new expense report, using the defined sequence. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You can change the default sequence (EX0001) by the one of your choice +going to *Settings > Technical > Sequences & Identifiers > Sequences*, +and editing the record Expense Report sequence. + +You will only have access to that section if your section has Technical +features permission check marked. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Serv. Tecnol. Avanzados - Pedro M. Baeza + +Contributors +------------ + +- Pedro M. Baeza +- Pimolnat Suntian +- Saran Lim. + +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. + +This module is part of the `OCA/hr-expense `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_expense_sequence/__init__.py b/hr_expense_sequence/__init__.py new file mode 100644 index 000000000..dc8f4578f --- /dev/null +++ b/hr_expense_sequence/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from .hooks import assign_old_sequences diff --git a/hr_expense_sequence/__manifest__.py b/hr_expense_sequence/__manifest__.py new file mode 100644 index 000000000..deb895a4d --- /dev/null +++ b/hr_expense_sequence/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "HR expense sequence", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "category": "Human Resources", + "author": "Serv. Tecnol. Avanzados - Pedro M. Baeza," + " Odoo Community Association (OCA)", + "website": "https://github.com/OCA/hr-expense", + "maintainers": ["dnplkndll"], + "depends": ["hr_expense"], + "data": [ + "data/hr_expense_data.xml", + "views/hr_expense_views.xml", + "report/report_expense.xml", + ], + "installable": True, + "post_init_hook": "assign_old_sequences", +} diff --git a/hr_expense_sequence/data/hr_expense_data.xml b/hr_expense_sequence/data/hr_expense_data.xml new file mode 100644 index 000000000..9a253d362 --- /dev/null +++ b/hr_expense_sequence/data/hr_expense_data.xml @@ -0,0 +1,10 @@ + + + + Expense sequence + hr.expense + + EX + + + diff --git a/hr_expense_sequence/hooks.py b/hr_expense_sequence/hooks.py new file mode 100644 index 000000000..8d48b9bba --- /dev/null +++ b/hr_expense_sequence/hooks.py @@ -0,0 +1,10 @@ +# Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +def assign_old_sequences(env): + expense_obj = env["hr.expense"] + sequence_obj = env["ir.sequence"] + for expense in expense_obj.search([], order="id"): + expense.write({"number": sequence_obj.next_by_code("hr.expense")}) diff --git a/hr_expense_sequence/i18n/cs_CZ.po b/hr_expense_sequence/i18n/cs_CZ.po new file mode 100644 index 000000000..2c5025186 --- /dev/null +++ b/hr_expense_sequence/i18n/cs_CZ.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# Lukáš Spurný , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-23 03:45+0000\n" +"PO-Revision-Date: 2018-02-23 03:45+0000\n" +"Last-Translator: Lukáš Spurný , 2018\n" +"Language-Team: Czech (Czech Republic) (https://www.transifex.com/oca/" +"teams/23907/cs_CZ/)\n" +"Language: cs_CZ\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "Zpráva o výdajích" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "Zpráva o nákladech" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Číslo" diff --git a/hr_expense_sequence/i18n/de.po b/hr_expense_sequence/i18n/de.po new file mode 100644 index 000000000..38c0855eb --- /dev/null +++ b/hr_expense_sequence/i18n/de.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 01:04+0000\n" +"PO-Revision-Date: 2017-07-01 01:04+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Nummer" diff --git a/hr_expense_sequence/i18n/es.po b/hr_expense_sequence/i18n/es.po new file mode 100644 index 000000000..61529afa0 --- /dev/null +++ b/hr_expense_sequence/i18n/es.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 01:04+0000\n" +"PO-Revision-Date: 2017-07-01 01:04+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Número" diff --git a/hr_expense_sequence/i18n/fi.po b/hr_expense_sequence/i18n/fi.po new file mode 100644 index 000000000..0ac819b73 --- /dev/null +++ b/hr_expense_sequence/i18n/fi.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 01:04+0000\n" +"PO-Revision-Date: 2017-07-01 01:04+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Numero" diff --git a/hr_expense_sequence/i18n/fr.po b/hr_expense_sequence/i18n/fr.po new file mode 100644 index 000000000..6eabc5304 --- /dev/null +++ b/hr_expense_sequence/i18n/fr.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# guillaume bauer , 2017 +# Alexandre Fayolle , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-23 03:45+0000\n" +"PO-Revision-Date: 2018-02-23 03:45+0000\n" +"Last-Translator: Alexandre Fayolle , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "Rapport de dépenses" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "Rapport de dépenses" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Numéro" diff --git a/hr_expense_sequence/i18n/hr.po b/hr_expense_sequence/i18n/hr.po new file mode 100644 index 000000000..84a2dc06d --- /dev/null +++ b/hr_expense_sequence/i18n/hr.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-04 06:52+0000\n" +"PO-Revision-Date: 2017-07-04 06:52+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "Izvještaj troškova" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "Izvještaji troškova" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Broj" diff --git a/hr_expense_sequence/i18n/hr_expense_sequence.pot b/hr_expense_sequence/i18n/hr_expense_sequence.pot new file mode 100644 index 000000000..bcb2440fb --- /dev/null +++ b/hr_expense_sequence/i18n/hr_expense_sequence.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "" diff --git a/hr_expense_sequence/i18n/it.po b/hr_expense_sequence/i18n/it.po new file mode 100644 index 000000000..537c338e6 --- /dev/null +++ b/hr_expense_sequence/i18n/it.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 01:04+0000\n" +"PO-Revision-Date: 2017-07-01 01:04+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Numero" diff --git a/hr_expense_sequence/i18n/nl_NL.po b/hr_expense_sequence/i18n/nl_NL.po new file mode 100644 index 000000000..a567a8a82 --- /dev/null +++ b/hr_expense_sequence/i18n/nl_NL.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 01:04+0000\n" +"PO-Revision-Date: 2017-07-01 01:04+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "Onkostennota" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "Onkostenrapport" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Nummer" diff --git a/hr_expense_sequence/i18n/pt_BR.po b/hr_expense_sequence/i18n/pt_BR.po new file mode 100644 index 000000000..298c80a87 --- /dev/null +++ b/hr_expense_sequence/i18n/pt_BR.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 01:04+0000\n" +"PO-Revision-Date: 2017-07-01 01:04+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Número" diff --git a/hr_expense_sequence/i18n/sl.po b/hr_expense_sequence/i18n/sl.po new file mode 100644 index 000000000..14b3be904 --- /dev/null +++ b/hr_expense_sequence/i18n/sl.po @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_expense_sequence +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-07-01 01:04+0000\n" +"PO-Revision-Date: 2017-07-01 01:04+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: hr_expense_sequence +#: model:ir.model,name:hr_expense_sequence.model_hr_expense_sheet +msgid "Expense Report" +msgstr "" + +#. module: hr_expense_sequence +#: model_terms:ir.ui.view,arch_db:hr_expense_sequence.report_expense_sheet +msgid "Expenses Report" +msgstr "" + +#. module: hr_expense_sequence +#: model:ir.model.fields,field_description:hr_expense_sequence.field_hr_expense_sheet__number +msgid "Number" +msgstr "Številka" diff --git a/hr_expense_sequence/models/__init__.py b/hr_expense_sequence/models/__init__.py new file mode 100644 index 000000000..ced2eb18d --- /dev/null +++ b/hr_expense_sequence/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import hr_expense diff --git a/hr_expense_sequence/models/hr_expense.py b/hr_expense_sequence/models/hr_expense.py new file mode 100644 index 000000000..fabc986dc --- /dev/null +++ b/hr_expense_sequence/models/hr_expense.py @@ -0,0 +1,21 @@ +# Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# Copyright 2026 Ledo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class HrExpense(models.Model): + _inherit = "hr.expense" + _rec_name = "number" + + number = fields.Char(required=True, default="/", readonly=True, copy=False) + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get("number", "/") == "/": + number = self.env["ir.sequence"].next_by_code("hr.expense") or "/" + vals["number"] = number + return super().create(vals_list) diff --git a/hr_expense_sequence/pyproject.toml b/hr_expense_sequence/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/hr_expense_sequence/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_expense_sequence/readme/CONFIGURE.md b/hr_expense_sequence/readme/CONFIGURE.md new file mode 100644 index 000000000..2a5f020da --- /dev/null +++ b/hr_expense_sequence/readme/CONFIGURE.md @@ -0,0 +1,6 @@ +You can change the default sequence (EX0001) by the one of your choice +going to *Settings \> Technical \> Sequences & Identifiers \> +Sequences*, and editing the record Expense sequence. + +You will only have access to that section if your section has Technical +features permission check marked. diff --git a/hr_expense_sequence/readme/CONTRIBUTORS.md b/hr_expense_sequence/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..86d51a5ae --- /dev/null +++ b/hr_expense_sequence/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Pedro M. Baeza \<\> +- Pimolnat Suntian \<\> +- Saran Lim. \<\> +- Don Kendall \<\> diff --git a/hr_expense_sequence/readme/DESCRIPTION.md b/hr_expense_sequence/readme/DESCRIPTION.md new file mode 100644 index 000000000..db7462363 --- /dev/null +++ b/hr_expense_sequence/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module adds the possibility to define a sequence for the expense's +reference. This reference is then set as default when you create a new +expense, using the defined sequence. + +On Odoo 19.0 `hr.expense.sheet` was removed and expenses became the unit +of work; the `number` field accordingly moved from the sheet to +`hr.expense` itself. diff --git a/hr_expense_sequence/report/report_expense.xml b/hr_expense_sequence/report/report_expense.xml new file mode 100644 index 000000000..70a2ae718 --- /dev/null +++ b/hr_expense_sequence/report/report_expense.xml @@ -0,0 +1,8 @@ + + + + diff --git a/hr_expense_sequence/static/description/icon.png b/hr_expense_sequence/static/description/icon.png new file mode 100644 index 000000000..91af287db Binary files /dev/null and b/hr_expense_sequence/static/description/icon.png differ diff --git a/hr_expense_sequence/static/description/index.html b/hr_expense_sequence/static/description/index.html new file mode 100644 index 000000000..1a86f6a00 --- /dev/null +++ b/hr_expense_sequence/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +HR expense sequence + + + +
+

HR expense sequence

+ + +

Beta License: AGPL-3 OCA/hr-expense Translate me on Weblate Try me on Runboat

+

This module adds the possibility to define a sequence for the expense +report’s reference. This reference is then set as default when you +create a new expense report, using the defined sequence.

+

Table of contents

+ +
+

Configuration

+

You can change the default sequence (EX0001) by the one of your choice +going to Settings > Technical > Sequences & Identifiers > Sequences, +and editing the record Expense Report sequence.

+

You will only have access to that section if your section has Technical +features permission check marked.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Serv. Tecnol. Avanzados - Pedro M. Baeza
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

This module is part of the OCA/hr-expense project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/hr_expense_sequence/tests/__init__.py b/hr_expense_sequence/tests/__init__.py new file mode 100644 index 000000000..68ada0e47 --- /dev/null +++ b/hr_expense_sequence/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_hr_expense_sequence diff --git a/hr_expense_sequence/tests/test_hr_expense_sequence.py b/hr_expense_sequence/tests/test_hr_expense_sequence.py new file mode 100644 index 000000000..8fd50b549 --- /dev/null +++ b/hr_expense_sequence/tests/test_hr_expense_sequence.py @@ -0,0 +1,59 @@ +# Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# Copyright 2026 Ledo +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestHrExpenseSequence(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.expense_model = cls.env["hr.expense"] + # Create our own product fixture — OCA CI runs without demo data so + # `product.product_product_4` is not available. + cls.product = cls.env["product.product"].create( + { + "name": "Test expense product", + "standard_price": 10.0, + "list_price": 10.0, + "can_be_expensed": True, + } + ) + cls.employee = cls.env["hr.employee"].create({"name": "Employee"}) + + def _create_expense(self, name="Expense", **kwargs): + vals = { + "name": name, + "employee_id": self.employee.id, + "product_id": self.product.id, + "total_amount_currency": self.product.standard_price or 10.0, + "quantity": 1, + } + vals.update(kwargs) + return self.expense_model.create(vals) + + def test_create_sequence_auto(self): + """Expense created without an explicit number gets an auto-assigned one.""" + expense = self._create_expense("Expense Auto") + self.assertNotEqual(expense.number, "/") + self.assertTrue(expense.number) + + def test_create_sequence_slash_marker(self): + """Expense created with explicit '/' also gets auto-assigned.""" + expense = self._create_expense("Expense Slash", number="/") + self.assertNotEqual(expense.number, "/") + + def test_create_sequence_manual_override(self): + """Caller can pass a specific number which is kept as-is.""" + expense = self._create_expense("Expense Manual", number="EX1") + self.assertEqual(expense.number, "EX1") + + def test_copy_assigns_new_sequence(self): + """Duplicating an expense draws a fresh sequence number.""" + expense = self._create_expense("Expense Copy Source") + first_number = expense.number + copy = expense.copy() + self.assertNotEqual(copy.number, first_number) + self.assertNotEqual(copy.number, "/") diff --git a/hr_expense_sequence/views/hr_expense_views.xml b/hr_expense_sequence/views/hr_expense_views.xml new file mode 100644 index 000000000..2df0801c0 --- /dev/null +++ b/hr_expense_sequence/views/hr_expense_views.xml @@ -0,0 +1,28 @@ + + + + hr.expense.list.sequence + hr.expense + + + + + + + + + hr.expense.view.search.sequence + hr.expense + + + + + ['|', ('name', 'ilike', self), ('number', 'ilike', self)] + + + + +