Skip to content
Open
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
62 changes: 62 additions & 0 deletions purchase_specific_location/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
==========================
Purchase Specific Location
==========================

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

.. |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-akretion%2Fak--odoo--incubator-lightgray.png?logo=github
:target: https://github.com/akretion/ak-odoo-incubator/tree/16.0/purchase_specific_location
:alt: akretion/ak-odoo-incubator

|badge1| |badge2| |badge3|

This module add a destination location on orderpoint and purchase order.
It allows to check the minimum stock on some parent location, but generate a PO on a specific sublocation
It also allow to create a PO directly for a sublocation of the global location configured on the choosen picking type.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/akretion/ak-odoo-incubator/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/akretion/ak-odoo-incubator/issues/new?body=module:%20purchase_specific_location%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
~~~~~~~

* Akretion

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

* Florian da Costa <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `akretion/ak-odoo-incubator <https://github.com/akretion/ak-odoo-incubator/tree/16.0/purchase_specific_location>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions purchase_specific_location/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
37 changes: 37 additions & 0 deletions purchase_specific_location/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 Akretion (<http://www.akretion.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

{
"name": "Purchase Specific Location",
"version": "16.0.1.0.0",
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/akretion/ak-odoo-incubator",
"summary": """
Allow to create reception in a sublocation of the location's orderpoint
""",
"license": "AGPL-3",
"category": "Generic Modules/Others",
"depends": ["purchase_stock"],
"data": [
"views/stock_orderpoint_view.xml",
"views/purchase_order_view.xml",
],
"installable": True,
}
4 changes: 4 additions & 0 deletions purchase_specific_location/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import stock_orderpoint
from . import stock_rule
from . import purchase_order
from . import procurement_group
24 changes: 24 additions & 0 deletions purchase_specific_location/models/procurement_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class ProcurementGroup(models.Model):
_inherit = "procurement.group"

@api.model
def run(self, procurements, raise_user_error=True):
new_procurements = []
for procurement in procurements:
orderpoint = procurement.values.get("orderpoint_id")
if (
self.env.context.get("from_orderpoint")
and orderpoint.location_destination_id
and orderpoint.location_id == procurement.location_id
):
new_procurements.append(
procurement._replace(location_id=orderpoint.location_destination_id)
)
else:
new_procurements.append(procurement)
return super().run(new_procurements, raise_user_error=raise_user_error)
31 changes: 31 additions & 0 deletions purchase_specific_location/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


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

specific_location_id = fields.Many2one(
"stock.location",
string="Specific Location",
compute="_compute_specific_location_id",
readonly=False,
store=True,
)
default_location_dest_id = fields.Many2one(
related="picking_type_id.default_location_dest_id", string="Default Location"
)

def _get_destination_location(self):
self.ensure_one()
if self.specific_location_id:
return self.specific_location_id.id
else:
return super()._get_destination_location()

@api.depends("picking_type_id")
def _compute_specific_location_id(self):
# reset in case the picking type changed
for po in self:
po.specific_location_id = False
9 changes: 9 additions & 0 deletions purchase_specific_location/models/stock_orderpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


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

location_destination_id = fields.Many2one("stock.location", "Destination Location")
21 changes: 21 additions & 0 deletions purchase_specific_location/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def _make_po_get_domain(self, company_id, values, partner):
domain = super()._make_po_get_domain(company_id, values, partner)
orderpoint = values.get("orderpoint_id", False)
dest_location = orderpoint.location_destination_id.id or False
domain += (("specific_location_id", "=", dest_location),)
return domain

def _prepare_purchase_order(self, company_id, origins, values):
vals = super()._prepare_purchase_order(company_id, origins, values)
values = values[0]
orderpoint = values.get("orderpoint_id", False)
vals["specific_location_id"] = orderpoint.location_destination_id.id or False
return vals
1 change: 1 addition & 0 deletions purchase_specific_location/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Florian da Costa <[email protected]>
3 changes: 3 additions & 0 deletions purchase_specific_location/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module add a destination location on orderpoint and purchase order.
It allows to check the minimum stock on some parent location, but generate a PO on a specific sublocation
It also allow to create a PO directly for a sublocation of the global location configured on the choosen picking type.
Loading
Loading