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][IMP]sale_line_refund_to_invoice_qty: credit note default #1748

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
3 changes: 3 additions & 0 deletions sale_line_refund_to_invoice_qty/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Furthermore, after creating the credit note, you can mark the field "Sale qty
not to reinvoice" to decide the criteria to be used for each specific invoice
line.

Enabling the "Reinvoice credit note by default" flag in the Invoice settings, will
enable the "This credit note will be reinvoiced" flag on Credit Notes by default.

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

Expand Down
1 change: 1 addition & 0 deletions sale_line_refund_to_invoice_qty/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"depends": ["sale_management"],
"data": [
"views/account_move_views.xml",
"views/res_config_settings_views.xml",
"views/sale_order_views.xml",
"wizards/account_move_reversal_view.xml",
],
Expand Down
2 changes: 2 additions & 0 deletions sale_line_refund_to_invoice_qty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright 2021 ForgeFlow (http://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import account
from . import res_company
from . import res_config_settings
from . import sale
9 changes: 9 additions & 0 deletions sale_line_refund_to_invoice_qty/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

reinvoice_credit_note_default = fields.Boolean(
"Reinvoice credit notes by default", default=True
)
10 changes: 10 additions & 0 deletions sale_line_refund_to_invoice_qty/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

reinvoice_credit_note_default = fields.Boolean(
related="company_id.reinvoice_credit_note_default",
readonly=False,
)
3 changes: 3 additions & 0 deletions sale_line_refund_to_invoice_qty/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ from the quantity invoiced of the related sales order lines.
Furthermore, after creating the credit note, you can mark the field "Sale qty
not to reinvoice" to decide the criteria to be used for each specific invoice
line.

Enabling the "Reinvoice credit note by default" flag in the Invoice settings, will
enable the "This credit note will be reinvoiced" flag on Credit Notes by default.
13 changes: 9 additions & 4 deletions sale_line_refund_to_invoice_qty/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,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 @@ -274,7 +275,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 @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

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

span.section-subtitle {
Expand Down Expand Up @@ -394,6 +395,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>Furthermore, after creating the credit note, you can mark the field “Sale qty
not to reinvoice” to decide the criteria to be used for each specific invoice
line.</p>
<p>Enabling the “Reinvoice credit note by default” flag in the Invoice settings, will
enable the “This credit note will be reinvoiced” flag on Credit Notes by default.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand Down Expand Up @@ -421,7 +424,9 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<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
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<div id="invoicing_settings" position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="reinvoice_credit_note_default" />
</div>
<div class="o_setting_right_pane">
<label for="reinvoice_credit_note_default" />
<div class="text-muted">
Enables the "This credit note will be reinvoiced" flag on Credit Notes by default
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>
14 changes: 12 additions & 2 deletions sale_line_refund_to_invoice_qty/wizards/account_move_reversal.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
# Copyright 2021 ForgeFlow (http://www.forgeflow.com)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models
from odoo import api, fields, models


class AccountMoveReversal(models.TransientModel):
_inherit = "account.move.reversal"

sale_qty_to_reinvoice = fields.Boolean(
string="This credit note will be reinvoiced",
default="True",
help="Leave it marked if you will reinvoice the same sale order line "
"(standard behaviour)",
)

@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
company = (
self.env["res.company"].browse(res.get("company_id"))
if res.get("company_id")
else self.env.company
)
res["sale_qty_to_reinvoice"] = company.reinvoice_credit_note_default
return res

def reverse_moves(self):
return super(
AccountMoveReversal,
Expand Down
Loading