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.0][MIG] account_template_active #1187

Merged
merged 3 commits into from
Aug 30, 2021
Merged
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
127 changes: 127 additions & 0 deletions account_template_active/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
==============================
Disable Account Template Items
==============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/14.0/account_template_active
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_template_active
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/92/14.0
:alt: Try me on Runbot

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

This module allows to disable account template items, adding
an ``active`` field on the following models:

* ``account.account.template``

.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/14.0/account_template_active/static/description/account_account_template_tree.png

* ``account.fiscal.position.template`` and it two related models
* ``account.fiscal.position.account.template``
* ``account.fiscal.position.tax.template``

.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/14.0/account_template_active/static/description/account_fiscal_position_template_form.png

This module can be interesting in a multi company context,
if you install a lot of accounting templates, with some changes.

It can also be interesting if you want to developp a custom localization
module based on the official one, but with some removed / added / altered items.

**Note:**

* The field ``active`` is present in the Odoo ``account`` module for the model
``account.tax.template``. for that field, this module only adds the ``active``
field on the tree view.

.. figure:: https://raw.githubusercontent.com/OCA/account-financial-tools/14.0/account_template_active/static/description/account_tax_template_tree.png

For consistency reason,

* if user disables an ``account.account.template`` it will disable the related
``account.fiscal.position.account.template``

* if user disables an ``account.tax.template`` it will disable the related
``account.fiscal.position.tax.template``

* if user enables an ``account.fiscal.position.account.template`` it will enable the
related ``account.account.template``

* if user enables an ``account.fiscal.position.tax.template`` it will enable the
related ``account.tax.template``

**Table of contents**

.. contents::
:local:

Usage
=====

* Go to Configuration > Templates
* Select then the template you want to change.

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

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

* GRAP

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

