Skip to content
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
6 changes: 1 addition & 5 deletions sale_order_line_no_print/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================================
Sale order line hidden in report
================================
Expand All @@ -17,7 +13,7 @@ Sale order line hidden in report
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
Expand Down
1 change: 1 addition & 0 deletions sale_order_line_no_print/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions sale_order_line_no_print/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
{
"name": "Sale order line hidden in report",
"summary": "Hide order lines in reports",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Sales/Sales",
"website": "https://github.com/OCA/sale-workflow",
"author": "Moduon, Odoo Community Association (OCA)",
"maintainers": ["chienandalu", "rafaelbn"],
"license": "LGPL-3",
"depends": ["sale"],
"data": [
"views/report_invoice_document.xml",
"views/report_saleorder_document.xml",
"views/account_move_views.xml",
"views/sale_order_views.xml",
],
}
2 changes: 2 additions & 0 deletions sale_order_line_no_print/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_move
from . import sale_order
20 changes: 20 additions & 0 deletions sale_order_line_no_print/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import fields, models


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

display_in_report = fields.Boolean(
default=True,
help="Disable it to hide it in the invoice reports that customer sees",
)

def _compute_totals(self):
res = super()._compute_totals()
# Avoid hiding lines with any amount
self.filtered(
lambda line: line.price_total and not line.display_in_report
).display_in_report = True
return res
25 changes: 25 additions & 0 deletions sale_order_line_no_print/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2025 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import fields, models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

display_in_report = fields.Boolean(
default=True,
help="Disable it to hide it in the quotations/sale orders that customer sees",
)

def _prepare_invoice_line(self, **optional_values):
res = super()._prepare_invoice_line(**optional_values)
res["display_in_report"] = self.display_in_report
return res

