Skip to content

Commit

Permalink
Merge PR #676 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by AaronHForgeFlow
  • Loading branch information
OCA-git-bot committed Aug 7, 2024
2 parents e767373 + a968b41 commit cb58499
Show file tree
Hide file tree
Showing 19 changed files with 915 additions and 0 deletions.
101 changes: 101 additions & 0 deletions sale_stock_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
=============================
Operating Unit in Sales Stock
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:07f09d56965d25da13c7945e35be9fc22c78f2b71c3927888edc191cdb21308e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/17.0/sale_stock_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/operating-unit-17-0/operating-unit-17-0-sale_stock_operating_unit
: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/operating-unit&target_branch=17.0
:alt: Try me on Runboat

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

This module was written to extend the Sales and the Stock capabilities
of Odoo. This module introduces some new operating unit (OU)
capabilities in order to enhance the performance of already existing OU
features for Sales and Stock.

**Table of contents**

.. contents::
:local:

Usage
=====

Follow these steps:

1. Use a created Operating Unit (OU) or create one in Settings ->
Users&Companies -> Operating Units.
2. Use a created Sales Team or create a new one in Sales ->
Configuration -> Sales Team and assign an OU
3. Create a new Warehouse with the previous OU (or use a Warehouse with
an assigned OU)
4. Check the Location has the same OU as the Warehouse in Inventory ->
Configuration Locations (make sure you have Storage Locations
checkbox activated)
5. Create a new Sale Order with the Sales Team, Operating Unit and
Warehouse used/created before.
6. OU, Picking Type and Location are propagated to the Picking.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20sale_stock_operating_unit%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
-------

* Eficent
* Serpent Consulting Services Pvt. Ltd.

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

- Eficent Business and IT Consulting Services S.L.
<[email protected]>
- Serpent Consulting Services Pvt. Ltd. <[email protected]>
- Alejandro Padrón <[email protected]>

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/operating-unit <https://github.com/OCA/operating-unit/tree/17.0/sale_stock_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions sale_stock_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models
22 changes: 22 additions & 0 deletions sale_stock_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2015-19 Eficent Business and IT Consulting Services S.L. -
# Jordi Ballester Alomar
# Copyright 2015-19 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Operating Unit in Sales Stock",
"summary": "An operating unit (OU) is an organizational entity part of a "
"company",
"version": "17.0.1.0.0",
"author": "Eficent, Serpent Consulting Services Pvt. Ltd., "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "https://github.com/OCA/operating-unit",
"category": "Sales Management",
"depends": [
"sale_stock",
"sale_operating_unit",
"stock_operating_unit",
],
"installable": True,
}
55 changes: 55 additions & 0 deletions sale_stock_operating_unit/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_stock_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-09-22 16:38+0000\n"
"Last-Translator: mymage <[email protected]>\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 4.17\n"

#. module: sale_stock_operating_unit
#: code:addons/sale_stock_operating_unit/models/sale_order.py:0
#, python-format
msgid ""
"Configuration error!\n"
"The OperatingUnit in the Sales Order and in the Warehouse must be the same."
msgstr ""
"Errore di configurazione!\n"
"L'Unità Operativa nell'ordine di vendita e nel magazzino deve essere la "
"stessa."

#. module: sale_stock_operating_unit
#: model:ir.model,name:sale_stock_operating_unit.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"

#. module: sale_stock_operating_unit
#: code:addons/sale_stock_operating_unit/models/stock_warehouse.py:0
#, python-format
msgid ""
"Sales Order records already exist(s) for this warehouse and operating unit."
msgstr ""
"Esistono già degli ordini di vendita per questo magazzino e Unità Operativa."

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

#. module: sale_stock_operating_unit
#: model:ir.model,name:sale_stock_operating_unit.model_stock_warehouse
#: model:ir.model.fields,field_description:sale_stock_operating_unit.field_sale_order__warehouse_id
msgid "Warehouse"
msgstr "Magazzino"

#~ msgid "Sale Order"
#~ msgstr "Ordine di Vendita"
56 changes: 56 additions & 0 deletions sale_stock_operating_unit/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_stock_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-02-29 15:13+0000\n"
"Last-Translator: Pedro Castro Silva <[email protected]>\n"
"Language-Team: none\n"
"Language: pt\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 3.10\n"

#. module: sale_stock_operating_unit
#: code:addons/sale_stock_operating_unit/models/sale_order.py:0
#, python-format
msgid ""
"Configuration error!\n"
"The OperatingUnit in the Sales Order and in the Warehouse must be the same."
msgstr ""
"Erro de Configuração!\n"
"As Unidades Operacionais na Encomenda de Venda e no Armazém têm que ser "
"iguais."

