Merge PR #1038 into 14.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2023-10-30 07:40:52 +00:00
6 changed files with 58 additions and 3 deletions

View File

@@ -6,6 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-16 12:27+0000\n"
"PO-Revision-Date: 2023-02-16 12:27+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -148,6 +150,11 @@ msgstr ""
msgid "Allow Litigation Move Lines"
msgstr ""
#. module: account_payment_order
#: model:ir.model.fields,field_description:account_payment_order.field_account_payment_order__allow_past_date
msgid "Allow date in the past"
msgstr ""
#. module: account_payment_order
#: model:ir.model.fields,field_description:account_payment_order.field_account_payment_order__allowed_journal_ids
msgid "Allowed journals"
@@ -1193,6 +1200,13 @@ msgstr ""
msgid "Website communication history"
msgstr ""
#. module: account_payment_order
#: model:ir.model.fields,help:account_payment_order.field_account_payment_order__allow_past_date
msgid ""
"When checked, the Payment Date won't fast-forward to today and will instead "
"remain the scheduled date"
msgstr ""
#. module: account_payment_order
#: model:ir.model,name:account_payment_order.model_account_payment_line_create
msgid "Wizard to create payment lines"

View File

@@ -163,6 +163,11 @@ msgstr "Todos los asientos asentados"
msgid "Allow Litigation Move Lines"
msgstr "Permitir apuntes en litigio"
#. module: account_payment_order
#: model:ir.model.fields,field_description:account_payment_order.field_account_payment_order__allow_past_date
msgid "Allow date in the past"
msgstr "Permitir fecha en el pasado"
#. module: account_payment_order
#: model:ir.model.fields,field_description:account_payment_order.field_account_payment_order__allowed_journal_ids
msgid "Allowed journals"
@@ -1249,6 +1254,14 @@ msgstr "Mensajes del sitio web"
msgid "Website communication history"
msgstr "Historial de comunicaciones del sitio web"
#. module: account_payment_order
#: model:ir.model.fields,help:account_payment_order.field_account_payment_order__allow_past_date
msgid ""
"When checked, the Payment Date won't fast-forward to today and will instead "
"remain the scheduled date"
msgstr ""
"Al marcar esta casilla, la fecha contable no se pondrá al día actual y permanecerá con la fecha de ejecución del pago"
#. module: account_payment_order
#: model:ir.model,name:account_payment_order.model_account_payment_line_create
msgid "Wizard to create payment lines"

View File

@@ -145,6 +145,15 @@ class AccountPaymentOrder(models.Model):
compute="_compute_move_count", string="Number of Journal Entries"
)
description = fields.Char()
allow_past_date = fields.Boolean(
string="Allow date in the past",
help=(
"When checked, the Payment Date won't fast-forward to today "
"and will instead remain the scheduled date"
),
readonly=True,
states={"draft": [("readonly", False)]},
)
@api.depends("payment_mode_id")
def _compute_allowed_journal_ids(self):
@@ -187,7 +196,7 @@ class AccountPaymentOrder(models.Model):
today = fields.Date.context_today(self)
for order in self:
if order.date_scheduled:
if order.date_scheduled < today:
if not order.allow_past_date and order.date_scheduled < today:
raise ValidationError(
_(
"On payment order %s, the Payment Execution Date "
@@ -304,8 +313,9 @@ class AccountPaymentOrder(models.Model):
requested_date = order.date_scheduled or today
else:
requested_date = today
# No payment date in the past
requested_date = max(today, requested_date)
# No payment date in the past unless allowed
if not order.allow_past_date:
requested_date = max(today, requested_date)
# inbound: check option no_debit_before_maturity
if (
order.payment_type == "inbound"

View File

@@ -89,6 +89,13 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase):
def test_constrains_date(self):
with self.assertRaises(ValidationError):
self.inbound_order.date_scheduled = date.today() - timedelta(days=1)
# No raise
self.inbound_order.write(
{
"allow_past_date": True,
"date_scheduled": date.today() - timedelta(days=2),
}
)
def test_invoice_communication_01(self):
self.assertEqual(

View File

@@ -250,6 +250,13 @@ class TestPaymentOrderOutbound(TestPaymentOrderOutboundBase):
)
with self.assertRaises(ValidationError):
outbound_order.date_scheduled = date.today() - timedelta(days=2)
# No raise
outbound_order.write(
{
"allow_past_date": True,
"date_scheduled": date.today() - timedelta(days=2),
}
)
def test_invoice_communication_01(self):
self.assertEqual("F1242", self.invoice._get_payment_order_communication())

View File

@@ -108,6 +108,10 @@
name="date_scheduled"
attrs="{'invisible': [('date_prefered', '!=', 'fixed')], 'required': [('date_prefered', '=', 'fixed')]}"
/>
<field
name="allow_past_date"
attrs="{'invisible': [('date_prefered', '!=', 'fixed')]}"
/>
<field name="date_generated" />
<field name="generated_user_id" />
<field name="date_uploaded" />