Skip to content

Commit

Permalink
Merge pull request #92 from mdietrichc2c/9.0-fix-rma-onchange-invoice
Browse files Browse the repository at this point in the history
Modify onchange in order to work for invoice_id
  • Loading branch information
yvaucher committed Sep 8, 2016
2 parents 315b9f3 + c6a47ee commit 9c79108
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 15 additions & 1 deletion crm_claim_rma/models/crm_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,21 @@ def _get_claim_type_default(self):
help="Claim classification",
required=True)

@api.onchange('invoice_id', 'warehouse_id', 'claim_type', 'date')
@api.onchange('invoice_id')
def _onchange_invoice(self):
# Since no parameters or context can be passed from the view,
# this method exists only to call the onchange below with
# a specific context (to recreate claim lines).
# This does require to re-assign self.invoice_id in the new object
claim_with_ctx = self.with_context(
create_lines=True
)
claim_with_ctx.invoice_id = self.invoice_id
claim_with_ctx._onchange_invoice_warehouse_type_date()
values = claim_with_ctx._convert_to_write(claim_with_ctx._cache)
self.update(values)

@api.onchange('warehouse_id', 'claim_type', 'date')
def _onchange_invoice_warehouse_type_date(self):
context = self.env.context
claim_line = self.env['claim.line']
Expand Down
10 changes: 0 additions & 10 deletions crm_claim_rma/views/crm_claim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,4 @@
</xpath>
</field>
</record>
<record model="ir.ui.view" id="crm_case_claims_form_view">
<field name="name">CRM - Claims Form</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim_type.crm_case_claims_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='claim_type']" position="attributes">
<attribute name="context">{'create_lines': False}</attribute>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 9c79108

Please sign in to comment.