Skip to content

Commit

Permalink
[ADD] tms_account
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagordz authored and EdgarRetes committed Oct 29, 2024
1 parent 612df64 commit 976534c
Show file tree
Hide file tree
Showing 34 changed files with 1,878 additions and 0 deletions.
177 changes: 177 additions & 0 deletions tms_account/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
================
TMS - Accounting
================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:db45d1c10ff3e81a786462d23541170716b867d6c2a502a5a6358c7a19af5841
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_account
: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_account
: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 - Accounting manages the accounting processes for the TMS
modules. This module enables features such as purchase orders invoicing,
sale order invoicing and analytic accounting.

.. 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 Trips block, enable the "Manage Trips Accounting" setting.

Apps list
---------

1. Go to Apps.
2. Search for TMS - Accounting module.
3. Install the module.

Configuration
=============

Analytic Distribution
---------------------

1. Go to Transport module.
2. Go to Configuration > Settings.
3. In the trips block, check the "Analytic Accounting" setting.
4. Check the "Trips" box to create analytic accounts for each trip using
this plan.
5. If routes are enabled, check the "Routes" box to create analytic
accounts for each route using this plan.

Usage
=====

Create sale order invoices
--------------------------

1. Go to Sale module.
2. Create a new sale quotation.
3. Add the trips to the Products page in the order.
4. When saving, the trips are created as drafts.
5. In the trips, check the "Create invoices and bills when completed?"
box.
6. Change the state of the trip to "Completed" and the invoices will be
generated (Sale order needs to be confirmed).

Create purchase bill
--------------------

1. Go to Transport module.
2. Create or select a trip.
3. Add purchases to the Purchase page.
4. Check the "Create invoices and bills when completed?" box.
5. Change the state of the trip to "Completed" and the bills will be
generated (Purchase order needs to be confirmed).

Analytic Accounting
-------------------

1. When adding trips to sale orders, the analytic account will be set by
default with the trip account and the route account (Depending on
which plans are enabled in the configration).
2. When adding purchase orders to trips, the analytic account will be
set by default with the trip account and the route account (Depending
on which plans are enabled in the configration).
3. When adding expenses to trips, the analytic account will be set by
default with the trip account and the route account (Depending on
which plans are enabled in the configration).
4. In the section of Transport > Reporting, the total revenue can be
seen for each trip and route according to the analytic accounts.

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_account%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_account>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions tms_account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (C) 2024 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
24 changes: 24 additions & 0 deletions tms_account/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2024 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "TMS - Accounting",
"summary": "Track invoices linked to TMS orders",
"version": "17.0.1.0.0",
"category": "Field Service",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-transport",
"depends": ["tms", "tms_sale", "tms_expense", "tms_purchase", "account_usability"],
"data": [
"security/res_groups.xml",
"data/analytic_plan.xml",
"views/res_config_settings.xml",
"views/account_move.xml",
"views/account_analytic_plan.xml",
"views/tms_order.xml",
"views/tms_route.xml",
],
"license": "AGPL-3",
"development_status": "Alpha",
"maintainers": ["max3903", "santiagordz", "EdgarRetes"],
}
12 changes: 12 additions & 0 deletions tms_account/data/analytic_plan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<odoo noupdate="1">

<record id="tms_route_analytic_plan" model="account.analytic.plan">
<field name="name">Routes</field>
<field name="tms_flag">True</field>
</record>
<record id="tms_order_analytic_plan" model="account.analytic.plan">
<field name="name">Trips</field>
<field name="tms_flag">True</field>
</record>

</odoo>
12 changes: 12 additions & 0 deletions tms_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from . import account_analytic_plan
from . import res_config_settings
from . import tms_order
from . import analytic_account
from . import tms_route
from . import account_move
from . import account_move_line
from . import purchase_order_line
from . import hr_expense
from . import sale_order_line
from . import sale_order
from . import account_analytic_line
24 changes: 24 additions & 0 deletions tms_account/models/account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2024 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

@api.model
def create(self, vals):
line = super().create(vals)

Check warning on line 11 in tms_account/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_analytic_line.py#L11

Added line #L11 was not covered by tests
if "x_plan3_id" in vals:
amount = line.amount

Check warning on line 13 in tms_account/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_analytic_line.py#L13

Added line #L13 was not covered by tests
if amount < 0:
line.x_plan3_id.trip_id.total_expenses += abs(amount)

Check warning on line 15 in tms_account/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_analytic_line.py#L15

Added line #L15 was not covered by tests
else:
line.x_plan3_id.trip_id.total_income += amount

Check warning on line 17 in tms_account/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_analytic_line.py#L17

Added line #L17 was not covered by tests
if "x_plan2_id" in vals:
amount = line.amount

Check warning on line 19 in tms_account/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_analytic_line.py#L19

Added line #L19 was not covered by tests
if amount < 0:
line.x_plan2_id.route_id.total_expenses += abs(amount)

Check warning on line 21 in tms_account/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_analytic_line.py#L21

Added line #L21 was not covered by tests
else:
line.x_plan2_id.route_id.total_income += amount
return line

Check warning on line 24 in tms_account/models/account_analytic_line.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_analytic_line.py#L23-L24

Added lines #L23 - L24 were not covered by tests
14 changes: 14 additions & 0 deletions tms_account/models/account_analytic_plan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (C) 2024 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models


class AccountAnalyticPlan(models.Model):
_inherit = "account.analytic.plan"

tms_flag = fields.Boolean(
string="Used for Transports?",
help="""This plan is used as a default in the Transport application.
""",
readonly=True,
)
31 changes: 31 additions & 0 deletions tms_account/models/account_move.py
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 AccountMove(models.Model):
_inherit = "account.move"

has_tms_order = fields.Boolean(readonly=True, compute="_compute_has_trip")

@api.depends("line_ids")
def _compute_has_trip(self):
for record in self:
if record.line_ids.sale_line_ids.order_id.tms_order_ids:
record.has_tms_order = True

Check warning on line 15 in tms_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_move.py#L15

Added line #L15 was not covered by tests
else:
record.has_tms_order = False

Check warning on line 17 in tms_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_move.py#L17

Added line #L17 was not covered by tests

def action_view_tms_orders(self):
self.ensure_one()
tms_orders = self.line_ids.sale_line_ids.order_id.tms_order_ids
action = self.env["ir.actions.act_window"]._for_xml_id(

Check warning on line 22 in tms_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_move.py#L20-L22

Added lines #L20 - L22 were not covered by tests
"tms.action_tms_dash_order"
)
if len(tms_orders) > 1:
action["domain"] = [("id", "in", tms_orders.ids)]

Check warning on line 26 in tms_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_move.py#L26

Added line #L26 was not covered by tests
else:
action["views"] = [(self.env.ref("tms.tms_order_view_form").id, "form")]
action["res_id"] = tms_orders.id

Check warning on line 29 in tms_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_move.py#L28-L29

Added lines #L28 - L29 were not covered by tests

return action

Check warning on line 31 in tms_account/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

tms_account/models/account_move.py#L31

Added line #L31 was not covered by tests
Loading

0 comments on commit 976534c

Please sign in to comment.