#. module: sale_stock_operating_unit
#: model:ir.model,name:sale_stock_operating_unit.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: sale_stock_operating_unit
#: code:addons/sale_stock_operating_unit/models/stock_warehouse.py:0
#, python-format
msgid ""
"Sales Order records already exist(s) for this warehouse and operating unit."
msgstr ""
"Já existem registos de Encomendas de Vendas para este armazém e unidade "
"operacional."

#. module: sale_stock_operating_unit
#: model:ir.model,name:sale_stock_operating_unit.model_stock_move
msgid "Stock Move"
msgstr "Movimento de Stock"

#. module: sale_stock_operating_unit
#: model:ir.model,name:sale_stock_operating_unit.model_stock_warehouse
#: model:ir.model.fields,field_description:sale_stock_operating_unit.field_sale_order__warehouse_id
msgid "Warehouse"
msgstr "Armazém"

#~ msgid "Sale Order"
#~ msgstr "Encomenda de Venda"
45 changes: 45 additions & 0 deletions sale_stock_operating_unit/i18n/sale_stock_operating_unit.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_stock_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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_operating_unit
#: code:addons/sale_stock_operating_unit/models/sale_order.py:0
#, python-format
msgid ""
"Configuration error!\n"
"The OperatingUnit in the Sales Order and in the Warehouse must be the same."
msgstr ""

#. module: sale_stock_operating_unit
#: model:ir.model,name:sale_stock_operating_unit.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: sale_stock_operating_unit
#: code:addons/sale_stock_operating_unit/models/stock_warehouse.py:0
#, python-format
msgid ""
"Sales Order records already exist(s) for this warehouse and operating unit."
msgstr ""

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

#. module: sale_stock_operating_unit
#: model:ir.model,name:sale_stock_operating_unit.model_stock_warehouse
#: model:ir.model.fields,field_description:sale_stock_operating_unit.field_sale_order__warehouse_id
msgid "Warehouse"
msgstr ""
4 changes: 4 additions & 0 deletions sale_stock_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import sale_order
from . import stock_move
from . import stock_warehouse
45 changes: 45 additions & 0 deletions sale_stock_operating_unit/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2015-19 Eficent Business and IT Consulting Services S.L. -
# Jordi Ballester Alomar
# Copyright 2015-19 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, models
from odoo.exceptions import ValidationError


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

@api.depends("user_id", "company_id", "operating_unit_id")
def _compute_warehouse_id(self):
res = super()._compute_warehouse_id()
for sale in self:
if sale.warehouse_id.operating_unit_id != sale.operating_unit_id:
warehouse = self.env["stock.warehouse"].search(
[
(
"operating_unit_id",
"=",
sale.operating_unit_id.id,
),
],
limit=1,
)
if warehouse:
sale.warehouse_id = warehouse.id
return res

@api.constrains("operating_unit_id", "warehouse_id")
def _check_wh_operating_unit(self):
for rec in self:
if (
rec.warehouse_id.operating_unit_id
and rec.operating_unit_id
and rec.operating_unit_id != rec.warehouse_id.operating_unit_id
):
raise ValidationError(
_(
"Configuration error!\nThe Operating"
"Unit in the Sales Order and in the"
" Warehouse must be the same."
)
)
24 changes: 24 additions & 0 deletions sale_stock_operating_unit/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2015-19 Eficent Business and IT Consulting Services S.L. -
# Jordi Ballester Alomar
# Copyright 2015-19 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import models


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

def _get_new_picking_values(self):
"""
Override to add Operating Units to Picking.
"""
values = super()._get_new_picking_values()

values.update(
{
"operating_unit_id": self.sale_line_id.operating_unit_id.id
or self.operating_unit_id.id
}
)

return values
28 changes: 28 additions & 0 deletions sale_stock_operating_unit/models/stock_warehouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2015-19 Eficent Business and IT Consulting Services S.L. -
# Jordi Ballester Alomar
# Copyright 2015-19 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import _, api, models
from odoo.exceptions import ValidationError


class StockWarehouse(models.Model):
_inherit = "stock.warehouse"

@api.constrains("operating_unit_id")
def _check_existing_so_in_wh(self):
for rec in self:
sales = self.env["sale.order"].search(
[
("warehouse_id", "=", rec.id),
("operating_unit_id", "!=", rec.operating_unit_id.id),
],
limit=1,
)
if sales:
raise ValidationError(
_(
"Sales Order records already exist(s) for this warehouse"
" and operating unit."
)
)
3 changes: 3 additions & 0 deletions sale_stock_operating_unit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions sale_stock_operating_unit/readme/CONFIGURATION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Go to 'Settings / Technical / Actions / User-defined Defaults' and remove
the default set for the Shop.
Loading

0 comments on commit cb58499

Please sign in to comment.