Skip to content

Commit

Permalink
[ADD] added new module l10n_do_gov_job_expense
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-pcg committed Jun 27, 2022
1 parent 92b75cc commit 519704e
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 0 deletions.
1 change: 1 addition & 0 deletions l10n_do_gov_job_expense/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions l10n_do_gov_job_expense/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Dominican Gov Job Expenses",
"summary": """
Short (1 phrase/line) summary of the module's purpose, used as
subtitle on modules listing or apps.openerp.com""",
"author": "Indexa",
"website": "https://www.indexa.do",
"category": "Uncategorized",
"version": "12.0.0.0.1",
"depends": ["hr_expense"],
"data": [
"views/hr_job_views.xml",
"views/hr_expense_views.xml",
],
}
63 changes: 63 additions & 0 deletions l10n_do_gov_job_expense/i18n/es_DO.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_do_gov_job_expense
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-27 21:43+0000\n"
"PO-Revision-Date: 2022-06-27 17:43-0400\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es_DO\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 3.1\n"

#. module: l10n_do_gov_job_expense
#: model:ir.model.fields,help:l10n_do_gov_job_expense.field_hr_job__l10n_do_gov_expense_product_ids
msgid "Allowed expense products for this job position"
msgstr "Productos de gasto permitidos para este puesto de trabajo"

#. module: l10n_do_gov_job_expense
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_expense__display_name
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_job__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: l10n_do_gov_job_expense
#: model:ir.model,name:l10n_do_gov_job_expense.model_hr_expense
msgid "Expense"
msgstr "Gasto"

#. module: l10n_do_gov_job_expense
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_job__l10n_do_gov_expense_product_ids
#: model_terms:ir.ui.view,arch_db:l10n_do_gov_job_expense.view_hr_job_form_inherited
msgid "Expense products"
msgstr "Productos para gastos"

#. module: l10n_do_gov_job_expense
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_expense__id
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_job__id
msgid "ID"
msgstr "ID (identificación)"

#. module: l10n_do_gov_job_expense
#: model:ir.model,name:l10n_do_gov_job_expense.model_hr_job
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_expense__job_id
msgid "Job Position"
msgstr "Puesto de trabajo"

#. module: l10n_do_gov_job_expense
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_expense____last_update
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_job____last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: l10n_do_gov_job_expense
#: model:ir.model.fields,field_description:l10n_do_gov_job_expense.field_hr_expense__product_id
msgid "Product"
msgstr "Producto"
2 changes: 2 additions & 0 deletions l10n_do_gov_job_expense/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import hr_job
from . import hr_expense
25 changes: 25 additions & 0 deletions l10n_do_gov_job_expense/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from odoo import models, fields, api


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

job_id = fields.Many2one("hr.job", related="employee_id.job_id")
product_id = fields.Many2one(
domain=[]
# domain=lambda self: [
# ("id", "in", self.job_id.l10n_do_gov_expense_product_ids.ids)]
)

@api.onchange("employee_id")
def _onchange_employee_id(self):
expense_product_ids = []
if self.employee_id:
expense_product_ids = self.job_id.l10n_do_gov_expense_product_ids.ids
return {
"domain": {
"product_id": [
("id", "in", expense_product_ids)
]
}
}
12 changes: 12 additions & 0 deletions l10n_do_gov_job_expense/models/hr_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import models, fields


class Job(models.Model):
_inherit = "hr.job"

l10n_do_gov_expense_product_ids = fields.Many2many(
"product.product",
string="Expense products",
domain=[("can_be_expensed", "=", True)],
help="Allowed expense products for this job position",
)
2 changes: 2 additions & 0 deletions l10n_do_gov_job_expense/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_template_module_template_module,template_module.template_module,model_template_module_template_module,,1,0,0,0
17 changes: 17 additions & 0 deletions l10n_do_gov_job_expense/views/hr_expense_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<record id="hr_expense_view_form_inherited" model="ir.ui.view">
<field name="name">hr.expense.view.form.inherited</field>
<field name="model">hr.expense</field>
<field name="inherit_id" ref="hr_expense.hr_expense_view_form"/>
<field name="arch" type="xml">
<field name="product_id" position="replace">
<field name="product_id"
options="{'no_create': True, 'no_open': True}"
context="{'default_can_be_expensed': 1, 'tree_view_ref': 'hr_expense.product_product_expense_tree_view'}"/>
</field>
</field>
</record>

</odoo>
31 changes: 31 additions & 0 deletions l10n_do_gov_job_expense/views/hr_job_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<record id="view_hr_job_form_inherited" model="ir.ui.view">
<field name="name">view.hr.job.form.inherited</field>
<field name="model">hr.job</field>
<field name="inherit_id" ref="hr.view_hr_job_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Expense products"
groups="hr_expense.group_hr_expense_manager">
<group>
<field name="l10n_do_gov_expense_product_ids" nolabel="1"
context="{
'default_can_be_expensed': 1,
'form_view_ref': 'hr_expense.product_product_expense_form_view'
}">
<tree>
<field name="name"/>
<field name="type"/>
<field name="default_code"/>
<field name="standard_price"/>
</tree>
</field>
</group>
</page>
</xpath>
</field>
</record>

</odoo>

0 comments on commit 519704e

Please sign in to comment.