[FIX] account: Buttons display relying on PDF instead of is_move_sent

- Create an invoice
- Sent it using the Send & Print wizard
- Remove the PDF manually
=> The Send & Print button is still secondary instead of primary

X-original-commit: ef9e266c86cbc4abc24e2a6f597a2014e6e3439a
Part-of: odoo/odoo#125302
This commit is contained in:
Laurent Smet
2023-06-16 01:40:25 +02:00
parent 6dd54ebb79
commit 3ee1ef2fb5
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -582,13 +582,13 @@
<button name="action_invoice_sent"
type="object"
string="Send &amp; Print"
attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('is_move_sent', '=', True), ('move_type', 'not in', ('out_invoice', 'out_refund'))]}"
attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('invoice_pdf_report_id', '=', True), ('move_type', 'not in', ('out_invoice', 'out_refund'))]}"
class="oe_highlight"
data-hotkey="y"/>
<button name="action_invoice_sent"
type="object"
string="Send &amp; Print"
attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('is_move_sent', '=', False), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"
attrs="{'invisible':['|', '|', ('state', '!=', 'posted'), ('invoice_pdf_report_id', '=', False), ('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"
data-hotkey="y"/>
<!-- Register Payment (only invoices / receipts) -->
<button name="action_register_payment" id="account_invoice_payment_btn"
@@ -742,6 +742,7 @@
<field name="invoice_has_outstanding" invisible="1"/>
<field name="is_move_sent" invisible="1"/>
<field name="invoice_pdf_report_id" invisible="1"/>
<field name="has_reconciled_entries" invisible="1"/>
<field name="restrict_mode_hash_table" invisible="1"/>
<field name="country_code" invisible="1"/>
+1 -1
View File
@@ -366,7 +366,7 @@ class AccountMoveSend(models.Model):
# note: Binary is used for security reason
invoice.message_main_attachment_id = self.env['ir.attachment'].create(invoice_data['pdf_attachment_values'])
invoice.invalidate_recordset(fnames=['invoice_pdf_report_id', 'invoice_pdf_report_file'])
self.env.add_to_compute(invoice._fields['is_move_sent'], invoice)
invoice.is_move_sent = True
def _hook_if_errors(self, moves_data, from_cron=False, allow_fallback_pdf=False):
""" Process errors found so far when generating the documents.