[MIG] hr_expense_analytic_account_preselect_with_projec: migrate to 18.0
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
==================================================
|
||||
HR Expense Analytic Account Preselect with Project
|
||||
==================================================
|
||||
|
||||
Preselect the analytic distribution on expenses based on the selected project.
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
This module adds a ``Project`` field to expense forms. When a project is
|
||||
selected, the analytic distribution is automatically set to the project's
|
||||
analytic account (100%), so the user does not need to manually set the
|
||||
analytic distribution.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``hr_expense_analytic_account_preselect_with_project``.
|
||||
|
||||
This module depends on:
|
||||
|
||||
* ``base`` (Odoo core)
|
||||
* ``hr_expense`` (Odoo core)
|
||||
* ``project`` (Odoo core)
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
When creating an expense:
|
||||
|
||||
1. Select a ``Project`` in the expense form.
|
||||
2. The analytic distribution is automatically populated with the project's
|
||||
analytic account at 100%.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/hr-tools/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smash it by providing detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Clément Thomas
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
@@ -0,0 +1,25 @@
|
||||
# Copyright 2023 Stéphan Sainléger (Elabore)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "hr_expense_analytic_account_preselect_with_project",
|
||||
"version": "18.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://git.elabore.coop/elabore/hr-tools",
|
||||
"maintainer": "Clément Thomas",
|
||||
"license": "AGPL-3",
|
||||
"category": "Tools",
|
||||
"summary": "Preselect analytic distribution on expenses from project",
|
||||
# any module necessary for this one to work correctly
|
||||
"depends": [
|
||||
"base",
|
||||
"hr_expense",
|
||||
"project",
|
||||
],
|
||||
"data": [
|
||||
"views/hr_expense_views.xml",
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install": False,
|
||||
"application": False,
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
This directory should contain the *.po for Odoo translation.
|
||||
@@ -0,0 +1 @@
|
||||
from . import hr_expense
|
||||
@@ -0,0 +1,14 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class HrExpense(models.Model):
|
||||
_inherit = "hr.expense"
|
||||
|
||||
project_id = fields.Many2one("project.project", string="Projet", required=True)
|
||||
|
||||
@api.onchange("project_id")
|
||||
def set_analytic_account(self):
|
||||
if self.project_id.account_id:
|
||||
self.analytic_distribution = {str(self.project_id.account_id.id): 100}
|
||||
else:
|
||||
self.analytic_distribution = {}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record
|
||||
id="hr_expense_view_form_analytic_account_preselect_with_project"
|
||||
model="ir.ui.view"
|
||||
>
|
||||
<field
|
||||
name="name"
|
||||
>hr.expense.view.form.analytic.account.preselect.with.project</field>
|
||||
<field name="model">hr.expense</field>
|
||||
<field name="inherit_id" ref="hr_expense.hr_expense_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='analytic_distribution']" position="before">
|
||||
<field name="project_id" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user