Skip to content

Commit

Permalink
Merge branch '16.0-mig-purchase_stock_operating_unit' into 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alan196 committed Sep 6, 2023
2 parents 43b8c01 + 3d4c757 commit 9a67f3d
Show file tree
Hide file tree
Showing 17 changed files with 712 additions and 0 deletions.
93 changes: 93 additions & 0 deletions purchase_stock_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
=============================
Purchase Stock Operating Unit
=============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-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%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/16.0/purchase_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-purchase_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 is used to integrated between Purchase and Stock to send
Operating Unit in the warehouse that has been selected from Deliver To to Stock Picking.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Create a purchase order
#. Select Deliver To that have operating unit in warehouse
#. Confirm purchase order
#. you should have your operating unit on your stock 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:%20purchase_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
~~~~~~~

* Ecosoft

Contributors
~~~~~~~~~~~~

* Saran Lim. <saranl@ecosoft.co.th>
* Alan Ramos <alan.ramos@jarsa.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.

.. |maintainer-Saran440| image:: https://github.com/Saran440.png?size=40px
:target: https://github.com/Saran440
:alt: Saran440

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Saran440|

This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/16.0/purchase_stock_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions purchase_stock_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
16 changes: 16 additions & 0 deletions purchase_stock_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Purchase Stock Operating Unit",
"summary": "Copies the operating unit of purchase picking to the stock picking",
"version": "16.0.1.0.0",
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/operating-unit",
"category": "Purchase Management",
"depends": ["purchase_operating_unit", "stock_operating_unit"],
"license": "AGPL-3",
"data": [],
"installable": True,
"maintainers": ["Saran440"],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_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: purchase_stock_operating_unit
#: code:addons/purchase_stock_operating_unit/models/purchase.py:0
#, python-format
msgid ""
"Configuration error. The Operating Unit in the Purchase and Deliver To must "
"be the same."
msgstr ""

#. module: purchase_stock_operating_unit
#: model:ir.model,name:purchase_stock_operating_unit.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_stock_operating_unit
#: model:ir.model,name:purchase_stock_operating_unit.model_purchase_order_line
msgid "Purchase Order Line"
msgstr ""
5 changes: 5 additions & 0 deletions purchase_stock_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import purchase_order_line
from . import purchase
from . import stock_rule
40 changes: 40 additions & 0 deletions purchase_stock_operating_unit/models/purchase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, models
from odoo.exceptions import UserError


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.onchange("operating_unit_id")
def _onchange_operating_unit_id(self):
if self.operating_unit_id:
self.picking_type_id = self.env["stock.picking.type"].search(
[
("warehouse_id.operating_unit_id", "=", self.operating_unit_id.id),
("code", "=", "incoming"),
],
limit=1,
)

@api.onchange("picking_type_id")
def _onchange_picking_type_id(self):
if self.picking_type_id:
self.operating_unit_id = self.picking_type_id.warehouse_id.operating_unit_id

@api.constrains("operating_unit_id", "picking_type_id")
def _check_operating_unit_picking_type(self):
for rec in self:
if (
rec.operating_unit_id
and rec.operating_unit_id
!= rec.picking_type_id.warehouse_id.operating_unit_id
):
raise UserError(
_(
"Configuration error. The Operating Unit in "
"the Purchase and Deliver To must be the same."
)
)
15 changes: 15 additions & 0 deletions purchase_stock_operating_unit/models/purchase_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

def _prepare_stock_moves(self, picking):
"""Add operating unit from warehouse to picking"""
picking.operating_unit_id = (
picking.picking_type_id.warehouse_id.operating_unit_id
)
return super()._prepare_stock_moves(picking)
14 changes: 14 additions & 0 deletions purchase_stock_operating_unit/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class StockRule(models.Model):
_inherit = "stock.rule"

def _prepare_purchase_order(self, company_id, origins, values):
res = super()._prepare_purchase_order(company_id, origins, values)
if self.operating_unit_id:
res["operating_unit_id"] = self.operating_unit_id.id
return res
2 changes: 2 additions & 0 deletions purchase_stock_operating_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Saran Lim. <saranl@ecosoft.co.th>
* Alan Ramos <alan.ramos@jarsa.com>
2 changes: 2 additions & 0 deletions purchase_stock_operating_unit/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module is used to integrated between Purchase and Stock to send
Operating Unit in the warehouse that has been selected from Deliver To to Stock Picking.
6 changes: 6 additions & 0 deletions purchase_stock_operating_unit/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To use this module, you need to:

#. Create a purchase order
#. Select Deliver To that have operating unit in warehouse
#. Confirm purchase order
#. you should have your operating unit on your stock picking
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 9a67f3d

Please sign in to comment.