Conversation
5c6ece6 to
1b57f7c
Compare
1b57f7c to
00079bf
Compare
| class AccountMove(models.Model): | ||
| _inherit = "account.move" | ||
|
|
||
| consumption_graph_svg = fields.Text() |
There was a problem hiding this comment.
storing the contents of a file in a database field is only useful in some rare cases (when the contents must be searched, for example), or for performance reasons. this is not the case here. it should use a Binary field, which will store the contents as an attachment. moreover, ideally, the svg could be gzipped in that case, taking less disk space.
| _inherit = "account.move" | ||
|
|
||
| consumption_graph_svg = fields.Text() | ||
| show_svg_field = fields.Boolean(string="Show SVG Code Field", default=False) |
There was a problem hiding this comment.
the name of this field is too generic. something like display_consumption_graph would be better (same remark for the name of the action below). the fact that it is an svg is not meaningful. what if they want to add another svg later on?
i don’t really understand the point of this field: it seems to be something ui-related and should not be stored in the database: should some invoices display the code and others not, and this should be remembered? i think it would be better to have a button displaying the contents, for example in a wizard, possibly also displaying the image as an image.
| <template id="report_invoice_document" inherit_id="account.report_invoice_document"> | ||
| <xpath expr="//div[@id='qrcode']" position="after"> | ||
| <div id="consumption_graph_svg" t-if="o.consumption_graph_svg"> | ||
| <t t-raw="o.consumption_graph_svg" /> |
There was a problem hiding this comment.
i think it would be better (and safer) to use an img element pointing to the svg file.
|
actually, why not use an invoice attachment (with a specific name) directly? if brupower needs to set is as a text field, it could be a non-stored non-readonly computed field, reading and writing from the attachment. |
* use a Binary field to store the svg file as an attachment. * use an <img> element in the account.move report instead of using the raw svg contents. * simplify the form view by using the Binary field directly.
Description
Add a text field representing an svg to account.move. Include this svg at the end of the report of account.move.
Odoo task (if applicable)
15244
Checklist before approval