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

[17.0][MIG] stock_orderpoint_generator #2049

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fbbf85e
stock_orderpoint_generator: Migration V9
Jun 6, 2016
ac2266e
[IMP] stock_orderpoint_generator: Add Automatic Reordering Rules (#258)
guewen May 29, 2017
225177c
[FIX] stock_orderpoint_generator (fields don't exist)
MiquelRForgeFlow Jul 19, 2017
b797659
[FIX] stock_orderpoint_generator: fix a bug when iterate the data wit…
nicomacr Aug 27, 2018
1f8b838
[MIG] stock_orderpoint_generator: Migration to 11.0
cubells Sep 27, 2018
2369aa4
[FIX] Fix singleton
Oct 18, 2019
53598f9
[IMP] stock_orderpoint_generator: auto values
chienandalu Nov 20, 2019
936bda3
[MIG] stock_orderpoint_generator: Migration to 12.0
chienandalu Dec 16, 2019
4db0f87
Translated using Weblate (Slovenian)
sysadminmatmoz Aug 11, 2020
63319b7
[IMP] stock_orderpoint_generator: black, isort, prettier
victoralmau Oct 27, 2020
aa47801
[MIG] stock_orderpoint_generator: Migration to 13.0
victoralmau Oct 27, 2020
869a023
[FIX] stock_orderpoint_generator: stock history initial value
chienandalu Feb 23, 2021
f4c8b29
[IMP] stock_orderpoint_generator: delivered items options
chienandalu Mar 30, 2021
8381778
[IMP] stock_orderpoint_generator: black, isort, prettier
chienandalu Feb 1, 2023
2e622ac
[MIG] stock_orderpoint_generator: Migration to 15.0
chienandalu Feb 1, 2023
178b629
[UPD] Update stock_orderpoint_generator.pot
Apr 14, 2023
9a00870
[UPD] README.rst
OCA-git-bot Apr 14, 2023
94823fa
Translated using Weblate (Italian)
mymage Apr 15, 2023
747a00e
Translated using Weblate (Italian)
mymage May 24, 2023
d0b8f63
Translated using Weblate (Italian)
francesco-ooops May 24, 2023
cbcba2b
[FIX] stock_orderpoint_generator: disable computes
chienandalu Jun 21, 2023
ea580a7
[UPD] Update stock_orderpoint_generator.pot
Jun 21, 2023
cc34a6a
stock_orderpoint_generator 15.0.1.0.1
OCA-git-bot Jun 21, 2023
621767f
Update translation files
weblate Jun 21, 2023
e376a97
[FIX] stock_orderpoint_generator: fix test test_errors
pilarvargas-tecnativa Jul 10, 2023
ca385cb
stock_orderpoint_generator 15.0.1.0.2
OCA-git-bot Jul 10, 2023
4a6a6b6
Translated using Weblate (Italian)
francesco-ooops Jul 12, 2023
624877a
Translated using Weblate (Spanish)
Ivorra78 Jul 26, 2023
074b5fd
[UPD] README.rst
OCA-git-bot Sep 3, 2023
2d0fe7f
Update translation files
weblate Oct 9, 2023
89c65a5
[MIG] stock_orderpoint_generator: pre-commit
astirpe May 24, 2024
c205047
[MIG] stock_orderpoint_generator: migrate to V17
astirpe May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stock_orderpoint_generator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ Contributors
- David Vidal
- Víctor Martínez

- `360ERP <https://www.360erp.com>`__:

- Andrea Stirpe

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion stock_orderpoint_generator/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Order point generator",
"summary": "Mass configuration of stock order points",
"version": "15.0.1.0.2",
"version": "17.0.1.0.0",
"author": "Camptocamp, Tecnativa, Odoo Community Association (OCA)",
"category": "Warehouse",
"license": "AGPL-3",
Expand Down
14 changes: 14 additions & 0 deletions stock_orderpoint_generator/models/orderpoint_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ class OrderpointTemplate(models.Model):
qty_forecast = fields.Float(compute=False, store=False)
product_category_id = fields.Many2one(related=False, store=False)

allowed_warehouse_ids = fields.One2many(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astirpe Could you put those changes that are enhancement in a separate commit in order to be able to backport them (and separate from real migration) ? Thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rousseldenis They are part of the real migration, not enhancement. Odoo would raise an error without this part. I think this should be backported as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why a separate commit is more convenient

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I get your point. When backporting from V17 to V16, other parts of the code should be changed, like the qty_done and the views, but not this part that could be kept as it is.

comodel_name="stock.warehouse", compute="_compute_allowed_warehouse_ids"
)

@api.depends("company_id")
def _compute_allowed_warehouse_ids(self):
for template in self:
domain = [
"|",
("company_id", "=", False),
("company_id", "=", template.company_id.id),
]
template.allowed_warehouse_ids = self.env["stock.warehouse"].search(domain)

def _template_fields_to_discard(self):
"""In order to create every orderpoint we should pop this template
customization fields"""
Expand Down
16 changes: 8 additions & 8 deletions stock_orderpoint_generator/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class ProductProduct(models.Model):
"the reordering rules of the product.",
)

@api.model
def create(self, vals):
record = super().create(vals)
if vals.get("auto_orderpoint_template_ids"):
record.auto_orderpoint_template_ids.create_orderpoints(record)
return record
@api.model_create_multi
def create(self, vals_list):
products = super().create(vals_list)
for product in products.filtered(lambda pp: pp.auto_orderpoint_template_ids):
product.auto_orderpoint_template_ids.create_orderpoints(product)
return products

def write(self, vals):
result = super().write(vals)
Expand Down Expand Up @@ -118,9 +118,9 @@ def _get_delivered_to_customer_dict(
if to_date:
domain += [("date", "<=", to_date)]
move_lines = self.env["stock.move.line"].read_group(
domain, ["product_id", "qty_done"], ["product_id"]
domain, ["product_id", "quantity"], ["product_id"]
)
return {p["product_id"][0]: p["qty_done"] for p in move_lines}
return {p["product_id"][0]: p["quantity"] for p in move_lines}

def _compute_historic_quantities_dict(
self, location_id=False, from_date=False, to_date=False
Expand Down
2 changes: 2 additions & 0 deletions stock_orderpoint_generator/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
- Vicent Cubells
- David Vidal
- Víctor Martínez
- [360ERP](https://www.360erp.com):
- Andrea Stirpe
4 changes: 4 additions & 0 deletions stock_orderpoint_generator/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Víctor Martínez</li>
</ul>
</li>
<li><a class="reference external" href="https://www.360erp.com">360ERP</a>:<ul>
<li>Andrea Stirpe</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
42 changes: 24 additions & 18 deletions stock_orderpoint_generator/tests/test_orderpoint_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
from odoo.exceptions import UserError
from odoo.tests import Form, TransactionCase
from odoo.tests import TransactionCase


class TestOrderpointGenerator(TransactionCase):
Expand Down Expand Up @@ -64,7 +64,8 @@ def setUpClass(cls):
{
"move_id": cls.p1m1.id,
"product_id": cls.p1.id,
"qty_done": 100,
"quantity": 100,
"picked": True,
"product_uom_id": cls.p1.uom_id.id,
"location_id": cls.supplier_loc.id,
"location_dest_id": cls.wh1.lot_stock_id.id,
Expand All @@ -86,7 +87,8 @@ def setUpClass(cls):
{
"move_id": cls.p1m2.id,
"product_id": cls.p1.id,
"qty_done": 50,
"quantity": 50,
"picked": True,
"product_uom_id": cls.p1.uom_id.id,
"location_id": cls.wh1.lot_stock_id.id,
"location_dest_id": cls.customer_loc.id,
Expand All @@ -110,7 +112,8 @@ def setUpClass(cls):
{
"move_id": cls.p1m3.id,
"product_id": cls.p1.id,
"qty_done": 5,
"quantity": 5,
"picked": True,
"product_uom_id": cls.p1.uom_id.id,
"location_id": cls.wh1.lot_stock_id.id,
"location_dest_id": cls.customer_loc.id,
Expand All @@ -132,7 +135,8 @@ def setUpClass(cls):
{
"move_id": cls.p1m4.id,
"product_id": cls.p1.id,
"qty_done": 10,
"quantity": 10,
"picked": True,
"product_uom_id": cls.p1.uom_id.id,
"location_id": cls.supplier_loc.id,
"location_dest_id": cls.wh1.lot_stock_id.id,
Expand All @@ -154,7 +158,8 @@ def setUpClass(cls):
{
"move_id": cls.p1m5.id,
"product_id": cls.p1.id,
"qty_done": 3,
"quantity": 3,
"picked": True,
"product_uom_id": cls.p1.uom_id.id,
"location_id": cls.wh1.lot_stock_id.id,
"location_dest_id": cls.customer_loc.id,
Expand All @@ -180,7 +185,8 @@ def setUpClass(cls):
{
"move_id": cls.p2m1.id,
"product_id": cls.p2.id,
"qty_done": 1000,
"quantity": 1000,
"picked": True,
"product_uom_id": cls.p2.uom_id.id,
"location_id": cls.supplier_loc.id,
"location_dest_id": cls.wh1.lot_stock_id.id,
Expand All @@ -202,7 +208,8 @@ def setUpClass(cls):
{
"move_id": cls.p2m2.id,
"product_id": cls.p2.id,
"qty_done": 50,
"quantity": 50,
"picked": True,
"product_uom_id": cls.p2.uom_id.id,
"location_id": cls.wh1.lot_stock_id.id,
"location_dest_id": cls.customer_loc.id,
Expand All @@ -224,7 +231,8 @@ def setUpClass(cls):
{
"move_id": cls.p2m3.id,
"product_id": cls.p2.id,
"qty_done": 7,
"quantity": 7,
"picked": True,
"product_uom_id": cls.p2.uom_id.id,
"location_id": cls.wh1.lot_stock_id.id,
"location_dest_id": cls.customer_loc.id,
Expand All @@ -246,7 +254,8 @@ def setUpClass(cls):
{
"move_id": cls.p2m4.id,
"product_id": cls.p2.id,
"qty_done": 100,
"quantity": 100,
"picked": True,
"product_uom_id": cls.p2.uom_id.id,
"location_id": cls.supplier_loc.id,
"location_dest_id": cls.wh1.lot_stock_id.id,
Expand All @@ -268,7 +277,8 @@ def setUpClass(cls):
{
"move_id": cls.p2m5.id,
"product_id": cls.p2.id,
"qty_done": 3,
"quantity": 3,
"picked": True,
"product_uom_id": cls.p2.uom_id.id,
"location_id": cls.wh1.lot_stock_id.id,
"location_dest_id": cls.customer_loc.id,
Expand Down Expand Up @@ -312,13 +322,9 @@ def test_template_orderpoint(self):
self.check_orderpoint(products, self.template, self.orderpoint_fields_dict)

def test_template_variants_orderpoint(self):
product_form = Form(self.p1.product_tmpl_id)
with product_form.attribute_line_ids.new() as attribute:
attribute.attribute_id = self.attr
attribute.value_ids.add(self.attr_value_a)
attribute.value_ids.add(self.attr_value_b)
product_form.save()
wizard = self.wizard_over_products(self.p1.product_tmpl_id, self.template)
"""Raise error if product has multiple variants"""
product_template = self.env.ref("product.product_product_11_product_template")
wizard = self.wizard_over_products(product_template, self.template)
with self.assertRaises(UserError):
wizard.action_configure()

Expand Down
47 changes: 23 additions & 24 deletions stock_orderpoint_generator/views/orderpoint_template_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
<record id="view_warehouse_orderpoint_template_tree" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.template.tree</field>
<field name="model">stock.warehouse.orderpoint.template</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="warehouse_id" groups="stock.group_stock_multi_locations" />
<field name="location_id" groups="stock.group_stock_multi_locations" />
<field
name="product_min_qty"
attrs="{'invisble': [('auto_min_qty', '!=', False)]}"
/>
<field
name="product_max_qty"
attrs="{'invisble': [('auto_min_qty', '!=', False)]}"
/>
<field name="product_min_qty" invisible="auto_min_qty" />
<field name="product_max_qty" invisible="auto_min_qty" />
<field name="auto_min_qty" />
<field name="auto_max_qty" />
<field name="auto_generate" />
Expand Down Expand Up @@ -61,7 +54,7 @@
type="object"
string="Generate Automatic Rules"
help="Reordering rules will be created for the selected products. This is equivalent to the Scheduled Action action."
attrs="{'invisible': [('auto_generate', '=', False)]}"
invisible="not auto_generate"
/>
</header>
<sheet>
Expand All @@ -70,14 +63,19 @@
<field name="name" />
</group>
<group>
<field name="allowed_warehouse_ids" invisible="1" />
<field
name="warehouse_id"
widget="selection"
groups="stock.group_stock_multi_locations"
options="{'no_open': True, 'no_create': True}"
domain="[('id', 'in', allowed_warehouse_ids)]"
/>
<field name="allowed_location_ids" invisible="1" />
<field
name="location_id"
groups="stock.group_stock_multi_locations"
options="{'no_create': True}"
domain="[('id', 'in', allowed_location_ids)]"
/>
<field name="group_id" groups="stock.group_adv_location" />
<field
Expand All @@ -92,12 +90,14 @@
<field name="auto_min_qty" />
<field
name="product_min_qty"
attrs="{'required': [('auto_min_qty','=', False)], 'invisible': [('auto_min_qty','!=', False)]}"
required="not auto_min_qty"
invisible="auto_min_qty"
/>
<field name="auto_max_qty" />
<field
name="product_max_qty"
attrs="{'required': [('auto_max_qty','=', False)], 'invisible': [('auto_max_qty','!=', False)]}"
required="not auto_max_qty"
invisible="auto_max_qty"
/>
<field name="qty_multiple" string="Quantity Multiple" />
</group>
Expand All @@ -108,47 +108,47 @@
<group
name="auto_minimum"
string="Auto Minimum Criteria"
attrs="{'invisible': [('auto_min_qty','=', False)]}"
invisible="not auto_min_qty"
>
<field
name="auto_min_qty_criteria"
string="Criteria"
attrs="{'required': [('auto_min_qty','!=', False)]}"
required="auto_min_qty"
/>
<field
name="auto_min_date_start"
string="From"
attrs="{'required': [('auto_min_qty','!=', False)]}"
required="auto_min_qty"
/>
<field
name="auto_min_date_end"
string="To"
attrs="{'required': [('auto_min_qty','!=', False)]}"
required="auto_min_qty"
/>
</group>
<group
name="auto_maximum"
string="Auto Maximum Criteria"
attrs="{'invisible': [('auto_max_qty','=', False)]}"
invisible="not auto_max_qty"
>
<field
name="auto_max_qty_criteria"
string="Criteria"
attrs="{'required': [('auto_max_qty','!=', False)]}"
required="auto_max_qty"
/>
<field
name="auto_max_date_start"
string="From"
attrs="{'required': [('auto_max_qty','!=', False)]}"
required="auto_max_qty"
/>
<field
name="auto_max_date_end"
string="To"
attrs="{'required': [('auto_max_qty','!=', False)]}"
required="auto_max_qty"
/>
</group>
</group>
<notebook attrs="{'invisible': [('auto_generate', '=', False)]}">
<notebook invisible="not auto_generate">
<page string="Products" name="auto_rules">
<field name="auto_product_ids" />
</page>
Expand All @@ -160,12 +160,11 @@
<record id="action_orderpoint_template" model="ir.actions.act_window">
<field name="name">Reordering Rule Templates</field>
<field name="res_model">stock.warehouse.orderpoint.template</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">form,tree</field>
<field name="view_id" ref="view_warehouse_orderpoint_template_tree" />
<field name="search_view_id" ref="view_warehouse_orderpoint_template_search" />
<field name="help" type="html">
<p class="oe_view_nocontent_create">
<p class="o_view_nocontent_smiling_face">
Click to add a reordering rule template.
</p>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
<record id="act_create_product_conf" model="ir.actions.act_window">
<field name="name">Reordering Rules Generator</field>
<field name="res_model">stock.warehouse.orderpoint.generator</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">form</field>
<field name="binding_model_id" ref="product.model_product_product" />
<field name="target">new</field>
</record>
<record id="act_create_product_template_conf" model="ir.actions.act_window">
<field name="name">Reordering Rules Generator</field>
<field name="res_model">stock.warehouse.orderpoint.generator</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">form</field>
<field name="binding_model_id" ref="product.model_product_template" />
<field name="target">new</field>
Expand Down
Loading