[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

@@ -2,23 +2,24 @@
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
=========================== ===============================
Manual assignment of quants Stock - Manual Quant Assignment
=========================== ===============================
With this module, user can manually change the automatic selection of quants. This module allows you to manually change the automatic quant selection.
Usage Usage
===== =====
To use this module, you need to: To use this module, you need to:
* You will able to select the quants from each stock.move. There will be a #. Select a stock move or a stock picking.
button that opens a wizard directly from the move or from the picking. #. Open the wizard with the button "Manual Quants".
#. Select the quants to assign (reserve).
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/153/8.0 :target: https://runbot.odoo-community.org/runbot/153/9.0
Bug Tracker Bug Tracker
=========== ===========
@@ -26,12 +27,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues
<https://github.com/OCA/stock-logistics-warehouse/issues>`_. In case of trouble, please <https://github.com/OCA/stock-logistics-warehouse/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first, check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed `feedback help us smashing it by providing a detailed and welcomed feedback.
<https://github.com/OCA/
stock-logistics-warehouse/issues/new?body=module:%20
stock_quant_manual_assign%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits Credits
======= =======

View File

@@ -3,8 +3,8 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{ {
"name": "Stock - Manual assignment of quants", "name": "Stock - Manual Quant Assignment",
"version": "8.0.1.0.0", "version": "9.0.1.0.0",
"category": "Warehouse Management", "category": "Warehouse Management",
"license": "AGPL-3", "license": "AGPL-3",
"author": "OdooMRP team, " "author": "OdooMRP team, "
@@ -12,12 +12,6 @@
"Serv. Tecnol. Avanzados - Pedro M. Baeza, " "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"website": "http://www.odoomrp.com", "website": "http://www.odoomrp.com",
"contributors": [
"Mikel Arregi <mikelarregi@avanzosc.es>",
"Ana Juaristi Olalde <anajuaristi@avanzosc.es>",
"Pedro Manuel Baeza Romero <pedro.baeza@serviciosbaeza.com>"
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
],
"depends": [ "depends": [
"stock", "stock",
], ],
@@ -25,5 +19,5 @@
"wizard/assign_manual_quants_view.xml", "wizard/assign_manual_quants_view.xml",
"views/stock_move_view.xml", "views/stock_move_view.xml",
], ],
"installable": False, "installable": True,
} }

View File

@@ -1,36 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<openerp> <odoo>
<data> <record model="ir.ui.view" id="stock_move_manual_quants_form_view">
<record model="ir.ui.view" id="stock_move_manual_quants_form_view"> <field name="name">stock.move.form</field>
<field name="name">stock.move.form</field> <field name="model">stock.move</field>
<field name="model">stock.move</field> <field name="inherit_id" ref="stock.view_move_form" />
<field name="inherit_id" ref="stock.view_move_form" /> <field name="arch" type="xml">
<field name="arch" type="xml"> <field name="state" position="before">
<button name="action_done" position="after"> <button name="%(assign_manual_quants_action)d" type="action"
<button name="%(assign_manual_quants_action)d" type="action" string="Manual Quants" class="oe_highlight"
string="Manual Quants" class="oe_highlight" attrs="{'invisible':['|',('picking_type_code','=','incoming'),('state','not in',('confirmed','assigned'))]}"/>
attrs="{'invisible':['|',('picking_type_code','=','incoming'),('state','not in',('confirmed','assigned'))]}"/>
</button>
<field name="picking_type_id" position="after">
<field name="picking_type_code" invisible="1" />
</field>
</field> </field>
</record> <field name="picking_type_id" position="after">
<field name="picking_type_code" invisible="1" />
</field>
</field>
</record>
<record model="ir.ui.view" id="stock_move_manual_quants_picking_form_view"> <record model="ir.ui.view" id="stock_move_manual_quants_picking_form_view">
<field name="name">stock.move.form</field> <field name="name">stock.move.form</field>
<field name="model">stock.move</field> <field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_picking_form" /> <field name="inherit_id" ref="stock.view_move_picking_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<button name="force_assign" position="after"> <field name="state" position="before">
<button name="%(assign_manual_quants_action)d" type="action" <button name="%(assign_manual_quants_action)d" type="action"
string="Manual Quants" class="oe_highlight" string="Manual Quants" class="oe_highlight"
attrs="{'invisible':['|',('picking_type_code','=','incoming'),('state','not in',('confirmed','assigned'))]}" /> attrs="{'invisible':['|',('picking_type_code','=','incoming'),('state','not in',('confirmed','assigned'))]}" />
</button>
<field name="picking_type_id" position="after">
<field name="picking_type_code" invisible="1" />
</field>
</field> </field>
</record> <field name="picking_type_id" position="after">
</data> <field name="picking_type_code" invisible="1" />
</openerp> </field>
</field>
</record>
</odoo>

View File

@@ -17,7 +17,9 @@ class AssignManualQuants(models.TransientModel):
if record.quants_lines: if record.quants_lines:
move = self.env['stock.move'].browse( move = self.env['stock.move'].browse(
self.env.context['active_id']) 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( raise exceptions.Warning(
_('Quantity is higher than the needed one')) _('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']) move = self.env['stock.move'].browse(self.env.context['active_id'])
lines_qty = sum(self.quants_lines.mapped('qty')) lines_qty = sum(self.quants_lines.mapped('qty'))
self.lines_qty = lines_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') name = fields.Char(string='Name')
lines_qty = fields.Float( lines_qty = fields.Float(
@@ -52,8 +56,8 @@ class AssignManualQuants(models.TransientModel):
return {} return {}
@api.model @api.model
def default_get(self, var_fields): def default_get(self, fields):
super(AssignManualQuants, self).default_get(var_fields) res = super(AssignManualQuants, self).default_get(fields)
move = self.env['stock.move'].browse(self.env.context['active_id']) move = self.env['stock.move'].browse(self.env.context['active_id'])
available_quants = self.env['stock.quant'].search([ available_quants = self.env['stock.quant'].search([
('location_id', 'child_of', move.location_id.id), ('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, 'qty': x.qty if x in move.reserved_quant_ids else 0,
'location_id': x.location_id.id, 'location_id': x.location_id.id,
} for x in available_quants] } 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): class AssignManualQuantsLines(models.TransientModel):

View File

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