-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca8e17e
commit be1ad38
Showing
15 changed files
with
686 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
==================================== | ||
Weighing assistant in batch pickings | ||
==================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:4c66742998294dc1a2cda1baab1b6a2921b00c423fe8325408af433c2543a566 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-OCA%2Fstock--weighing-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-weighing/tree/15.0/mrp_weighing | ||
:alt: OCA/stock-weighing | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-weighing-15-0/stock-weighing-15-0-mrp_weighing | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-weighing&target_branch=15.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Weighing production finished moves | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-weighing/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/OCA/stock-weighing/issues/new?body=module:%20mrp_weighing%0Aversion:%2015.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 | ||
------- | ||
|
||
* Tecnativa | ||
|
||
Contributors | ||
------------ | ||
|
||
- `Tecnativa <https://www.tecnativa.com>`__ | ||
|
||
- Sergio Teruel | ||
- Carlos Dauden | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/stock-weighing <https://github.com/OCA/stock-weighing/tree/15.0/mrp_weighing>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from . import models | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Tecnativa - Sergio Teruel | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
{ | ||
"name": "Weighing assistant in batch pickings", | ||
"summary": "Launch the weighing assistant from batch pickings", | ||
"version": "15.0.1.0.0", | ||
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-weighing", | ||
"license": "AGPL-3", | ||
"category": "MRP", | ||
"depends": [ | ||
"stock_weighing", | ||
"mrp", | ||
], | ||
"data": ["views/mrp_production_view.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from . import mrp_production | ||
from . import stock_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2024 Tecnativa - Sergio Teruel | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
import ast | ||
|
||
from odoo import _, api, fields, models | ||
|
||
|
||
class MrpProduction(models.Model): | ||
_inherit = "mrp.production" | ||
|
||
weighing_operations = fields.Boolean(related="picking_type_id.weighing_operations") | ||
has_weighing_operations = fields.Boolean(compute="_compute_has_weighing_operations") | ||
|
||
@api.depends("move_finished_ids") | ||
def _compute_has_weighing_operations(self): | ||
for mrp_production in self: | ||
mrp_production.has_weighing_operations = mrp_production.move_finished_ids | ||
|
||
def action_weighing_operations(self): | ||
"""Weighing operations for this production order""" | ||
action = self.env["ir.actions.actions"]._for_xml_id( | ||
"stock_weighing.weighing_operation_action" | ||
) | ||
weight_moves = self.move_finished_ids | ||
action["name"] = _("Weighing operations for %(name)s", name=self.name) | ||
action["domain"] = [("id", "in", weight_moves.ids)] | ||
ctx = dict( | ||
self.env.context, | ||
**ast.literal_eval(action["context"]), | ||
group_by=["production_id"], | ||
show_weight_detail_buttons=True | ||
) | ||
# We weigh mrp operations that are not in ready state | ||
ctx.pop("search_default_ready") | ||
action["context"] = ctx | ||
return action | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2024 Tecnativa - Sergio Teruel | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import api, models | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
@api.model | ||
def action_mrp_production_weighing(self): | ||
"""Used in the start screen""" | ||
action = self.env["ir.actions.actions"]._for_xml_id("mrp.mrp_production_action") | ||
ctx = {"search_default_todo": True} | ||
action["context"] = ctx | ||
return action | ||
|
||
def action_add_move_line(self): | ||
action = super().action_add_move_line() | ||
if not self.production_id.lot_producing_id: | ||
return action | ||
default_lot_id = False | ||
if self.product_id == self.production_id.product_id: | ||
default_lot_id = self.production_id.lot_producing_id.id | ||
else: | ||
last_lot = self.move_line_ids.lot_id[-1:] | ||
if last_lot: | ||
default_lot_id = last_lot.id | ||
elif self.has_tracking: | ||
lot = self.env["stock.production.lot"].search( | ||
[ | ||
("company_id", "=", self.company_id.id), | ||
("product_id", "=", self.product_id.id), | ||
("name", "=", self.production_id.lot_producing_id.name), | ||
], | ||
limit=1, | ||
) | ||
if lot: | ||
default_lot_id = lot.id | ||
else: | ||
sml = self.move_line_ids[:1] | ||
if not sml: | ||
sml = self.env["stock.move.line"].new( | ||
{ | ||
"lot_name": self.production_id.lot_producing_id.name, | ||
"product_id": self.product_id.id, | ||
"company_id": self.company_id.id, | ||
} | ||
) | ||
sml._create_and_assign_production_lot() | ||
default_lot_id = sml.lot_id.id | ||
if default_lot_id: | ||
action["context"].update({"default_lot_id": default_lot_id}) | ||
return action | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- [Tecnativa](https://www.tecnativa.com) | ||
- Sergio Teruel | ||
- Carlos Dauden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Weighing production finished moves |
Oops, something went wrong.