Skip to content
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

[14.0][ADD] account_analytic_line_split: add new module #681

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions account_analytic_line_split/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
===========================
Account Analytic Line Split
===========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:51841c6908ca68e10fec816309262b08de0c26c69a85b25e60ade24c8b007b58
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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%2Faccount--analytic-lightgray.png?logo=github
:target: https://github.com/OCA/account-analytic/tree/14.0/account_analytic_line_split
:alt: OCA/account-analytic
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-analytic-14-0/account-analytic-14-0-account_analytic_line_split
: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/account-analytic&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to split analytic lines in two or more lines.

**Table of contents**

.. contents::
:local:

Usage
=====

To split an analytic line:

#. Go to Invoicing > Configuration > Management > Analytic Items.
#. Open an Anlytic Entry.
#. Click on "Split Line" button to open the wizard.
#. Create the lines setting the Analytic Account and Percentage of the amount.
#. The new lines will be created and displayed in "Child Lines" notebook.

To split an analytic line directly from the Account Move:

#. Open one Account Move (a Journal Entry, Bill or Invoice).
#. Go to "Analytic Lines" notebook.
#. Click on "Split Line" button inside the line to open the wizard.
#. Create the lines setting the Analytic Account and Percentage of the amount.
#. The new lines will be created and displayed in notebook.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/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/account-analytic/issues/new?body=module:%20account_analytic_line_split%0Aversion:%2014.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
~~~~~~~

* Escodoo

Contributors
~~~~~~~~~~~~

* `Escodoo <https://escodoo.com.br>`_:

* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
* Wesley Oliveira <wesley.oliveira@escodoo.com.br>

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.

This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/14.0/account_analytic_line_split>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions account_analytic_line_split/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
19 changes: 19 additions & 0 deletions account_analytic_line_split/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 - TODAY, Escodoo
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Account Analytic Line Split",
"summary": """
Account Analytic Line Split""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Escodoo, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"depends": ["account", "analytic"],
"data": [
"views/account_analytic_line.xml",
"views/account_move.xml",
"wizard/analytic_line_split_wizard.xml",
"security/ir.model.access.csv",
],
}
2 changes: 2 additions & 0 deletions account_analytic_line_split/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_analytic_line
from . import account_move
43 changes: 43 additions & 0 deletions account_analytic_line_split/models/account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


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

parent_line_id = fields.Many2one(
comodel_name="account.analytic.line",
string="Origin",
ondelete="cascade",
readonly=True,
)
child_line_ids = fields.One2many(
comodel_name="account.analytic.line",
inverse_name="parent_line_id",
string="Child Lines",
readonly=True,
)

def action_edit_analytic_line(self):
context = dict(self.env.context)
context["form_view_initial_mode"] = "edit"
action = self.env["ir.actions.act_window"]._for_xml_id(
"analytic.account_analytic_line_action_entries"
)
action["context"] = context
action["views"] = [(False, "form")]
action["res_id"] = self.id
return action

def action_split_analytic_line(self):
action = self.env["ir.actions.act_window"]._for_xml_id(
"account_analytic_line_split.analytic_line_split_wizard_action"
)
action["context"] = {
"active_id": self.id,
"amount": self.amount,
"account_id": self.account_id.id,
}
return action
19 changes: 19 additions & 0 deletions account_analytic_line_split/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountMove(models.Model):
_inherit = "account.move"

analytic_line_ids = fields.Many2many(
comodel_name="account.analytic.line",
string="Analytic Lines",
compute="_compute_analytic_line_ids",
)

@api.depends("line_ids.analytic_line_ids")
def _compute_analytic_line_ids(self):
for move in self:
move.analytic_line_ids = move.line_ids.mapped("analytic_line_ids")
4 changes: 4 additions & 0 deletions account_analytic_line_split/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Escodoo <https://escodoo.com.br>`_:

* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
* Wesley Oliveira <wesley.oliveira@escodoo.com.br>
1 change: 1 addition & 0 deletions account_analytic_line_split/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to split analytic lines in two or more lines.
15 changes: 15 additions & 0 deletions account_analytic_line_split/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
To split an analytic line:

#. Go to Invoicing > Configuration > Management > Analytic Items.
#. Open an Anlytic Entry.
#. Click on "Split Line" button to open the wizard.
#. Create the lines setting the Analytic Account and Percentage of the amount.
#. The new lines will be created and displayed in "Child Lines" notebook.

To split an analytic line directly from the Account Move:

#. Open one Account Move (a Journal Entry, Bill or Invoice).
#. Go to "Analytic Lines" notebook.
#. Click on "Split Line" button inside the line to open the wizard.
#. Create the lines setting the Analytic Account and Percentage of the amount.
#. The new lines will be created and displayed in notebook.
3 changes: 3 additions & 0 deletions account_analytic_line_split/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_analytic_line_split_wizard,analytic.line.split.wizard,model_analytic_line_split_wizard,analytic.group_analytic_accounting,1,1,1,1
access_analytic_line_split,analytic.line.split,model_analytic_line_split,analytic.group_analytic_accounting,1,1,1,1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading