Skip to content

Commit

Permalink
Merge pull request #5 from sygel-technology/T-2911
Browse files Browse the repository at this point in the history
T-2911[ADD]invoice_report_hide_price
  • Loading branch information
ValentinVinagre authored Jul 13, 2022
2 parents 4e70a3d + 54be0b1 commit 0e30ff4
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Available addons
addon | version | summary
--- | --- | ---

[delete_payment_reference_invoice_report](delete_payment_reference_invoice_report/) | 14.0.1.0.0 | Remove the payment reference message from the outgoing invoice reports.
[delete_payment_reference_invoice_report](delete_payment_reference_invoice_report/) | 15.0.1.0.0 | Remove the payment reference message from the outgoing invoice reports.
[invoice_report_hide_price](invoice_report_hide_price/) | 15.0.1.0.0 | Show/Hide price info in invoice PDF.

[//]: # (end addons)
4 changes: 4 additions & 0 deletions invoice_report_hide_price/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
21 changes: 21 additions & 0 deletions invoice_report_hide_price/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Invoice Report Hide Price",
"summary": "Show/Hide price info in invoice PDF",
"version": "15.0.1.0.0",
"category": "Invoicing",
"website": "https://www.sygel.es",
"author": "Sygel",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
'account'
],
"data": [
"views/account_move_views.xml",
"report/report_invoice.xml",
],
}
5 changes: 5 additions & 0 deletions invoice_report_hide_price/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import account_move_line
from . import account_move
33 changes: 33 additions & 0 deletions invoice_report_hide_price/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models, fields


class AccountMove(models.Model):
_inherit = 'account.move'

has_show_price_report_lines = fields.Boolean(
string="Has Show Price Report Lines",
compute="_compute_has_show_price_report_lines"
)

def _compute_has_show_price_report_lines(self):
for sel in self:
sel.has_show_price_report_lines = any(
line.show_price_info_report for line in sel.invoice_line_ids
)

def action_activate_show_price_info_report(self):
self.mapped('invoice_line_ids').filtered(
lambda a: not a.show_price_info_report
).write({
'show_price_info_report': True
})

def action_deactivate_show_price_info_report(self):
self.mapped('invoice_line_ids').filtered(
lambda a: a.show_price_info_report
).write({
'show_price_info_report': False
})
13 changes: 13 additions & 0 deletions invoice_report_hide_price/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models, fields


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

show_price_info_report = fields.Boolean(
string="Price in Report",
default=True
)
37 changes: 37 additions & 0 deletions invoice_report_hide_price/report/report_invoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="invoice_report_hide_price_report_invoice_document" name="invoice.report.hide.price.report.invoice.document" inherit_id="account.report_invoice_document" >
<xpath expr="//th[@name='th_priceunit']" position="attributes">
<attribute name="t-if">o.has_show_price_report_lines</attribute>
</xpath>
<xpath expr="//th[@name='th_price_unit']" position="attributes">
<attribute name="t-if">display_discount and o.has_show_price_report_lines</attribute>
</xpath>
<xpath expr="//th[@name='th_subtotal']" position="attributes">
<attribute name="t-if">o.has_show_price_report_lines</attribute>
</xpath>
<xpath expr="//t[@name='account_invoice_line_accountable']/td[3]" position="attributes">
<attribute name="t-if">o.has_show_price_report_lines</attribute>
</xpath>
<xpath expr="//t[@name='account_invoice_line_accountable']/td[4]" position="attributes">
<attribute name="t-if">display_discount and o.has_show_price_report_lines</attribute>
</xpath>
<xpath expr="//t[@name='account_invoice_line_accountable']/td[6]" position="attributes">
<attribute name="t-if">o.has_show_price_report_lines</attribute>
</xpath>
<xpath expr="//span[@t-field='line.price_unit']" position="attributes">
<attribute name="t-if">line.show_price_info_report</attribute>
</xpath>
<xpath expr="//span[@t-field='line.discount']" position="attributes">
<attribute name="t-if">line.show_price_info_report</attribute>
</xpath>
<xpath expr="//span[@t-field='line.price_subtotal']" position="attributes">
<attribute name="t-if">line.show_price_info_report</attribute>
</xpath>
<xpath expr="//span[@t-field='line.price_total']" position="attributes">
<attribute name="t-if">line.show_price_info_report</attribute>
</xpath>
</template>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions invoice_report_hide_price/views/account_move_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2022 Manuel Regidor <manuel.regidor@sygel.es>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="invoice_report_hide_price_view_move_form" model="ir.ui.view">
<field name="name">invoice.report.hide.price.view.move.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']" position="before">
<button name="action_activate_show_price_info_report" type="object" string="Show Lines Price Info in Report" />
<button name="action_deactivate_show_price_info_report" type="object" string="Hide Lines Price Info in Report" />
</xpath>
<!-- We add the field to the line_ids tree view so it can be saved when modified
from the invoice lines tabs -->
<xpath expr="//field[@name='line_ids']/tree" position="inside">
<field name="show_price_info_report" invisible="1"/>
</xpath>
<xpath expr="//field[@name='invoice_line_ids']/tree" position="inside">
<field name="show_price_info_report" />
</xpath>
</field>
</record>
</odoo>

0 comments on commit 0e30ff4

Please sign in to comment.