-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
11c868d
commit aabd809
Showing
22 changed files
with
1,000 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,135 @@ | ||
============= | ||
TMS - Expense | ||
============= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:65ec3a61c01781d3682b41318b29cdf68ed5dfaebaa56633685d68e6431c29e5 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Alpha | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--transport-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-transport/tree/17.0/tms_expense | ||
:alt: OCA/stock-logistics-transport | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-transport-17-0/stock-logistics-transport-17-0-tms_expense | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-transport&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
The TMS - Expense module allows drivers and users to register expenses | ||
in trips. This module creates two new expense categories: Fuel and Toll | ||
expenses. | ||
|
||
.. IMPORTANT:: | ||
This is an alpha version, the data model and design can change at any time without warning. | ||
Only for development or testing purpose, do not use in production. | ||
`More details on development status <https://odoo-community.org/page/development-status>`_ | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Installation | ||
============ | ||
|
||
There are two ways of installing the module: | ||
|
||
Transport settings | ||
------------------ | ||
|
||
1. Go to Transport app. | ||
2. Go to Configuration > Settings. | ||
3. In the Trip block, enable the "Manage trip-expenses" setting. | ||
|
||
Apps list | ||
--------- | ||
|
||
1. Go to Apps. | ||
2. Search for TMS - Expense module. | ||
3. Install the module. | ||
|
||
Usage | ||
===== | ||
|
||
Create expenses in trips | ||
------------------------ | ||
|
||
1. Go to Transport module. | ||
2. Select or create a new trip. | ||
3. In the Expense page, create a new expense. The driver is set as the | ||
default employee that registered the expense. | ||
4. When the trip is completed, the expense is automatically submitted. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-transport/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/stock-logistics-transport/issues/new?body=module:%20tms_expense%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Open Source Integrators | ||
|
||
Contributors | ||
------------ | ||
|
||
- Santiago Rodriguez srodriguez@opensourceintegrators.com | ||
- Edgar Martinez emartinez@opensourceintegrators.com | ||
- Maxime Chambreuil mchambreuil@opensourceintegrators.com | ||
|
||
Other credits | ||
------------- | ||
|
||
- Open Source Integrators https://opensourceintegrators.com | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px | ||
:target: https://github.com/max3903 | ||
:alt: max3903 | ||
.. |maintainer-santiagordz| image:: https://github.com/santiagordz.png?size=40px | ||
:target: https://github.com/santiagordz | ||
:alt: santiagordz | ||
.. |maintainer-EdgarRetes| image:: https://github.com/EdgarRetes.png?size=40px | ||
:target: https://github.com/EdgarRetes | ||
:alt: EdgarRetes | ||
|
||
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-max3903| |maintainer-santiagordz| |maintainer-EdgarRetes| | ||
|
||
This module is part of the `OCA/stock-logistics-transport <https://github.com/OCA/stock-logistics-transport/tree/17.0/tms_expense>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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,21 @@ | ||
# Copyright (C) 2018 Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "TMS - Expense", | ||
"summary": "Manage expenses of a trip: hotel, tolls, fuel", | ||
"version": "17.0.1.0.0", | ||
"license": "AGPL-3", | ||
"category": "TMS", | ||
"author": "Open Source Integrators, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-logistics-transport", | ||
"depends": ["tms", "hr_expense"], | ||
"data": [ | ||
"data/hr_expense_data.xml", | ||
"data/hr_employee_driver.xml", | ||
"views/hr_expense_views.xml", | ||
"views/tms_order.xml", | ||
], | ||
"demo": [], | ||
"development_status": "Alpha", | ||
"maintainers": ["max3903", "santiagordz", "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,3 @@ | ||
<odoo noupdate="1"> | ||
<function model="tms.driver" name="update_existing_drivers_as_employees" /> | ||
</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,27 @@ | ||
<odoo noupdate="1"> | ||
<record id="expense_trip_toll" model="product.product"> | ||
<field name="name">Toll</field> | ||
<field name="description">Toll expenses for transportation trips</field> | ||
<field name="standard_price">0.0</field> | ||
<field name="type">service</field> | ||
<field name="uom_id" ref="uom.product_uom_unit" /> | ||
<field name="uom_po_id" ref="uom.product_uom_unit" /> | ||
<field name="default_code">TOLL</field> | ||
<field name="can_be_expensed" eval="True" /> | ||
<field name="sale_ok" eval="False" /> | ||
<field name="purchase_ok" eval="False" /> | ||
</record> | ||
|
||
<record id="expense_trip_fuel" model="product.product"> | ||
<field name="name">Fuel</field> | ||
<field name="description">Fuel expenses for transportation trips</field> | ||
<field name="standard_price">0.0</field> | ||
<field name="type">service</field> | ||
<field name="uom_id" ref="uom.product_uom_unit" /> | ||
<field name="uom_po_id" ref="uom.product_uom_unit" /> | ||
<field name="default_code">FUEL</field> | ||
<field name="can_be_expensed" eval="True" /> | ||
<field name="sale_ok" eval="False" /> | ||
<field name="purchase_ok" eval="False" /> | ||
</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,3 @@ | ||
from . import hr_expense | ||
from . import tms_driver | ||
from . import tms_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,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" | ||
|
||
trip_id = fields.Many2one("tms.order") | ||
|
||
def action_view_order(self): | ||
self.ensure_one() | ||
return { | ||
"type": "ir.actions.act_window", | ||
"res_model": "tms.order", | ||
"view_mode": "form", | ||
"res_id": self.trip_id.id, | ||
"target": "current", | ||
"name": _("Trip: %s") % self.trip_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,38 @@ | ||
# Copyright (C) 2018 - TODAY, Open Source Integrators | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class TmsDriver(models.Model): | ||
_inherit = "tms.driver" | ||
|
||
@api.model | ||
def create(self, vals): | ||
driver = super().create(vals) | ||
self.create_driver_employee(driver) | ||
return driver | ||
|
||
@api.model | ||
def update_existing_drivers_as_employees(self): | ||
drivers = self.env["tms.driver"].search([]) | ||
for driver in drivers: | ||
driver.create_driver_employee(driver) | ||
|
||
def open_commercial_entity(self): | ||
res = super().open_commercial_entity() | ||
return res | ||
|
||
def create_driver_employee(self, driver): | ||
employee = self.env["hr.employee"].search([("name", "=", driver.name)], limit=1) | ||
|
||
if not employee: | ||
employee_id = self.env["hr.employee"].create( | ||
{ | ||
"name": driver.name, | ||
"work_email": driver.email, | ||
"work_phone": driver.phone, | ||
"work_contact_id": driver.id, | ||
} | ||
) | ||
driver.partner_id.employee_ids = [(4, employee_id.id)] |
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,60 @@ | ||
# 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 TMSOrder(models.Model): | ||
_inherit = "tms.order" | ||
|
||
expense_ids = fields.One2many( | ||
"hr.expense", | ||
"trip_id", | ||
) | ||
|
||
employee_id = fields.Many2one( | ||
"hr.employee", | ||
string="Driver", | ||
compute="_compute_driver_employee_id", | ||
store=True, | ||
) | ||
|
||
expense_count = fields.Integer(compute="_compute_expenses") | ||
|
||
@api.depends("driver_id") | ||
def _compute_driver_employee_id(self): | ||
for record in self: | ||
record.employee_id = self.env["hr.employee"].search( | ||
[("work_contact_id", "=", record.driver_id.id)], limit=1 | ||
) | ||
if not record.employee_id: | ||
record.employee_id = self.env["hr.employee"].search( | ||
[("address_id", "=", record.driver_id.id)], limit=1 | ||
) | ||
|
||
@api.model | ||
def write(self, vals): | ||
result = super().write(vals) | ||
if "stage_id" in vals: | ||
if vals["stage_id"] == 3: | ||
for expense in self.expense_ids: | ||
if expense.state != "reported": | ||
expense.action_submit_expenses() | ||
expense.sheet_id.action_submit_sheet() | ||
return result | ||
|
||
@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": "tree,form", | ||
"domain": [("trip_id", "=", self.id)], | ||
"context": {"default_trip_id": self.id}, | ||
"name": _("Expenses for Trip %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,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,3 @@ | ||
- Santiago Rodriguez <srodriguez@opensourceintegrators.com> | ||
- Edgar Martinez <emartinez@opensourceintegrators.com> | ||
- Maxime Chambreuil <mchambreuil@opensourceintegrators.com> |
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 @@ | ||
- Open Source Integrators <https://opensourceintegrators.com> |
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 @@ | ||
The TMS - Expense module allows drivers and users to register expenses in trips. This module creates two new expense categories: Fuel and Toll expenses. |
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,11 @@ | ||
There are two ways of installing the module: | ||
|
||
## Transport settings | ||
1. Go to Transport app. | ||
2. Go to Configuration > Settings. | ||
3. In the Trip block, enable the "Manage trip-expenses" setting. | ||
|
||
## Apps list | ||
1. Go to Apps. | ||
2. Search for TMS - Expense module. | ||
3. Install the module. |
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,13 @@ | ||
This module is maintained by the OCA. | ||
|
||
[![Odoo Community Association](https://odoo-community.org/logo.png)](https://odoo-community.org) | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to | ||
support the collaborative development of Odoo features and promote its widespread use. | ||
|
||
This module is part of the | ||
`OCA/stock-logistics-transport <https://github.com/OCA/stock-logistics-transport/tree/16.0/shipment_advice>`\_ | ||
project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit | ||
https://odoo-community.org/page/Contribute. |
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,5 @@ | ||
## Create expenses in trips | ||
1. Go to Transport module. | ||
2. Select or create a new trip. | ||
3. In the Expense page, create a new expense. The driver is set as the default employee that registered the expense. | ||
4. When the trip is completed, the expense is automatically submitted. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.