Skip to content

Commit

Permalink
Merge pull request #21 from yvaucher/8.0-new-form-view-for-LRL
Browse files Browse the repository at this point in the history
Adding a display field of parent requisition
  • Loading branch information
lepistone committed Nov 7, 2014
2 parents 65baeb2 + a782c87 commit 78fce04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions logistic_requisition/model/logistic_requisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ class LogisticsRequisitionLine(models.Model):
readonly=True,
required=True,
ondelete='cascade')
# field for displaying requisition both on
# line form view and on requisition on inner line form view
display_requisition_id = fields.Many2one(
comodel_name='logistic.requisition',
string='Requisition',
compute='_get_display_requisition_id',
readonly=True)
source_ids = fields.One2many(
'logistic.requisition.source',
'requisition_line_id',
Expand Down Expand Up @@ -495,6 +502,18 @@ def _do_quoted(self):
def _store_get_requisition_ids(self):
return list(set([line.requisition_id.id for line in self]))

@api.multi
@api.depends('requisition_id')
def _get_display_requisition_id(self):
""" Return the requisition if we are not creating a new
requisition line in form view. Otherwise we let the field
empty as NewId is not jsonisable
"""
for line in self:

if not isinstance(line.id, models.NewId):
line.display_requisition_id = line.requisition_id

@api.multi
@api.depends('source_ids.total_cost',
'requisition_id.currency_id',
Expand Down
2 changes: 1 addition & 1 deletion logistic_requisition/view/logistic_requisition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
<div class="oe_title">
<h1>
<label string="Requisition"/>
<field name="requisition_id" class="oe_inline" readonly="1"/> /
<field name="display_requisition_id" class="oe_inline" readonly="1"/> /
<label string="Line N° "/>
<field name="name" class="oe_inline"/>
</h1>
Expand Down

0 comments on commit 78fce04

Please sign in to comment.