mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[MIG] V13 models
This commit is contained in:
@@ -7,7 +7,6 @@ from openerp.exceptions import ValidationError
|
||||
|
||||
class HotelChannelConnectorIssue(models.Model):
|
||||
_name = 'hotel.channel.connector.issue'
|
||||
_old_name = 'wubook.issue'
|
||||
|
||||
backend_id = fields.Many2one('channel.backend',
|
||||
'Backend',
|
||||
@@ -23,11 +22,11 @@ class HotelChannelConnectorIssue(models.Model):
|
||||
('room', 'Room'),
|
||||
('avail', 'Availability')], required=True)
|
||||
to_read = fields.Boolean("To Read", default=True)
|
||||
internal_message = fields.Char("Internal Message", old_name='message')
|
||||
internal_message = fields.Char("Internal Message")
|
||||
date_start = fields.Date("From", readonly=True)
|
||||
date_end = fields.Date("To", readonly=True)
|
||||
channel_object_id = fields.Char("Channel Object ID", old_name='wid', readonly=True)
|
||||
channel_message = fields.Char("Channel Message", old_name='wmessage', readonly=True)
|
||||
channel_object_id = fields.Char("Channel Object ID", readonly=True)
|
||||
channel_message = fields.Char("Channel Message", readonly=True)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
@@ -37,17 +36,17 @@ class HotelChannelConnectorIssue(models.Model):
|
||||
title=_("Oops! %s Issue Reported!!") % issue_id.section)
|
||||
return issue_id
|
||||
|
||||
|
||||
|
||||
def mark_readed(self):
|
||||
for record in self:
|
||||
record.to_read = False
|
||||
|
||||
|
||||
|
||||
def toggle_to_read(self):
|
||||
for record in self:
|
||||
record.to_read = not record.to_read
|
||||
|
||||
|
||||
|
||||
def mark_as_read(self):
|
||||
reserv_ids = []
|
||||
for record in self:
|
||||
|
||||
@@ -17,8 +17,7 @@ class ChannelHotelRoomTypeRestrictionItem(models.Model):
|
||||
string='Hotel Virtual Room Restriction',
|
||||
required=True,
|
||||
ondelete='cascade')
|
||||
channel_pushed = fields.Boolean("Channel Pushed", readonly=True, default=False,
|
||||
old_name='wpushed')
|
||||
channel_pushed = fields.Boolean("Channel Pushed", readonly=True, default=False)
|
||||
|
||||
@job(default_channel='root.channel')
|
||||
@api.model
|
||||
|
||||
@@ -15,10 +15,9 @@ class HotelFolio(models.Model):
|
||||
record.has_channel_reservations = any(channel_reservations)
|
||||
|
||||
customer_notes = fields.Text("Channel Customer Notes",
|
||||
readonly=True, old_name='wcustomer_notes')
|
||||
readonly=True)
|
||||
has_channel_reservations = fields.Boolean(compute=_has_channel_reservations,
|
||||
store=False,
|
||||
old_name='whas_wubook_reservations')
|
||||
store=False)
|
||||
unconfirmed_channel_price = fields.Boolean(default=False)
|
||||
|
||||
@job(default_channel='root.channel')
|
||||
@@ -28,7 +27,7 @@ class HotelFolio(models.Model):
|
||||
importer = work.component(usage='channel.importer')
|
||||
importer.fetch_new_bookings()
|
||||
|
||||
|
||||
|
||||
def action_confirm(self):
|
||||
for rec in self:
|
||||
rec.reservation_ids.write({
|
||||
@@ -36,7 +35,7 @@ class HotelFolio(models.Model):
|
||||
})
|
||||
return super().action_confirm()
|
||||
|
||||
|
||||
|
||||
def get_grouped_reservations_json(self, state, import_all=False):
|
||||
super().get_grouped_reservations_json(state, import_all=import_all)
|
||||
self.ensure_one()
|
||||
|
||||
@@ -18,8 +18,7 @@ class ChannelProductPricelistItem(models.Model):
|
||||
string='Hotel Product Pricelist Item',
|
||||
required=True,
|
||||
ondelete='cascade')
|
||||
channel_pushed = fields.Boolean("Channel Pushed", readonly=True, default=False,
|
||||
old_name='wpushed')
|
||||
channel_pushed = fields.Boolean("Channel Pushed", readonly=True, default=False)
|
||||
|
||||
@job(default_channel='root.channel')
|
||||
@api.model
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'pms',
|
||||
'name': 'PMS (Property Management System)',
|
||||
'summary': "A property management system",
|
||||
'version': '13.0.1.0.0',
|
||||
'development_status': 'Beta',
|
||||
@@ -57,7 +57,7 @@
|
||||
'views/pms_room_views.xml',
|
||||
'views/pms_room_closure_reason_views.xml',
|
||||
'views/inherited_account_payment_views.xml',
|
||||
'views/inherited_account_invoice_views.xml',
|
||||
'views/inherited_account_move_views.xml',
|
||||
'views/inherited_res_users_views.xml',
|
||||
'views/pms_room_type_class_views.xml',
|
||||
'views/pms_room_type_restriction_views.xml',
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- pms.users -->
|
||||
|
||||
<record id="base.user_root" model="res.users">
|
||||
<record id="base.user_admin" model="res.users">
|
||||
<field name="groups_id" eval="[(4,ref('pms.group_pms_manager'))]"/>
|
||||
</record>
|
||||
|
||||
@@ -39,4 +39,4 @@
|
||||
<field name="pms_property_ids" eval="[(4, ref('main_pms_property'))]"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
</odoo>
|
||||
|
||||
@@ -16,7 +16,7 @@ from . import pms_amenity
|
||||
from . import pms_amenity_type
|
||||
from . import pms_room_type
|
||||
from . import pms_service
|
||||
from . import inherited_account_invoice
|
||||
from . import inherited_account_move
|
||||
from . import inherited_product_template
|
||||
from . import inherited_res_company
|
||||
from . import inherited_account_payment
|
||||
@@ -33,5 +33,5 @@ from . import pms_service_line
|
||||
from . import pms_board_service
|
||||
from . import pms_board_service_room_type_line
|
||||
from . import pms_board_service_line
|
||||
from . import inherited_account_invoice_line
|
||||
from . import inherited_account_move_line
|
||||
from . import pms_cancelation_rule
|
||||
|
||||
@@ -23,20 +23,20 @@ class AccountMove(models.Model):
|
||||
compute='_get_outstanding_folios_JSON')
|
||||
|
||||
# Compute and Search methods
|
||||
|
||||
|
||||
def _computed_folio_origin(self):
|
||||
for inv in self:
|
||||
folios = inv.mapped('move_line_ids.reservation_ids.folio_id')
|
||||
folios |= inv.mapped('move_line_ids.service_ids.folio_id')
|
||||
folios = inv.mapped('invoice_line_ids.reservation_ids.folio_id')
|
||||
folios |= inv.mapped('invoice_line_ids.service_ids.folio_id')
|
||||
if folios:
|
||||
inv.from_folio = True
|
||||
inv.folio_ids = [(6, 0, folios.ids)]
|
||||
|
||||
# Action methods
|
||||
|
||||
|
||||
def action_folio_payments(self):
|
||||
self.ensure_one()
|
||||
sales = self.mapped('move_line_ids.sale_line_ids.order_id')
|
||||
sales = self.mapped('invoice_line_ids.sale_line_ids.order_id')
|
||||
folios = self.env['pms.folio'].search([
|
||||
('order_id.id', 'in', sales.ids)
|
||||
])
|
||||
@@ -64,8 +64,7 @@ class PmsFolio(models.Model):
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
'Company',
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'pms.folio'))
|
||||
default=lambda self: self.env.company)
|
||||
analytic_account_id = fields.Many2one(
|
||||
'account.analytic.account',
|
||||
'Analytic Account',
|
||||
@@ -133,7 +132,6 @@ class PmsFolio(models.Model):
|
||||
related="partner_invoice_id.country_id")
|
||||
fiscal_position_id = fields.Many2one(
|
||||
'account.fiscal.position',
|
||||
oldname='fiscal_position',
|
||||
string='Fiscal Position')
|
||||
closure_reason_id = fields.Many2one(
|
||||
'room.closure.reason')
|
||||
@@ -143,7 +141,7 @@ class PmsFolio(models.Model):
|
||||
ondelete='restrict')
|
||||
team_id = fields.Many2one(
|
||||
'crm.team',
|
||||
string='Sales Channel',
|
||||
string='Sales Team',
|
||||
ondelete='restrict',
|
||||
change_default=True,
|
||||
default=_get_default_team)
|
||||
@@ -235,9 +233,9 @@ class PmsFolio(models.Model):
|
||||
readonly=True,
|
||||
default='no')
|
||||
partner_invoice_vat = fields.Char(related="partner_invoice_id.vat")
|
||||
partner_invoice_name = fields.Char(related="partner_invoice_id.name")
|
||||
partner_invoice_street = fields.Char(related="partner_invoice_id.street")
|
||||
partner_invoice_street2 = fields.Char(related="partner_invoice_id.street")
|
||||
partner_invoice_name = fields.Char(related="partner_invoice_id.name", string="Partner Name")
|
||||
partner_invoice_street = fields.Char(related="partner_invoice_id.street", string="Street")
|
||||
partner_invoice_street2 = fields.Char(related="partner_invoice_id.street", string="Street2")
|
||||
partner_invoice_zip = fields.Char(related="partner_invoice_id.zip")
|
||||
partner_invoice_city = fields.Char(related="partner_invoice_id.city")
|
||||
partner_invoice_email = fields.Char(related="partner_invoice_id.email")
|
||||
|
||||
@@ -191,7 +191,7 @@ class PmsReservation(models.Model):
|
||||
('booking', 'On Board'),
|
||||
('done', 'Out'),
|
||||
('cancelled', 'Cancelled')],
|
||||
string='State',
|
||||
string='Status',
|
||||
readonly=True,
|
||||
default=lambda *a: 'draft',
|
||||
copy=False,
|
||||
@@ -223,8 +223,8 @@ class PmsReservation(models.Model):
|
||||
help="Default Departure Hour (HH:MM)")
|
||||
partner_invoice_vat = fields.Char(related="partner_invoice_id.vat")
|
||||
partner_invoice_name = fields.Char(related="partner_invoice_id.name")
|
||||
partner_invoice_street = fields.Char(related="partner_invoice_id.street")
|
||||
partner_invoice_street2 = fields.Char(related="partner_invoice_id.street")
|
||||
partner_invoice_street = fields.Char(related="partner_invoice_id.street", string="Street")
|
||||
partner_invoice_street2 = fields.Char(related="partner_invoice_id.street", string="Street2")
|
||||
partner_invoice_zip = fields.Char(related="partner_invoice_id.zip")
|
||||
partner_invoice_city = fields.Char(related="partner_invoice_id.city")
|
||||
partner_invoice_email = fields.Char(related="partner_invoice_id.email")
|
||||
@@ -320,7 +320,7 @@ class PmsReservation(models.Model):
|
||||
digits=('Product Price'),
|
||||
compute='_compute_amount_reservation')
|
||||
price_tax = fields.Float(
|
||||
string='Taxes',
|
||||
string='Taxes Amount',
|
||||
readonly=True,
|
||||
store=True,
|
||||
compute='_compute_amount_reservation')
|
||||
|
||||
@@ -149,7 +149,7 @@ class PmsService(models.Model):
|
||||
store=True,
|
||||
compute='_compute_amount_service')
|
||||
price_tax = fields.Float(
|
||||
string='Taxes',
|
||||
string='Taxes Amount',
|
||||
readonly=True,
|
||||
store=True,
|
||||
compute='_compute_amount_service')
|
||||
|
||||
@@ -52,7 +52,7 @@ class PmsServiceLine(models.Model):
|
||||
readonly=True,
|
||||
store=True)
|
||||
cancel_discount = fields.Float(
|
||||
'Discount', compute='_compute_cancel_discount')
|
||||
'Discount cancel', compute='_compute_cancel_discount')
|
||||
|
||||
# Compute and Search methods
|
||||
@api.depends('day_qty', 'service_id.price_total')
|
||||
|
||||
@@ -61,18 +61,17 @@
|
||||
<button name="open_master" string="Open Master" type="object" class="oe_highlight" icon="fa-file" attrs="{'invisible':['|',['parent_reservation', '=', False]]}" />
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,booking,done"/>
|
||||
</header>
|
||||
|
||||
<sheet>
|
||||
<div class="alert alert-info" role="alert" style="margin-bottom:0px;"
|
||||
<div class="alert alert-info" role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible': ['|',('shared_folio','=',False),('splitted', '=', True)]}">
|
||||
This reservation has other reservantions and/or services in the folio, you can check it in the
|
||||
<bold><button class="alert-link" type="object" name="open_folio" string="Folio Form"/></bold>
|
||||
</div>
|
||||
<div class="alert alert-warning" role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible': [('splitted','=',False)]}">
|
||||
This reservation is part of splitted reservation!, you can check it in the
|
||||
<bold><button class="alert-link" type="object" name="open_folio" string="Folio Form"/></bold>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-warning" role="alert" style="margin-bottom:0px;"
|
||||
attrs="{'invisible': [('splitted','=',False)]}">
|
||||
This reservation is part of splitted reservation!, you can check it in the
|
||||
<bold><button class="alert-link" type="object" name="open_folio" string="Folio Form"/></bold>
|
||||
</div>
|
||||
<sheet>
|
||||
<field name="shared_folio" invisible="1"/>
|
||||
<div class="oe_button_box" name="button_box" attrs="{'invisible': [('folio_id','=',False)]}">
|
||||
<button type="object" class="oe_stat_button"
|
||||
|
||||
@@ -161,14 +161,14 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
'account_analytic_id': folio.analytic_account_id.id or False,
|
||||
})],
|
||||
'currency_id': folio.pricelist_id.currency_id.id,
|
||||
'payment_term_id': folio.payment_term_id.id,
|
||||
'invoice_payment_term_id': folio.payment_term_id.id,
|
||||
'fiscal_position_id': folio.fiscal_position_id.id \
|
||||
or folio.partner_id.property_account_position_id.id,
|
||||
'team_id': folio.team_id.id,
|
||||
'user_id': folio.user_id.id,
|
||||
'comment': folio.note,
|
||||
})
|
||||
invoice.compute_taxes()
|
||||
#invoice.compute_taxes() #TODO: Review method (view sales module)
|
||||
invoice.message_post_with_view(
|
||||
'mail.message_origin_link',
|
||||
values={'self': invoice, 'invoice_origin': folio},
|
||||
@@ -202,7 +202,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
|
||||
|
||||
def create_invoices(self):
|
||||
inv_obj = self.env['account.invoice']
|
||||
inv_obj = self.env['account.move']
|
||||
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
|
||||
folios = self.folio_ids
|
||||
|
||||
@@ -253,7 +253,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
})
|
||||
del context
|
||||
invoice = self._create_invoice(folio, service_line, amount)
|
||||
invoice.compute_taxes()
|
||||
#invoice.compute_taxes() #TODO: Review Method
|
||||
if not invoice.invoice_line_ids:
|
||||
raise UserError(_('There is no invoiceable line.'))
|
||||
# If invoice is negative, do a refund invoice instead
|
||||
@@ -266,7 +266,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
line._set_additional_fields(invoice)
|
||||
# Necessary to force computation of taxes. In account_invoice, they are triggered
|
||||
# by onchanges, which are not triggered when doing a create.
|
||||
invoice.compute_taxes()
|
||||
#invoice.compute_taxes() TODO: REVIEW method
|
||||
self._validate_invoices(invoice)
|
||||
invoice.message_post_with_view('mail.message_origin_link',
|
||||
values={'self': invoice, 'invoice_origin': folios},
|
||||
@@ -376,7 +376,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
a clean extension chain).
|
||||
"""
|
||||
|
||||
journal_id = self.env['account.invoice'].default_get(['journal_id'])['journal_id']
|
||||
journal_id = self.env['account.move'].default_get(['journal_id'])['journal_id']
|
||||
if not journal_id:
|
||||
raise UserError(_('Please define an accounting sales journal for this company.'))
|
||||
origin = ' '.join(self.folio_ids.mapped('name'))
|
||||
@@ -395,16 +395,15 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
'name': self.folio_ids[0].client_order_ref or '',
|
||||
'invoice_origin': origin,
|
||||
'type': 'out_invoice',
|
||||
'account_id': self.partner_invoice_id.property_account_receivable_id.id,
|
||||
'partner_id': self.partner_invoice_id.id,
|
||||
'journal_id': journal_id,
|
||||
'currency_id': currency.id,
|
||||
'payment_term_id': payment_term.id,
|
||||
'invoice_payment_term_id': payment_term.id,
|
||||
'fiscal_position_id': fiscal_position.id or self.partner_invoice_id.property_account_position_id.id,
|
||||
'company_id': company.id,
|
||||
'user_id': user and user.id,
|
||||
'team_id': team.id,
|
||||
'comment': self.folio_ids[0].note
|
||||
'narration': self.folio_ids[0].note
|
||||
}
|
||||
return invoice_vals
|
||||
|
||||
@@ -478,11 +477,10 @@ class LineAdvancePaymentInv(models.TransientModel):
|
||||
""" Create an invoice line.
|
||||
:param invoice_id: integer
|
||||
:param qty: float quantity to invoice
|
||||
:returns recordset of account.invoice.line created
|
||||
:returns recordset of account.move.line created
|
||||
"""
|
||||
self.ensure_one()
|
||||
invoice_lines = self.env['account.invoice.line']
|
||||
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
|
||||
invoice_lines = self.env['account.move.line']
|
||||
origin = self.reservation_id if self.reservation_id.id else self.service_id
|
||||
product = self.product_id
|
||||
account = product.property_account_income_id or product.categ_id.property_account_income_categ_id
|
||||
@@ -496,28 +494,27 @@ class LineAdvancePaymentInv(models.TransientModel):
|
||||
vals = {
|
||||
'sequence': origin.sequence,
|
||||
'invoice_origin': origin.name,
|
||||
'account_id': account.id,
|
||||
'price_unit': self.price_unit,
|
||||
'quantity': self.qty,
|
||||
'discount': self.discount,
|
||||
'uom_id': product.uom_id.id,
|
||||
'product_id': product.id or False,
|
||||
'invoice_line_tax_ids': [(6, 0, origin.tax_ids.ids)],
|
||||
'account_analytic_id': self.folio_id.analytic_account_id.id,
|
||||
'account_analytic_id': self.folio_id.analytic_account_id.id or False,
|
||||
'analytic_tag_ids': [(6, 0, origin.analytic_tag_ids.ids)]
|
||||
}
|
||||
if self.reservation_id:
|
||||
vals.update({
|
||||
'name': self.description + ' (' + self.description_dates + ')',
|
||||
'invoice_id': invoice_id,
|
||||
'move_id': invoice_id,
|
||||
'reservation_ids': [(6, 0, [origin.id])],
|
||||
'reservation_line_ids': [(6, 0, self.reservation_line_ids.ids)]
|
||||
})
|
||||
elif self.service_id:
|
||||
vals.update({
|
||||
'name': self.description,
|
||||
'invoice_id': invoice_id,
|
||||
'move_id': invoice_id,
|
||||
'service_ids': [(6, 0, [origin.id])]
|
||||
})
|
||||
invoice_lines |= self.env['account.invoice.line'].create(vals)
|
||||
invoice_lines |= self.env['account.move.line'].create(vals)
|
||||
return invoice_lines
|
||||
|
||||
@@ -80,7 +80,7 @@ class FolioWizard(models.TransientModel):
|
||||
autoassign = fields.Boolean('Autoassign', default="1")
|
||||
company_id = fields.Many2one('res.company',
|
||||
'Company',
|
||||
default=lambda self: self.env['res.company']._company_default_get('pms.folio.wizard'))
|
||||
default=lambda self: self.env.company)
|
||||
channel_type = fields.Selection([
|
||||
('door', 'Door'),
|
||||
('mail', 'Mail'),
|
||||
|
||||
Reference in New Issue
Block a user