def _compute_amount(self):
res = super()._compute_amount()
# Avoid hiding lines with any amount
self.filtered(
lambda line: line.price_total and not line.display_in_report
).display_in_report = True
return res
3 changes: 3 additions & 0 deletions sale_order_line_no_print/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In some ocassions the salesman wants to hide some info that's no relevant for the
customer but that it's needed for other documents (delivery info, pack items, etc.) as
they don't want to disclose some strategic data to the competence.
2 changes: 2 additions & 0 deletions sale_order_line_no_print/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- David Vidal ([Moduon](https://www.moduon.team/))
- Jairo Llopis ([Moduon](https://www.moduon.team/))
2 changes: 2 additions & 0 deletions sale_order_line_no_print/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows to hide some order lines from the reports and portal views
that the final customer has access to.
6 changes: 6 additions & 0 deletions sale_order_line_no_print/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To hide sale lines from the report:

- Go to a sales order/quotation/invoice.
- In the lines, click on the column selector to reveal the *Display in report* column.
- Toggle it on or off depending on your will.
- Go to the portal view: you won't see those hidden lines.
28 changes: 11 additions & 17 deletions sale_order_line_no_print/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Sale order line hidden in report</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="sale-order-line-hidden-in-report">
<h1 class="title">Sale order line hidden in report</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="sale-order-line-hidden-in-report">
<h1>Sale order line hidden in report</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a03ee690d8ef56078c0373a096d2e5494611e4ea80869c08c66dae8d266c24ca
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/16.0/sale_order_line_no_print"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_line_no_print"><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/sale-workflow&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><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/16.0/sale_order_line_no_print"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_line_no_print"><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/sale-workflow&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 to hide some order lines from the reports and portal
views that the final customer has access to.</p>
<div class="admonition important">
Expand All @@ -398,14 +393,14 @@ <h1>Sale order line hidden in report</h1>
</ul>
</div>
<div class="section" id="use-cases-context">
<h2><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
<p>In some ocassions the salesman wants to hide some info that’s no
relevant for the customer but that it’s needed for other documents
(delivery info, pack items, etc.) as they don’t want to disclose some
strategic data to the competence.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>To hide sale lines from the report:</p>
<ul class="simple">
<li>Go to a sales order/quotation/invoice.</li>
Expand All @@ -416,30 +411,30 @@ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/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
<a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_line_no_print%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">
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Moduon</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>David Vidal (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li>Jairo Llopis (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">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" />
Expand All @@ -454,6 +449,5 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
40 changes: 40 additions & 0 deletions sale_order_line_no_print/views/account_move_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 Moduon Team S.L.
License Licencia Moduon 1.0 -->
<odoo>
<record id="view_move_form" model="ir.ui.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="priority">99</field>
<field name="arch" type="xml">
<!-- `display_in_report` must be on both `invoice_line_ids` and `line_ids`
because move._move_autocomplete_invoice_lines_write() from write() call
can remove `invoice_line_ids` from write vals -->
<xpath expr="//field[@name='invoice_line_ids']/tree" position="inside">
<!-- We need to set it twice as depending on the tax display group we
need to apply the rules on different fields constrained to those
groups-->
<field
name="display_in_report"
widget="boolean_toggle"
options="{'autosave': False}"
optional="hide"
groups="account.group_show_line_subtotals_tax_excluded"
attrs="{'readonly': [('price_subtotal', '!=', 0)], 'invisible': [('price_subtotal', '!=', 0)]}"
/>
<field
name="display_in_report"
widget="boolean_toggle"
options="{'autosave': False}"
optional="hide"
groups="account.group_show_line_subtotals_tax_included"
attrs="{'readonly': [('price_total', '!=', 0)], 'invisible': [('price_total', '!=', 0)]}"
/>
</xpath>
<xpath expr="//field[@name='line_ids']/tree" position="inside">
<field name="display_in_report" invisible="1" />
</xpath>
</field>
</record>
</odoo>
14 changes: 14 additions & 0 deletions sale_order_line_no_print/views/report_invoice_document.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 Moduon Team S.L.
License Licencia Moduon 1.0 -->
<odoo>
<template
id="report_invoice_document"
inherit_id="account.report_invoice_document"
priority="99"
>
<xpath expr="//t[@name='account_invoice_line_accountable']" position="replace">
<t t-if="line.display_in_report">$0</t>
</xpath>
</template>
</odoo>
33 changes: 33 additions & 0 deletions sale_order_line_no_print/views/report_saleorder_document.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 Moduon Team S.L.
License Licencia Moduon 1.0 -->
<odoo>
<template
id="report_saleorder_document"
inherit_id="sale.report_saleorder_document"
priority="999"
>
<!-- Ensure compatibility if other modules extend the conditions matching
just the beggining of the condition-->
<xpath
expr="//t[starts-with(@t-if, 'not line.display_type')]"
position="replace"
>
<t t-if="not line.display_type and line.display_in_report">$0</t>
</xpath>
</template>
<template
id="sale_order_portal_content"
inherit_id="sale.sale_order_portal_content"
priority="99"
>
<!-- Ensure compatibility if other modules extend the conditions matching
just the beggining of the condition-->
<xpath
expr="//t[starts-with(@t-if, 'not line.display_type')]"
position="replace"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@chienandalu Don't you have any solution without replace?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, this is not really replacing the node, but wrapping it inside a <t> tag. So it's equivalent to:

<xpath expr="//t[starts-with(@t-if, 'not line.display_type')]" position="before">
  <t t-if="line.display_in_report" />
</xpath>
<xpath expr="//t[@t-if='line.display_in_report']" position="inside">
  <xpath expr="//t[starts-with(@t-if, 'not line.display_type')]" position="move">
</xpath>

>
<t t-if="line.display_in_report">$0</t>
</xpath>
</template>
</odoo>
26 changes: 26 additions & 0 deletions sale_order_line_no_print/views/sale_order_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 Moduon Team S.L.
License Licencia Moduon 1.0 -->
<odoo>
<record id="view_order_form" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="priority">99</field>
<field name="arch" type="xml">
<xpath
expr="//field[@name='order_line']/tree//field[@name='price_subtotal']"
position="after"
>
<field name="price_total" invisible="1" />
<field
name="display_in_report"
widget="boolean_toggle"
options="{'autosave': False}"
optional="hide"
attrs="{'readonly': [('price_total', '!=', 0)], 'invisible': [('price_total', '!=', 0)]}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thought: I'm not sure if this is enough... I could set total to zero, hide line, and change total. Maybe we should have a constraint in the model itself.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd be afraid of performance for such case...

/>
</xpath>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/sale_order_line_no_print/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)