Skip to content

Commit

Permalink
Merge pull request #1906 from VoicuStefan2001/17.0
Browse files Browse the repository at this point in the history
[17.0][UPD] deltatech_auto_reorder_rule
  • Loading branch information
VoicuStefan2001 authored Feb 13, 2025
2 parents d6b2cbd + b658ae8 commit c477b1e
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 371 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ addon | version | maintainers | summary | price
[deltatech_agreement_management](deltatech_agreement_management/) | 17.0.0.0.3 | [![danila12](https://github.com/danila12.png?size=30px)](https://github.com/danila12) | Manage agreements numbers, date, state | Free
[deltatech_alternative](deltatech_alternative/) | 17.0.2.0.9 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Alternative product codes | Free
[deltatech_alternative_website](deltatech_alternative_website/) | 17.0.1.0.6 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Show alternative code in website | Free
[deltatech_auto_reorder_rule](deltatech_auto_reorder_rule/) | 17.0.0.0.1 | | Auto create reorder rule | Free
[deltatech_auto_reorder_rule](deltatech_auto_reorder_rule/) | 17.0.0.0.2 | | Auto create reorder rule | Free
[deltatech_average_payment_period](deltatech_average_payment_period/) | 17.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Computes average duration of cash accounting | Free
[deltatech_backup_attachment](deltatech_backup_attachment/) | 17.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Backup attachments for selected file type | Free
[deltatech_batch_transfer](deltatech_batch_transfer/) | 17.0.0.0.2 | [![danila12](https://github.com/danila12.png?size=30px)](https://github.com/danila12) | Batch transfer improvements | Free
Expand Down Expand Up @@ -134,7 +134,7 @@ addon | version | maintainers | summary | price
[deltatech_sale_activity_search](deltatech_sale_activity_search/) | 17.0.0.0.0 | [![VoicuStefan2001](https://github.com/VoicuStefan2001.png?size=30px)](https://github.com/VoicuStefan2001) | Adds a field with the active activity types on that sale order | Free
[deltatech_sale_add_extra_line](deltatech_sale_add_extra_line/) | 17.0.1.0.9 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Sale Add Extra Line | Free
[deltatech_sale_add_extra_line_pos](deltatech_sale_add_extra_line_pos/) | 17.0.0.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | POS Add Extra Line | Free
[deltatech_sale_commission](deltatech_sale_commission/) | 17.0.1.2.4 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Compute sale commission | Free
[deltatech_sale_commission](deltatech_sale_commission/) | 17.0.1.2.5 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Compute sale commission | Free
[deltatech_sale_contact](deltatech_sale_contact/) | 17.0.1.0.21 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Limit contacts insale order | Free
[deltatech_sale_cost_product](deltatech_sale_cost_product/) | 17.0.0.0.2 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Sale Cost on Order | Free
[deltatech_sale_feedback](deltatech_sale_feedback/) | 17.0.1.0.5 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Sale Feedback | Free
Expand Down
10 changes: 7 additions & 3 deletions deltatech_auto_reorder_rule/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
"name": "Deltatech Auto Reorder Rule",
"category": "Stock",
"summary": "Auto create reorder rule",
"version": "17.0.0.0.1",
"version": "17.0.0.0.2",
"author": "Terrabit, Dan Stoica",
"website": "https://www.terrabit.ro",
"license": "OPL-1",
"depends": ["stock"],
"data": ["data/ir_server_action.xml"],
"depends": ["stock", "purchase_stock", "sale_stock"],
"data": [
"data/ir_server_action.xml",
"views/stock_warehouse_view.xml",
"views/stock_route_view.xml",
],
"development_status": "Beta",
"installable": True,
}
2 changes: 2 additions & 0 deletions deltatech_auto_reorder_rule/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
# See README.rst file on addons root folder for license details

from . import product
from . import stock_warehouse
from . import stock_route
51 changes: 41 additions & 10 deletions deltatech_auto_reorder_rule/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,48 @@ class ProductProduct(models.Model):
_inherit = "product.product"

def create_rule(self):
warehouses = self.env["stock.warehouse"].search(
[("generate_reorder_rules", "=", True), ("company_id", "=", self.env.user.company_id.id)]
)
routes = self.env["stock.route"].search(
[
("use_this_for_auto_rules", "=", True),
]
)
route = False
if routes:
route = routes[0].id
for record in self:
rules = record.env["stock.warehouse.orderpoint"].search([("product_id", "=", record.id)])
if not rules and record.type == "product":
record.env["stock.warehouse.orderpoint"].create(
{
"product_id": record.id,
"product_min_qty": 0,
"product_max_qty": 0,
"qty_multiple": 0,
}
)
rules = record.env["stock.warehouse.orderpoint"].search(
[("product_id", "=", record.id), ("company_id", "=", self.env.user.company_id.id)]
)
if not rules:
values = []
for warehouse in warehouses:
if warehouse.lot_stock_id.usage == "internal":
values.append(
{
"product_id": record.id,
"product_min_qty": 0,
"product_max_qty": 0,
"qty_multiple": 0,
"trigger": "manual",
"route_id": route,
"location_id": warehouse.lot_stock_id.id,
}
)
if values:
record.env["stock.warehouse.orderpoint"].create(values)

# if not rules and record.type == "product":
# record.env["stock.warehouse.orderpoint"].create(
# {
# "product_id": record.id,
# "product_min_qty": 0,
# "product_max_qty": 0,
# "qty_multiple": 0,
# }
# )

@api.model_create_multi
def create(self, vals_list):
Expand Down
9 changes: 9 additions & 0 deletions deltatech_auto_reorder_rule/models/stock_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class StockRoute(models.Model):
_inherit = "stock.route"

use_this_for_auto_rules = fields.Boolean(
string="Use This for Auto Rules", help="You should only have one route with this option"
)
7 changes: 7 additions & 0 deletions deltatech_auto_reorder_rule/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import fields, models


class StockWarehouse(models.Model):
_inherit = "stock.warehouse"

generate_reorder_rules = fields.Boolean(string="Generate Reorder Rules", default=True)
Loading

0 comments on commit c477b1e

Please sign in to comment.