Hi,
You can use wizard with transient model and add “Update Payments Phase” action to Actions menu, so you will select the payments from list view and then from action you will select “Update Payments Phase” action and the wizard form will be shown and you will select the phase from the list and you will have a button in wizard form to update the phase and you will write the code which change the phase to the selected phase.
Transient Model (Wizard)
class AccountPaymentsPhaseWizard(models.TransientModel):
_name = "account.payments.phase.wizard"
_description = "Update the phase for multi payemnt"
# define the phase field which you will use to change the phase for the selected payments, for example if the phase field is a selection
phase = fields.Selection([('phase1', 'phase1'), ('phase2', 'phase2'), ('phase3', 'phase3')],string='phase')
# method update_payments_phase which will be called from wizard once click on Update phase button
@api.multi
def update_payments_phase(self):
# return all selected payments using active_ids and you can filter them and use any validation you want
payments = self.env['account.payments'].browse(self._context.get('active_ids'))
# loop the payments
for payment in payments:
# set the selected phase for each payment
payment.phase = self.phase
Form View and action for transient model:
<record id="view_account_payment_from_change_phase" model="ir.ui.view">
<field name="name">account.phase.payments.wizard</field>
<field name="model">account.payments.phase.wizard</field>
<field name="arch" type="xml">
<form string="Change Phase">
<field name=" phase"/>
<footer>
<button string='Update Phase' name="update_payments_phase" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
<!-- Action to launch Wizard for change phase of payments from action menu -->
<record id=" view_account_payment_from_change_phase_action" model="ir.actions.act_window">
<field name="name">Update Payments Phase</field>
<field name="res_model">account.payments.phase.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_payment_from_change_phase"/>
<field name="target">new</field>
<field name="binding_model_id" ref="account.model_account_payment"/>
</record>