-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[16.0][ADD] sale_order_line_no_print: new module #3733
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| 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", | ||
| ], | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import account_move | ||
| from . import sale_order |
| 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 |
| 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 |
| 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. |
| 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/)) |
| 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. |
| 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. |
| 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> |
| 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> |
| 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" | ||
| > | ||
| <t t-if="line.display_in_report">$0</t> | ||
| </xpath> | ||
| </template> | ||
| </odoo> | ||
| 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)]}" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../sale_order_line_no_print |
| 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, | ||
| ) |
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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: