Browse Source

Merge pull request #94 from coopiteasy/12.0-operation-request-effective-date-field

[ADD][12.0] easy_my_coop: effective date field on operation request
pull/122/head
Rémy Taymans 4 years ago
committed by GitHub
parent
commit
6e5c2394a1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      easy_my_coop/i18n/fr_BE.po
  2. 16
      easy_my_coop/models/operation_request.py
  3. 7
      easy_my_coop/views/operation_request_view.xml

5
easy_my_coop/i18n/fr_BE.po

@ -2004,6 +2004,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_terms:ir.ui.view,arch_db:easy_my_coop.theme_invoice_G002_document
msgid "Request to Release\n"

16
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,15 @@ 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 and obj.effective_date > fields.Date.today():
raise ValidationError(
_("The effective date can not be in the future.")
)
@api.multi
def approve_operation(self):
for rec in self:
@ -322,7 +332,11 @@ 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()
self.effective_date = effective_date
sub_request = self.env["subscription.request"]
self.validate()

7
easy_my_coop/views/operation_request_view.xml

@ -7,6 +7,7 @@
<tree string="Operation requests"
colors="green:state in ('approved'); blue:state in ('draft');grey: state in ('done')">
<field name="request_date"/>
<field name="effective_date"/>
<field name="partner_id"/>
<field name="operation_type"/>
<field name="quantity"/>
@ -44,16 +45,18 @@
<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')]}"/>
attrs="{'invisible':[('operation_type','!=','transfer')], 'readonly':[('state','!=','draft')]}"/>
<field name="partner_id"
options="{'no_create':True}"
attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="partner_id_to"
options="{'no_create':True}"
attrs="{'invisible':['|',('operation_type','!=','transfer'), ('receiver_not_member','=',True)]}"/>
attrs="{'invisible':['|',('operation_type','!=','transfer'), ('receiver_not_member','=',True)], 'readonly':[('state','!=','draft')]}"/>
</group>
<group>
<field name="user_id"/>

Loading…
Cancel
Save