Skip to content

Commit

Permalink
[MIG] sale_automatic_workflow_stock: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chaule97 committed Dec 5, 2024
1 parent 0b6cad9 commit c580ff6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 7 deletions.
7 changes: 7 additions & 0 deletions sale_automatic_workflow_stock/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ Contributors
- Thomas Fossoul <thomas@niboo.com>
- Silvija Butko <silvija@focusate.eu>
- Tri Doan <<tridm@trobz.com>>
- Chau Le <<chaulb@trobz.com>>

Other credits
-------------

The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion sale_automatic_workflow_stock/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Sale Automatic Workflow Stock",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Sales Management",
"license": "AGPL-3",
"author": "Akretion, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _validate_pickings(self, picking_filter):
def _handle_pickings(self, sale_workflow):
"""Override to add stock picking validation."""
super()._handle_pickings(sale_workflow)
workflow_domain = [("workflow_process_id", "=", sale_workflow.id)]
workflow_domain = self._sale_workflow_domain(sale_workflow)
if sale_workflow.validate_picking:
self._validate_pickings(
safe_eval(sale_workflow.picking_filter_id.domain) + workflow_domain
Expand Down
11 changes: 11 additions & 0 deletions sale_automatic_workflow_stock/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def _depends_picking_policy(self):
depends.append("workflow_process_id")
return depends

@api.depends("delivery_status")
def _compute_all_qty_delivered(self):
for order in self:
order.all_qty_delivered = order.delivery_status == "full"

@api.onchange("workflow_process_id")
def _onchange_workflow_process_id(self):
if self.workflow_process_id.picking_policy:
self.picking_policy = self.workflow_process_id.picking_policy
return super()._onchange_workflow_process_id()

@api.depends(lambda self: self._depends_picking_policy())
def _compute_picking_policy(self):
res = None
Expand Down
1 change: 1 addition & 0 deletions sale_automatic_workflow_stock/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
- Thomas Fossoul \<<thomas@niboo.com>\>
- Silvija Butko \<<silvija@focusate.eu>\>
- Tri Doan \<\<<tridm@trobz.com>\>\>
- Chau Le \<\<<chaulb@trobz.com>\>\>
1 change: 1 addition & 0 deletions sale_automatic_workflow_stock/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp.
11 changes: 9 additions & 2 deletions sale_automatic_workflow_stock/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ <h1 class="title">Sale Automatic Workflow Stock</h1>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -428,10 +429,16 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<li>Thomas Fossoul &lt;<a class="reference external" href="mailto:thomas&#64;niboo.com">thomas&#64;niboo.com</a>&gt;</li>
<li>Silvija Butko &lt;<a class="reference external" href="mailto:silvija&#64;focusate.eu">silvija&#64;focusate.eu</a>&gt;</li>
<li>Tri Doan &lt;&lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;&gt;</li>
<li>Chau Le &lt;&lt;<a class="reference external" href="mailto:chaulb&#64;trobz.com">chaulb&#64;trobz.com</a>&gt;&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<p>The migration of this module from 17.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
14 changes: 11 additions & 3 deletions sale_automatic_workflow_stock/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@
class TestAutomaticWorkflowStockMixin(TestAutomaticWorkflowMixin):
"""Extend to add stock related workflow."""

def create_sale_order(self, workflow, override=None, product_type="product"):
def create_sale_order(
self, workflow, override=None, product_type="consu", extra_product_values=None
):
extra_product_values = extra_product_values or {}
extra_product_values["is_storable"] = True

# Override to create stock operations for each product
order = super().create_sale_order(
workflow, override=override, product_type=product_type
workflow,
override=override,
product_type=product_type,
extra_product_values=extra_product_values,
)
# Create inventory
for line in order.order_line:
if line.product_id.type == "product":
if line.product_id.is_storable:
inventory = self.env["stock.quant"].create(
{
"product_id": line.product_id.id,
Expand Down

0 comments on commit c580ff6

Please sign in to comment.