Skip to content

Commit

Permalink
[IMP] l10n_it_riba: Pay multiple lines at once
Browse files Browse the repository at this point in the history
Also allow to set a date during payment and past due process
  • Loading branch information
SirAionTech authored and odooNextev committed Feb 4, 2025
1 parent ea8d2f5 commit dd20304
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 61 deletions.
24 changes: 13 additions & 11 deletions l10n_it_ricevute_bancarie/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
ITA - Ricevute bancarie
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:bd9589fce4ca329bffe086bf3419f0740cd57580f2e51c5e46538ae59a143476
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
Expand All @@ -23,10 +20,10 @@ ITA - Ricevute bancarie
:target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_ricevute_bancarie
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=14.0
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/l10n-italy&target_branch=14.0
:alt: Try me on Runboat

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

**Italiano**

Expand Down Expand Up @@ -108,10 +105,15 @@ esposizione, cioè l'importo dovuto dal cliente a fronte dell'emissione
della RiBa non ancora scaduta.

In maniera predefinita la data delle registrazioni dei pagamenti viene
impostata con la data di scadenza della RiBa, ma è possibile modificarla
successivamente a pagamento effettivamente avvenuto selezionando la
registrazione dalla vista ed elenco ed eseguendo l'azione "Imposta data
di pagamento RiBa".
impostata con la data di scadenza della RiBa, ma è possibile modificarla in due momenti:

- durante la creazione del pagamento,
cliccando su "Segna righe come pagate" o su "Segna coma pagata"
o usando l'azione "Registrazione Riba a data di scadenza"
e indicando una data nel campo `Data pagamento`,
- successivamente a pagamento effettivamente avvenuto selezionando la selezionando la
registrazione dalla vista ed elenco ed eseguendo l'azione "Imposta data
di pagamento RiBa".

