Skip to content

Commit

Permalink
Merge PR #583 into 10.0
Browse files Browse the repository at this point in the history
Signed-off-by rousseldenis
  • Loading branch information
OCA-git-bot committed Oct 1, 2019
2 parents c71cf86 + 36fda7e commit 8b65a84
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 1 deletion.
20 changes: 20 additions & 0 deletions stock_putaway_product/README.rst
Expand Up @@ -48,6 +48,19 @@ To use this module, you need to:

#. Select the proper stock locations for each product on the product form
on the "Inventory" tab
#. If your products share some locations, you can use a wizard to make
encoding easier. To do so you need to select some product variants from the
tree view and use the action "Add Default Stock Location".

.. image:: static/description/default_loc.png
:alt: Set default location by putaway method to products

|
.. image:: stock_product_putaway/static/description/default_loc.png
:alt: Set default location by putaway method to products

|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
Expand All @@ -61,6 +74,12 @@ Bugs are tracked on `GitHub Issues
, please 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.

Roadmap
===========

- Two modes : for the moment, it allows only to select one location for several products. In another mode, you could select different products and then a different location per product (you can have configuration with one location per product).
- Allow to launch the wizard on product templates (if you don't activate product variants you haven't access to wizard).

Images
------

Expand All @@ -73,6 +92,7 @@ Contributors
* Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.com>
* Denis Roussel - ACSONE SA/NV <denis.roussel@acsone.eu>
* Thomas Fossoul - WINK SA/NV <tfossoul@wink.be>
* David Béal - Akretion <david.beal@akretion.com>


Maintainer
Expand Down
4 changes: 3 additions & 1 deletion stock_putaway_product/__manifest__.py
Expand Up @@ -5,11 +5,12 @@
{
'name': 'Putaway strategy per product',
'summary': 'Set a product location and put-away strategy per product',
'version': '10.0.1.0.1',
'version': '10.0.1.0.2',
'category': 'Inventory',
'website': 'http://www.apertoso.be',
'author': 'Apertoso N.V., '
'Tecnativa, '
'Akretion, '
'Odoo Community Association (OCA)',
'license': 'AGPL-3',
'depends': [
Expand All @@ -19,6 +20,7 @@
'data': [
'views/product.xml',
'views/product_putaway.xml',
'wizard/quick_add_location.xml',
'security/ir.model.access.csv',
],
'demo': [
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions stock_putaway_product/wizard/__init__.py
Expand Up @@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock_change_product_qty
from . import quick_add_location
79 changes: 79 additions & 0 deletions stock_putaway_product/wizard/quick_add_location.py
@@ -0,0 +1,79 @@
# coding: utf-8
# © 2017 David BEAL @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, models, api, fields


class QuickAddProductLocation(models.TransientModel):
_name = "quick.add.product.location"

def _default_putaway(self):
""" Overridable method
"""
return self.env.ref(
"stock_putaway_product.product_putaway_per_product_wh",
raise_if_not_found=False,
)

putaway_id = fields.Many2one(
comodel_name="product.putaway",
string="Put Away Method",
required=True,
default=lambda self: self._default_putaway(),
)
fixed_location_id = fields.Many2one(
comodel_name="stock.location", string="Location", required=True
)
product_ids = fields.Many2many(
comodel_name="product.product", string="Products", required=True
)

@api.model
def default_get(self, fields):
res = super(QuickAddProductLocation, self).default_get(fields)
product_ids = self.env.context.get("active_ids")
if product_ids:
res["product_ids"] = product_ids
return res

@api.multi
def apply_location(self):
self.ensure_one()
products = {}
for product in self.product_ids:
products.setdefault(
product.product_tmpl_id, self.env["product.product"].browse()
)
products[product.product_tmpl_id] |= product
# Remove existing putaway locations
self.env["stock.product.putaway.strategy"].search(
[
("putaway_id", "=", self.putaway_id.id),
("product_product_id", "in", self.product_ids._ids),
]
).unlink()
for template in products:
products[template].write(
{
"product_putaway_ids": [
(
0,
0,
{
"putaway_id": self.putaway_id.id,
"product_tmpl_id": template.id,
"fixed_location_id": self.fixed_location_id.id,
},
)
]
}
)
product_names = ", ".join([x.name for x in self.product_ids])
return {
"name": _("Updated products putaway: %s" % product_names),
"type": "ir.actions.act_window",
"res_id": self.env.ref("product.product_normal_action").id,
"view_mode": "tree,form",
"res_model": "product.product",
}
46 changes: 46 additions & 0 deletions stock_putaway_product/wizard/quick_add_location.xml
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_model_form" model="ir.ui.view">
<field name="model">quick.add.product.location</field>
<field name="active" eval="True" />
<field name="arch" type="xml">
<form string="Quick Product Putaway">
<sheet>
<div>
<h2>Set default location by putaway method to products</h2>
</div>
<group>
<field name="putaway_id" widget="radio"/>
<field name="fixed_location_id"/>
</group>
<group col="1">
<separator string="Products"/>
<field name="product_ids" nolabel="1"/>
</group>
</sheet>
<footer>
<button name="apply_location" string="Apply"
type="object" class="oe_highlight"/>
<button special="cancel" string="Cancel" class="oe_link"/>
</footer>
</form>
</field>
</record>

<record id="quick_add_product_location_act_window" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="name">Add Default Stock Location</field>
<field name="res_model">quick.add.product.location</field>
<field name="src_model">product.product</field>
<field name="view_mode">form,tree</field>
<field name="target">new</field>
</record>
<record id="quick_add_product_location_values" model="ir.values">
<field eval="'client_action_multi'" name="key2"/>
<field eval="'product.product'" name="model"/>
<field name="name">Add Default Stock Location</field>
<field eval="'ir.actions.act_window,'+str(quick_add_product_location_act_window)" name="value"/>
</record>

</odoo>

0 comments on commit 8b65a84

Please sign in to comment.