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

[FIX] Validation of mandatory plans #1

Open
wants to merge 1 commit into
base: 17.0-mig-account_move_update_analytic
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
3 changes: 3 additions & 0 deletions account_move_update_analytic/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Contributors
- Eduardo de Miguel ([Moduon](https://www.moduon.team/))
- Rafael Blasco ([Moduon](https://www.moduon.team/))
- Mario Luis ([Binhex](https://www.binhex.cloud/))
- APSL - Nagarro <https://apsl.tech>

- Bernat Obrador

Maintainers
-----------
Expand Down
2 changes: 2 additions & 0 deletions account_move_update_analytic/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
- Eduardo de Miguel (\[Moduon\](<https://www.moduon.team/>))
- Rafael Blasco (\[Moduon\](<https://www.moduon.team/>))
- Mario Luis (\[Binhex\](<https://www.binhex.cloud/>))
- APSL - Nagarro \<<https://apsl.tech>\>
- Bernat Obrador
15 changes: 11 additions & 4 deletions account_move_update_analytic/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +276,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +302,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -426,12 +427,18 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Eduardo de Miguel ([Moduon](<a class="reference external" href="https://www.moduon.team/">https://www.moduon.team/</a>))</li>
<li>Rafael Blasco ([Moduon](<a class="reference external" href="https://www.moduon.team/">https://www.moduon.team/</a>))</li>
<li>Mario Luis ([Binhex](<a class="reference external" href="https://www.binhex.cloud/">https://www.binhex.cloud/</a>))</li>
<li>APSL - Nagarro &lt;<a class="reference external" href="https://apsl.tech">https://apsl.tech</a>&gt;<ul>
<li>Bernat Obrador</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<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>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2022 Le Filament
# Copyright 2022 Moduon - Eduardo de Miguel
# Copyright 2024 (Nagarro - APSL) - Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
Expand All @@ -8,17 +9,16 @@
class AccountMoveUpdateAnalytic(models.TransientModel):
_name = "account.move.update.analytic.wizard"
_description = "Account Move Update Analytic Account Wizard"
_inherit = "analytic.mixin"

line_id = fields.Many2one("account.move.line", string="Invoice line")
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")
company_id = fields.Many2one(related="line_id.company_id")
current_analytic_distribution = fields.Json(
related="line_id.analytic_distribution", string="Current Analytic Distribution"
)
company_id = fields.Many2one(related="line_id.company_id")
analytic_distribution = fields.Json(string="New Analytic Distribution")

@api.model
def default_get(self, fields):
Expand All @@ -32,6 +32,7 @@ def default_get(self, fields):
"account_id": aml.account_id.id,
"move_type": aml.move_id.move_type,
"analytic_precision": aml.analytic_precision,
"company_id": aml.company_id.id,
"current_analytic_distribution": aml.analytic_distribution,
"analytic_distribution": aml.analytic_distribution,
}
Expand All @@ -40,4 +41,6 @@ def default_get(self, fields):

def update_analytic_lines(self):
self.ensure_one()
# Validate if mandatory plans has 100%
self.with_context(validate_analytic=True)._validate_distribution()
self.line_id.analytic_distribution = self.analytic_distribution