Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pms/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================================
PMS (Property Management System)
================================
Expand All @@ -17,7 +13,7 @@ PMS (Property Management System)
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpms-lightgray.png?logo=github
Expand Down
5 changes: 1 addition & 4 deletions pms/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "PMS (Property Management System)",
"summary": "A property management system",
"version": "16.0.0.14.0",
"version": "16.0.0.16.0",
"development_status": "Beta",
"category": "Generic Modules/Property Management System",
"website": "https://github.com/OCA/pms",
Expand All @@ -26,7 +26,6 @@
"partner_contact_birthdate",
"partner_contact_nationality",
# "partner_identification_unique_by_category",
"queue_job",
"web_timeline",
"partner_identification",
"analytic",
Expand All @@ -50,8 +49,6 @@
"report/invoice.xml",
# "templates/pms_email_template.xml",
"data/menus.xml",
"data/queue_data.xml",
"data/queue_job_function_data.xml",
"wizards/wizard_payment_folio.xml",
"wizards/folio_make_invoice_advance_views.xml",
"wizards/pms_booking_engine_views.xml",
Expand Down
33 changes: 1 addition & 32 deletions pms/data/cron_jobs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,5 @@
<field name="nextcall" eval="DateTime.now()" />
<field name="code">model.send_cancelation_mail()</field>
</record> -->
<record model="ir.cron" id="autoinvoicing_folios">
<field name="name">Auto Invoicing Folios</field>
<field name="interval_number">1</field>
<field name="user_id" ref="base.user_root" />
<field name="active" eval="False" />
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="state">code</field>
<field name="model_id" ref="model_pms_property" />
<field
name="nextcall"
eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 23:30:00')"
/>
<field name="code">model.autoinvoicing()</field>
</record>
<record model="ir.cron" id="autoinvoicing_downpayments">
<field name="name">Auto Invoicing DownPayments</field>
<field name="interval_number">1</field>
<field name="user_id" ref="base.user_root" />
<field name="active" eval="False" />
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="state">code</field>
<field name="model_id" ref="model_account_payment" />
<field
name="nextcall"
eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 04:30:00')"
/>
<field name="code">model.auto_invoice_downpayments(offset=1)</field>
</record>

</odoo>
7 changes: 0 additions & 7 deletions pms/data/queue_data.xml

This file was deleted.

15 changes: 0 additions & 15 deletions pms/data/queue_job_function_data.xml

This file was deleted.

