-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69e8c44
commit bae75e8
Showing
10 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
**This file is going to be generated by oca-gen-addon-readme.** | ||
|
||
*Manual changes will be overwritten.* | ||
|
||
Please provide content in the ``readme`` directory: | ||
|
||
* **DESCRIPTION.rst** (required) | ||
* INSTALL.rst (optional) | ||
* CONFIGURE.rst (optional) | ||
* **USAGE.rst** (optional, highly recommended) | ||
* DEVELOP.rst (optional) | ||
* ROADMAP.rst (optional) | ||
* HISTORY.rst (optional, recommended) | ||
* **CONTRIBUTORS.rst** (optional, highly recommended) | ||
* CREDITS.rst (optional) | ||
|
||
Content of this README will also be drawn from the addon manifest, | ||
from keys such as name, authors, maintainers, development_status, | ||
and license. | ||
|
||
A good, one sentence summary in the manifest is also highly recommended. | ||
|
||
|
||
Automatic changelog generation | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_. | ||
|
||
Just put towncrier compatible changelog fragments into `readme/newsfragments` | ||
and the changelog file will be automatically generated and updated when a new fragment is added. | ||
|
||
Please refer to `towncrier` documentation to know more. | ||
|
||
NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. | ||
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (C) 2018 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Field Service - Expenses", | ||
"summary": "Manage expenses of orders", | ||
"version": "18.0.1.0.0", | ||
"license": "AGPL-3", | ||
"category": "TMS", | ||
"author": "Open Source Integrators, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/field-service", | ||
"depends": ["fieldservice", "hr_expense"], | ||
"data": [ | ||
"views/hr_expense_views.xml", | ||
"views/fsm_order_views.xml", | ||
], | ||
"demo": [], | ||
"development_status": "Alpha", | ||
"maintainers": ["max3903", "EdgarRetes"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import hr_expense | ||
from . import fsm_order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (C) 2024 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, api, fields, models | ||
|
||
|
||
class FSMOrder(models.Model): | ||
_inherit = "fsm.order" | ||
|
||
expense_ids = fields.One2many( | ||
"hr.expense", | ||
"fsm_order_id", | ||
) | ||
|
||
expense_count = fields.Integer(compute="_compute_expenses") | ||
|
||
@api.depends("expense_ids") | ||
def _compute_expenses(self): | ||
for record in self: | ||
record.expense_count = len(record.expense_ids) | ||
|
||
def action_view_expenses(self): | ||
self.ensure_one() | ||
return { | ||
"type": "ir.actions.act_window", | ||
"res_model": "hr.expense", | ||
"view_mode": "list,form", | ||
"domain": [("fsm_order_id", "=", self.id)], | ||
"context": {"default_fsm_order_id": self.id}, | ||
"name": _("Expenses for FSM Order %s") % self.name, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (C) 2024 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, fields, models | ||
|
||
|
||
class HrExpense(models.Model): | ||
_inherit = "hr.expense" | ||
|
||
fsm_order_id = fields.Many2one("fsm.order") | ||
|
||
def action_view_order(self): | ||
self.ensure_one() | ||
return { | ||
"type": "ir.actions.act_window", | ||
"res_model": "fsm.order", | ||
"view_mode": "form", | ||
"res_id": self.fsm_order_id.id, | ||
"target": "current", | ||
"name": _("Order: %s") % self.fsm_order_id.name, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Create expenses in orders | ||
1. Go to FSM module. | ||
2. Select or create a new order. | ||
3. In the Expense page, create a new expense. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<odoo> | ||
<record id="fsm_order_inherit_view_form" model="ir.ui.view"> | ||
<field name="name">fsm.order.inherit.view.form</field> | ||
<field name="model">fsm.order</field> | ||
<field name="inherit_id" ref="fieldservice.fsm_order_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@name='button_box']" position="inside"> | ||
<button | ||
name="action_view_expenses" | ||
type="object" | ||
class="oe_stat_button" | ||
icon="fa-money" | ||
invisible="not expense_ids" | ||
> | ||
<field string="Expenses" name="expense_count" widget="statinfo" /> | ||
</button> | ||
</xpath> | ||
<xpath expr="//page[@name='execution_page']" position="before"> | ||
<page string="Expenses"> | ||
<field name="expense_ids" /> | ||
</page> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<odoo> | ||
<record id="fsm_hr_expense_inherit_view_form" model="ir.ui.view"> | ||
<field name="name">fsm.hr.expense.inherit.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="//sheet" position="inside"> | ||
<div class="oe_button_box" name="button_box"> | ||
<button | ||
name="action_view_order" | ||
type="object" | ||
class="oe_stat_button" | ||
icon="fa-code-fork" | ||
invisible="not fsm_order_id" | ||
> | ||
<span class="o_stat_text">FSM Order</span> | ||
</button> | ||
</div> | ||
</xpath> | ||
<xpath expr="//sheet" position="inside"> | ||
<notebook> | ||
<page string="FSM Order"> | ||
<group> | ||
<field name="fsm_order_id" string="Order" /> | ||
</group> | ||
</page> | ||
</notebook> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="hr_expense_inherit_view_search" model="ir.ui.view"> | ||
<field name="name">hr.expense.inherit.view.search</field> | ||
<field name="model">hr.expense</field> | ||
<field name="inherit_id" ref="hr_expense.hr_expense_view_search" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//filter[@name='activities_upcoming_all']" position="after"> | ||
<separator /> | ||
<filter | ||
string="Order" | ||
name="order" | ||
domain="[('fsm_order_id', '!=', False)]" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |