Skip to content

Commit

Permalink
[MIG] account_move_update_analytic to v16
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Jul 19, 2023
1 parent 5a71e0e commit 06fa73c
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 127 deletions.
23 changes: 11 additions & 12 deletions account_move_update_analytic/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ Account move update analytic
: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/15.0/account_move_update_analytic
:target: https://github.com/OCA/account-analytic/tree/16.0/account_move_update_analytic
: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-15-0/account-analytic-15-0-account_move_update_analytic
:target: https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-account_move_update_analytic
: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/15.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/account-analytic&target_branch=16.0
:alt: Try me on Runboat

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

This module allows users to update analytic account and tags on account_move lines
Adds tracking to fields ``analytic_account_id`` and ``analytic_tag_ids`` on move lines
This module allows users to update the analytic distribution on journal items.

**Table of contents**

Expand All @@ -38,19 +37,19 @@ Usage

1. In a posted move and from customer invoices and vendor bills, 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 account and tags are 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. Analytic lines will be dropped from current analytic account and recreated on new analytic distribution.

.. figure:: https://raw.githubusercontent.com/OCA/account-analytic/15.0/account_move_update_analytic/static/description/update_from_invoice.png
.. figure:: https://raw.githubusercontent.com/OCA/account-analytic/16.0/account_move_update_analytic/static/description/update_from_invoice.png

.. figure:: https://raw.githubusercontent.com/OCA/account-analytic/15.0/account_move_update_analytic/static/description/update_from_journals.png
.. figure:: https://raw.githubusercontent.com/OCA/account-analytic/16.0/account_move_update_analytic/static/description/update_from_journals.png

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_move_update_analytic%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20account_move_update_analytic%0Aversion:%2016.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.

Expand Down Expand Up @@ -83,6 +82,6 @@ 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/15.0/account_move_update_analytic>`_ project on GitHub.
This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/16.0/account_move_update_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 0 additions & 1 deletion account_move_update_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import models
from . import wizards
2 changes: 1 addition & 1 deletion account_move_update_analytic/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Account move update analytic",
"version": "15.0.1.1.0",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"summary": "This module allows the user to update analytic on posted moves",
"author": "Le Filament, Moduon, Odoo Community Association (OCA)",
Expand Down
14 changes: 0 additions & 14 deletions account_move_update_analytic/models/account_move_line.py

This file was deleted.

3 changes: 1 addition & 2 deletions account_move_update_analytic/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
This module allows users to update analytic account and tags on account_move lines
Adds tracking to fields ``analytic_account_id`` and ``analytic_tag_ids`` on move lines
This module allows users to update the analytic distribution on journal items.
2 changes: 1 addition & 1 deletion account_move_update_analytic/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1. In a posted move and from customer invoices and vendor bills, 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 account and tags are 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. Analytic lines will be dropped from current analytic account and recreated on new analytic distribution.

.. figure:: ../static/description/update_from_invoice.png

Expand Down
1 change: 0 additions & 1 deletion account_move_update_analytic/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
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
17 changes: 8 additions & 9 deletions account_move_update_analytic/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Account move update analytic</title>
<style type="text/css">

Expand Down Expand Up @@ -367,9 +367,8 @@ <h1 class="title">Account move update analytic</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-analytic/tree/15.0/account_move_update_analytic"><img alt="OCA/account-analytic" src="https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-analytic-15-0/account-analytic-15-0-account_move_update_analytic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/87/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows users to update analytic account and tags on account_move lines
Adds tracking to fields <tt class="docutils literal">analytic_account_id</tt> and <tt class="docutils literal">analytic_tag_ids</tt> on move lines</p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-analytic/tree/16.0/account_move_update_analytic"><img alt="OCA/account-analytic" src="https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-account_move_update_analytic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/webui/builds.html?repo=OCA/account-analytic&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows users to update the analytic distribution on journal items.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand All @@ -388,21 +387,21 @@ <h1><a class="toc-backref" href="#id1">Usage</a></h1>
<ol class="arabic simple">
<li>In a posted move and from customer invoices and vendor bills, 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).</li>
<li>Current analytic account and tags are shown, you can select another one then click on Confirm</li>
<li>Analytic lines will be dropped from current analytic account and recreated on new analytic account/tags.</li>
<li>Analytic lines will be dropped from current analytic account and recreated on new analytic distribution.</li>
</ol>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/account-analytic/15.0/account_move_update_analytic/static/description/update_from_invoice.png" src="https://raw.githubusercontent.com/OCA/account-analytic/15.0/account_move_update_analytic/static/description/update_from_invoice.png" />
<img alt="https://raw.githubusercontent.com/OCA/account-analytic/16.0/account_move_update_analytic/static/description/update_from_invoice.png" src="https://raw.githubusercontent.com/OCA/account-analytic/16.0/account_move_update_analytic/static/description/update_from_invoice.png" />
</div>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/account-analytic/15.0/account_move_update_analytic/static/description/update_from_journals.png" src="https://raw.githubusercontent.com/OCA/account-analytic/15.0/account_move_update_analytic/static/description/update_from_journals.png" />
<img alt="https://raw.githubusercontent.com/OCA/account-analytic/16.0/account_move_update_analytic/static/description/update_from_journals.png" src="https://raw.githubusercontent.com/OCA/account-analytic/16.0/account_move_update_analytic/static/description/update_from_journals.png" />
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-analytic/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-analytic/issues/new?body=module:%20account_move_update_analytic%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-analytic/issues/new?body=module:%20account_move_update_analytic%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -429,7 +428,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-analytic/tree/15.0/account_move_update_analytic">OCA/account-analytic</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-analytic/tree/16.0/account_move_update_analytic">OCA/account-analytic</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
21 changes: 2 additions & 19 deletions account_move_update_analytic/views/account_move_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,16 @@
<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_tag_ids" position="after">
<field name="analytic_distribution" 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"
groups="analytic.group_analytic_accounting"
attrs="{'invisible': [('parent_state', '!=', 'posted')]}"
/>
</field>
</field>
</record>

<record model="ir.ui.view" id="view_move_line_tree_grouped">
<field name="name">account.move.line.tree.grouped</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree_grouped" />
<field name="arch" type="xml">
<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'),]}"
/>
</field>
</field>
</record>

</odoo>
20 changes: 1 addition & 19 deletions account_move_update_analytic/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,14 @@
<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']"
expr="//field[@name='line_ids']/tree/field[@name='analytic_distribution']"
position="after"
>
<field name="parent_state" invisible="1" />
<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="{'column_invisible': [('parent.state', '!=', 'posted')]}"
/>
</xpath>
<xpath
expr="//field[@name='line_ids']/tree/field[@name='analytic_tag_ids']"
position="after"
>
<field name="parent_state" invisible="1" />
<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="{
'column_invisible': [('parent.state', '!=', 'posted')],
'invisible': [('display_type', 'in', ('line_section', 'line_note'))],
}"
/>
</xpath>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ class AccountMoveUpdateAnalytic(models.TransientModel):
_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"
product_id = fields.Many2one(related="line_id.product_id")
account_id = fields.Many2one(related="line_id.account_id")
move_type = fields.Selection(related="line_id.move_id.move_type")
analytic_precision = fields.Integer(related="line_id.analytic_precision")
current_analytic_distribution = fields.Json(
related="line_id.analytic_distribution", string="Current Analytic Distribution"
)
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
)
analytic_distribution = fields.Json(string="New Analytic Distribution")

@api.model
def default_get(self, fields):
Expand All @@ -31,28 +27,17 @@ def default_get(self, fields):
aml = self.env["account.move.line"].browse(active_id)
rec.update(
{
"line_id": active_id,
"current_analytic_account_id": aml.analytic_account_id.id,
"new_analytic_account_id": aml.analytic_account_id.id,
"current_analytic_tag_ids": [(6, 0, aml.analytic_tag_ids.ids or [])],
"new_analytic_tag_ids": [(6, 0, aml.analytic_tag_ids.ids or [])],
"company_id": aml.company_id.id,
"line_id": aml.id,
"product_id": aml.product_id.id,
"account_id": aml.account_id.id,
"move_type": aml.move_id.move_type,
"analytic_precision": aml.analytic_precision,
"current_analytic_distribution": aml.analytic_distribution,
"analytic_distribution": aml.analytic_distribution,
}
)
return rec

def update_analytic_lines(self):
self.ensure_one()
self.line_id.analytic_line_ids.unlink()
if self.user_has_groups("analytic.group_analytic_accounting"):
self.line_id.analytic_account_id = self.new_analytic_account_id.id
if self.user_has_groups("analytic.group_analytic_tags"):
self.line_id.write(
{"analytic_tag_ids": [(6, 0, self.new_analytic_tag_ids.ids)]}
)
if self.line_id.parent_state == "posted" and (
self.new_analytic_account_id or self.new_analytic_tag_ids
):
self.line_id.create_analytic_lines()

return False
self.line_id.analytic_distribution = self.analytic_distribution
Loading

0 comments on commit 06fa73c

Please sign in to comment.