diff --git a/l10n_mx_facturae/models/account_payment.py b/l10n_mx_facturae/models/account_payment.py index ef11f80259336fe46cc8974c7b5703ab785de4aa..bf5636be1bd99f82416491b222dd9e9fc1caa47c 100644 --- a/l10n_mx_facturae/models/account_payment.py +++ b/l10n_mx_facturae/models/account_payment.py @@ -145,7 +145,9 @@ class AccountPayment(models.Model): def replace_cfdi(self): """Cancel voucher cfdi by replacing with 1 MXN voucher""" for record in self: - self._cancel_cfdi() + record.cancel_cfdi() + record.action_draft() + record.action_cancel() def currency_rate(self): """Compute currency rate used for current voucher to display on XML diff --git a/l10n_mx_facturae/views/account_payment.xml b/l10n_mx_facturae/views/account_payment.xml index c35f3805ce9e588a62514ef53f72b0bbfdb1136b..fbee1ae8573548d48c20745ee908fa0bc23ce592 100644 --- a/l10n_mx_facturae/views/account_payment.xml +++ b/l10n_mx_facturae/views/account_payment.xml @@ -24,6 +24,11 @@ <field name="model">account.payment</field> <field name="inherit_id" ref="account.view_account_payment_form"/> <field name="arch" type="xml"> + <button name="action_draft" position="attributes"> + <attribute name="attrs"> + {'invisible': ['&',('state', 'in', ('posted', 'cancel')),('cfdi_state', 'in', ('done', 'cancel'))]} + </attribute> + </button> <button name="action_post" position="after"> <button name="sign_payment" type="object" string="Sign" class="oe_highlight" @@ -33,8 +38,9 @@ ('cfdi_state', '!=', False) ]}" /> <!--<button name="substitute_payment" type="object" string="Replace" - attrs="{'invisible': ['|', ('cfdi_state', 'not in', ['signed', 'done']), ('state', '=', 'cancel')]}"/> - <button name="replace_cfdi" type="object" string="Cancel" + attrs="{'invisible': ['|', ('cfdi_state', 'not in', ['signed', + 'done']), ('state', '=', 'cancel')]}"/>--> + <button name="replace_cfdi" type="object" class="btn-primary" string="Cancel" confirm="Are you sure to cancel this payment?" attrs="{'invisible': ['|', ('cfdi_state', 'not in', ['signed', 'done']), ('state', '=', 'cancel')]}"/>-->