Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
828 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# list the OCA project dependencies, one per line | ||
# add a github url if you need a forked version | ||
stock_operating_unit https://github.com/eficent/operating-unit 12.0-mig-stock_operating_unit | ||
sale_operating_unit https://github.com/eficent/operating-unit 12.0-mig-sale_operating_unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
============================= | ||
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/12.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-12-0/operating-unit-12-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/12.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:%2012.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. <contact@eficent.com> | ||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> | ||
|
||
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/12.0/sale_stock_operating_unit>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# © 2015-19 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 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": "12.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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# © 2015-19 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 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, fields, models, _ | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
@api.model | ||
def _default_warehouse_id(self): | ||
res = super(SaleOrder, self)._default_warehouse_id() | ||
team = self._get_default_team() | ||
warehouses = self.env['stock.warehouse'].search( | ||
[('operating_unit_id', '=', team.sudo().operating_unit_id.id)], | ||
limit=1) | ||
if warehouses: | ||
return warehouses | ||
return res | ||
|
||
warehouse_id = fields.Many2one( | ||
comodel_name='stock.warehouse', | ||
default=_default_warehouse_id) | ||
|
||
@api.onchange('team_id') | ||
def onchange_team_id(self): | ||
super(SaleOrder, self).onchange_team_id() | ||
if self.team_id and self.team_id.operating_unit_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: | ||
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.multi | ||
@api.constrains('operating_unit_id', 'warehouse_id') | ||
def _check_wh_operating_unit(self): | ||
for rec in self: | ||
if 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.')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# © 2015-17 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 2015-17 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(StockMove, self)._get_new_picking_values() | ||
|
||
values.update({ | ||
'operating_unit_id': self.sale_line_id.operating_unit_id.id | ||
}) | ||
|
||
return values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# © 2015-19 Eficent Business and IT Consulting Services S.L. - | ||
# Jordi Ballester Alomar | ||
# © 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.multi | ||
@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)]) | ||
if sales: | ||
raise ValidationError(_( | ||
'Sales Order records already exist(s) for this warehouse' | ||
' and operating unit.')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com> | ||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.