-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] fieldservice_expense #1284
Open
EdgarRetes
wants to merge
1
commit into
OCA:18.0
Choose a base branch
from
ursais:18.0-fieldservice_expense
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "fieldservice_account"], | ||
"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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.