diff --git a/easy_my_coop/i18n/fr_BE.po b/easy_my_coop/i18n/fr_BE.po index 1f70b67..bd660c9 100644 --- a/easy_my_coop/i18n/fr_BE.po +++ b/easy_my_coop/i18n/fr_BE.po @@ -1666,6 +1666,11 @@ msgstr "" msgid "Request date" msgstr "Date de la demande" +#. module: easy_my_coop +#: model:ir.model.fields,field_description:easy_my_coop.field_operation_request__effective_date +msgid "Effective date" +msgstr "Date effective" + #. module: easy_my_coop #: model_terms:ir.ui.view,arch_db:easy_my_coop.theme_invoice_G002_document msgid "Request to Release Capital" diff --git a/easy_my_coop/models/operation_request.py b/easy_my_coop/models/operation_request.py index d608128..e6d247d 100644 --- a/easy_my_coop/models/operation_request.py +++ b/easy_my_coop/models/operation_request.py @@ -29,6 +29,7 @@ class OperationRequest(models.Model): request_date = fields.Date( string="Request date", default=lambda self: self.get_date_now() ) + effective_date = fields.Date(string='Effective date') partner_id = fields.Many2one( "res.partner", string="Cooperator", @@ -118,6 +119,13 @@ class OperationRequest(models.Model): invoice = fields.Many2one("account.invoice", string="Invoice") + @api.multi + @api.constrains("effective_date") + def _constrain_effective_date(self): + for obj in self: + if obj.effective_date > fields.Datetime.now(): + raise ValidationError("The effective date can not be in the future.")\ + @api.multi def approve_operation(self): for rec in self: @@ -322,7 +330,10 @@ class OperationRequest(models.Model): def execute_operation(self): self.ensure_one() - effective_date = self.get_date_now() + if self.effective_date: + effective_date = self.effective_date + else: + effective_date = self.get_date_now() sub_request = self.env["subscription.request"] self.validate() diff --git a/easy_my_coop/views/operation_request_view.xml b/easy_my_coop/views/operation_request_view.xml index eb1f415..8560f44 100644 --- a/easy_my_coop/views/operation_request_view.xml +++ b/easy_my_coop/views/operation_request_view.xml @@ -44,6 +44,8 @@ +