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] module account_move_update_analytic #497

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
35 changes: 35 additions & 0 deletions account_move_update_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
**This file is going to be generated by oca-gen-addon-readme.**

*Manual changes will be overwritten.*

Please provide content in the ``readme`` directory:

* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)

Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.

A good, one sentence summary in the manifest is also highly recommended.


Automatic changelog generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_.

Just put towncrier compatible changelog fragments into `readme/newsfragments`
and the changelog file will be automatically generated and updated when a new fragment is added.

Please refer to `towncrier` documentation to know more.

NOTE: the changelog will be automatically generated when using `/ocabot merge $option`.
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_.
1 change: 1 addition & 0 deletions account_move_update_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import wizards
20 changes: 20 additions & 0 deletions account_move_update_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Account move update analytic",
"version": "14.0.1.0.0",
"category": "Accounting & Finance",
"summary": "This module allows the user to update analytic on posted moves",
"author": "Le Filament, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"license": "AGPL-3",
"depends": ["account"],
"data": [
"security/ir.model.access.csv",
"wizards/account_move_update_analytic_view.xml",
"views/account_move_view.xml",
"views/account_move_line_view.xml",
],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_update_analytic_account
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-03 15:05+0000\n"
"PO-Revision-Date: 2022-11-03 15:05+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_move_update_analytic_account
#: model:ir.model,name:account_move_update_analytic_account.model_account_move_update_analytic_wizard
msgid "Account Move Update Analytic Account Wizard"
msgstr ""

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.view_account_move_update_analytic_account
msgid "Cancel"
msgstr "Annuler"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__company_id
msgid "Company"
msgstr "Société"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__create_uid
msgid "Created by"
msgstr "Créé par"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__create_date
msgid "Created on"
msgstr "Créé le"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__current_analytic_account_id
msgid "Current Analytic Account"
msgstr "Compte Analytique Actuel"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__display_name
msgid "Display Name"
msgstr "Nom Affiché"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__id
msgid "ID"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__line_id
msgid "Invoice line"
msgstr "Ligne de Facture"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__new_analytic_account_id
msgid "New Analytic Account"
msgstr "Nouveau Compte Analytique"

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.account_move_form_view
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.account_move_line_tree_view
msgid "Update Analytic Account"
msgstr "Mettre à jour le Compte Analytique"

#. module: account_move_update_analytic_account
#: model:ir.actions.act_window,name:account_move_update_analytic_account.action_view_account_move_update_analytic_account
msgid "Update Analytic Account for selected Account Moves"
msgstr "Mettre à jour le compte analytique pour les factures sélectionnées"

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.view_account_move_update_analytic_account
msgid "Update Analytic Accounts"
msgstr "Mettre à jour les comptes analytiques"

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.view_account_move_update_analytic_account
msgid "Update analytic accounts"
msgstr "Mettre à jour les comptes analytiques"
102 changes: 102 additions & 0 deletions account_move_update_analytic/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_update_analytic_account
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-03 15:06+0000\n"
"PO-Revision-Date: 2022-11-03 15:06+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_move_update_analytic_account
#: model:ir.model,name:account_move_update_analytic_account.model_account_move_update_analytic_wizard
msgid "Account Move Update Analytic Account Wizard"
msgstr ""

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.view_account_move_update_analytic_account
msgid "Cancel"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__company_id
msgid "Company"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__create_uid
msgid "Created by"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__create_date
msgid "Created on"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__current_analytic_account_id
msgid "Current Analytic Account"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__display_name
msgid "Display Name"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__id
msgid "ID"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__line_id
msgid "Invoice line"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard____last_update
msgid "Last Modified on"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__write_uid
msgid "Last Updated by"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__write_date
msgid "Last Updated on"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.model.fields,field_description:account_move_update_analytic_account.field_account_move_update_analytic_wizard__new_analytic_account_id
msgid "New Analytic Account"
msgstr ""

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.account_move_form_view
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.account_move_line_tree_view
msgid "Update Analytic Account"
msgstr ""

#. module: account_move_update_analytic_account
#: model:ir.actions.act_window,name:account_move_update_analytic_account.action_view_account_move_update_analytic_account
msgid "Update Analytic Account for selected Account Moves"
msgstr ""

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.view_account_move_update_analytic_account
msgid "Update Analytic Accounts"
msgstr ""