Known issues / Roadmap
======================
Expand All @@ -126,7 +128,7 @@ Bug Tracker

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_ricevute_bancarie%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.
Expand Down
1 change: 1 addition & 0 deletions l10n_it_ricevute_bancarie/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"views/riba_detail_view.xml",
"views/wizard_presentation.xml",
"views/wizard_due_date_settlement.xml",
"wizard/wizard_riba_multiple_payment_views.xml",
],
"demo": ["demo/riba_demo.xml"],
"installable": True,
Expand Down
47 changes: 39 additions & 8 deletions l10n_it_ricevute_bancarie/models/riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ def _compute_total_amount(self):
)
date_accepted = fields.Date("Acceptance Date")
date_accreditation = fields.Date("Credit Date")
date_paid = fields.Date("Payment Date", readonly=True)
date_paid = fields.Date(
string="Payment Date",
help="Default date for payments.",
readonly=True,
states={
"credited": [
("readonly", False),
],
},
)
date_unsolved = fields.Date("Past Due Date", readonly=True)
company_id = fields.Many2one(
"res.company",
Expand Down Expand Up @@ -187,10 +196,15 @@ def riba_cancel(self):
distinta.state = "cancel"

def settle_all_line(self):
for riba_list in self:
for line in riba_list.line_ids:
if line.state == "accredited":
line.riba_line_settlement()
payment_wizard_action = self.env["ir.actions.actions"]._for_xml_id(
"l10n_it_ricevute_bancarie.riba_payment_multiple_action"
)
context = dict(self.env.context)
context.update(
active_ids=self.ids,
)
payment_wizard_action["context"] = context
return payment_wizard_action

@api.onchange("date_accepted", "date_accreditation")
def _onchange_date(self):
Expand Down Expand Up @@ -228,7 +242,7 @@ def action_cancel_draft(self):

def action_open_lines(self):
action = self.env.ref("l10n_it_ricevute_bancarie.detail_riba_action").read()[0]
action["domain"] = [("slip_id", "=", self.id)]
action["domain"] = [("distinta_id", "=", self.id)]

Check warning on line 245 in l10n_it_ricevute_bancarie/models/riba.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_ricevute_bancarie/models/riba.py#L245

Added line #L245 was not covered by tests
return action


Expand Down Expand Up @@ -475,7 +489,23 @@ def confirm(self):
if not line.distinta_id.date_accepted:
line.distinta_id.date_accepted = fields.Date.context_today(self)

def riba_line_settlement(self):
def button_settle(self):
payment_wizard_action = self.env["ir.actions.actions"]._for_xml_id(

Check warning on line 493 in l10n_it_ricevute_bancarie/models/riba.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_ricevute_bancarie/models/riba.py#L493

Added line #L493 was not covered by tests
"l10n_it_ricevute_bancarie.riba_payment_multiple_action"
)
context = dict(self.env.context)
context.update(

Check warning on line 497 in l10n_it_ricevute_bancarie/models/riba.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_ricevute_bancarie/models/riba.py#L496-L497

Added lines #L496 - L497 were not covered by tests
active_ids=self.distinta_id.ids,
default_riba_line_ids=self.ids,
)
payment_wizard_action["context"] = context
return payment_wizard_action

Check warning on line 502 in l10n_it_ricevute_bancarie/models/riba.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_ricevute_bancarie/models/riba.py#L501-L502

Added lines #L501 - L502 were not covered by tests

def riba_line_settlement(self, date=None):
"""Create payment the acceptance move of each line in `self`.
:param date: The created payment's date.
"""
for riba_line in self:
if not riba_line.distinta_id.config_id.settlement_journal_id:
raise UserError(_("Please define a Settlement Journal."))
Expand All @@ -498,12 +528,13 @@ def riba_line_settlement(self):
riba_line.distinta_id.name,
riba_line.partner_id.name,
)
move_date = date or riba_line.due_date.strftime("%Y-%m-%d")
settlement_move = move_model.create(
{
"journal_id": (
riba_line.distinta_id.config_id.settlement_journal_id.id
),
"date": riba_line.due_date.strftime("%Y-%m-%d"),
"date": move_date,
"ref": move_ref,
}
)
Expand Down
13 changes: 9 additions & 4 deletions l10n_it_ricevute_bancarie/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ esposizione, cioè l'importo dovuto dal cliente a fronte dell'emissione
della RiBa non ancora scaduta.

In maniera predefinita la data delle registrazioni dei pagamenti viene
impostata con la data di scadenza della RiBa, ma è possibile modificarla
successivamente a pagamento effettivamente avvenuto selezionando la
registrazione dalla vista ed elenco ed eseguendo l'azione "Imposta data
di pagamento RiBa".
impostata con la data di scadenza della RiBa, ma è possibile modificarla in due momenti:

- durante la creazione del pagamento,
cliccando su "Segna righe come pagate" o su "Segna coma pagata"
o usando l'azione "Registrazione Riba a data di scadenza"
e indicando una data nel campo `Data pagamento`,
- successivamente a pagamento effettivamente avvenuto selezionando la selezionando la
registrazione dalla vista ed elenco ed eseguendo l'azione "Imposta data
di pagamento RiBa".
1 change: 1 addition & 0 deletions l10n_it_ricevute_bancarie/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ access_riba_file_export,riba_file_export,model_riba_file_export,account.group_ac
access_presentation_riba_issue,access_presentation_riba_issue,model_presentation_riba_issue,account.group_account_invoice,1,1,1,1
access_riba_due_date_settlement,riba_due_date_settlement,model_riba_due_date_settlement,account.group_account_invoice,1,1,1,1
access_riba_payment_date,riba_payment_date,model_riba_payment_date,account.group_account_invoice,1,1,1,1
access_riba_multiple_payment_date,Full access to Pay multiple RiBa lines,model_riba_payment_multiple,account.group_account_invoice,1,1,1,1
64 changes: 34 additions & 30 deletions l10n_it_ricevute_bancarie/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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: https://docutils.sourceforge.io/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>ITA - Ricevute bancarie</title>
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z 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
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* 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 +301,7 @@
span.pre {
white-space: pre }

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

