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

[16.0] [ADD] foodhub_picking_operations #122

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
58 changes: 58 additions & 0 deletions foodhub_picking_operations/README.rst
Copy link
Member

Choose a reason for hiding this comment

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

why _operations in the module name? suggestion: foodhub_custom_stock_picking.

Copy link
Member Author

Choose a reason for hiding this comment

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

done, dropped the custom because it's useless I think

Copy link
Member

Choose a reason for hiding this comment

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

then i think foodhub_stock_picking is better, because picking alone is a little strange.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
==========================
Foodhub Picking Operations
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7d681b62ded7841560c15427c9d8b30b35a514b6c31f2c2b36c47419e1e1120c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Fcie--custom-lightgray.png?logo=github
:target: https://github.com/coopiteasy/cie-custom/tree/16.0/foodhub_picking_operations
:alt: coopiteasy/cie-custom

|badge1| |badge2| |badge3|

Sort picking operations by internal category and internal reference.

Context : Increase the efficiency of picking by sorting products by location and priority. We cannot use "locations" because some products are of type Consumable and should stay this way : these are products that are received and sent on the same date, we don't want to manage stock on these products.
So instead we sort by internal categories and by reference.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/cie-custom/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/coopiteasy/cie-custom/issues/new?body=module:%20foodhub_picking_operations%0Aversion:%2016.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.

Credits
=======

Authors
~~~~~~~

* Coop IT Easy SC

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/cie-custom <https://github.com/coopiteasy/cie-custom/tree/16.0/foodhub_picking_operations>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions foodhub_picking_operations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions foodhub_picking_operations/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Foodhub Picking Operations",
"version": "16.0.1.0.0",
"summary": """
Foodhub customizations : sort picking operations by category and reference""",
"author": "Coop IT Easy SC",
"website": "https://coopiteasy.be",
"license": "AGPL-3",
"category": "Stock",
"depends": [
"stock",
],
"data": ["reports/report_picking_operations.xml"],
}
2 changes: 2 additions & 0 deletions foodhub_picking_operations/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_move
from . import stock_move_line
13 changes: 13 additions & 0 deletions foodhub_picking_operations/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2020 Coop IT Easy SCRL fs
# Robin Keunen <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class StockMove(models.Model):
_inherit = "stock.move"
_order = "product_category,product_default_code"

product_category = fields.Many2one(related="product_id.categ_id", store=True)
Copy link
Member

Choose a reason for hiding this comment

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

this will sort by the id of the category, not by its name. is it on purpose? otherwise, it should be like this:

Suggested change
_order = "product_category,product_default_code"
product_category = fields.Many2one(related="product_id.categ_id", store=True)
_order = "product_category_name,product_default_code"
product_category_name = fields.Many2one(related="product_id.categ_id.name", store=True)

Copy link
Member Author

@victor-champonnois victor-champonnois Dec 16, 2024

Choose a reason for hiding this comment

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

In theory I agree with you, but in practice it works ! checkout out this delivery, on the picking operations, valdibela is sorted last, while it's id is 3 (lower than the id from tierra y liberdad). Unless the sorting is descending ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that I will only keep the sorting for move lines, not moves

Copy link
Member

Choose a reason for hiding this comment

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

my bad: i just checked, and indeed, odoo does it better than i think: if a many2one field is used in _order, it will correctly use the ordering of that model, automatically joining with all needed tables.

product_default_code = fields.Char(related="product_id.default_code", store=True)
12 changes: 12 additions & 0 deletions foodhub_picking_operations/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2020 Coop IT Easy SCRL fs
# Robin Keunen <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class StockMove(models.Model):
_inherit = "stock.move.line"
_order = "product_category_name,product_default_code"

product_default_code = fields.Char(related="product_id.default_code", store=True)
6 changes: 6 additions & 0 deletions foodhub_picking_operations/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Sort picking operations by internal category and internal reference.

Context : Increase the efficiency of picking by sorting products by location and priority. We cannot use "locations" because some products are of type Consumable and should stay this way : these are products that are received and sent on the same date, we don't want to manage stock on these products.
So instead we sort by internal categories and by reference.

- Put the name of the SO in title, rather than the picking reference. Because this picking will be sent to the client, who only knows the reference of the SO. In principle this document should not be sent to the client, but here it's easier to only rely on one document.
29 changes: 29 additions & 0 deletions foodhub_picking_operations/reports/report_picking_operations.xml
Copy link
Member

Choose a reason for hiding this comment

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

in the stock module, the file is called report_stockpicking_operations.xml. i think it can be simply named report_picking.xml, as this is also the name of the report.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_picking" inherit_id="stock.report_picking">
<xpath expr="//h1" position="replace">
<h1 t-field="o.origin" class="mt0"/>
</xpath>
victor-champonnois marked this conversation as resolved.
Show resolved Hide resolved
<xpath expr="//div[@name='div_origin']" position="replace">
<div t-if="o.origin" class="col-auto" name="div_origin">
<strong>Picking:</strong>
<p t-field="o.name"/>
</div>
</xpath>
victor-champonnois marked this conversation as resolved.
Show resolved Hide resolved
<xpath expr="//th[@name='th_product']" position="before">
<th>
<strong>Category</strong>
</th>
</xpath>

<xpath
expr="//span[@t-field='ml.product_id.display_name']/.."
position="before"
>
<td>
<span t-field="ml.product_category_name" />
</td>
</xpath>

</template>
</odoo>
Loading
Loading