[FIX] cancel extantion without payment
This commit is contained in:
parent
58de5702a0
commit
737a3e79be
|
|
@ -38,6 +38,20 @@ class AccountRegisterPayment(models.TransientModel):
|
|||
string="Show Cancel Button",
|
||||
compute="_compute_show_cancel_button"
|
||||
)
|
||||
show_payment_group = fields.Boolean(
|
||||
string="Show Payment Group",
|
||||
compute="_compute_show_payment_group"
|
||||
)
|
||||
|
||||
@api.depends('can_group_payments')
|
||||
def _compute_show_payment_group(self):
|
||||
active_ids = self.env.context.get('active_ids', [])
|
||||
invoices = self.env['account.move'].browse(active_ids)
|
||||
unique_partners = invoices.mapped('partner_id')
|
||||
|
||||
for rec in self:
|
||||
rec.show_payment_group = (len(unique_partners) == 1)
|
||||
|
||||
|
||||
@api.depends_context('wiz_id')
|
||||
def _compute_show_cancel_button(self):
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='amount']" position="after">
|
||||
<field name="is_refund_sponsorship" invisible="1"/>
|
||||
<field name="show_payment_group" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='group_payment']" position="attributes">
|
||||
<attribute name="attrs">{'invisible':['|', ('show_payment_group','=',False), ('can_group_payments', '=', False)]}</attribute>
|
||||
</xpath>
|
||||
<!-- <xpath expr="//field[@name='amount']" position="attributes">-->
|
||||
<!-- <attribute name="attrs">{'readonly':[('group_payment','=',True)]}</attribute>-->
|
||||
|
|
@ -62,79 +66,6 @@
|
|||
<xpath expr="//footer/button[2]" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('show_cancel_button','=',False)]}</attribute>
|
||||
</xpath>
|
||||
|
||||
<!--<xpath expr="//group" position="after">-->
|
||||
<!-- <notebook>-->
|
||||
<!-- <page string="Sub Payments" attrs="{'invisible': [('group_payment', '=', False)]}">-->
|
||||
<!-- <field name="account_payment_register_ids" attrs="{'invisible': [('group_payment', '=', False)]}" nolabel="1">-->
|
||||
<!-- <tree editable="bottom" delete="true" create="true">-->
|
||||
<!-- <field name="sponsorship_payment" invisible="1"/>-->
|
||||
<!-- <field name="takaful_payment_method" invisible="1"/>-->
|
||||
<!-- <field name="available_partner_bank_ids" invisible="1"/>-->
|
||||
<!-- <field name="company_id" invisible="1"/>-->
|
||||
<!-- <field name="takaful_payment_method_id" options="{'no_create': True, 'no_create_edit': True}"/>-->
|
||||
<!-- <field name="journal_id" string="Association Journal"/>-->
|
||||
<!-- <field name="amount"/>-->
|
||||
<!-- <field name="check_number"-->
|
||||
<!-- attrs="{-->
|
||||
<!-- 'invisible': [-->
|
||||
<!-- ('takaful_payment_method','!=','check')-->
|
||||
<!-- ],-->
|
||||
<!-- 'required': [-->
|
||||
<!-- ('takaful_payment_method','=','check')-->
|
||||
<!-- ]-->
|
||||
<!-- }"-->
|
||||
<!-- optional="hide"/>-->
|
||||
<!-- <field name="check_due_date"-->
|
||||
<!-- attrs="{-->
|
||||
<!-- 'invisible': [-->
|
||||
<!-- ('takaful_payment_method','!=','check')-->
|
||||
<!-- ],-->
|
||||
<!-- 'required': [-->
|
||||
<!-- ('takaful_payment_method','=','check')-->
|
||||
<!-- ]-->
|
||||
<!-- }"-->
|
||||
<!-- optional="hide"/>-->
|
||||
<!-- <field name="partner_bank_id"-->
|
||||
<!-- context="{-->
|
||||
<!-- 'form_view_ref': 'odex_takaful.res_partner_bank_view_form_quick_create',-->
|
||||
<!-- 'default_partner_id': context.get('force_sponsorship_line_partner_id')-->
|
||||
<!-- }"-->
|
||||
<!-- attrs="{-->
|
||||
<!-- 'required': [-->
|
||||
<!-- ('takaful_payment_method','=','bank')-->
|
||||
<!-- ],-->
|
||||
<!-- 'invisible': [-->
|
||||
<!-- ('takaful_payment_method','!=','bank')-->
|
||||
<!-- ]-->
|
||||
<!-- }"-->
|
||||
<!-- readonly="0"-->
|
||||
<!-- optional="hide"/>-->
|
||||
<!-- <field name="transaction_file_attachment"-->
|
||||
<!-- widget="binary"-->
|
||||
<!-- filename="transaction_attachment_file_name"-->
|
||||
<!-- attrs="{-->
|
||||
<!-- 'invisible': [-->
|
||||
<!-- ('takaful_payment_method','not in',['bank', 'check'])-->
|
||||
<!-- ],-->
|
||||
<!-- 'required': ['|',-->
|
||||
<!-- ('takaful_payment_method','=','bank'),-->
|
||||
<!-- ('takaful_payment_method','=','check')-->
|
||||
<!-- ]-->
|
||||
<!-- }"-->
|
||||
<!-- optional="hide"/>-->
|
||||
<!-- </tree>-->
|
||||
<!-- </field>-->
|
||||
<!-- </page>-->
|
||||
<!-- </notebook>-->
|
||||
<!-- </xpath>-->
|
||||
<!-- <xpath expr="//footer/button[@name='action_create_payments']" position="after">-->
|
||||
<!-- <button name="action_register_all_lines"-->
|
||||
<!-- type="object"-->
|
||||
<!-- string="Register All Lines"-->
|
||||
<!-- class="btn-secondary"-->
|
||||
<!-- attrs="{'invisible': [('line_ids','=',False)]}"/>-->
|
||||
<!-- </xpath>-->
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,10 @@ class DonationExtensionWizard(models.TransientModel):
|
|||
"""
|
||||
Cancel the wizard
|
||||
"""
|
||||
for rec in self:
|
||||
for line in rec.line_ids:
|
||||
line.cancel_extension()
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
class ExtensionPaymentWizardLine(models.TransientModel):
|
||||
|
|
@ -273,6 +277,8 @@ class DonationExtensionWizardLine(models.TransientModel):
|
|||
debit_payment_file_attachment = fields.Binary(string='Debit Payment Attachment', attachment=True)
|
||||
debit_payment_attachment_file_name = fields.Char('Debit Payment File Name', required=False)
|
||||
journal_id = fields.Many2one('account.journal', string="Journal",domain="[('type','=','bank')]", default=_default_journal_id)
|
||||
old_end_date = fields.Date()
|
||||
old_payment_month_count = fields.Integer()
|
||||
|
||||
# related
|
||||
record_type = fields.Selection(related='donation_line_id.record_type')
|
||||
|
|
@ -321,6 +327,9 @@ class DonationExtensionWizardLine(models.TransientModel):
|
|||
raise ValidationError(_("No donation detail line selected."))
|
||||
if not self.extension_invoice_id:
|
||||
# Update the donation detail line
|
||||
self.old_end_date = self.current_end_date
|
||||
self.old_payment_month_count = self.donation_line_id.payment_month_count
|
||||
|
||||
new_end_date = self.current_end_date + relativedelta(months=self.months)
|
||||
old_end_date = self.current_end_date
|
||||
|
||||
|
|
@ -456,4 +465,36 @@ class DonationExtensionWizardLine(models.TransientModel):
|
|||
invoice_id.action_post()
|
||||
|
||||
return invoice_id
|
||||
|
||||
|
||||
def cancel_extension(self):
|
||||
self.ensure_one()
|
||||
|
||||
if self.extension_invoice_id:
|
||||
invoice = self.extension_invoice_id
|
||||
|
||||
if invoice.state == 'posted':
|
||||
invoice.button_draft()
|
||||
invoice.button_cancel()
|
||||
|
||||
else:
|
||||
invoice.button_cancel()
|
||||
|
||||
scheduling_lines = self.env['sponsorship.scheduling.line'].search([
|
||||
('donation_detail_linked_id', '=', self.donation_line_id.id),
|
||||
('scheduled_date', '>', self.old_end_date)
|
||||
])
|
||||
scheduling_lines.sudo().unlink()
|
||||
|
||||
self.donation_line_id.write({
|
||||
'end_date': self.old_end_date,
|
||||
'payment_month_count': self.old_payment_month_count,
|
||||
})
|
||||
|
||||
history_records = self.env['donation.extension.history'].search([
|
||||
('donation_detail_id', '=', self.donation_line_id.id),
|
||||
('invoice_id', '=', self.extension_invoice_id.id if self.extension_invoice_id else False),
|
||||
('new_end_date', '=', self.new_end_date),
|
||||
])
|
||||
history_records.sudo().unlink()
|
||||
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@
|
|||
</sheet>
|
||||
<footer>
|
||||
<button name="action_extend" type="object" string="Extend" class="oe_highlight"/>
|
||||
<button name="action_cancel" type="object" string="Cancel" special="cancel" attrs="{'invisible': [('is_different_payment', '=', True)]}"/>
|
||||
<button name="action_cancel" type="object" string="Cancel" class="btn-secondary" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
|||
Loading…
Reference in New Issue