mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
When the product_id change, change the warranty infos as well
This commit is contained in:
@@ -309,6 +309,56 @@ class claim_line(orm.Model):
|
||||
location_dest_id = seller.name.property_stock_supplier.id
|
||||
return location_dest_id
|
||||
|
||||
def onchange_product_id(self, cr, uid, ids, product_id, invoice_line_id,
|
||||
claim_id, company_id, warehouse_id,
|
||||
claim_type, claim_date, context=None):
|
||||
if not claim_id and not (company_id and warehouse_id and
|
||||
claim_type and claim_date):
|
||||
# if we have a claim_id, we get the info from there,
|
||||
# otherwise we get it from the args (on creation typically)
|
||||
return {}
|
||||
if not (product_id and invoice_line_id):
|
||||
return {}
|
||||
product_obj = self.pool['product.product']
|
||||
claim_obj = self.pool['crm.claim']
|
||||
invoice_line_obj = self.pool['account.invoice.line']
|
||||
claim_line_obj = self.pool.get('claim.line')
|
||||
product = product_obj.browse(cr, uid, product_id, context=context)
|
||||
invoice_line = invoice_line_obj.browse(cr, uid, invoice_line_id,
|
||||
context=context)
|
||||
invoice = invoice_line.invoice_id
|
||||
|
||||
if claim_id:
|
||||
claim = claim_obj.browse(cr, uid, claim_id, context=context)
|
||||
company = claim.company_id
|
||||
warehouse = claim.warehouse_id
|
||||
claim_type = claim.claim_type
|
||||
claim_date = claim.date
|
||||
else:
|
||||
warehouse_obj = self.pool['stock.warehouse']
|
||||
company_obj = self.pool['res.company']
|
||||
company = company_obj.browse(cr, uid, company_id, context=context)
|
||||
warehouse = warehouse_obj.browse(cr, uid, warehouse_id,
|
||||
context=context)
|
||||
|
||||
values = {}
|
||||
try:
|
||||
warranty = claim_line_obj._warranty_limit_values(
|
||||
cr, uid, [], invoice,
|
||||
claim_type, product,
|
||||
claim_date, context=context)
|
||||
except (InvoiceNoDate, ProductNoSupplier):
|
||||
# we don't mind at this point if the warranty can't be
|
||||
# computed and we don't want to block the user
|
||||
pass
|
||||
else:
|
||||
values.update(warranty)
|
||||
|
||||
warranty_address = claim_line_obj._warranty_return_address_values(
|
||||
cr, uid, [], product, company, warehouse, context=context)
|
||||
values.update(warranty_address)
|
||||
return {'value': values}
|
||||
|
||||
def _warranty_return_address_values(self, cr, uid, ids, product, company,
|
||||
warehouse, context=None):
|
||||
"""Return the partner to be used as return destination and
|
||||
|
||||
@@ -92,7 +92,8 @@
|
||||
<group>
|
||||
<group string="Returned good">
|
||||
<field name="product_returned_quantity"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_id"
|
||||
on_change="onchange_product_id(product_id, invoice_line_id, claim_id, False, False, False, False, context)"/>
|
||||
<field name="prodlot_id"/>
|
||||
<field name="unit_sale_price"/>
|
||||
<field name="return_value"/>
|
||||
@@ -172,7 +173,55 @@
|
||||
<group>
|
||||
<!-- Place for mass return button from crm_rma_lot_mass_return -->
|
||||
</group>
|
||||
<field name="claim_line_ids" nolabel="1" colspan="4" editable="top"/>
|
||||
<field name="claim_line_ids" nolabel="1" colspan="4" editable="top">
|
||||
<form string="Claim Line" version="7.0">
|
||||
<header>
|
||||
<button name="set_warranty" string="Calculate warranty state" type="object" class="oe_highlight"/>
|
||||
</header>
|
||||
<sheet string="Claims">
|
||||
<div class="oe_title">
|
||||
<group>
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name"/></h1>
|
||||
</group>
|
||||
</div>
|
||||
<group>
|
||||
<group string="Returned good">
|
||||
<field name="product_returned_quantity"/>
|
||||
<field name="product_id"
|
||||
on_change="onchange_product_id(product_id, invoice_line_id, parent.id, parent.company_id, parent.warehouse_id, parent.claim_type, parent.date, context)"/>
|
||||
<field name="prodlot_id"/>
|
||||
<field name="unit_sale_price"/>
|
||||
<field name="return_value"/>
|
||||
</group>
|
||||
<group string="Linked Document">
|
||||
<field name="invoice_line_id"/>
|
||||
<field name="refund_line_id"/>
|
||||
<field name="move_in_id"/>
|
||||
<field name="move_out_id"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group string="Problem">
|
||||
<field name="claim_origine" nolabel="1" colspan="4"/>
|
||||
<field name="claim_descr" nolabel="1" colspan="4"/>
|
||||
</group>
|
||||
<group string="Warranty">
|
||||
<field name="guarantee_limit"/>
|
||||
<field name="warning"/>
|
||||
<field name="warranty_return_partner"/>
|
||||
<field name="warranty_type"/>
|
||||
</group>
|
||||
</group>
|
||||
<separator string="State" colspan="4"/>
|
||||
<group col="6" colspan="4">
|
||||
<field name="state"/>
|
||||
<field name="substate_id" widget='selection' />
|
||||
<field name="last_state_change"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</group>
|
||||
<group col="4" colspan="4" attrs="{'invisible':[('state', '<>','open')]}">
|
||||
<separator string="Action" colspan="4" />
|
||||
|
||||
Reference in New Issue
Block a user