Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] migration of sale_stock_operating_unit #614

Open
wants to merge 22 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bc563c4
Added Sale Stock OU module for v8.
sudhir-serpentcs Feb 10, 2016
a4119d7
Migrated Sale Stock OU module from v7 to v8.
sudhir-serpentcs Feb 10, 2016
1fc5c01
Added Test cases and Readme file.
sudhir-serpentcs Feb 10, 2016
64539c0
Migrate to v9
AaronHForgeFlow Aug 24, 2016
6ddb8fb
[MIG] sale_stock_operating_unit to v10.
LoisRForgeFlow Jan 31, 2017
ece3e7c
Fix constraint on warehouses (#61)
guewen Feb 8, 2017
59337a7
[FIX]team operating unit has more priority than the default warehouse
AaronHForgeFlow May 16, 2018
e26afd4
[MIG] sale_stock_operating_unit: Migration to v12
bjeficent Feb 11, 2019
b338e33
[UPD] Update sale_stock_operating_unit.pot
oca-travis Dec 18, 2019
5a4d468
[UPD] README.rst
OCA-git-bot Dec 18, 2019
6e33488
[IMP] Sale Multi Ware
osi-scampbell Jan 15, 2020
33744a1
[UPD] Update sale_stock_operating_unit.pot
oca-travis Jan 16, 2020
c8f0e4e
sale_stock_operating_unit 12.0.1.0.1
OCA-git-bot Jan 16, 2020
dd62ca2
Added translation using Weblate (Portuguese)
pedrocs-exo Feb 29, 2020
fff3159
Added translation using Weblate (Italian)
francesco-ooops Jan 8, 2021
69850af
[IMP] sale_stock_operating_unit: black, isort, prettier
Jun 20, 2022
70a9925
[15.0][MIG] sale_stock_operating_unit: Migration to 15.0
Jun 20, 2022
6d0d0e0
[UPD] Update sale_stock_operating_unit.pot
Jun 8, 2023
cf803e0
[UPD] README.rst
OCA-git-bot Jun 8, 2023
a1a6fe7
Update translation files
weblate Jun 8, 2023
e77d1d0
[IMP] sale_stock_operating_unit: pre-commit stuff
alan196 Jul 27, 2023
a09239c
[MIG] sale_stock_operating_unit: Migration to 16.0
alan196 Jul 27, 2023
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
98 changes: 98 additions & 0 deletions sale_stock_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
=============================
Operating Unit in Sales Stock
=============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-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/16.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-16-0/operating-unit-16-0-sale_stock_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/213/16.0
:alt: Try me on Runbot

|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:

#. Use a created Operating Unit (OU) or create one in Settings ->
Users&Companies -> Operating
Units.
#. Use a created Sales Team or create a new one in Sales -> Configuration ->
Sales Team and assign an OU
#. Create a new Warehouse with the previous OU (or use a Warehouse with an
assigned OU)
#. Check the Location has the same OU as the Warehouse in Inventory ->
Configuration Locations (make sure you have Storage Locations checkbox
activated)
#. Create a new Sale Order with the Sales Team, Operating Unit and Warehouse
used/created before.
#. 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20sale_stock_operating_unit%0Aversion:%2016.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]>
* Alan Ramos <[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/16.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": "16.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-06-12 11:09+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 ""

#. 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 ""
5 changes: 5 additions & 0 deletions sale_stock_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import res_users
from . import sale_order
from . import stock_move
from . import stock_warehouse
20 changes: 20 additions & 0 deletions sale_stock_operating_unit/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Jarsa
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import models


class ResUsers(models.Model):
_inherit = "res.users"

def _get_default_warehouse_id(self):
warehouse = self.env["stock.warehouse"].search(
[
("company_id", "=", self.env.company.id),
("operating_unit_id", "=", self.env.user.default_operating_unit_id.id),
],
limit=1,
)
if not warehouse:
return super()._get_default_warehouse_id()
return warehouse
62 changes: 62 additions & 0 deletions sale_stock_operating_unit/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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.onchange("team_id")
def _onchange_team_id(self):
if (
self.team_id
and self.team_id.operating_unit_id
and self.team_id.operating_unit_id.id
!= self.warehouse_id.operating_unit_id.id
):
warehouses = self.env["stock.warehouse"].search(
[("operating_unit_id", "=", self.team_id.operating_unit_id.id)], limit=1
)
if warehouses:
self.warehouse_id = warehouses[0]

@api.onchange("operating_unit_id")
def _onchange_operating_unit_id(self):
if (
self.operating_unit_id
and self.operating_unit_id.id != self.warehouse_id.operating_unit_id.id
):
warehouses = self.env["stock.warehouse"].search(
[("operating_unit_id", "=", self.operating_unit_id.id)], limit=1
)
if warehouses:
self.warehouse_id = warehouses[0]

@api.onchange("warehouse_id")
def _onchange_warehouse_id(self):
if self.warehouse_id:
self.operating_unit_id = self.warehouse_id.operating_unit_id
if (
self.team_id
and self.team_id.operating_unit_id != self.operating_unit_id
):
self.team_id = False

@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
Loading
Loading