Skip to content

Commit

Permalink
Merge commit 'refs/pull/114/head' of https://github.com/oca/product-pack
Browse files Browse the repository at this point in the history
 into 16.0-3400
  • Loading branch information
docker-odoo committed Aug 21, 2023
2 parents 3a8496a + 9732b99 commit 0c743c1
Show file tree
Hide file tree
Showing 15 changed files with 653 additions and 0 deletions.
93 changes: 93 additions & 0 deletions sale_stock_product_pack/README.rst
@@ -0,0 +1,93 @@
=======================
Sale Stock Product Pack
=======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fproduct--pack-lightgray.png?logo=github
:target: https://github.com/OCA/product-pack/tree/13.0/sale_stock_product_pack
:alt: OCA/product-pack
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-pack-13-0/product-pack-13-0-sale_stock_product_pack
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/286/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This modules adds compatibility of product packs with sales and stock altogether:

- Correctly compute delivered quantities for the different types of packs so they
can be properly invoiced when the pack is storable.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

* Non detailed packs aren't yet supported by stock_product_pack, so no support for them
either in this module.

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

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

* Ernesto Tejeda
* Pedro M. Baeza

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.

.. |maintainer-chienandalu| image:: https://github.com/chienandalu.png?size=40px
:target: https://github.com/chienandalu
:alt: chienandalu

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-chienandalu|

This module is part of the `OCA/product-pack <https://github.com/OCA/product-pack/tree/13.0/sale_stock_product_pack>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_stock_product_pack/__init__.py
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions sale_stock_product_pack/__manifest__.py
@@ -0,0 +1,15 @@
# Copyright 2021 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Sale Stock Product Pack",
"summary": "Compatibility module for packs that are storable products",
"version": "16.0.1.0.0",
"development_status": "Beta",
"category": "Sale",
"website": "https://github.com/OCA/product-pack",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["chienandalu"],
"license": "AGPL-3",
"depends": ["sale_product_pack", "stock_product_pack"],
"data": [],
}
19 changes: 19 additions & 0 deletions sale_stock_product_pack/i18n/sale_stock_product_pack.pot
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_stock_product_pack
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \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: sale_stock_product_pack
#: model:ir.model,name:sale_stock_product_pack.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
1 change: 1 addition & 0 deletions sale_stock_product_pack/models/__init__.py
@@ -0,0 +1 @@
from . import sale_order
31 changes: 31 additions & 0 deletions sale_stock_product_pack/models/sale_order.py
@@ -0,0 +1,31 @@
# Copyright 2021 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# pylint: disable=W8110
from odoo import models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _compute_qty_delivered(self):
"""Compute pack delivered pack quantites according to its components
deliveries"""
super()._compute_qty_delivered()
main_pack_lines = self.filtered("pack_parent_line_id").mapped(
"pack_parent_line_id"
)
for line in main_pack_lines.filtered(
lambda x: x.qty_delivered_method == "stock_move"
and x.pack_child_line_ids
and x.product_uom_qty
):
delivered_packs = []
# We filter non qty lines of editable packs
for pack_line in line.pack_child_line_ids.filtered("product_uom_qty"):
# If a component isn't delivered, the pack isn't as well
if not pack_line.qty_delivered:
delivered_packs.append(0)
break
qty_per_pack = pack_line.product_uom_qty / line.product_uom_qty
delivered_packs.append(pack_line.qty_delivered / qty_per_pack)
line.qty_delivered = delivered_packs and min(delivered_packs) or 0.0
4 changes: 4 additions & 0 deletions sale_stock_product_pack/readme/CONTRIBUTORS.rst
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Ernesto Tejeda
* Pedro M. Baeza
4 changes: 4 additions & 0 deletions sale_stock_product_pack/readme/DESCRIPTION.rst
@@ -0,0 +1,4 @@
This modules adds compatibility of product packs with sales and stock altogether:

- Correctly compute delivered quantities for the different types of packs so they
can be properly invoiced when the pack is storable.
2 changes: 2 additions & 0 deletions sale_stock_product_pack/readme/ROADMAP.rst
@@ -0,0 +1,2 @@
* Non detailed packs aren't yet supported by stock_product_pack, so no support for them
either in this module.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0c743c1

Please sign in to comment.