mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: take account period_lock_date in folios invoices
This commit is contained in:
@@ -1896,7 +1896,6 @@ class PmsFolio(models.Model):
|
|||||||
if partner_invoice.invoicing_policy == "property"
|
if partner_invoice.invoicing_policy == "property"
|
||||||
else partner_invoice.invoicing_policy
|
else partner_invoice.invoicing_policy
|
||||||
)
|
)
|
||||||
|
|
||||||
invoice_date = False
|
invoice_date = False
|
||||||
if date:
|
if date:
|
||||||
invoice_date = date
|
invoice_date = date
|
||||||
@@ -1911,8 +1910,6 @@ class PmsFolio(models.Model):
|
|||||||
.search([("sale_line_ids", "in", lines_to_invoice.keys())])
|
.search([("sale_line_ids", "in", lines_to_invoice.keys())])
|
||||||
.mapped("checkout")
|
.mapped("checkout")
|
||||||
) + datetime.timedelta(days=margin_days_autoinvoice)
|
) + datetime.timedelta(days=margin_days_autoinvoice)
|
||||||
if invoice_date < datetime.date.today():
|
|
||||||
invoice_date = datetime.date.today()
|
|
||||||
if partner_invoice_policy == "month_day":
|
if partner_invoice_policy == "month_day":
|
||||||
month_day = (
|
month_day = (
|
||||||
self.pms_property_id.invoicing_month_day
|
self.pms_property_id.invoicing_month_day
|
||||||
@@ -1931,6 +1928,19 @@ class PmsFolio(models.Model):
|
|||||||
month_day,
|
month_day,
|
||||||
)
|
)
|
||||||
if invoice_date:
|
if invoice_date:
|
||||||
|
if (
|
||||||
|
self.company_id.period_lock_date
|
||||||
|
and invoice_date < self.company_id.period_lock_date
|
||||||
|
and not self.user_has_groups("account.group_account_manager")
|
||||||
|
):
|
||||||
|
raise UserError(
|
||||||
|
_(
|
||||||
|
"The period to create this invoice is locked. "
|
||||||
|
"Please contact your administrator to unlock it."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if invoice_date < datetime.date.today():
|
||||||
|
invoice_date = datetime.date.today()
|
||||||
key_field = (
|
key_field = (
|
||||||
"invoice_date"
|
"invoice_date"
|
||||||
if invoice_date == fields.Date.today()
|
if invoice_date == fields.Date.today()
|
||||||
|
|||||||
Reference in New Issue
Block a user