Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
96 changes: 96 additions & 0 deletions product_catalog_stock/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=====================
Stock Product Catalog
=====================

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

.. |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/license-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--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/19.0/product_catalog_stock
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-19-0/product-attribute-19-0-product_catalog_stock
: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-attribute&target_branch=19.0
:alt: Try me on Runboat

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

Implementation of the product catalog for stock pickings.

**Table of contents**

.. contents::
:local:

Usage
=====

To access the catalog from a stock picking.

1. Create a new draft picking.
2. Click on the product catalog button.
3. Click it and start adding products to the picking.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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-attribute/issues/new?body=module:%20product_catalog_stock%0Aversion:%2019.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://tecnativa.com>`__

- David Vidal
- Víctor Martínez

- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

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/product-attribute <https://github.com/OCA/product-attribute/tree/19.0/product_catalog_stock>`_ 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 product_catalog_stock/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions product_catalog_stock/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Stock Product Catalog",
"summary": "Use the product catalog on stock pickings",
"version": "19.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"license": "AGPL-3",
"category": "Product",
"depends": ["stock"],
"data": [
"views/stock_picking_views.xml",
"views/stock_picking_type_views.xml",
],
"assets": {
"web.assets_backend": [
"product_catalog_stock/static/src/**/*",
],
},
}
54 changes: 54 additions & 0 deletions product_catalog_stock/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_catalog_stock
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-05-06 12:24+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.10.4\n"

#. module: product_catalog_stock
#. odoo-python
#: code:addons/product_catalog_stock/models/stock_picking.py:0
#, python-format
msgid "Back to picking"
msgstr "Torna al prelievo"

#. module: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.view_picking_form
msgid "Catalog"
msgstr "Catalogo"

#. module: product_catalog_stock
#: model:ir.model.fields,field_description:product_catalog_stock.field_stock_picking__catalog_button_text
msgid "Catalog Button Text"
msgstr "Testo pulsante catalogo"

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipo prelievo"

#. module: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.stock_picking_type_kanban
msgid "Planned transfer from catalog"
msgstr "Trasferimento pianificato da catalogo"

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_move
msgid "Stock Move"
msgstr "Movimento di magazzino"

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_picking
msgid "Transfer"
msgstr "Trasferimento"
53 changes: 53 additions & 0 deletions product_catalog_stock/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_catalog_stock
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-09-11 14:42+0000\n"
"Last-Translator: Bosd <c5e2fd43-d292-4c90-9d1f-74ff3436329a@anonaddy.me>\n"
"Language-Team: none\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.10.4\n"

#. module: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.view_picking_form
msgid "Add a line"
msgstr "Een regel toevoegen"

#. module: product_catalog_stock
#. odoo-javascript
#: code:addons/product_catalog_stock/static/src/components/product_catalog/kanban_controller.esm.js:0
msgid "Back to picking"
msgstr "Terug naar verplaatsing"

#. module: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.view_picking_form
msgid "Catalog"
msgstr "Catalogus"

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_picking_type
msgid "Picking Type"
msgstr "Type verplaatsing"

#. module: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.stock_picking_type_kanban
msgid "Planned transfer from catalog"
msgstr "Geplande verplaatsing vanuit catalogus"

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_move
msgid "Stock Move"
msgstr "Voorraadverplaatsing"

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_picking
msgid "Transfer"
msgstr "Verplaatsing"
50 changes: 50 additions & 0 deletions product_catalog_stock/i18n/product_catalog_stock.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_catalog_stock
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.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: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.view_picking_form
msgid "Add a line"
msgstr ""

#. module: product_catalog_stock
#. odoo-javascript
#: code:addons/product_catalog_stock/static/src/components/product_catalog/kanban_controller.esm.js:0
msgid "Back to picking"
msgstr ""

#. module: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.view_picking_form
msgid "Catalog"
msgstr ""

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_picking_type
msgid "Picking Type"
msgstr ""

