Skip to content

Commit

Permalink
[MIG] stock_move_line_force_done: Migration to 16.0 (#1874)
Browse files Browse the repository at this point in the history
* 14.0 mig stock move line force done (#1526)

* [ADD] stock_move_line_force_done: New button in pickings "Force done detailed operations". (#1479)

* [MIG] stock_move_line_force_done: Migration to 14.0

* [IMP] stock_move_line_force_done: change view

---------

Co-authored-by: alfredoavanzosc <[email protected]>
Co-authored-by: Oihane Crucelaegui <[email protected]>
Co-authored-by: Ana Juaristi <[email protected]>
  • Loading branch information
4 people authored Jul 2, 2024
1 parent 9643756 commit 0aaf0ce
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 0 deletions.
31 changes: 31 additions & 0 deletions stock_move_line_force_done/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==========================
Stock move line force done
==========================

* New button in pickings "Force done detailed operations". This module sets in
detailed operations the "Done" field equal to the amount requested in
operations. If the detailed operation of the operation does not exist, it is
created automatically.

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

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted
it first, help us smash it by providing detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Contributors
------------

* Ana Juaristi <[email protected]>
* Alfredo de la Fuente <[email protected]>
1 change: 1 addition & 0 deletions stock_move_line_force_done/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions stock_move_line_force_done/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Stock Move Line Force Done",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "AvanzOSC",
"website": "http://www.avanzosc.es",
"category": "Warehouse",
"depends": [
"stock"
],
"data": [
"views/stock_picking_view.xml",
],
"installable": True,
}
27 changes: 27 additions & 0 deletions stock_move_line_force_done/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_move_line_force_done
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-14 08:40+0000\n"
"PO-Revision-Date: 2022-03-14 08:40+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_move_line_force_done
#: model_terms:ir.ui.view,arch_db:stock_move_line_force_done.view_picking_form
msgid "Force done detailed operations"
msgstr "Forzar realizadas operaciones detalladas"

#. module: stock_move_line_force_done
#: model:ir.model,name:stock_move_line_force_done.model_stock_picking
msgid "Transfer"
msgstr "Transferir"

27 changes: 27 additions & 0 deletions stock_move_line_force_done/i18n/stock_move_line_force_done.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_move_line_force_done
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-14 08:40+0000\n"
"PO-Revision-Date: 2022-03-14 08:40+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_move_line_force_done
#: model_terms:ir.ui.view,arch_db:stock_move_line_force_done.view_picking_form
msgid "Force done detailed operations"
msgstr ""

#. module: stock_move_line_force_done
#: model:ir.model,name:stock_move_line_force_done.model_stock_picking
msgid "Transfer"
msgstr ""

2 changes: 2 additions & 0 deletions stock_move_line_force_done/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_picking
from . import stock_quant
20 changes: 20 additions & 0 deletions stock_move_line_force_done/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2022 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import models


class StockPicking(models.Model):
_inherit = "stock.picking"

def button_force_done_detailed_operations(self):
move_line_obj = self.env["stock.move.line"]
for picking in self:
pending_move_lines = picking.move_line_ids.filtered(
lambda l: not l.move_id)
pending_move_lines.unlink()
for move in picking.move_ids:
if not move.move_line_ids:
move_line_obj.create(move._prepare_move_line_vals())
line = move.move_line_ids[:1]
if line and line.qty_done != move.product_uom_qty:
line.qty_done = move.product_uom_qty
31 changes: 31 additions & 0 deletions stock_move_line_force_done/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2022 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import models, api
from odoo.tools.float_utils import float_compare


class StockQuant(models.Model):
_inherit = 'stock.quant'

@api.model
def _update_reserved_quantity(self, product_id, location_id, quantity,
lot_id=None, package_id=None, owner_id=None,
strict=False):
self = self.sudo()
rounding = product_id.uom_id.rounding
quants = self._gather(
product_id, location_id, lot_id=lot_id, package_id=package_id,
owner_id=owner_id, strict=strict)
if float_compare(quantity, 0, precision_rounding=rounding) < 0:
available_quantity = sum(quants.mapped('reserved_quantity'))
if float_compare(
abs(quantity), available_quantity,
precision_rounding=rounding) > 0:
if len(quants) == 1:
if quantity < 0:
quantity = quantity * -1
my_quantity = available_quantity + quantity
quants.write({'reserved_quantity': my_quantity})
return super(StockQuant, self)._update_reserved_quantity(
product_id, location_id, quantity, lot_id=lot_id,
package_id=package_id, owner_id=owner_id, strict=strict)
15 changes: 15 additions & 0 deletions stock_move_line_force_done/views/stock_picking_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record model="ir.ui.view" id="view_picking_form" >
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<button name="action_assign" position="after">
<button name="button_force_done_detailed_operations"
attrs="{'invisible': ['|', ('state', 'not in', ('waiting', 'confirmed', 'assigned')), ('show_operations', '=', False)]}"
string="Force done detailed operations" type="object"
groups="stock.group_stock_user" class="o_btn_validate"/>
</button>
</field>
</record>
</odoo>

0 comments on commit 0aaf0ce

Please sign in to comment.