[ADD]:Added Upstream Patch for mrp_repair

This commit is contained in:
Fatemi Lokhandwala 2018-07-06 13:28:57 +05:30
parent cb0640a320
commit f313b7e8e8
3 changed files with 16 additions and 6 deletions

View File

@ -207,9 +207,11 @@ class Repair(models.Model):
def action_validate(self): def action_validate(self):
self.ensure_one() self.ensure_one()
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure') precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
available_qty = self.env['stock.quant']._get_available_quantity(self.product_id, self.location_id, self.lot_id, strict=True) available_qty_owner = self.env['stock.quant']._get_available_quantity(self.product_id, self.location_id, self.lot_id, owner_id=self.partner_id, strict=True)
if float_compare(available_qty, self.product_qty, precision_digits=precision) >= 0: available_qty_noown = self.env['stock.quant']._get_available_quantity(self.product_id, self.location_id, self.lot_id, strict=True)
return self.action_repair_confirm() for available_qty in [available_qty_owner, available_qty_noown]:
if float_compare(available_qty, self.product_qty, precision_digits=precision) >= 0:
return self.action_repair_confirm()
else: else:
return { return {
'name': _('Insufficient Quantity'), 'name': _('Insufficient Quantity'),
@ -435,8 +437,15 @@ class Repair(models.Model):
if self.filtered(lambda repair: not repair.repaired): if self.filtered(lambda repair: not repair.repaired):
raise UserError(_("Repair must be repaired in order to make the product moves.")) raise UserError(_("Repair must be repaired in order to make the product moves."))
res = {} res = {}
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
Move = self.env['stock.move'] Move = self.env['stock.move']
for repair in self: for repair in self:
# Try to create move with the appropriate owner
owner_id = False
available_qty_owner = self.env['stock.quant']._get_available_quantity(repair.product_id, repair.location_id, repair.lot_id, owner_id=repair.partner_id, strict=True)
if float_compare(available_qty_owner, repair.product_qty, precision_digits=precision) >= 0:
owner_id = repair.partner_id.id
moves = self.env['stock.move'] moves = self.env['stock.move']
for operation in repair.operations: for operation in repair.operations:
move = Move.create({ move = Move.create({
@ -454,6 +463,7 @@ class Repair(models.Model):
'qty_done': operation.product_uom_qty, 'qty_done': operation.product_uom_qty,
'package_id': False, 'package_id': False,
'result_package_id': False, 'result_package_id': False,
'owner_id': owner_id,
'location_id': operation.location_id.id, #TODO: owner stuff 'location_id': operation.location_id.id, #TODO: owner stuff
'location_dest_id': operation.location_dest_id.id,})], 'location_dest_id': operation.location_dest_id.id,})],
'repair_id': repair.id, 'repair_id': repair.id,
@ -476,6 +486,7 @@ class Repair(models.Model):
'qty_done': repair.product_qty, 'qty_done': repair.product_qty,
'package_id': False, 'package_id': False,
'result_package_id': False, 'result_package_id': False,
'owner_id': owner_id,
'location_id': repair.location_id.id, #TODO: owner stuff 'location_id': repair.location_id.id, #TODO: owner stuff
'location_dest_id': repair.location_dest_id.id,})], 'location_dest_id': repair.location_dest_id.id,})],
'repair_id': repair.id, 'repair_id': repair.id,

View File

@ -2,7 +2,7 @@
<flectra> <flectra>
<data> <data>
<template id="report_mrprepairorder"> <template id="report_mrprepairorder">
<t t-foreach="docs" t-as="o"> <t t-set="o" t-value="doc"/>
<t t-call="web.external_layout"> <t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context({'lang': o.partner_id.lang})" /> <t t-set="o" t-value="o.with_context({'lang': o.partner_id.lang})" />
<div class="page"> <div class="page">
@ -155,7 +155,6 @@
<div class="oe_structure"/> <div class="oe_structure"/>
</div> </div>
</t> </t>
</t>
</template> </template>
<template id="report_mrprepairorder2"> <template id="report_mrprepairorder2">

View File

@ -150,7 +150,7 @@
</group> </group>
</form> </form>
<tree string="Fees" editable="bottom"> <tree string="Fees" editable="bottom">
<field name="product_id" domain="[('type','=','service')]"/> <field name="product_id" domain="[('type','=','service')]" required="True"/>
<field name='name'/> <field name='name'/>
<field name="product_uom_qty" string="Quantity"/> <field name="product_uom_qty" string="Quantity"/>
<field name="product_uom" string="Unit of Measure" groups="product.group_uom"/> <field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>