mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Edit mode and button to payments modify
This commit is contained in:
@@ -327,26 +327,6 @@ class HotelFolio(models.Model):
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def action_payments(self):
|
||||
self.ensure_one()
|
||||
payments_obj = self.env['account.payment']
|
||||
payments = payments_obj.search([('folio_id', '=', self.id)])
|
||||
view_form_id = self.env.ref('hotel.account_payment_view_form_folio').id
|
||||
view_tree_id = self.env.ref('account.view_account_payment_tree').id
|
||||
# invoices = self.mapped('invoice_ids.id')
|
||||
return{
|
||||
'name': _('Payments'),
|
||||
'view_type': 'form',
|
||||
'views': [(view_tree_id, 'tree'),(view_form_id, 'form')],
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.payment',
|
||||
'target': 'new',
|
||||
'init_mode': 'edit',
|
||||
'type': 'ir.actions.act_window',
|
||||
'domain': [('id', 'in', payments.ids)],
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def open_invoices_folio(self):
|
||||
invoices = self.mapped('invoice_ids')
|
||||
|
||||
@@ -48,14 +48,7 @@ class AccountPayment(models.Model):
|
||||
self.payment_date = self.save_date
|
||||
if self.save_journal_id:
|
||||
self.journal_id = self.env['account.journal'].browse(self.save_journal_id)
|
||||
return {
|
||||
'name': 'Folio Payment Return',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'payment.return',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_id': return_pay.id,
|
||||
}
|
||||
return_pay.action_confirm()
|
||||
|
||||
@api.multi
|
||||
def modify(self):
|
||||
@@ -114,9 +107,26 @@ class AccountPayment(models.Model):
|
||||
|
||||
@api.multi
|
||||
def post(self):
|
||||
rec = super(AccountPayment,self).post()
|
||||
rec = super(AccountPayment, self).post()
|
||||
if rec and not self._context.get("ignore_notification_post", False):
|
||||
for pay in self:
|
||||
if pay.folio_id:
|
||||
msg = _("Payment of %s %s registered from %s using %s payment method") % (pay.amount, pay.currency_id.symbol, pay.communication, pay.journal_id.name)
|
||||
pay.folio_id.message_post(subject=_('Payment'), body=msg)
|
||||
|
||||
@api.multi
|
||||
def modify_payment(self):
|
||||
self.ensure_one()
|
||||
view_form_id = self.env.ref('hotel.account_payment_view_form_folio').id
|
||||
# invoices = self.mapped('invoice_ids.id')
|
||||
return{
|
||||
'name': _('Payment'),
|
||||
'view_type': 'form',
|
||||
'views': [(view_form_id, 'form')],
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.payment',
|
||||
'target': 'new',
|
||||
'init_mode': 'edit',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_id': self.id,
|
||||
}
|
||||
|
||||
@@ -171,11 +171,12 @@
|
||||
</page>
|
||||
<page name="payments" string="Payments" attrs="{'invisible': [('invoices_paid','<=',0)]}">
|
||||
<field name="payment_ids"
|
||||
options="{'no_create': True,'no_edit': True}" />
|
||||
context="{'tree_view_ref':'hotel.account_payment_view_tree_folio', 'form_view_ref':'hotel.account_payment_view_form_folio'}"
|
||||
options="{'no_create': True}" />
|
||||
</page>
|
||||
<page name="returns" string="Retun Payments" attrs="{'invisible': [('refund_amount','<=',0)]}">
|
||||
<field name="return_ids"
|
||||
options="{'no_create': True,'no_edit': True}" />
|
||||
options="{'no_create': True}" />
|
||||
</page>
|
||||
<page string="Other data" invisible="1">
|
||||
<group>
|
||||
|
||||
@@ -17,20 +17,20 @@
|
||||
<record id="account_payment_view_form_folio" model="ir.ui.view">
|
||||
<field name="name">account.payment.folio.form</field>
|
||||
<field name="model">account.payment</field>
|
||||
<field name="priority">20</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Register Payment" version="7">
|
||||
<header>
|
||||
<button name="post" class="oe_highlight" states="draft" string="Confirm" type="object"/>
|
||||
<button name="action_draft" class="oe_highlight" states="cancelled" string="Set To Draft" type="object"/>
|
||||
<button string="Validate" name="post" type="object" class="btn-primary"
|
||||
attrs="{'invisible': [('state','!=','draft')]}"/>
|
||||
<button string="Modify" name="modify" type="object" class="btn-primary"
|
||||
<button string="Modify" name="modify" type="object" class="oe_edit_only btn-primary"
|
||||
attrs="{'invisible': [('state','=','draft')]}"/>
|
||||
<button string="Return" name="return_payment_folio" type="object" class="btn-primary"
|
||||
<button string="Return" name="return_payment_folio" type="object" class="oe_edit_only btn-primary"
|
||||
attrs="{'invisible': [('state','=','draft')]}"/>
|
||||
<button string="Delete" name="delete" type="object" class="btn-primary"
|
||||
<button string="Delete" name="delete" type="object" class="oe_read_only btn-primary"
|
||||
attrs="{'invisible': [('state','=','draft')]}"/>
|
||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||
<button string="Cancel" class="oe_read_only btn-default" special="cancel"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,posted,reconciled,cancelled"/>
|
||||
</header>
|
||||
<sheet>
|
||||
@@ -90,4 +90,27 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_payment_view_tree_folio" model="ir.ui.view">
|
||||
<field name="name">account.payment.folio.tree</field>
|
||||
<field name="model">account.payment</field>
|
||||
<field name="priority">20</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree decoration-info="state == 'draft'" decoration-muted="state in ['reconciled', 'cancelled']" edit="false">
|
||||
<field name="payment_date" />
|
||||
<field name="name" />
|
||||
<field name="journal_id" />
|
||||
<field name="payment_method_id" />
|
||||
<field name="partner_id" string="Customer" />
|
||||
<field name="amount" sum="Amount" />
|
||||
<field name="state" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<field name="currency_id" invisible="1" />
|
||||
<field name="partner_type" invisible="1" />
|
||||
<button type="object" class="oe_stat_button"
|
||||
icon="fa fa-2x fa-pencil"
|
||||
name="modify_payment" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user