[MIG] stock_warehouse_orderpoint_stock_info: Migration to 10.0

This commit is contained in:
mreficent
2017-07-18 17:30:14 +02:00
committed by ps-tubtim
parent 60df43819e
commit 92cbd9a464
6 changed files with 32 additions and 24 deletions

View File

@@ -2,9 +2,9 @@
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
===========================
Reordering Rules stock info
===========================
=====================================
Stock Warehouse Orderpoint Stock Info
=====================================
This modules allows to know the product availability directly in the reordering
rules.
@@ -14,7 +14,7 @@ Usage
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/153/9.0
:target: https://runbot.odoo-community.org/runbot/153/10.0
Bug Tracker
===========
@@ -31,12 +31,14 @@ Credits
Contributors
------------
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <anajuaristi@avanzosc.es>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Serpent Consulting Services Pvt. Ltd. <http://www.serpentcs.com>
Do not contact contributors directly about support or help with technical issues.
Maintainer
----------

View File

@@ -7,8 +7,8 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Reordering rules stock info",
"version": "9.0.1.0.0",
"name": "Stock Warehouse Orderpoint Stock Info",
"version": "10.0.1.0.0",
"depends": [
"stock",
],
@@ -23,5 +23,5 @@
"views/stock_warehouse_orderpoint_view.xml",
],
"installable": True,
"auto_install": False,
"application": False,
}

View File

@@ -3,10 +3,11 @@
# Copyright 2016 AvanzOSC
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# Copyright 2016 Eficent Business and IT Consulting Services, S.L.
# Copyright 2016-17 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import models, fields, api
from odoo import api, fields, models
from collections import defaultdict
class StockWarehouseOrderpoint(models.Model):
@@ -14,14 +15,21 @@ class StockWarehouseOrderpoint(models.Model):
@api.multi
def _compute_product_available_qty(self):
for rec in self:
product_available = rec.product_id.with_context(
location=rec.location_id.id
)._product_available()[rec.product_id.id]
rec.product_location_qty = product_available['qty_available']
rec.incoming_location_qty = product_available['incoming_qty']
rec.outgoing_location_qty = product_available['outgoing_qty']
rec.virtual_location_qty = product_available['virtual_available']
op_by_loc = defaultdict(lambda: self.env['stock.warehouse.orderpoint'])
for order in self:
op_by_loc[order.location_id] |= order
for location_id, order_in_loc in op_by_loc.items():
products = order_in_loc.mapped('product_id').with_context(
location=location_id.id)._compute_quantities_dict(
lot_id=self.env.context.get('lot_id'),
owner_id=self.env.context.get('owner_id'),
package_id=self.env.context.get('package_id'))
for order in order_in_loc:
product = products[order.product_id.id]
order.product_location_qty = product['qty_available']
order.incoming_location_qty = product['incoming_qty']
order.outgoing_location_qty = product['outgoing_qty']
order.virtual_location_qty = product['virtual_available']
product_location_qty = fields.Float(
string='Quantity On Location',
@@ -37,4 +45,4 @@ class StockWarehouseOrderpoint(models.Model):
compute='_compute_product_available_qty')
product_category = fields.Many2one(string='Product Category',
related='product_id.categ_id',
store=True)
store=True, readonly=True)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -3,10 +3,10 @@
# Copyright 2016 AvanzOSC
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# Copyright 2016 Eficent Business and IT Consulting Services, S.L.
# Copyright 2016-17 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests import common
from odoo.tests import common
class TestStockWarehouseOrderpoint(common.TransactionCase):

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<odoo>
<record model="ir.ui.view" id="stock_warehouse_orderpoint_tree_view">
<field name="name">stock.warehouse.orderpoint.tree</field>
<field name="model">stock.warehouse.orderpoint</field>
@@ -50,5 +49,4 @@
</xpath>
</field>
</record>
</data>
</openerp>
</odoo>