* Sylvain LE GAL <https://twitter.com/legalsylvain>
* Stefan Rijnhart <[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.

.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
:target: https://github.com/legalsylvain
:alt: legalsylvain

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-legalsylvain|

This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_template_active>`_ 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_template_active/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
24 changes: 24 additions & 0 deletions account_template_active/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Disable Account Template Items",
"version": "14.0.1.0.0",
"category": "Accounting",
"license": "AGPL-3",
"summary": "Allow to disable / enable account template items"
" (tax, fiscal position, account)",
"author": "GRAP, Odoo Community Association (OCA)",
"maintainers": ["legalsylvain"],
"website": "https://github.com/OCA/account-financial-tools",
"depends": [
"account_menu",
],
"data": [
"views/view_account_account_template.xml",
"views/view_account_fiscal_position_template.xml",
"views/view_account_tax_template.xml",
],
"installable": True,
}
50 changes: 50 additions & 0 deletions account_template_active/i18n/account_template_active.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_template_active
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-04 16:56+0000\n"
"PO-Revision-Date: 2020-05-04 16:56+0000\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_template_active
#: model:ir.model,name:account_template_active.model_account_fiscal_position_account_template
msgid "Accounts Mapping Template of Fiscal Position"
msgstr ""

#. module: account_template_active
#: model:ir.model.fields,field_description:account_template_active.field_account_account_template__active
#: model:ir.model.fields,field_description:account_template_active.field_account_fiscal_position_account_template__active
#: model:ir.model.fields,field_description:account_template_active.field_account_fiscal_position_tax_template__active
#: model:ir.model.fields,field_description:account_template_active.field_account_fiscal_position_template__active
msgid "Active"
msgstr ""

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_fiscal_position_tax_template
msgid "Tax Mapping Template of Fiscal Position"
msgstr ""

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_fiscal_position_template
msgid "Template for Fiscal Position"
msgstr ""

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_account_template
msgid "Templates for Accounts"
msgstr ""

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_tax_template
msgid "Templates for Taxes"
msgstr ""

50 changes: 50 additions & 0 deletions account_template_active/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_template_active
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-04 16:57+0000\n"
"PO-Revision-Date: 2020-05-04 16:57+0000\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_template_active
#: model:ir.model,name:account_template_active.model_account_fiscal_position_account_template
msgid "Accounts Mapping Template of Fiscal Position"
msgstr "Modèle de mapping de compte de position fiscale"

#. module: account_template_active
#: model:ir.model.fields,field_description:account_template_active.field_account_account_template__active
#: model:ir.model.fields,field_description:account_template_active.field_account_fiscal_position_account_template__active
#: model:ir.model.fields,field_description:account_template_active.field_account_fiscal_position_tax_template__active
#: model:ir.model.fields,field_description:account_template_active.field_account_fiscal_position_template__active
msgid "Active"
msgstr "Actif"

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_fiscal_position_tax_template
msgid "Tax Mapping Template of Fiscal Position"
msgstr "Modèle de mapping de taxe de position fiscale"

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_fiscal_position_template
msgid "Template for Fiscal Position"
msgstr "Modèle de position fiscale"

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_account_template
msgid "Templates for Accounts"
msgstr "Modèles pour les comptes"

#. module: account_template_active
#: model:ir.model,name:account_template_active.model_account_tax_template
msgid "Templates for Taxes"
msgstr "Modèles pour les taxes"

5 changes: 5 additions & 0 deletions account_template_active/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import account_account_template
from . import account_fiscal_position_account_template
from . import account_fiscal_position_tax_template
from . import account_fiscal_position_template
from . import account_tax_template
26 changes: 26 additions & 0 deletions account_template_active/models/account_account_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (C) 2015 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountAccountTemplate(models.Model):
_inherit = "account.account.template"

active = fields.Boolean(string="Active", default=True)

def write(self, vals):
FpaTemplate = self.env["account.fiscal.position.account.template"]
if "active" in vals and not vals.get("active"):
# Disable account.account.template should disable
# account.fiscal.position.account.template associated
fpaTemplates = FpaTemplate.search(
[
"|",
("account_src_id", "in", self.ids),
("account_dest_id", "in", self.ids),
]
)
fpaTemplates.write({"active": False})
return super().write(vals)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2018-Today GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountFiscalPositionAccountTemplate(models.Model):
_inherit = "account.fiscal.position.account.template"

active = fields.Boolean("Active", default=True)

def write(self, vals):
AccountTemplate = self.env["account.account.template"]
if vals.get("active", False):
# enable account.fiscal.position.account.template should enable
# related account.account.template
account_ids = set(
self.mapped("account_src_id").ids + self.mapped("account_dest_id").ids
)
accountTemplates = AccountTemplate.browse(account_ids)
accountTemplates.write({"active": True})
return super().write(vals)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2019-Today GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountFiscalPositionTaxTemplate(models.Model):
_inherit = "account.fiscal.position.tax.template"

active = fields.Boolean("Active", default=True)

def write(self, vals):
TaxTemplate = self.env["account.tax.template"]
if vals.get("active", False):
# enable account.fiscal.position.tax.template should enable
# related account.tax.template
tax_ids = set(
self.mapped("tax_src_id").ids + self.mapped("tax_dest_id").ids
)
taxTemplates = TaxTemplate.browse(tax_ids)
taxTemplates.write({"active": True})
return super().write(vals)
11 changes: 11 additions & 0 deletions account_template_active/models/account_fiscal_position_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (C) 2019-Today GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountFiscalPositionTemplate(models.Model):
_inherit = "account.fiscal.position.template"

active = fields.Boolean("Active", default=True)
24 changes: 24 additions & 0 deletions account_template_active/models/account_tax_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


class AccountTaxTemplate(models.Model):
_inherit = "account.tax.template"

def write(self, vals):
FptTemplate = self.env["account.fiscal.position.tax.template"]
if "active" in vals and not vals.get("active"):
# Disable account.tax.template should disable
# account.fiscal.position.tax.template associated
fptTemplates = FptTemplate.search(
[
"|",
("tax_src_id", "in", self.ids),
("tax_dest_id", "in", self.ids),
]
)
fptTemplates.write({"active": False})
return super().write(vals)
2 changes: 2 additions & 0 deletions account_template_active/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
* Stefan Rijnhart <[email protected]>
Loading