[9.0][MIG] stock_manual_assign: Migration to 9.0

* Fix uom issue
* Convert move quantity in the default product uom to use the same uom as quant
This commit is contained in:
Laurent Bélorgey
2016-07-02 12:07:55 +02:00
committed by Pedro M. Baeza
parent f458bd7cb0
commit 9eab5e04fd
5 changed files with 86 additions and 95 deletions

View File

@@ -17,7 +17,9 @@ class AssignManualQuants(models.TransientModel):
if record.quants_lines:
move = self.env['stock.move'].browse(
self.env.context['active_id'])
if record.lines_qty > move.product_uom_qty:
move_qty = self.env['product.uom']._compute_qty_obj(
move.product_uom, move.product_uom_qty, move.product_id.uom_id)
if record.lines_qty > move_qty:
raise exceptions.Warning(
_('Quantity is higher than the needed one'))
@@ -26,7 +28,9 @@ class AssignManualQuants(models.TransientModel):
move = self.env['stock.move'].browse(self.env.context['active_id'])
lines_qty = sum(self.quants_lines.mapped('qty'))
self.lines_qty = lines_qty
self.move_qty = move.product_uom_qty - lines_qty
move_qty = self.env['product.uom']._compute_qty_obj(
move.product_uom, move.product_uom_qty, move.product_id.uom_id)
self.move_qty = move_qty - lines_qty
name = fields.Char(string='Name')
lines_qty = fields.Float(
@@ -52,8 +56,8 @@ class AssignManualQuants(models.TransientModel):
return {}
@api.model
def default_get(self, var_fields):
super(AssignManualQuants, self).default_get(var_fields)
def default_get(self, fields):
res = super(AssignManualQuants, self).default_get(fields)
move = self.env['stock.move'].browse(self.env.context['active_id'])
available_quants = self.env['stock.quant'].search([
('location_id', 'child_of', move.location_id.id),
@@ -71,7 +75,9 @@ class AssignManualQuants(models.TransientModel):
'qty': x.qty if x in move.reserved_quant_ids else 0,
'location_id': x.location_id.id,
} for x in available_quants]
return {'quants_lines': quants_lines}
res.update({'quants_lines': quants_lines})
res = self._convert_to_write(self._convert_to_cache(res))
return res
class AssignManualQuantsLines(models.TransientModel):

View File

@@ -1,38 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="assign_manual_quants_form_view">
<field name="name">assign.manual.quants.form</field>
<field name="model">assign.manual.quants</field>
<field name="arch" type="xml">
<form string="Manual Quants">
<group col='4' colspan="4">
<field name='quants_lines' colspan="4">
<tree editable="top" delete="0" create="0">
<field name="quant" />
<field name="location_id" />
<field name="lot_id" />
<field name="package_id" />
<field name="selected" />
<field name="qty" attrs="{'readonly':[('selected', '=' ,False)]}" sum="qty"/>
</tree>
</field>
<field name="move_qty" colspan="2" readonly="1"/>
<field name="lines_qty" invisible="1" />
</group>
<footer>
<button name="assign_quants" type="object"
string="Confirm" class="oe_highlight" />
or
<button string="Cancel" class="oe_link"
special="cancel" />
</footer>
</form>
</field>
</record>
<odoo>
<record model="ir.ui.view" id="assign_manual_quants_form_view">
<field name="name">assign.manual.quants.form</field>
<field name="model">assign.manual.quants</field>
<field name="arch" type="xml">
<form name="Manual Quants">
<group col='4' colspan="4">
<field name='quants_lines' colspan="4">
<tree editable="top" delete="0" create="0">
<field name="quant" />
<field name="location_id" />
<field name="lot_id" />
<field name="package_id" />
<field name="selected" />
<field name="qty" attrs="{'readonly':[('selected', '=' ,False)]}" sum="qty"/>
</tree>
</field>
<field name="move_qty" colspan="2" readonly="1"/>
<field name="lines_qty" invisible="1" />
</group>
<footer>
<button name="assign_quants" type="object"
string="Confirm" class="oe_highlight" />
<button name="cancel" string="Cancel" class="oe_link"
special="cancel" />
</footer>
</form>
</field>
</record>
<act_window name="Manual quants" res_model="assign.manual.quants"
src_model="stock.move" view_mode="form" target="new"
id="assign_manual_quants_action" />
</data>
</openerp>
<act_window name="Manual quants" res_model="assign.manual.quants"
src_model="stock.move" view_mode="form" target="new"
id="assign_manual_quants_action" />
</odoo>