Skip to content

Commit

Permalink
Merge PR #270 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Oct 1, 2024
2 parents 38e6859 + d884526 commit 5bd54fc
Show file tree
Hide file tree
Showing 16 changed files with 741 additions and 0 deletions.
110 changes: 110 additions & 0 deletions hr_expense_employee_analytic_default/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
=================================
Expense Employee Analytic Default
=================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7ca70fd00344e3819c9e4182d3d93d46aaa252b6e7e0df780f5cab1bb48db091
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/17.0/hr_expense_employee_analytic_default
: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-17-0/hr-expense-17-0-hr_expense_employee_analytic_default
: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=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to create Analytic Distribution Models for employees
to be applied to expenses.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

1. Enable the “Analytic Accounting” permission on the user
2. Go to an employee (or create a new one) and set a work address
3. Go to *Invocing > Configuration > Analytic Accounting \|> Analytic
Distribution Models* and create a record that has as partner the
employee's work address.

Usage
=====

To use this module, you need to:

1. Go to *Expenses* and create a new one.
2. The analytical distribution will be set according to the analytic
distribution model.
3. When changing the employee, the analytical distribution will be
updated.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-expense/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/hr-expense/issues/new?body=module:%20hr_expense_employee_analytic_default%0Aversion:%2017.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
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Víctor Martínez
- Pedro M. Baeza

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-victoralmau| image:: https://github.com/victoralmau.png?size=40px
:target: https://github.com/victoralmau
:alt: victoralmau

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/hr-expense <https://github.com/OCA/hr-expense/tree/17.0/hr_expense_employee_analytic_default>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions hr_expense_employee_analytic_default/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
13 changes: 13 additions & 0 deletions hr_expense_employee_analytic_default/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Expense Employee Analytic Default",
"version": "17.0.1.0.0",
"category": "Human Resources",
"website": "https://github.com/OCA/hr-expense",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["hr_expense"],
"installable": True,
"maintainers": ["victoralmau"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_employee_analytic_default
#
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: hr_expense_employee_analytic_default
#: model:ir.model,name:hr_expense_employee_analytic_default.model_account_analytic_default
msgid "Analytic Distribution"
msgstr ""

#. module: hr_expense_employee_analytic_default
#: model:ir.model,name:hr_expense_employee_analytic_default.model_hr_expense
msgid "Expense"
msgstr ""
4 changes: 4 additions & 0 deletions hr_expense_employee_analytic_default/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_analytic_distribution_model
from . import hr_expense
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class AccountAnalyticDistributionModel(models.Model):
_inherit = "account.analytic.distribution.model"

@api.model
def _get_distribution(self, vals):
"""If custom context is set, change partner to user partner of the employee
to get the correct distribution."""
if self.env.context.get("hr_expense_employee_id"):
employee = self.env["hr.employee"].browse(
self.env.context.get("hr_expense_employee_id")
)
if employee.address_id:
vals.update(partner_id=employee.address_id.id)
return super()._get_distribution(vals)
14 changes: 14 additions & 0 deletions hr_expense_employee_analytic_default/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class HrExpense(models.Model):
_inherit = "hr.expense"

@api.depends("employee_id")
def _compute_analytic_distribution(self):
"""Set a specific context with the employee of the expense."""
self = self.with_context(hr_expense_employee_id=self.employee_id.id)
return super()._compute_analytic_distribution()
3 changes: 3 additions & 0 deletions hr_expense_employee_analytic_default/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions hr_expense_employee_analytic_default/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To configure this module, you need to:

1. Enable the “Analytic Accounting” permission on the user
2. Go to an employee (or create a new one) and set a work address
3. Go to *Invocing \> Configuration \> Analytic Accounting |>
Analytic Distribution Models* and create a record that has as partner
the employee's work address.
3 changes: 3 additions & 0 deletions hr_expense_employee_analytic_default/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Tecnativa](https://www.tecnativa.com):
- Víctor Martínez
- Pedro M. Baeza
2 changes: 2 additions & 0 deletions hr_expense_employee_analytic_default/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows to create Analytic Distribution Models for employees to be
applied to expenses.
7 changes: 7 additions & 0 deletions hr_expense_employee_analytic_default/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To use this module, you need to:

1. Go to *Expenses* and create a new one.
2. The analytical distribution will be set according to
the analytic distribution model.
3. When changing the employee, the analytical distribution will
be updated.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5bd54fc

Please sign in to comment.