Skip to content

Commit

Permalink
[IMP] stock_orderpoint_generator: Add Automatic Reordering Rules (OCA…
Browse files Browse the repository at this point in the history
…#258)

And improve the wording

* Add an option to automatically generate rules

When a product variant is created with a (or several) rule template(s), it
automatically generates (on the fly) the corresponding rule(s). When a rule template
is modified, it automatically updates the existing rules of the linked
products (it uses the mechanism in place, disable the old and create a
fresh one). The latter update is done by a cron because it might take a
long time to update all the products reordering rules.

* Add documentation

* Copy orderpoint views to orderpoint templates

Unfortunately we cannot rely on the possibility to copy a view with
"inherit_id" + "mode=primary" in Odoo 9.0 in this use case (precisely
with a model that is a "copy by prototype").

The explanation:

We "copy by prototype" the model "stock.warehouse.orderpoint" to a new
"stock.warehouse.orderpoint.template" model (with both _inherit and
different _name). Before this commit, we were reusing the
stock.warehouse.orderpoint's views, just making the changes needed for
the templates. Thing is: when a third (unrelated) addon adds a column on
the model, the ORM doesn't add the column in the
stock.warehouse.orderpoint.template model. So the templates' views
complains about this unexisting field.

Therefore, copy-pasting the view ensure that changes on
'stock.warehouse.orderpoint' does not have any side effect on the
templates.

From Odoo 10.0, the "copy by prototype" reports the changes made on the
"prototype" model to the "copy" so we should be able to revert to the
"inherit_id" + "mode=primary" views.
  • Loading branch information
guewen authored and chienandalu committed Feb 1, 2023
1 parent 08d3b93 commit dd3d04b
Show file tree
Hide file tree
Showing 75 changed files with 7,419 additions and 812 deletions.
37 changes: 36 additions & 1 deletion stock_orderpoint_generator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,40 @@
Order point generator
=====================

Add a wizard to configure order points for multiple products in one go.
Add a wizard to configure reordering rules for multiple products in one go,
and allow to automatically update reordering rules from rule templates.

Configuration
=============

Reordering rule templates can be configured in "Inventory > Configuration >
Products > Reordering Rule Templates".

The frequency of the cron that updates the Reordering Rules can be configured
in "Settings > Technical > Actions > Scheduled Actions". The name of the
scheduled action is "Reordering Rule Templates Generator".

Usage
=====

By activating the "Create Rules Automatically" on a reordering rule template,
you are able to select a list of products. Any change on the template will then
be replicated on the products Reordering Rules. The change is not immediate as
it is processed by a scheduled action.

On a product, you can also choose one or more Reordering Rule Templates. Any
template added or removed on the product is immediately reflected on its
Reordering Rules.

Lastly, you can promptly create Reordering Rules for a product or a product
template using the "Reordering Rules Generator". Note that it will replace all
the existing rules for the product. You will usually not want to use this
feature on products that have Automatic Reordering Rules Templates.


.. 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


Bug Tracker
Expand All @@ -22,9 +55,11 @@ Credits

Contributors
------------

* Yannick Vaucher <[email protected]>
* Matthieu Dietrich <[email protected]>
* Cyril Gaudin <[email protected]>
* Guewen Baconnier <[email protected]>

Maintainer
----------
Expand Down
5 changes: 4 additions & 1 deletion stock_orderpoint_generator/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
{
'name': 'Order point generator',
'summary': 'Mass configuration of stock order points',
'version': '9.0.1.0.0',
'version': '9.0.1.1.0',
'author': "Camptocamp, Odoo Community Association (OCA)",
'category': 'Warehouse',
'license': 'AGPL-3',
'website': "http://www.camptocamp.com",
'depends': ['stock'],
'data': [
'views/orderpoint_template_views.xml',
'views/product_views.xml',
"wizard/orderpoint_generator_view.xml",
"data/ir_cron.xml",
"security/ir.model.access.csv",
],
'installable': True,
Expand Down
16 changes: 16 additions & 0 deletions stock_orderpoint_generator/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">

<record id="ir_cron_auto_orderpoint_template" model="ir.cron">
<field name="name">Reordering Rule Templates Generator</field>
<field name="interval_number">1</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'stock.warehouse.orderpoint.template'" name="model"/>
<field eval="'_cron_create_auto_orderpoints'" name="function"/>
<field eval="'()'" name="args"/>
<field name="active" eval="True" />
</record>

</odoo>
122 changes: 110 additions & 12 deletions stock_orderpoint_generator/i18n/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ msgid ""
msgstr ""
"Project-Id-Version: stock-logistics-warehouse (9.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-21 18:42+0000\n"
"PO-Revision-Date: 2016-10-22 16:43+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2017-05-31 02:38+0000\n"
"PO-Revision-Date: 2017-05-29 20:54+0000\n"
"Last-Translator: OCA Transbot <[email protected]>\n"
"Language-Team: Arabic (http://www.transifex.com/oca/OCA-stock-logistics-warehouse-9-0/language/ar/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: ar\n"
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"

#. module: stock_orderpoint_generator
#: model:ir.model.fields,help:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_auto_product_ids
msgid ""
"A reordering rule will be automatically created by the scheduled action for "
"every product in this list."
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_active
msgid "Active"
Expand All @@ -27,6 +34,17 @@ msgstr "نشِط"
msgid "Apply"
msgstr "تطبيق"

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_product_product_auto_orderpoint_template_ids
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.product_normal_form_view
msgid "Automatic Reordering Rules"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_form
msgid "Automatic Rules"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.orderpoint_generator_view
msgid "Cancel"
Expand All @@ -38,11 +56,21 @@ msgstr "إلغاء"
msgid "Cannot apply because some of selected products has multiple variants."
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.actions.act_window,help:stock_orderpoint_generator.action_orderpoint_template
msgid "Click to add a reordering rule template."
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_company_id
msgid "Company"
msgstr "الشركة"

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_auto_generate
msgid "Create Rules Automatically"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_procurement_ids
msgid "Created Procurements"
Expand Down Expand Up @@ -76,6 +104,16 @@ msgstr ""
msgid "Display Name"
msgstr "اسم العرض"

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_form
msgid "Generate Automatic Rules"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_search
msgid "Group By"
msgstr "تجميع حسب"

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_generator_id
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_id
Expand All @@ -89,6 +127,11 @@ msgid ""
"orderpoint without removing it."
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_auto_last_generation
msgid "Last Automatic Generation"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_generator___last_update
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template___last_update
Expand Down Expand Up @@ -119,6 +162,7 @@ msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_location_id
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_search
msgid "Location"
msgstr ""

Expand All @@ -128,13 +172,13 @@ msgid "Maximum Quantity"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model,name:stock_orderpoint_generator.model_stock_warehouse_orderpoint_template
msgid "Minimum Inventory Rule"
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_product_min_qty
msgid "Minimum Quantity"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_product_min_qty
msgid "Minimum Quantity"
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_form
msgid "Misc"
msgstr ""

#. module: stock_orderpoint_generator
Expand Down Expand Up @@ -168,6 +212,7 @@ msgid "Procurement Group"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model,name:stock_orderpoint_generator.model_product_product
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_product_id
msgid "Product"
msgstr ""
Expand All @@ -178,10 +223,8 @@ msgid "Product Unit of Measure"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.actions.act_window,name:stock_orderpoint_generator.act_create_product_conf
#: model:ir.actions.act_window,name:stock_orderpoint_generator.act_create_product_template_conf
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.orderpoint_generator_view
msgid "Product warehouse config"
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_auto_product_ids
msgid "Products"
msgstr ""

#. module: stock_orderpoint_generator
Expand All @@ -190,8 +233,47 @@ msgid "Qty Multiple"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_form
msgid "Quantity Multiple"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_form
msgid "Reordering Rule Template"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.actions.act_window,name:stock_orderpoint_generator.action_orderpoint_template
#: model:ir.model,name:stock_orderpoint_generator.model_stock_warehouse_orderpoint_template
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_generator_orderpoint_template_id
msgid "Stock rule template"
#: model:ir.ui.menu,name:stock_orderpoint_generator.menu_orderpoint_template
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_search
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_tree
msgid "Reordering Rule Templates"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_search
msgid "Reordering Rule Templates Search"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.actions.act_window,name:stock_orderpoint_generator.act_create_product_conf
#: model:ir.actions.act_window,name:stock_orderpoint_generator.act_create_product_template_conf
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.orderpoint_generator_view
msgid "Reordering Rules Generator"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_form
msgid ""
"Reordering rules will be created for the selected products. This is "
"equivalent to the Scheduled Action action."
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_form
msgid "Rules"
msgstr ""

#. module: stock_orderpoint_generator
Expand All @@ -213,9 +295,25 @@ msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,field_description:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_warehouse_id
#: model:ir.ui.view,arch_db:stock_orderpoint_generator.view_warehouse_orderpoint_template_search
msgid "Warehouse"
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,help:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_auto_generate
msgid ""
"When checked, the 'Reordering Rule Templates Generator' scheduled action "
"will automatically update the rules of a selection of products."
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,help:stock_orderpoint_generator.field_product_product_auto_orderpoint_template_ids
msgid ""
"When one or several automatic reordering rule is selected, a Scheduled "
"Action will automatically generate or update the reordering rules of the "
"product."
msgstr ""

#. module: stock_orderpoint_generator
#: model:ir.model.fields,help:stock_orderpoint_generator.field_stock_warehouse_orderpoint_template_product_min_qty
msgid ""
Expand Down
Loading

0 comments on commit dd3d04b

Please sign in to comment.