Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] stock_putaway_product_template: Migration to 13.0 #1001

Merged
merged 7 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/stock_putaway_product_template/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
97 changes: 97 additions & 0 deletions stock_putaway_product_template/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
=======================================
Putaway strategies on product form view
=======================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/1.0/stock_putaway_product_template
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_putaway_product_template
victoralmau marked this conversation as resolved.
Show resolved Hide resolved
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/1.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds an easy way to modify product-specific putaway strategies from the product view for a better UX.
victoralmau marked this conversation as resolved.
Show resolved Hide resolved

**Table of contents**

.. contents::
:local:

Usage
=====

* In Settings, set "Storage Locations" to True
* User should be in "Manage push and pull inventory flows"
* Open the form view of a product template or a product and use the fields located under the "Inventory" tab
victoralmau marked this conversation as resolved.
Show resolved Hide resolved

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <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, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_putaway_product_template%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* `Akretion <https://www.akretion.com>`_:

* Kevin Khao <kevin.khao@akretion.com>

* `Tecnativa <https://www.tecnativa.com>`_:

* Sergio Teruel

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-kevinkhao| image:: https://github.com/kevinkhao.png?size=40px
:target: https://github.com/kevinkhao
:alt: kevinkhao
.. |maintainer-sebastienbeau| image:: https://github.com/sebastienbeau.png?size=40px
:target: https://github.com/sebastienbeau
:alt: sebastienbeau

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-kevinkhao| |maintainer-sebastienbeau|

This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_putaway_product_template>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions stock_putaway_product_template/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
13 changes: 13 additions & 0 deletions stock_putaway_product_template/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Product template in putaway strategies",
"summary": "Add product template in putaway strategies from the product view",
"version": "13.0.1.0.0",
"category": "Inventory",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "Akretion, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["stock"],
"data": ["views/stock_putaway_rule_views.xml"],
"maintainers": ["kevinkhao", "sebastienbeau"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_putaway_product_template
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-10 15:21+0000\n"
"PO-Revision-Date: 2021-02-10 15:21+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_putaway_product_template
#: model:ir.model.fields,field_description:stock_putaway_product_template.field_stock_putaway_rule__product_tmpl_id
msgid "Product Tmpl"
msgstr ""

#. module: stock_putaway_product_template
#: model:ir.model,name:stock_putaway_product_template.model_stock_putaway_rule
msgid "Putaway Rule"
msgstr ""
3 changes: 3 additions & 0 deletions stock_putaway_product_template/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import product
from . import stock_location
from . import stock_putaway_rule
19 changes: 19 additions & 0 deletions stock_putaway_product_template/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2021 Tecnativa - Víctor Martínez

from odoo import models


class ProductTemplate(models.Model):
_inherit = "product.template"

def action_view_related_putaway_rules(self):
self.ensure_one()
domain = [
"|",
"|",
("product_tmpl_id", "=", self.id),
("category_id", "=", self.categ_id.id),
("product_id.product_tmpl_id", "=", self.id),
]
return self._get_action_view_related_putaway_rules(domain)
13 changes: 13 additions & 0 deletions stock_putaway_product_template/models/stock_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2020 Tecnativa - Sergio Teruel

from odoo import models


class StockLocation(models.Model):
_inherit = "stock.location"

def _get_putaway_strategy(self, product):
return super(
StockLocation, self.with_context(filter_putaway_rule=True)
)._get_putaway_strategy(product)
41 changes: 41 additions & 0 deletions stock_putaway_product_template/models/stock_putaway_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Copyright 2020 Sergio Teruel - Tecnativa
# Copyright 2020 Víctor Martínez - Tecnativa

from odoo import api, fields, models


class StockPutawayRule(models.Model):
_inherit = "stock.putaway.rule"

product_tmpl_id = fields.Many2one(
comodel_name="product.template",
compute="_compute_product_tmpl_id",
store=True,
readonly=False,
ondelete="cascade",
)

@api.depends("product_id")
def _compute_product_tmpl_id(self):
for rec in self:
rec.product_tmpl_id = False
if rec.product_id:
rec.product_tmpl_id = rec.product_id.product_tmpl_id
else:
params = self.env.context.get("params", {})
if params.get("model", "") == "product.template":
rec.product_tmpl_id = params.get("id", False)

def filtered(self, func):
res = super(StockPutawayRule, self).filtered(func)
if res or not self.env.context.get("filter_putaway_rule"):
return res
product = func.__closure__[0].cell_contents
if product._name != "product.product":
return res
return self.with_context(filter_putaway_rule=False).filtered(
lambda x: (
x.product_tmpl_id == product.product_tmpl_id and not x.product_id
)
)
8 changes: 8 additions & 0 deletions stock_putaway_product_template/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* `Akretion <https://www.akretion.com>`_:

* Kevin Khao <kevin.khao@akretion.com>

* `Tecnativa <https://www.tecnativa.com>`_:

* Sergio Teruel
* Víctor Martínez
1 change: 1 addition & 0 deletions stock_putaway_product_template/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module add product template in putaway strategies from the product view to not need defined putaway strategies for all variants.
4 changes: 4 additions & 0 deletions stock_putaway_product_template/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* In Inventory Settings, set "Storage Locations" to True
* User should be in "Manage push and pull inventory flows"
* Inside a product go to "Putaway rules"
* It's possible to define record to template
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.