Skip to content

Commit

Permalink
Merge PR #170 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by rvalyi
  • Loading branch information
OCA-git-bot committed Jan 10, 2025
2 parents 8d73597 + 1bf1628 commit 9337979
Show file tree
Hide file tree
Showing 14 changed files with 656 additions and 0 deletions.
97 changes: 97 additions & 0 deletions sale_stock_product_pack/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
=======================
Sale Stock Product Pack
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c81e7b28f443c2245ae020a601f05690394a2d93dbdcd6da083db3bc63784d4e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/17.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-17-0/product-pack-17-0-sale_stock_product_pack
: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/product-pack&target_branch=17.0
:alt: Try me on Runboat

|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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-pack/issues/new?body=module:%20sale_stock_product_pack%0Aversion:%2017.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/17.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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions sale_stock_product_pack/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": "17.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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
31 changes: 31 additions & 0 deletions sale_stock_product_pack/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions sale_stock_product_pack/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions sale_stock_product_pack/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Tecnativa](https://www.tecnativa.com):
- Ernesto Tejeda
- Pedro M. Baeza
5 changes: 5 additions & 0 deletions sale_stock_product_pack/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Non detailed packs aren't yet supported by stock_product_pack, so no
support for them either in this module.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9337979

Please sign in to comment.