span.section-subtitle {
Expand Down Expand Up @@ -366,28 +366,26 @@ <h1 class="title">ITA - Ricevute bancarie</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:bd9589fce4ca329bffe086bf3419f0740cd57580f2e51c5e46538ae59a143476
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_ricevute_bancarie"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_ricevute_bancarie"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></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/l10n-italy/tree/14.0/l10n_it_ricevute_bancarie"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_ricevute_bancarie"><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/l10n-italy&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><strong>Italiano</strong></p>
<p>Modulo per gestire le ricevute bancarie.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id5">Credits</a><ul>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p><strong>Italiano</strong></p>
<p>Nella configurazione delle Ri.Ba. è possibile specificare se si tratti di
‘Salvo buon fine’ o ‘Al dopo incasso’, che hanno un flusso completamente diverso.</p>
Expand Down Expand Up @@ -423,7 +421,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<em>Configurazione → Impostazioni → Contabilità → Imposte → Spese di incasso Ri.Ba.</em>.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p><strong>Italiano</strong></p>
<p>Per utilizzare il meccanismo delle Ri.Ba. è necessario configurare un termine
di pagamento di tipo ‘Ri.Ba.’.</p>
Expand All @@ -447,29 +445,37 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
esposizione, cioè l’importo dovuto dal cliente a fronte dell’emissione
della RiBa non ancora scaduta.</p>
<p>In maniera predefinita la data delle registrazioni dei pagamenti viene
impostata con la data di scadenza della RiBa, ma è possibile modificarla
successivamente a pagamento effettivamente avvenuto selezionando la
impostata con la data di scadenza della RiBa, ma è possibile modificarla in due momenti:</p>
<blockquote>
<ul class="simple">
<li>durante la creazione del pagamento,
cliccando su “Segna righe come pagate” o su “Segna coma pagata”
o usando l’azione “Registrazione Riba a data di scadenza”
e indicando una data nel campo <cite>Data pagamento</cite>,</li>
<li>successivamente a pagamento effettivamente avvenuto selezionando la selezionando la
registrazione dalla vista ed elenco ed eseguendo l’azione “Imposta data
di pagamento RiBa”.</p>
di pagamento RiBa”.</li>
</ul>
</blockquote>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<h1><a class="toc-backref" href="#id3">Known issues / Roadmap</a></h1>
<p><strong>Italiano</strong></p>
<p>Attenzione!
Il modulo è stato migrato, ma gli script di migrazione non sono stati provati.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-italy/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 to smash it by providing a detailed and welcomed
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_ricevute_bancarie%0Aversion:%2014.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">
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<h1><a class="toc-backref" href="#id5">Credits</a></h1>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Lorenzo Battistini &lt;<a class="reference external" href="mailto:lorenzo.battistini&#64;agilebg.com">lorenzo.battistini&#64;agilebg.com</a>&gt;</li>
<li>Andrea Cometa &lt;<a class="reference external" href="mailto:a.cometa&#64;apuliasoftware.it">a.cometa&#64;apuliasoftware.it</a>&gt;</li>
Expand All @@ -495,11 +501,9 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id7">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
2 changes: 2 additions & 0 deletions l10n_it_ricevute_bancarie/tests/riba_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def create_config_incasso(self):
"bank_id": self.company_bank.id,
"acceptance_journal_id": self.bank_journal.id,
"acceptance_account_id": self.sbf_effects.id,
"settlement_journal_id": self.bank_journal.id,
}
)

Expand All @@ -268,5 +269,6 @@ def create_config(self, sbf_collection_type):
"unsolved_journal_id": self.bank_journal.id,
"overdue_effects_account_id": self.unsolved_account.id,
"protest_charge_account_id": self.expenses_account.id,
"settlement_journal_id": self.bank_journal.id,
}
)
Loading

0 comments on commit dd20304

Please sign in to comment.