#. module: account_move_update_analytic_account
#: model_terms:ir.ui.view,arch_db:account_move_update_analytic_account.view_account_move_update_analytic_account
msgid "Update analytic accounts"
msgstr ""
1 change: 1 addition & 0 deletions account_move_update_analytic/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Rémi - Le Filament <remi-filament>
1 change: 1 addition & 0 deletions account_move_update_analytic/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows users to update analytic account and tags on account_move lines
3 changes: 3 additions & 0 deletions account_move_update_analytic/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1. In a posted move, go to the move line you want to update, and click on 'Update analytic' to open the wizard. (You also have the button directly on account move lines)
2. Current analytic is shown, you can select another one then click on Confirm
3. Analytic lines will be dropped from current analytic account and recreated on new analytic account/tags.
3 changes: 3 additions & 0 deletions account_move_update_analytic/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_account_move_update_analytic_wizard,access_account_move_update_analytic_wizard,model_account_move_update_analytic_wizard,analytic.group_analytic_accounting,1,1,1,1
access_account_move_update_analytic_tags_wizard,access_account_move_update_analytic_wizard,model_account_move_update_analytic_wizard,analytic.group_analytic_tags,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.
23 changes: 23 additions & 0 deletions account_move_update_analytic/views/account_move_line_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2022 Le Filament
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="account_move_line_tree_view">
<field name="name">account.move.line.tree</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree" />
<field name="arch" type="xml">
<field name="analytic_account_id" position="after">
<button
name="account_move_update_analytic.action_view_account_move_update_analytic"
string="Update Analytic"
type="action"
groups="analytic.group_analytic_accounting,analytic.group_analytic_tags"
attrs="{'invisible': [('parent_state', '!=', 'posted'),]}"
remi-filament marked this conversation as resolved.
Show resolved Hide resolved
/>
</field>
</field>
</record>

remi-filament marked this conversation as resolved.
Show resolved Hide resolved
</odoo>
38 changes: 38 additions & 0 deletions account_move_update_analytic/views/account_move_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2022 Le Filament
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="account_move_form_view">
<field name="name">account.move.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='invoice_line_ids']/tree/field[@name='analytic_tag_ids']"
position="after"
>
<button
name="account_move_update_analytic.action_view_account_move_update_analytic"
string="Update Analytic"
type="action"
groups="analytic.group_analytic_accounting,analytic.group_analytic_tags"
attrs="{'invisible': [('parent.state', '!=', 'posted'),]}"
remi-filament marked this conversation as resolved.
Show resolved Hide resolved
/>
</xpath>
<xpath
expr="//field[@name='line_ids']/tree/field[@name='analytic_tag_ids']"
position="after"
>
<button
name="account_move_update_analytic.action_view_account_move_update_analytic"
string="Update Analytic"
type="action"
groups="analytic.group_analytic_accounting,analytic.group_analytic_tags"
attrs="{'invisible': [('parent.state', '!=', 'posted'), ('display_type', 'in', ('line_section', 'line_note'))]}"
remi-filament marked this conversation as resolved.
Show resolved Hide resolved
/>
</xpath>
</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions account_move_update_analytic/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move_update_analytic
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2022 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class AccountMoveUpdateAnalytic(models.TransientModel):
_name = "account.move.update.analytic.wizard"
_description = "Account Move Update Analytic Account Wizard"

line_id = fields.Many2one("account.move.line", string="Invoice line")
current_analytic_account_id = fields.Many2one(
related="line_id.analytic_account_id", string="Current Analytic Account"
)
current_analytic_tag_ids = fields.Many2many(
related="line_id.analytic_tag_ids", string="Current Analytic Tags"
)
company_id = fields.Many2one(related="line_id.company_id")
new_analytic_account_id = fields.Many2one(
"account.analytic.account", string="New Analytic Account", check_company=True
)
new_analytic_tag_ids = fields.Many2many(
"account.analytic.tag", string="New Analytic Tags", check_company=True
)

@api.model
def default_get(self, fields):
rec = super(AccountMoveUpdateAnalytic, self).default_get(fields)
remi-filament marked this conversation as resolved.
Show resolved Hide resolved
context = dict(self._context or {})
active_id = context.get("active_id", False)
remi-filament marked this conversation as resolved.
Show resolved Hide resolved
aml = self.env["account.move.line"].browse(active_id)
rec.update(
{
"line_id": active_id,
"current_analytic_account_id": aml.analytic_account_id.id,
"current_analytic_tag_ids": [(6, 0, aml.analytic_tag_ids.ids or [])],
"company_id": aml.company_id.id,
}
)
return rec

def update_analytic_lines(self):
self.line_id.analytic_line_ids.unlink()
remi-filament marked this conversation as resolved.
Show resolved Hide resolved
if self.user_has_groups("analytic.group_analytic_accounting"):
self.line_id.write(
remi-filament marked this conversation as resolved.
Show resolved Hide resolved
{"analytic_account_id": self.new_analytic_account_id.id or False}
)
if self.user_has_groups("analytic.group_analytic_tags"):
self.line_id.write(

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the or [] but had to keep the [(6,0,xx)] otherwise it does not empty the field if you remove analytic tags

{"analytic_tag_ids": [(6, 0, self.new_analytic_tag_ids.ids or [])]}
)
if self.new_analytic_account_id or self.new_analytic_tag_ids:
self.line_id.create_analytic_lines()

return False
Loading