14 changes: 14 additions & 0 deletions pms/migrations/16.0.0.16.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
_deleted_xml_records = [
"pms.view_partner_property_form",
"pms.autoinvoicing_folios",
"pms.autoinvoicing_downpayments",
"pms.autoinvoice_folio_job_function",
"pms.autovalidate_invoice_folio_job_function",
"pms.channel_autoinvoicing_folios",
]
openupgrade.delete_records_safely_by_xml_id(env, _deleted_xml_records)
4 changes: 0 additions & 4 deletions pms/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class AccountJournal(models.Model):
string="For manual payments",
help="Use to pay for reservations",
)
avoid_autoinvoice_downpayment = fields.Boolean(
help="Avoid autoinvoice downpayment",
default=False,
)
is_simplified_invoice = fields.Boolean(
string="Simplified invoice",
help="Use to simplified invoice",
Expand Down
85 changes: 0 additions & 85 deletions pms/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Copyright 2017 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from collections import defaultdict

from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models


Expand Down Expand Up @@ -125,51 +121,6 @@ def action_draft(self):
downpayment_invoices.unlink()
return super().action_draft()

@api.model
def auto_invoice_downpayments(self, offset=0):
"""
This method is called by a cron job to invoice the downpayments
based on the company settings.
"""
date_reference = fields.Date.today() - relativedelta(days=offset)
payments = self._get_downpayments_to_invoice(date_reference)
for payment in payments:
partner_id = (
payment.partner_id.id or self.env.ref("pms.various_pms_partner").id
)
self._create_downpayment_invoice(
payment=payment,
partner_id=partner_id,
)
return True

@api.model
def _get_downpayments_to_invoice(self, date_reference):
companys = self.env["res.company"].search([])
payments = self.env["account.payment"]
for company in companys:
if company.pms_invoice_downpayment_policy == "all":
date_ref = fields.Date.today()
elif company.pms_invoice_downpayment_policy == "checkout_past_month":
date_ref = fields.Date.today().replace(
day=1, month=fields.Date.today().month + 1
)
else:
continue
payments += self.search(
[
("state", "=", "posted"),
("partner_type", "=", "customer"),
("company_id", "=", company.id),
("journal_id.avoid_autoinvoice_downpayment", "=", False),
("folio_ids", "!=", False),
("folio_ids.last_checkout", ">=", date_ref),
("date", "<=", date_reference),
]
)
payments = payments.filtered(lambda p: not p.reconciled_invoice_ids)
return payments

@api.model
def _check_has_downpayment_invoice(self, payment):
if (
Expand All @@ -181,39 +132,3 @@ def _check_has_downpayment_invoice(self, payment):
):
return True
return False

@api.model
def _create_downpayment_invoice(self, payment, partner_id):
invoice_wizard = self.env["folio.advance.payment.inv"].create(
{
"partner_invoice_id": partner_id,
"advance_payment_method": "fixed",
"fixed_amount": payment.amount,
}
)
move = invoice_wizard.with_context(
active_ids=payment.folio_ids.ids,
return_invoices=True,
).create_invoices()
if payment.payment_type == "outbound":
move.action_switch_invoice_into_refund_credit_note()
move.action_post()
for invoice, payment_move in zip(move, payment.move_id, strict=True):
group = defaultdict(list)
for line in (invoice.line_ids + payment_move.line_ids).filtered(
lambda r: not r.reconciled
):
group[(line.account_id, line.currency_id)].append(line.id)
for (account, _dummy), line_ids in group.items():
if (
account.reconcile or account.account_type == "liquidity"
): # TODO: liquidity not in account.account_type
self.env["account.move.line"].browse(line_ids).reconcile()
# Set folio sale lines default_invoice_to to partner downpayment invoice
for folio in payment.folio_ids:
for sale_line in folio.sale_line_ids.filtered(
lambda r: not r.default_invoice_to
):
sale_line.default_invoice_to = move.partner_id.id

return move
55 changes: 0 additions & 55 deletions pms/models/folio_sale_line.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Copyright 2020 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import timedelta
from math import ceil

import babel.dates
from dateutil import relativedelta

from odoo import _, api, fields, models
from odoo.exceptions import UserError
Expand Down Expand Up @@ -330,10 +328,6 @@ class FolioSaleLine(models.Model):
ondelete="restrict",
index=True,
)
autoinvoice_date = fields.Date(
compute="_compute_autoinvoice_date",
store=True,
)
auto_reservation_note = fields.Boolean(
help="Indicates if the folio sale line is an auto reservation note",
default=False,
Expand Down Expand Up @@ -402,55 +396,6 @@ def _compute_date_order(self):
else:
record.date_order = 0

@api.depends(
"default_invoice_to",
"invoice_status",
"folio_id.last_checkout",
"reservation_id.checkout",
"service_id.reservation_id.checkout",
)
def _compute_autoinvoice_date(self):
for record in self:
record.autoinvoice_date = record._get_to_invoice_date()

def _get_to_invoice_date(self):
self.ensure_one()
partner = self.default_invoice_to
if self.reservation_id:
last_checkout = self.reservation_id.checkout
elif self.service_id and self.service_id.reservation_id:
last_checkout = self.service_id.reservation_id.checkout
else:
last_checkout = self.folio_id.last_checkout
if not last_checkout:
return False
invoicing_policy = (
self.folio_id.pms_property_id.default_invoicing_policy
if not partner or partner.invoicing_policy == "property"
else partner.invoicing_policy
)
if invoicing_policy == "manual":
return False
if invoicing_policy == "checkout":
margin_days = (
self.folio_id.pms_property_id.margin_days_autoinvoice
if not partner or partner.invoicing_policy == "property"
else partner.margin_days_autoinvoice
)
return last_checkout + timedelta(days=margin_days)
if invoicing_policy == "month_day":
month_day = (
self.folio_id.pms_property_id.invoicing_month_day
if not partner or partner.invoicing_policy == "property"
else partner.invoicing_month_day
)
if last_checkout.day <= month_day:
return last_checkout.replace(day=month_day)
else:
return (last_checkout + relativedelta.relativedelta(months=1)).replace(
day=month_day
)

@api.depends("date_order")
def _compute_reservation_order(self):
for record in self:
Expand Down
Loading