#. module: product_catalog_stock
#: model_terms:ir.ui.view,arch_db:product_catalog_stock.stock_picking_type_kanban
msgid "Planned transfer from catalog"
msgstr ""

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: product_catalog_stock
#: model:ir.model,name:product_catalog_stock.model_stock_picking
msgid "Transfer"
msgstr ""
2 changes: 2 additions & 0 deletions product_catalog_stock/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_picking
from . import stock_picking_type
114 changes: 114 additions & 0 deletions product_catalog_stock/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright 2024 Tecnativa - David Vidal
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from collections import defaultdict

from odoo import api, models
from odoo.fields import Domain


class StockPicking(models.Model):
_name = "stock.picking"
_inherit = ["stock.picking", "product.catalog.mixin"]

def _get_action_add_from_catalog_extra_context(self):
return {
**super()._get_action_add_from_catalog_extra_context(),
"order_id": self.id,
}

def _default_order_line_values(self, child_field=False):
default_data = super()._default_order_line_values(child_field)
new_default_data = self.env["stock.move"]._get_product_catalog_lines_data(
parent_record=self
)
return {**default_data, **new_default_data}

def _get_product_catalog_domain(self):
return super()._get_product_catalog_domain() & Domain("type", "!=", "service")

def _get_product_catalog_record_lines(self, product_ids, **kwargs):
grouped_moves = defaultdict(lambda: self.env["stock.move"])
for move in self.move_ids:
if move.product_id.id not in product_ids:
continue
grouped_moves[move.product_id] |= move
return grouped_moves

def _get_product_catalog_order_data(self, products, **kwargs):
# Extended to add price avoiding the Component.validateProps check error
product_catalog = super()._get_product_catalog_order_data(products, **kwargs)
for product in products:
product_catalog[product.id] |= self._get_product_price_and_data(product)
return product_catalog

def _get_product_price_and_data(self, product):
self.ensure_one()
return {"price": product.list_price}

@api.model
def _prepare_stock_move_vals_from_catalog(self, product_id, quantity):
self.ensure_one()
product_id = self.env["product.product"].browse(product_id)
return {
"product_id": product_id.id,
"product_uom_qty": quantity,
"product_uom": product_id.uom_id.id,
"location_id": self.location_id.id,
"location_dest_id": self.location_dest_id.id,
"picking_id": self.id,
"state": self.state,
"picking_type_id": self.picking_type_id.id,
"restrict_partner_id": self.owner_id.id,
"company_id": self.company_id.id,
"partner_id": self.partner_id.id,
# Put it at the end of the order
"sequence": ((self.move_ids and self.move_ids[-1].sequence + 1) or 10),
}

def _update_order_line_info(self, product_id, quantity, **kwargs):
"""Update stock move information for a given product or create a
new one if none exists yet.
:param int product_id: The product, as a `product.product` id.
:return: There's no price unit so we return always None show nothing is shown
:rtype: None
"""
move = self.move_ids.filtered(lambda move: move.product_id.id == product_id)
if move:
if quantity != 0:
move.product_uom_qty = quantity
elif self.state == "draft":
move.unlink()
else:
move.product_uom_qty = 0
elif quantity > 0:
move = self.env["stock.move"].create(
self._prepare_stock_move_vals_from_catalog(product_id, quantity)
)
return self.env["product.product"].browse(product_id).list_price

def _is_readonly(self):
"""Return Whether the sale order is read-only or not based on the state or the
lock status.

A sale order is considered read-only if its state is 'cancel' or if the sale
order is locked.

:return: Whether the sale order is read-only or not.
:rtype: bool
"""
self.ensure_one()
return self.state in ["cancel", "done"]


class StockMove(models.Model):
_inherit = "stock.move"

def action_add_from_catalog_picking(self):
picking = self.env["stock.picking"].browse(self.env.context.get("order_id"))
return picking.action_add_from_catalog()

def _get_product_catalog_lines_data(self, parent_record=False, **kwargs):
data = super()._get_product_catalog_lines_data(parent_record, **kwargs)
if "readOnly" in data:
data["readOnly"] = self.picking_id._is_readonly()
return data
Loading
Loading