Skip to content

Commit

Permalink
[14.0][ADD] hr_expense_widget_o2m
Browse files Browse the repository at this point in the history
  • Loading branch information
kittiu authored and ps-tubtim committed May 29, 2022
1 parent 3028302 commit ad3fe56
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hr_expense_widget_o2m/__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
19 changes: 19 additions & 0 deletions hr_expense_widget_o2m/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "HR Expense one2many widget",
"version": "14.0.1.0.0",
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/hr-expense",
"license": "AGPL-3",
"category": "Human Resources",
"depends": ["hr_expense"],
"data": [
"security/hr_expense_security.xml",
"views/res_config_settings_views.xml",
"views/hr_expense_views.xml",
],
"installable": True,
"maintainers": ["kittiu"],
}
3 changes: 3 additions & 0 deletions hr_expense_widget_o2m/models/__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 res_config_settings
13 changes: 13 additions & 0 deletions hr_expense_widget_o2m/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

group_hr_expense_widget_o2m = fields.Boolean(
string="Use form view when add line for expense report",
implied_group="hr_expense_widget_o2m.group_hr_expense_widget_o2m",
)
1 change: 1 addition & 0 deletions hr_expense_widget_o2m/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Go to Human Reqsource > Expenses settings, and enable option "Use form view when add line for expense report"
1 change: 1 addition & 0 deletions hr_expense_widget_o2m/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Kitti U. <[email protected]>
6 changes: 6 additions & 0 deletions hr_expense_widget_o2m/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Currently, if user create new expense sheet first, and then click to add expense lines,
System will popup a selection window (many2many widget) allowing user to select the existing expenses first, and also to create new expense.

This can be confusing for some user, and might not be suitable for some use case.

With this module, user have option to directly add new lines on expense report (one2many widget).
6 changes: 6 additions & 0 deletions hr_expense_widget_o2m/security/hr_expense_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<odoo>
<record id="group_hr_expense_widget_o2m" model="res.groups">
<field name="name">Use form view when add line for expense report</field>
<field name="category_id" ref="base.module_category_hidden" />
</record>
</odoo>
Binary file added hr_expense_widget_o2m/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions hr_expense_widget_o2m/views/hr_expense_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<odoo>
<!-- Views activated for group_hr_expense_widget_o2m -->
<record id="view_hr_expense_sheet_form" model="ir.ui.view">
<field name="name">hr.expense.sheet.form.inherit</field>
<field name="model">hr.expense.sheet</field>
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form" />
<field
name="groups_id"
eval="[(4, ref('hr_expense_widget_o2m.group_hr_expense_widget_o2m'))]"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='expense_line_ids']" position="attributes">
<attribute name="widget">one2many</attribute>
</xpath>
<xpath expr="//field[@name='expense_line_ids']/tree" position="attributes">
<attribute name="editable" />
</xpath>
</field>
</record>

<record id="hr_expense_view_form" model="ir.ui.view">
<field name="name">hr.expense.view.form</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='account_id']" position="attributes">
<attribute name="force_save">1</attribute>
</xpath>
<xpath expr="//field[@name='total_amount']" position="attributes">
<attribute name="force_save">1</attribute>
</xpath>
<xpath expr="//field[@name='amount_residual']" position="attributes">
<attribute name="force_save">1</attribute>
</xpath>
<xpath expr="//field[@name='employee_id']" position="attributes">
<attribute name="force_save">1</attribute>
</xpath>
</field>
</record>
</odoo>
23 changes: 23 additions & 0 deletions hr_expense_widget_o2m/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.hr.expense</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="85" />
<field name="inherit_id" ref="hr_expense.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='expenses_setting_container']" position="inside">
<div
class="col-12 col-lg-6 o_setting_box"
id="expense_widget_o2m_settings"
>
<div class="o_setting_left_pane">
<field name="group_hr_expense_widget_o2m" />
</div>
<div class="o_setting_right_pane">
<label for="group_hr_expense_widget_o2m" />
</div>
</div>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/hr_expense_widget_o2m/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit ad3fe56

Please sign in to comment.