Browse Source

[ADD] easy_my_coop: effective date field on operation request

pull/93/head
Manuel Claeys Bouuaert 5 years ago
parent
commit
0274ebff3c
  1. 5
      easy_my_coop/i18n/fr_BE.po
  2. 11
      easy_my_coop/models/operation_request.py
  3. 1
      easy_my_coop/view/operation_request_view.xml

5
easy_my_coop/i18n/fr_BE.po

@ -2135,6 +2135,11 @@ msgstr "Date de la demande"
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:ir.ui.view,arch_db:easy_my_coop.view_subscription_request_filter
msgid "Request type"

11
easy_my_coop/models/operation_request.py

@ -23,6 +23,7 @@ class operation_request(models.Model):
request_date = fields.Date(string='Request date',
default=lambda self: self.get_date_now())
effective_date = fields.Date(string='Effective date', required=False)
partner_id = fields.Many2one('res.partner',
string='Cooperator',
domain=[('member', '=', True)],
@ -87,6 +88,13 @@ class operation_request(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:
@ -211,6 +219,9 @@ class operation_request(models.Model):
def execute_operation(self):
self.ensure_one()
if self.effective_date:
effective_date = self.effective_date
else:
effective_date = self.get_date_now()
sub_request = self.env['subscription.request']

1
easy_my_coop/view/operation_request_view.xml

@ -33,6 +33,7 @@
<group>
<group>
<field name="request_date" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="effective_date" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="operation_type" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="receiver_not_member" attrs="{'invisible':[('operation_type','!=','transfer')]}"/>
<field name="partner_id" options="{'no_create':True}" attrs="{'readonly':[('state','!=','draft')]}"/>

Loading…
Cancel
Save