mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_putaway_product_template: Migration to 13.0
[UPD] Update stock_putaway_product_template.pot [UPD] README.rst
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
=======================================
|
||||
Putaway strategies on product form view
|
||||
=======================================
|
||||
======================================
|
||||
Product template in putaway strategies
|
||||
======================================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
@@ -14,18 +14,18 @@ Putaway strategies on product form view
|
||||
: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/12.0/stock_putaway_product_form
|
||||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.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_form
|
||||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_putaway_product_template
|
||||
: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/12.0
|
||||
:target: https://runbot.odoo-community.org/runbot/153/13.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.
|
||||
This module add product template in putaway strategies from the product view to not need defined putaway strategies for all variants.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
@@ -35,9 +35,10 @@ This module adds an easy way to modify product-specific putaway strategies from
|
||||
Usage
|
||||
=====
|
||||
|
||||
* In Settings, set "Storage Locations" to True
|
||||
* In Inventory 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
|
||||
* Inside a product go to "Putaway rules"
|
||||
* It's possible to define record to template
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
@@ -45,7 +46,7 @@ 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_form%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`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.
|
||||
|
||||
@@ -67,6 +68,7 @@ Contributors
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Sergio Teruel
|
||||
* Víctor Martínez
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
@@ -92,6 +94,6 @@ 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/12.0/stock_putaway_product_form>`_ project on GitHub.
|
||||
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.
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
from . import tests
|
||||
from .hooks import post_init_hook
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Putaway strategies on product form view",
|
||||
"summary": "Edit putaway strategies directly from the product form view",
|
||||
"version": "12.0.1.0.0",
|
||||
"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"],
|
||||
"external_dependencies": {"python": ["openupgradelib"]},
|
||||
"data": ["views/product.xml"],
|
||||
"demo": ["demo/putaway_strategies.xml"],
|
||||
"data": ["views/stock_putaway_rule_views.xml"],
|
||||
"maintainers": ["kevinkhao", "sebastienbeau"],
|
||||
"post_init_hook": "post_init_hook",
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<!--Shows simplest case for categories -->
|
||||
<record id="putaway_strat_1" model="product.putaway">
|
||||
<field name="name">Putaway Strategy 1</field>
|
||||
</record>
|
||||
<record id="putaway_strat_1_line_1" model="stock.fixed.putaway.strat">
|
||||
<field name="product_id" ref="product.product_product_11" />
|
||||
<field name="putaway_id" ref="stock_putaway_product_form.putaway_strat_1" />
|
||||
<field name="fixed_location_id" ref="stock.stock_location_shop0" />
|
||||
</record>
|
||||
<record id="putaway_strat_1_line_2" model="stock.fixed.putaway.strat">
|
||||
<field name="category_id" ref="product.product_category_5" />
|
||||
<field name="putaway_id" ref="stock_putaway_product_form.putaway_strat_1" />
|
||||
<field name="fixed_location_id" ref="stock.stock_location_shop0" />
|
||||
</record>
|
||||
<!--Shows inherited case for categories-->
|
||||
<record id="putaway_strat_2" model="product.putaway">
|
||||
<field name="name">Putaway Strategy 2</field>
|
||||
</record>
|
||||
<record id="putaway_strat_2_line_1" model="stock.fixed.putaway.strat">
|
||||
<field name="category_id" ref="product.product_category_1" />
|
||||
<field name="putaway_id" ref="stock_putaway_product_form.putaway_strat_2" />
|
||||
<field name="fixed_location_id" ref="stock.stock_location_stock" />
|
||||
</record>
|
||||
<record id="putaway_strat_2_line_2" model="stock.fixed.putaway.strat">
|
||||
<field name="category_id" ref="product.product_category_all" />
|
||||
<field name="putaway_id" ref="stock_putaway_product_form.putaway_strat_2" />
|
||||
<field name="fixed_location_id" ref="stock.stock_location_stock" />
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,21 +0,0 @@
|
||||
# Copyright 2020 Tecnativa - Sergio Teruel
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
|
||||
from openupgradelib import openupgrade
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
openupgrade.logged_query(
|
||||
cr,
|
||||
"""
|
||||
UPDATE stock_fixed_putaway_strat sfps
|
||||
SET product_tmpl_id=pp.product_tmpl_id
|
||||
FROM product_product pp
|
||||
WHERE pp.id=sfps.product_id AND
|
||||
sfps.product_tmpl_id <> pp.product_tmpl_id
|
||||
""",
|
||||
)
|
||||
@@ -1,88 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * stock_putaway_product_form
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.0\n"
|
||||
"Report-Msgid-Bugs-To: \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_form
|
||||
#: model:ir.model.fields,field_description:stock_putaway_product_form.field_product_putaway__product_location_ids
|
||||
msgid "Fixed Locations Per Product"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model,name:stock_putaway_product_form.model_stock_fixed_putaway_strat
|
||||
msgid "Fixed Putaway Strategy on Location"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model_terms:ir.ui.view,arch_db:stock_putaway_product_form.view_template_form_putaway
|
||||
msgid "Keep empty product field to apply strategy to all variants."
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model,name:stock_putaway_product_form.model_product_product
|
||||
msgid "Product"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model,name:stock_putaway_product_form.model_product_template
|
||||
msgid "Product Template"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model.fields,field_description:stock_putaway_product_form.field_stock_fixed_putaway_strat__product_tmpl_id
|
||||
msgid "Product Tmpl"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model.fields,field_description:stock_putaway_product_form.field_product_product__product_putaway_categ_ids
|
||||
#: model:ir.model.fields,field_description:stock_putaway_product_form.field_product_template__product_putaway_categ_ids
|
||||
msgid "Product putaway strategies by category"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model.fields,field_description:stock_putaway_product_form.field_product_product__product_tmpl_putaway_ids
|
||||
#: model:ir.model.fields,field_description:stock_putaway_product_form.field_product_template__product_tmpl_putaway_ids
|
||||
msgid "Product putaway strategies by product"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model.fields,field_description:stock_putaway_product_form.field_product_product__product_product_putaway_ids
|
||||
msgid "Product putaway strategies by product variant"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model_terms:ir.ui.view,arch_db:stock_putaway_product_form.view_template_form_putaway
|
||||
msgid "Put Away Strategies by category"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model_terms:ir.ui.view,arch_db:stock_putaway_product_form.view_product_form_putaway
|
||||
#: model_terms:ir.ui.view,arch_db:stock_putaway_product_form.view_template_form_putaway
|
||||
msgid "Put Away Strategies by products"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model:ir.model,name:stock_putaway_product_form.model_product_putaway
|
||||
msgid "Put Away Strategy"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model_terms:ir.ui.view,arch_db:stock_putaway_product_form.view_template_form_putaway
|
||||
msgid "Putaway strategies"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_form
|
||||
#: model_terms:ir.ui.view,arch_db:stock_putaway_product_form.view_template_form_putaway
|
||||
msgid "The rules defined per product will be applied before the rules defined per product category."
|
||||
msgstr ""
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# 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"
|
||||
"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,name:stock_putaway_product_template.model_stock_location
|
||||
msgid "Inventory Locations"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_putaway_product_template
|
||||
#: model:ir.model,name:stock_putaway_product_template.model_product_template
|
||||
msgid "Product Template"
|
||||
msgstr ""
|
||||
|
||||
#. 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 ""
|
||||
@@ -1,3 +1,3 @@
|
||||
from . import product_product
|
||||
from . import product_template
|
||||
from . import putaway_strategy
|
||||
from . import product
|
||||
from . import stock_location
|
||||
from . import stock_putaway_rule
|
||||
|
||||
19
stock_putaway_product_template/models/product.py
Normal file
19
stock_putaway_product_template/models/product.py
Normal file
@@ -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)
|
||||
@@ -1,13 +0,0 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
product_product_putaway_ids = fields.One2many(
|
||||
comodel_name="stock.fixed.putaway.strat",
|
||||
inverse_name="product_id",
|
||||
string="Product putaway strategies by product variant",
|
||||
)
|
||||
@@ -1,58 +0,0 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
product_tmpl_putaway_ids = fields.One2many(
|
||||
comodel_name="stock.fixed.putaway.strat",
|
||||
inverse_name="product_tmpl_id",
|
||||
string="Product putaway strategies by product",
|
||||
)
|
||||
|
||||
product_putaway_categ_ids = fields.Many2many(
|
||||
comodel_name="stock.fixed.putaway.strat",
|
||||
string="Product putaway strategies by category",
|
||||
compute="_compute_putaway_categ_ids",
|
||||
)
|
||||
|
||||
def _find_closest_categ_match(self, categ, putaway_lines):
|
||||
"""Returns the putaway line with the nearest product category"""
|
||||
lines_match_categ = putaway_lines.filtered(lambda r: r.category_id == categ)
|
||||
if lines_match_categ:
|
||||
return lines_match_categ[0]
|
||||
elif categ.parent_id:
|
||||
return self._find_closest_categ_match(categ.parent_id, putaway_lines)
|
||||
else:
|
||||
return self.env["stock.fixed.putaway.strat"]
|
||||
|
||||
def _get_categ_and_parents(self, categ):
|
||||
parent_categ_iterator = categ
|
||||
res = self.env["product.category"]
|
||||
while parent_categ_iterator:
|
||||
res += parent_categ_iterator
|
||||
parent_categ_iterator = parent_categ_iterator.parent_id
|
||||
return res
|
||||
|
||||
@api.depends("categ_id")
|
||||
def _compute_putaway_categ_ids(self):
|
||||
"""Pay attention to keep only 1 (most specific,
|
||||
i.e closest to our product category's parents)
|
||||
putaway.strat per product.putaway"""
|
||||
for rec in self:
|
||||
res = self.env["stock.fixed.putaway.strat"]
|
||||
categ = rec.categ_id
|
||||
categs = self._get_categ_and_parents(categ)
|
||||
# get matching lines from our category or its parents
|
||||
product_putaway_categ_lines = self.env["stock.fixed.putaway.strat"].search(
|
||||
[("category_id", "in", categs.ids)]
|
||||
)
|
||||
# from these, get the matching putaway.strats and find
|
||||
# the lowest-level category match
|
||||
product_putaways = product_putaway_categ_lines.mapped("putaway_id")
|
||||
for el in product_putaways:
|
||||
lines = el.fixed_location_ids
|
||||
res += self._find_closest_categ_match(categ, lines)
|
||||
rec.product_putaway_categ_ids = res
|
||||
13
stock_putaway_product_template/models/stock_location.py
Normal file
13
stock_putaway_product_template/models/stock_location.py
Normal file
@@ -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)
|
||||
@@ -1,35 +1,25 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
# Copyright 2020 Sergio Teruel - Tecnativa <sergio.teruel@tecnativa.com>
|
||||
# Copyright 2020 Sergio Teruel - Tecnativa
|
||||
# Copyright 2020 Víctor Martínez - Tecnativa
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class PutAwayStrategy(models.Model):
|
||||
_inherit = "product.putaway"
|
||||
|
||||
# Remove product domain to allow to select product templates
|
||||
product_location_ids = fields.One2many(domain=[])
|
||||
|
||||
def _get_putaway_rule(self, product):
|
||||
return super(
|
||||
PutAwayStrategy, self.with_context(filter_putaway_rule=True)
|
||||
)._get_putaway_rule(product)
|
||||
|
||||
|
||||
class FixedPutAwayStrategy(models.Model):
|
||||
_inherit = "stock.fixed.putaway.strat"
|
||||
class StockPutawayRule(models.Model):
|
||||
_inherit = "stock.putaway.rule"
|
||||
|
||||
product_tmpl_id = fields.Many2one(
|
||||
comodel_name="product.template",
|
||||
compute="_compute_product_tmpl_id",
|
||||
store=True,
|
||||
inverse=lambda self: self,
|
||||
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:
|
||||
@@ -38,7 +28,7 @@ class FixedPutAwayStrategy(models.Model):
|
||||
rec.product_tmpl_id = params.get("id", False)
|
||||
|
||||
def filtered(self, func):
|
||||
res = super(FixedPutAwayStrategy, self).filtered(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
|
||||
@@ -5,3 +5,4 @@
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Sergio Teruel
|
||||
* Víctor Martínez
|
||||
|
||||
@@ -1 +1 @@
|
||||
This module adds an easy way to modify product-specific putaway strategies from the product view for a better UX.
|
||||
This module add product template in putaway strategies from the product view to not need defined putaway strategies for all variants.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
* In Settings, set "Storage Locations" to True
|
||||
* In Inventory 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
|
||||
* Inside a product go to "Putaway rules"
|
||||
* It's possible to define record to template
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<title>Putaway strategies on product form view</title>
|
||||
<title>Product template in putaway strategies</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
@@ -360,15 +360,15 @@ ul.auto-toc {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="putaway-strategies-on-product-form-view">
|
||||
<h1 class="title">Putaway strategies on product form view</h1>
|
||||
<div class="document" id="product-template-in-putaway-strategies">
|
||||
<h1 class="title">Product template in putaway strategies</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_putaway_product_form"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_putaway_product_form"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module adds an easy way to modify product-specific putaway strategies from the product view for a better UX.</p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_putaway_product_template"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_putaway_product_template"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module add product template in putaway strategies from the product view to not need defined putaway strategies for all variants.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
@@ -385,9 +385,10 @@ ul.auto-toc {
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
|
||||
<ul class="simple">
|
||||
<li>In Settings, set “Storage Locations” to True</li>
|
||||
<li>In Inventory Settings, set “Storage Locations” to True</li>
|
||||
<li>User should be in “Manage push and pull inventory flows”</li>
|
||||
<li>Open the form view of a product template or a product and use the fields located under the “Inventory” tab</li>
|
||||
<li>Inside a product go to “Putaway rules”</li>
|
||||
<li>It’s possible to define record to template</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
@@ -395,7 +396,7 @@ ul.auto-toc {
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
|
||||
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
|
||||
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_putaway_product_form%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="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**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -415,6 +416,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
</li>
|
||||
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||
<li>Sergio Teruel</li>
|
||||
<li>Víctor Martínez</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -428,7 +430,7 @@ mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
|
||||
<p><a class="reference external" href="https://github.com/kevinkhao"><img alt="kevinkhao" src="https://github.com/kevinkhao.png?size=40px" /></a> <a class="reference external" href="https://github.com/sebastienbeau"><img alt="sebastienbeau" src="https://github.com/sebastienbeau.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_putaway_product_form">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_putaway_product_template">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_product_putaway
|
||||
from . import test_stock_putaway_rule
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestProductPutaway(TransactionCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.putawayObj = self.env["product.putaway"]
|
||||
self.putawayLineObj = self.env["stock.fixed.putaway.strat"]
|
||||
ProductTemplate = self.env["product.template"]
|
||||
ProductAttribute = self.env["product.attribute"]
|
||||
ProductAttributeValue = self.env["product.attribute.value"]
|
||||
TemplateAttributeLine = self.env["product.template.attribute.line"]
|
||||
ref = self.env.ref
|
||||
self.product_tmpl_chair = ref("product.product_product_11_product_template")
|
||||
self.product_product_chair = ref("product.product_product_11")
|
||||
self.category_services = ref("product.product_category_3")
|
||||
self.putaway_line_1 = ref("stock_putaway_product_form.putaway_strat_1_line_1")
|
||||
self.putaway_line_2 = ref("stock_putaway_product_form.putaway_strat_1_line_2")
|
||||
self.putaway_line_3 = ref("stock_putaway_product_form.putaway_strat_2_line_1")
|
||||
self.putaway_line_4 = ref("stock_putaway_product_form.putaway_strat_2_line_2")
|
||||
|
||||
# Add a product with variants
|
||||
self.template = ProductTemplate.create(
|
||||
{"name": "Product test", "type": "consu"}
|
||||
)
|
||||
self.size_attribute = ProductAttribute.create(
|
||||
{"name": "Test size", "sequence": 1}
|
||||
)
|
||||
self.size_m = ProductAttributeValue.create(
|
||||
{"name": "Size M", "attribute_id": self.size_attribute.id, "sequence": 1}
|
||||
)
|
||||
self.size_l = ProductAttributeValue.create(
|
||||
{"name": "Size L", "attribute_id": self.size_attribute.id, "sequence": 2}
|
||||
)
|
||||
self.template_attribute_lines = TemplateAttributeLine.create(
|
||||
{
|
||||
"product_tmpl_id": self.template.id,
|
||||
"attribute_id": self.size_attribute.id,
|
||||
"value_ids": [(6, 0, [self.size_m.id, self.size_l.id])],
|
||||
}
|
||||
)
|
||||
self.template.create_variant_ids()
|
||||
|
||||
def test_tmpl_has_putaways_from_products(self):
|
||||
self.assertIn(
|
||||
self.putaway_line_1, self.product_tmpl_chair.product_tmpl_putaway_ids,
|
||||
)
|
||||
self.putaway_line_1.product_id = self.env["product.product"]
|
||||
self.assertNotIn(
|
||||
self.putaway_line_1, self.product_tmpl_chair.product_tmpl_putaway_ids,
|
||||
)
|
||||
|
||||
def test_tmpl_has_putaways_from_category_simple(self):
|
||||
self.assertIn(
|
||||
self.putaway_line_2, self.product_tmpl_chair.product_putaway_categ_ids,
|
||||
)
|
||||
self.product_tmpl_chair.categ_id = self.category_services
|
||||
self.assertNotIn(
|
||||
self.putaway_line_2, self.product_tmpl_chair.product_putaway_categ_ids,
|
||||
)
|
||||
|
||||
def test_tmpl_has_putaways_from_category_parent(self):
|
||||
# chair is under category: all/saleable/office
|
||||
self.assertIn(
|
||||
self.putaway_line_3, self.product_tmpl_chair.product_putaway_categ_ids,
|
||||
)
|
||||
self.assertNotIn(
|
||||
self.putaway_line_4, self.product_tmpl_chair.product_putaway_categ_ids,
|
||||
)
|
||||
|
||||
def test_apply_putaway(self):
|
||||
# Create one strategy line for product template and other with a
|
||||
# specific variant
|
||||
location = self.env.ref("stock.stock_location_shop0")
|
||||
location1 = location.copy(
|
||||
{"name": "Location test 1", "location_id": location.id}
|
||||
)
|
||||
location2 = location.copy(
|
||||
{"name": "Location test 2", "location_id": location.id}
|
||||
)
|
||||
variant1 = self.template.product_variant_ids[0]
|
||||
variant2 = self.template.product_variant_ids[1]
|
||||
putaway = self.putawayObj.create({"name": "Putaway for test"})
|
||||
val_list = [
|
||||
{
|
||||
"putaway_id": putaway.id,
|
||||
"product_tmpl_id": self.template.id,
|
||||
"fixed_location_id": location1.id,
|
||||
},
|
||||
{
|
||||
"putaway_id": putaway.id,
|
||||
"product_id": variant2.id,
|
||||
"fixed_location_id": location2.id,
|
||||
},
|
||||
]
|
||||
self.putawayLineObj.create(val_list)
|
||||
location_applied = putaway._get_putaway_rule(variant1).fixed_location_id
|
||||
self.assertEqual(location_applied, location1)
|
||||
location_applied = putaway._get_putaway_rule(variant2).fixed_location_id
|
||||
self.assertEqual(location_applied, location2)
|
||||
110
stock_putaway_product_template/tests/test_stock_putaway_rule.py
Normal file
110
stock_putaway_product_template/tests/test_stock_putaway_rule.py
Normal file
@@ -0,0 +1,110 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
# Copyright 2020 Tecnativa - Sergio Teruel
|
||||
# Copyright 2020-2021 Víctor Martínez - Tecnativa
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestStockPutawayRule(common.SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.putawayRuleObj = cls.env["stock.putaway.rule"]
|
||||
ProductTemplate = cls.env["product.template"]
|
||||
ProductAttribute = cls.env["product.attribute"]
|
||||
ProductAttributeValue = cls.env["product.attribute.value"]
|
||||
TemplateAttributeLine = cls.env["product.template.attribute.line"]
|
||||
# Add a product with variants
|
||||
cls.template = ProductTemplate.create({"name": "Product test", "type": "consu"})
|
||||
cls.size_attribute = ProductAttribute.create(
|
||||
{"name": "Test size", "sequence": 1}
|
||||
)
|
||||
cls.size_m = ProductAttributeValue.create(
|
||||
{"name": "Size M", "attribute_id": cls.size_attribute.id, "sequence": 1}
|
||||
)
|
||||
cls.size_l = ProductAttributeValue.create(
|
||||
{"name": "Size L", "attribute_id": cls.size_attribute.id, "sequence": 2}
|
||||
)
|
||||
cls.size_xl = ProductAttributeValue.create(
|
||||
{"name": "Size XL", "attribute_id": cls.size_attribute.id, "sequence": 3}
|
||||
)
|
||||
cls.template_attribute_lines = TemplateAttributeLine.create(
|
||||
{
|
||||
"product_tmpl_id": cls.template.id,
|
||||
"attribute_id": cls.size_attribute.id,
|
||||
"value_ids": [(6, 0, [cls.size_m.id, cls.size_l.id, cls.size_xl.id])],
|
||||
}
|
||||
)
|
||||
cls.template._create_variant_ids()
|
||||
cls.view_id = cls.env.ref("stock.stock_putaway_list").id
|
||||
|
||||
def _stock_putaway_rule_product(self, location, product):
|
||||
rule = self.putawayRuleObj.create(
|
||||
{
|
||||
"company_id": location.company_id.id,
|
||||
"product_id": product.id,
|
||||
"location_in_id": location.id,
|
||||
"location_out_id": location.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(rule.location_in_id, location)
|
||||
self.assertEqual(rule.product_tmpl_id, product.product_tmpl_id)
|
||||
self.assertEqual(rule.product_id, product)
|
||||
return rule
|
||||
|
||||
def _get_product_rules(self, product):
|
||||
return self.putawayRuleObj.search(
|
||||
product.action_view_related_putaway_rules()["domain"]
|
||||
)
|
||||
|
||||
def test_apply_putaway(self):
|
||||
# Create one strategy line for product template and other with a
|
||||
# specific variant
|
||||
location = self.env.ref("stock.stock_location_shop0")
|
||||
location1 = location.copy(
|
||||
{"name": "Location test 1", "location_id": location.id}
|
||||
)
|
||||
location2 = location.copy(
|
||||
{"name": "Location test 2", "location_id": location.id}
|
||||
)
|
||||
# Create rule according to product_tmpl_id
|
||||
rule_product = self.putawayRuleObj.create(
|
||||
{
|
||||
"company_id": location1.company_id.id,
|
||||
"product_tmpl_id": self.template.id,
|
||||
"location_in_id": location1.id,
|
||||
"location_out_id": location1.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(rule_product.location_in_id, location1)
|
||||
self.assertEqual(rule_product.product_tmpl_id, self.template)
|
||||
self.assertEqual(rule_product.product_id.id, False)
|
||||
# Create rules related to variants and diferente locations
|
||||
variant1 = self.template.product_variant_ids[0]
|
||||
variant2 = self.template.product_variant_ids[1]
|
||||
variant3 = self.template.product_variant_ids[2]
|
||||
self._stock_putaway_rule_product(location1, variant1)
|
||||
self._stock_putaway_rule_product(location2, variant2)
|
||||
# Create rule according to category
|
||||
rule_category = self.putawayRuleObj.create(
|
||||
{
|
||||
"company_id": location1.company_id.id,
|
||||
"category_id": self.template.categ_id.id,
|
||||
"location_in_id": location1.id,
|
||||
"location_out_id": location1.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(rule_category.category_id, self.template.categ_id)
|
||||
self.assertEqual(rule_category.location_in_id, location1)
|
||||
self.assertEqual(rule_category.product_tmpl_id.id, False)
|
||||
self.assertEqual(rule_category.product_id.id, False)
|
||||
# Check rules related
|
||||
self.assertEqual(len(self._get_product_rules(self.template)), 4)
|
||||
self.assertEqual(len(self._get_product_rules(variant1)), 2)
|
||||
self.assertEqual(len(self._get_product_rules(variant2)), 2)
|
||||
self.assertEqual(len(self._get_product_rules(variant3)), 1)
|
||||
# Check _get_putaway_strategy
|
||||
locations = location + location.child_ids
|
||||
self.assertEqual(locations._get_putaway_strategy(variant1), location1)
|
||||
self.assertEqual(locations._get_putaway_strategy(variant2), location2)
|
||||
self.assertEqual(locations._get_putaway_strategy(variant3), location1)
|
||||
@@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). -->
|
||||
<odoo>
|
||||
<record id="view_template_form_putaway" model="ir.ui.view">
|
||||
<field name="name">product.template.product.form</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_form_view" />
|
||||
<field name="groups_id" eval="[(4,ref('stock.group_stock_manager'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='inventory']" position="inside">
|
||||
<div
|
||||
name="putaway"
|
||||
groups="stock.group_adv_location"
|
||||
string="Putaway strategies"
|
||||
>
|
||||
<field name="product_variant_ids" invisible="1" />
|
||||
<group
|
||||
name="putaway_products"
|
||||
string="Put Away Strategies by products"
|
||||
attrs="{'invisible': [('is_product_variant', '=', True)]}"
|
||||
>
|
||||
<group>
|
||||
<p class="oe_grey">
|
||||
The rules defined per product will be applied before the rules defined per product category.
|
||||
<div
|
||||
>Keep empty product field to apply strategy to all variants.</div>
|
||||
</p>
|
||||
</group>
|
||||
<field name="product_tmpl_putaway_ids" nolabel="1">
|
||||
<tree editable="top">
|
||||
<field
|
||||
name="product_id"
|
||||
domain="[('product_tmpl_id', '=', parent.id)]"
|
||||
/>
|
||||
<field name="putaway_id" />
|
||||
<field name="fixed_location_id" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group
|
||||
name="putaway_categ"
|
||||
string="Put Away Strategies by category"
|
||||
attrs="{'readonly': 1}"
|
||||
>
|
||||
<field name="product_putaway_categ_ids" nolabel="1">
|
||||
<tree>
|
||||
<field name="category_id" />
|
||||
<field name="putaway_id" widget="selection" />
|
||||
<field name="fixed_location_id" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_product_form_putaway" model="ir.ui.view">
|
||||
<field name="name">product.product.form.putaway</field>
|
||||
<field name="model">product.product</field>
|
||||
<field name="inherit_id" ref="product.product_normal_form_view" />
|
||||
<field name="groups_id" eval="[(4,ref('stock.group_stock_manager'))]" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='putaway_categ']" position="before">
|
||||
<group
|
||||
name="putaway_products"
|
||||
string="Put Away Strategies by products"
|
||||
attrs="{'invisible': [('is_product_variant', '=', False)]}"
|
||||
>
|
||||
<field
|
||||
name="product_product_putaway_ids"
|
||||
groups="stock.group_adv_location"
|
||||
nolabel="1"
|
||||
>
|
||||
<tree editable="bottom">
|
||||
<field name="putaway_id" />
|
||||
<field name="fixed_location_id" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). -->
|
||||
<odoo>
|
||||
<record id="stock_putaway_list" model="ir.ui.view">
|
||||
<field name="name">Add product_tmpl_id field</field>
|
||||
<field name="model">stock.putaway.rule</field>
|
||||
<field name="inherit_id" ref="stock.stock_putaway_list" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="attributes">
|
||||
<attribute name="readonly">False</attribute>
|
||||
<attribute
|
||||
name="attrs"
|
||||
>{'readonly': [('category_id', '!=', False)], 'required': [('category_id', '=', False),('product_tmpl_id', '=', False)]}</attribute>
|
||||
</field>
|
||||
<field name="category_id" position="attributes">
|
||||
<attribute name="readonly">False</attribute>
|
||||
<attribute
|
||||
name="attrs"
|
||||
>{'readonly': ['|', ('product_id', '!=', False), ('product_tmpl_id', '!=', False)], 'required': [('product_id', '=', False),('product_tmpl_id', '=', False)]}</attribute>
|
||||
</field>
|
||||
<field name="product_id" position="before">
|
||||
<field
|
||||
name="product_tmpl_id"
|
||||
attrs="{'readonly': [('category_id', '!=', False)], 'required': [('category_id', '=', False)]}"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
force_save="1"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user