Skip to content

Commit

Permalink
Merge PR #443 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by AaronHForgeFlow
  • Loading branch information
OCA-git-bot committed Mar 23, 2022
2 parents 6b779dc + 2638c86 commit e6d067d
Show file tree
Hide file tree
Showing 18 changed files with 740 additions and 0 deletions.
85 changes: 85 additions & 0 deletions account_analytic_tag_default/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
============================
Account Analytic Tag Default
============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/13.0/account_analytic_tag_default
: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-13-0/account-analytic-13-0-account_analytic_tag_default
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/87/13.0
:alt: Try me on Runbot

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

Set default default tags on analytic accounts that apply to invoices when no
other tag is specified and when changing the analytic account.

**Table of contents**

.. contents::
:local:

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

Go to an analytic account and set *Default Analytic Tags*.

Usage
=====

Go to an invoice and select a analytic account in a line, default tags for the
account are automatically applied.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20account_analytic_tag_default%0Aversion:%2013.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
~~~~~~~

* ForgeFlow

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

* Lois Rilo <[email protected]>

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/13.0/account_analytic_tag_default>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_analytic_tag_default/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
12 changes: 12 additions & 0 deletions account_analytic_tag_default/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Account Analytic Tag Default",
"summary": "Set default tags on analytic accounts.",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"depends": ["account"],
"data": ["views/account_analytic_account_view.xml"],
}
34 changes: 34 additions & 0 deletions account_analytic_tag_default/i18n/account_analytic_tag_default.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_analytic_tag_default
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_analytic_tag_default
#: model:ir.model,name:account_analytic_tag_default.model_account_analytic_account
msgid "Analytic Account"
msgstr ""

#. module: account_analytic_tag_default
#: model:ir.model.fields,field_description:account_analytic_tag_default.field_account_move_line__analytic_tag_ids
msgid "Analytic Tags"
msgstr ""

#. module: account_analytic_tag_default
#: model:ir.model.fields,field_description:account_analytic_tag_default.field_account_analytic_account__default_analytic_tag_ids
msgid "Default Analytic Tag"
msgstr ""

#. module: account_analytic_tag_default
#: model:ir.model,name:account_analytic_tag_default.model_account_move_line
msgid "Journal Item"
msgstr ""
2 changes: 2 additions & 0 deletions account_analytic_tag_default/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_analytic_account
from . import account_move
10 changes: 10 additions & 0 deletions account_analytic_tag_default/models/account_analytic_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


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

default_analytic_tag_ids = fields.Many2many(comodel_name="account.analytic.tag")
44 changes: 44 additions & 0 deletions account_analytic_tag_default/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2020 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


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

# make standard field a stored, computed, editable field.
analytic_tag_ids = fields.Many2many(
compute="_compute_analytic_tag_ids",
store=True,
readonly=False,
)

@api.depends("analytic_account_id")
def _compute_analytic_tag_ids(self):
for rec in self:
if not rec._origin and rec.analytic_tag_ids:
continue
if rec.analytic_account_id.default_analytic_tag_ids:
rec.analytic_tag_ids = rec.analytic_account_id.default_analytic_tag_ids
else:
rec.analytic_tag_ids = False

@api.model_create_multi
def create(self, vals_list):
# This is needed to apply default tags when creating and invoice/entry
# from an action in other model, for instance a SO.
aa_model = self.env["account.analytic.account"]
for vals in vals_list:
if vals.get("analytic_account_id"):
a_acc = aa_model.browse(vals.get("analytic_account_id"))
tags_value = vals.get("analytic_tag_ids")
is_tags_empty = not tags_value or (
isinstance(tags_value, list) and tags_value == [(6, 0, [])]
)
if a_acc.default_analytic_tag_ids and is_tags_empty:
vals["analytic_tag_ids"] = [
(6, 0, a_acc.default_analytic_tag_ids.ids)
]

return super().create(vals_list)
1 change: 1 addition & 0 deletions account_analytic_tag_default/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Go to an analytic account and set *Default Analytic Tags*.
1 change: 1 addition & 0 deletions account_analytic_tag_default/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Lois Rilo <[email protected]>
2 changes: 2 additions & 0 deletions account_analytic_tag_default/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Set default default tags on analytic accounts that apply to invoices when no
other tag is specified and when changing the analytic account.
2 changes: 2 additions & 0 deletions account_analytic_tag_default/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Go to an invoice and select a analytic account in a line, default tags for the
account are automatically applied.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e6d067d

Please sign in to comment.