mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Payments Notifications
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
'sale_stock',
|
'sale_stock',
|
||||||
'account_payment_return',
|
'account_payment_return',
|
||||||
'partner_firstname',
|
'partner_firstname',
|
||||||
|
'account_cancel'
|
||||||
],
|
],
|
||||||
'license': "AGPL-3",
|
'license': "AGPL-3",
|
||||||
'demo': ['data/hotel_demo.xml'],
|
'demo': ['data/hotel_demo.xml'],
|
||||||
|
|||||||
@@ -101,12 +101,6 @@ class HotelFolio(models.Model):
|
|||||||
# @api.depends('state', 'product_uom_qty', 'qty_delivered', 'qty_to_invoice', 'qty_invoiced')
|
# @api.depends('state', 'product_uom_qty', 'qty_delivered', 'qty_to_invoice', 'qty_invoiced')
|
||||||
def _compute_invoice_status(self):
|
def _compute_invoice_status(self):
|
||||||
pass
|
pass
|
||||||
# @api.depends('product_uom_qty', 'discount', 'price_unit', 'tax_id')
|
|
||||||
def _compute_amount(self):
|
|
||||||
pass
|
|
||||||
# @api.depends('order_line.price_total')
|
|
||||||
def _amount_all(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_default_team(self):
|
def _get_default_team(self):
|
||||||
@@ -336,13 +330,17 @@ class HotelFolio(models.Model):
|
|||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
payments_obj = self.env['account.payment']
|
payments_obj = self.env['account.payment']
|
||||||
payments = payments_obj.search([('folio_id', '=', self.id)])
|
payments = payments_obj.search([('folio_id', '=', self.id)])
|
||||||
#invoices = self.mapped('invoice_ids.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{
|
return{
|
||||||
'name': _('Payments'),
|
'name': _('Payments'),
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
|
'views': [(view_tree_id, 'tree'),(view_form_id, 'form')],
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'res_model': 'account.payment',
|
'res_model': 'account.payment',
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
|
'init_mode': 'edit',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'domain': [('id', 'in', payments.ids)],
|
'domain': [('id', 'in', payments.ids)],
|
||||||
}
|
}
|
||||||
@@ -854,7 +852,7 @@ class HotelFolio(models.Model):
|
|||||||
'mail_template_reservation_reminder_24hrs')[1]
|
'mail_template_reservation_reminder_24hrs')[1]
|
||||||
template_rec = self.env['mail.template'].browse(template_id)
|
template_rec = self.env['mail.template'].browse(template_id)
|
||||||
for reserv_rec in self.search([]):
|
for reserv_rec in self.search([]):
|
||||||
checkin_date = datetime.strptime(reserv_rec.checkin, DEFAULT_SERVER_DATETIME_FORMAT)
|
checkin_date = datetime.strptime(reserv_rec.checkin, dt)
|
||||||
difference = relativedelta(now_date, checkin_date)
|
difference = relativedelta(now_date, checkin_date)
|
||||||
if(difference.days == -1 and reserv_rec.partner_id.email and
|
if(difference.days == -1 and reserv_rec.partner_id.email and
|
||||||
reserv_rec.state == 'confirm'):
|
reserv_rec.state == 'confirm'):
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ class AccountPayment(models.Model):
|
|||||||
compute="_compute_folio_amount", store=True,
|
compute="_compute_folio_amount", store=True,
|
||||||
string="Total amount in folio",
|
string="Total amount in folio",
|
||||||
)
|
)
|
||||||
|
save_amount = fields.Monetary(string='onchange_amount')
|
||||||
|
save_date = fields.Date()
|
||||||
|
save_journal_id = fields.Integer()
|
||||||
|
|
||||||
|
@api.onchange('amount','payment_date','journal_id')
|
||||||
|
def onchange_amount(self):
|
||||||
|
if self._origin:
|
||||||
|
self.save_amount = self._origin.amount
|
||||||
|
self.save_journal_id = self._origin.journal_id.id
|
||||||
|
self.save_date = self._origin.payment_date
|
||||||
|
|
||||||
"""WIP"""
|
"""WIP"""
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -32,6 +42,12 @@ class AccountPayment(models.Model):
|
|||||||
'line_ids': [(0, 0, return_line_vals)],
|
'line_ids': [(0, 0, return_line_vals)],
|
||||||
}
|
}
|
||||||
return_pay = self.env['payment.return'].create(return_vals)
|
return_pay = self.env['payment.return'].create(return_vals)
|
||||||
|
if self.save_amount:
|
||||||
|
self.amount = self.save_amount
|
||||||
|
if self.save_date:
|
||||||
|
self.payment_date = self.save_date
|
||||||
|
if self.save_journal_id:
|
||||||
|
self.journal_id = self.env['account.journal'].browse(self.save_journal_id)
|
||||||
return {
|
return {
|
||||||
'name': 'Folio Payment Return',
|
'name': 'Folio Payment Return',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
@@ -40,6 +56,7 @@ class AccountPayment(models.Model):
|
|||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'res_id': return_pay.id,
|
'res_id': return_pay.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def modify(self):
|
def modify(self):
|
||||||
self.cancel()
|
self.cancel()
|
||||||
@@ -49,15 +66,29 @@ class AccountPayment(models.Model):
|
|||||||
'amount': self.amount,
|
'amount': self.amount,
|
||||||
'payment_date': self.payment_date,
|
'payment_date': self.payment_date,
|
||||||
'communication': self.communication,
|
'communication': self.communication,
|
||||||
'folio_id': self.folio_id}
|
'state': 'draft'}
|
||||||
self.update(vals)
|
self.update(vals)
|
||||||
self.post()
|
self.with_context({'ignore_notification_post': True}).post()
|
||||||
|
if self.folio_id:
|
||||||
|
msg = _("Payment %s modified: \n") % (self.communication)
|
||||||
|
if self.save_amount and self.save_amount != self.amount:
|
||||||
|
msg += _("Amount from %s to %s %s \n") % (self.save_amount, self.amount, self.currency_id.symbol)
|
||||||
|
if self.save_date and self.save_date != self.payment_date:
|
||||||
|
msg += _("Date from %s to %s \n") % (self.save_date, self.payment_date)
|
||||||
|
if self.save_journal_id and self.save_journal_id != self.journal_id.id:
|
||||||
|
msg += _("Journal from %s to %s") % (self.env['account.journal'].browse(self.save_journal_id).name, self.journal_id.name)
|
||||||
|
self.folio_id.message_post(subject=_('Payment'), body=msg)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def delete(self):
|
def delete(self):
|
||||||
|
msg = False
|
||||||
|
if self.folio_id:
|
||||||
|
msg = _("Deleted payment: %s %s ") % (self.amount, self.currency_id.symbol)
|
||||||
self.cancel()
|
self.cancel()
|
||||||
self.move_name = ''
|
self.move_name = ''
|
||||||
self.unlink()
|
self.unlink()
|
||||||
|
if msg:
|
||||||
|
self.folio_id.message_post(subject=_('Payment Deleted'), body=msg)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('state')
|
@api.depends('state')
|
||||||
@@ -66,8 +97,6 @@ class AccountPayment(models.Model):
|
|||||||
res = []
|
res = []
|
||||||
fol = ()
|
fol = ()
|
||||||
for payment in self:
|
for payment in self:
|
||||||
amount_pending = 0
|
|
||||||
total_amount = 0
|
|
||||||
if payment.folio_id:
|
if payment.folio_id:
|
||||||
fol = payment.env['hotel.folio'].search([
|
fol = payment.env['hotel.folio'].search([
|
||||||
('id', '=', payment.folio_id.id)
|
('id', '=', payment.folio_id.id)
|
||||||
@@ -82,3 +111,12 @@ class AccountPayment(models.Model):
|
|||||||
else:
|
else:
|
||||||
fol.compute_amount()
|
fol.compute_amount()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def post(self):
|
||||||
|
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)
|
||||||
|
|||||||
@@ -13,10 +13,14 @@ class PaymentReturn(models.Model):
|
|||||||
pay = super(PaymentReturn,self).action_confirm()
|
pay = super(PaymentReturn,self).action_confirm()
|
||||||
if pay:
|
if pay:
|
||||||
folio_ids = []
|
folio_ids = []
|
||||||
|
folios = self.env['hotel.folio'].browse(folio_ids)
|
||||||
for line in self.line_ids:
|
for line in self.line_ids:
|
||||||
payments = self.env['account.payment'].search([
|
payments = self.env['account.payment'].search([
|
||||||
('move_line_ids', 'in', line.move_line_ids.ids)
|
('move_line_ids', 'in', line.move_line_ids.ids)
|
||||||
])
|
])
|
||||||
folio_ids += payments.mapped('folio_id.id')
|
folios_line = self.env['hotel.folio'].browse(payments.mapped('folio_id.id'))
|
||||||
folios = self.env['hotel.folio'].browse(folio_ids)
|
for folio in folios_line:
|
||||||
|
msg = _("Return of %s registered") % (line.amount)
|
||||||
|
folio.message_post(subject=_('Payment Return'), body=msg)
|
||||||
|
folios += folios_line
|
||||||
folios.compute_amount()
|
folios.compute_amount()
|
||||||
|
|||||||
@@ -428,7 +428,7 @@
|
|||||||
decoration-success="folio_pending_amount == 0 and checkout <= current_date and not overbooking"
|
decoration-success="folio_pending_amount == 0 and checkout <= current_date and not overbooking"
|
||||||
decoration-warning="overbooking">
|
decoration-warning="overbooking">
|
||||||
<field name="splitted" invisible="1" />
|
<field name="splitted" invisible="1" />
|
||||||
<field name="pricelist_id" invisible="1" />
|
<field name="pricelist_id" invisible="1" />
|
||||||
<button icon="fa fa-1x fa-chain-broken"
|
<button icon="fa fa-1x fa-chain-broken"
|
||||||
type="object"
|
type="object"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='communication']" position="after">
|
<xpath expr="//field[@name='communication']" position="after">
|
||||||
<field name="folio_id"/>
|
<field name="folio_id"/>
|
||||||
|
<field name="save_amount" invisible="1"/>
|
||||||
|
<field name="save_journal" invisible="1"/>
|
||||||
|
<field name="save_date" invisible="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -19,6 +22,15 @@
|
|||||||
<header>
|
<header>
|
||||||
<button name="post" class="oe_highlight" states="draft" string="Confirm" type="object"/>
|
<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 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"
|
||||||
|
attrs="{'invisible': [('state','=','draft')]}"/>
|
||||||
|
<button string="Return" name="return_payment_folio" type="object" class="btn-primary"
|
||||||
|
attrs="{'invisible': [('state','=','draft')]}"/>
|
||||||
|
<button string="Delete" name="delete" type="object" class="btn-primary"
|
||||||
|
attrs="{'invisible': [('state','=','draft')]}"/>
|
||||||
|
<button string="Cancel" class="btn-default" special="cancel"/>
|
||||||
<field name="state" widget="statusbar" statusbar_visible="draft,posted,reconciled,cancelled"/>
|
<field name="state" widget="statusbar" statusbar_visible="draft,posted,reconciled,cancelled"/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
@@ -44,36 +56,31 @@
|
|||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="payment_type" invisible="1"/>
|
<field name="payment_type" invisible="1"/>
|
||||||
|
<field name="save_amount" invisible="1"/>
|
||||||
|
<field name="save_date" invisible="1"/>
|
||||||
|
<field name="save_journal_id" invisible="1"/>
|
||||||
<field name="partner_type" widget="selection" invisible="1"/>
|
<field name="partner_type" widget="selection" invisible="1"/>
|
||||||
<field name="partner_id" attrs="{'required': [('state', '=', 'draft'), ('payment_type', 'in', ('inbound', 'outbound'))], 'invisible': [('payment_type', 'not in', ('inbound', 'outbound'))], 'readonly': [('state', '!=', 'draft')]}" context="{'default_is_company': True, 'default_supplier': payment_type == 'outbound', 'default_customer': payment_type == 'inbound'}"/>
|
<field name="partner_id" attrs="{'required': [('state', '=', 'draft'), ('payment_type', 'in', ('inbound', 'outbound'))], 'invisible': [('payment_type', 'not in', ('inbound', 'outbound'))]}" context="{'default_is_company': True, 'default_supplier': payment_type == 'outbound', 'default_customer': payment_type == 'inbound'}"/>
|
||||||
<label for="amount"/>
|
<label for="amount"/>
|
||||||
<div name="amount_div" class="o_row">
|
<div name="amount_div" class="o_row">
|
||||||
<field name="amount" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="amount" />
|
||||||
<field name="currency_id" options="{'no_create': True, 'no_open': True}" groups="base.group_multi_currency" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="currency_id" options="{'no_create': True, 'no_open': True}" groups="base.group_multi_currency" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||||
</div>
|
</div>
|
||||||
<field name="journal_id" widget="selection" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="journal_id" widget="selection" />
|
||||||
<field name="destination_journal_id" widget="selection" attrs="{'required': [('payment_type', '=', 'transfer')], 'invisible': [('payment_type', '!=', 'transfer')], 'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="destination_journal_id" widget="selection" attrs="{'required': [('payment_type', '=', 'transfer')], 'invisible': [('payment_type', '!=', 'transfer')], 'readonly': [('state', '!=', 'draft')]}"/>
|
||||||
<field name="hide_payment_method" invisible="1"/>
|
<field name="hide_payment_method" invisible="1"/>
|
||||||
<field name="payment_method_id" string=" " widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)], 'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="payment_method_id" string=" " widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)]}"/>
|
||||||
<field name="payment_method_code" invisible="1"/>
|
<field name="payment_method_code" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="payment_date" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="payment_date" />
|
||||||
<field name="communication" attrs="{'invisible': [('state', '!=', 'draft'), ('communication', '=', False)], 'readonly': [('state', '!=', 'draft')]}"/>
|
<field name="communication" attrs="{'invisible': [('state', '!=', 'draft'), ('communication', '=', False)]}"/>
|
||||||
<field name="folio_id"/>
|
<field name="folio_id" readonly="1" force_save="1"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
<footer>
|
<footer>
|
||||||
<button string="Validate" name="post" type="object" class="btn-primary"
|
|
||||||
attrs="{'invisible': [('state','!=','draft')]}"/>
|
|
||||||
<button string="Modify" name="modify" type="object" class="btn-primary"
|
|
||||||
attrs="{'invisible': [('state','=','draft')]}"/>
|
|
||||||
<button string="Return" name="return_payment_folio" type="object" class="btn-primary"
|
|
||||||
attrs="{'invisible': [('state','=','draft')]}"/>
|
|
||||||
<button string="Delete" name="delete" type="object" class="btn-primary"
|
|
||||||
attrs="{'invisible': [('state','=','draft')]}"/>
|
|
||||||
<button string="Cancel" class="btn-default" special="cancel"/>
|
|
||||||
</footer>
|
</footer>
|
||||||
<div class="oe_chatter">
|
<div class="oe_chatter">
|
||||||
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
|
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
|
||||||
|
|||||||
@@ -155,7 +155,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hcal-restriction-room-day {
|
.hcal-restriction-room-day {
|
||||||
background-color: #b3218366 !important;
|
background-color: #9b18704d !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hcal-table-day {
|
.hcal-table-day {
|
||||||
|
|||||||
@@ -60,7 +60,18 @@ class HotelReservation(models.Model):
|
|||||||
if user.has_group('hotel.group_hotel_call'):
|
if user.has_group('hotel.group_hotel_call'):
|
||||||
self.write({'to_assign': True})
|
self.write({'to_assign': True})
|
||||||
|
|
||||||
|
<<<<<<< b9c294db6ea8fe0ebb7998209a7a905c3c240082
|
||||||
return super(HotelReservation, self).action_cancel()
|
return super(HotelReservation, self).action_cancel()
|
||||||
|
=======
|
||||||
|
res = super(HotelReservation, self).action_cancel()
|
||||||
|
for record in self:
|
||||||
|
# Only can cancel reservations created directly in wubook
|
||||||
|
for binding in record.channel_bind_ids:
|
||||||
|
if binding.external_id and not binding.ota_id and \
|
||||||
|
int(binding.channel_status) in WUBOOK_STATUS_GOOD:
|
||||||
|
self.sudo().env['channel.hotel.reservation']._event('on_record_cancel').notify(binding)
|
||||||
|
return res
|
||||||
|
>>>>>>> [WIP] Payments Notifications
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user