Skip to content

Commit

Permalink
Revert "TA#70584 [14.0][DEL] stock_location_production (#441)"
Browse files Browse the repository at this point in the history
This reverts commit 19459ba.
  • Loading branch information
majouda authored Nov 12, 2024
1 parent 19459ba commit 511f773
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 51 deletions.
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"project_time_range",
"project_timesheet_analytic_update",
"project_type",
"stock_location_production",
"project_wip",
"project_wip_material",
"timesheet_task_project_no_change",
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ COPY project_timesheet_analytic_update /mnt/extra-addons/project_timesheet_anal
COPY project_type /mnt/extra-addons/project_type
COPY project_wip /mnt/extra-addons/project_wip
COPY project_wip_material /mnt/extra-addons/project_wip_material
COPY stock_location_production /mnt/extra-addons/stock_location_production
COPY timesheet_task_project_no_change /mnt/extra-addons/timesheet_task_project_no_change


Expand Down
3 changes: 2 additions & 1 deletion project_material/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Project Material",
"version": "14.0.1.3.0",
"version": "14.0.1.2.1",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
Expand All @@ -12,6 +12,7 @@
"summary": "Consume material on projects",
"depends": [
"project_task_date_planned",
"stock_location_production",
"stock_account",
"purchase_stock",
],
Expand Down
7 changes: 0 additions & 7 deletions project_material/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,3 @@ msgid ""
msgstr ""
"Vous ne pouvez pas modifier l'article ou la tâche sur la ligne de matériel "
"{line} car elle est liée à un (des) mouvement(s) de stock au statut terminé."


#. module: project_material
#: code:addons/project_material/models/stock_warehouse.py:73
#, python-format
msgid "You need to have a property_stock_production for product.template. Please contact your administrator or manager."
msgstr "Vous devez définir une property_stock_production pour product.template. Veuillez contacter votre administrateur ou manager."
52 changes: 15 additions & 37 deletions project_material/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class Warehouse(models.Model):

_inherit = "stock.warehouse"

def _get_default_consumption_location_id(self):
return self.env.ref(
"stock_location_production.location_production", raise_if_not_found=False
).id

consu_steps = fields.Selection(
[(ONE_STEP_KEY, ONE_STEP_DESCRIPTION)], default=ONE_STEP_KEY
)
Expand All @@ -23,47 +28,27 @@ def _has_one_step_consumption(self):
consu_location_id = fields.Many2one(
"stock.location",
"Consumption Location",
domain="[('usage', '=', 'production'), ('company_id', '=', company_id)]",
compute='_compute_consu_location_id',
domain=[("usage", "=", "production")],
ondelete="restrict",
store=True,
check_company=True,
default=_get_default_consumption_location_id,
)

consu_type_id = fields.Many2one(
"stock.picking.type",
"Consumption Picking Type",
ondelete="restrict",
check_company=True,
"stock.picking.type", "Consumption Picking Type", ondelete="restrict"
)

consu_return_type_id = fields.Many2one(
"stock.picking.type",
"Consumption Return Picking Type",
ondelete="restrict",
check_company=True,
"stock.picking.type", "Consumption Return Picking Type", ondelete="restrict"
)

consu_route_id = fields.Many2one(
"stock.location.route",
"Consumption Route",
ondelete="restrict",
domain="[('company_id', '=', company_id)]",
check_company=True,
"stock.location.route", "Consumption Route", ondelete="restrict"
)

consu_mto_pull_id = fields.Many2one(
"stock.rule", "Consumption MTO Pull", ondelete="restrict",
"stock.rule", "Consumption MTO Pull", ondelete="restrict"
)

@api.depends('company_id')
def _compute_consu_location_id(self):
for record in self:
Proprerty = self.env["ir.property"].with_company(record.company_id)
record.consu_location_id = Proprerty._get(
"property_stock_production", "product.template"
).id

@api.model
def create(self, vals):
"""When creating a new warehouse, create the consumption route.
Expand Down Expand Up @@ -98,6 +83,7 @@ def _create_or_update_consumption_picking_types(self):
def _create_consumption_picking_types(self):
vals = self._get_consumption_picking_type_create_values()
self.consu_type_id = self.env["stock.picking.type"].create(vals)

vals = self._get_consumption_return_picking_type_create_values()
self.consu_return_type_id = self.env["stock.picking.type"].create(vals)

Expand Down Expand Up @@ -195,7 +181,6 @@ def _get_consumption_return_sequence_values(self):
}

def _create_or_update_consumption_route(self):
self = self.with_company(self.company_id)
if self.consu_route_id:
self._update_consumption_route()
else:
Expand Down Expand Up @@ -317,23 +302,16 @@ def _has_two_steps_consumption(self):
consu_prep_location_id = fields.Many2one(
"stock.location",
"Preparation Picking Location",
domain="[('usage', '=', 'internal'), ('company_id', '=', company_id)]",
domain=[("usage", "=", "internal")],
ondelete="restrict",
check_company=True,
)

consu_prep_type_id = fields.Many2one(
"stock.picking.type",
"Preparation Picking Type",
ondelete="restrict",
check_company=True,
"stock.picking.type", "Preparation Picking Type", ondelete="restrict"
)

consu_prep_return_type_id = fields.Many2one(
"stock.picking.type",
"Preparation Return Picking Type",
ondelete="restrict",
check_company=True,
"stock.picking.type", "Preparation Return Picking Type", ondelete="restrict"
)

def _create_consumption_route(self):
Expand Down
8 changes: 2 additions & 6 deletions project_material/tests/test_consumption_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ def setUpClass(cls):

class TestConsumptionStep(ConsumptionRouteCase):
def test_default_consumption_location(self):
consu_location_id = (
self.env["ir.property"]
.with_company(self.new_company.id)
._get("property_stock_production", "product.template")
assert self.new_warehouse.consu_location_id == self.env.ref(
"stock_location_production.location_production"
)
self.assertTrue(consu_location_id.exists())
assert self.new_warehouse.consu_location_id.id == consu_location_id.id

def test_main_warehouse_has_consumption_route(self):
assert self.main_warehouse.consu_route_id
Expand Down
7 changes: 7 additions & 0 deletions stock_location_production/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Stock Picking Split Quantity
============================
This module adds a Production Stock Location data.

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)
2 changes: 2 additions & 0 deletions stock_location_production/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
18 changes: 18 additions & 0 deletions stock_location_production/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{

Check warning on line 4 in stock_location_production/__manifest__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

stock_location_production/__manifest__.py#L4

Statement seems to have no effect
"name": "Stock Location Production",
"version": "1.0.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
"license": "AGPL-3",
"category": "Stock",
"depends": ["stock"],
"summary": """
Add a Production Stock Location data.
""",
"data": ["data/stock_data.xml"],
"installable": True,
}
11 changes: 11 additions & 0 deletions stock_location_production/data/stock_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="location_production" model="stock.location">
<field name="name">Production</field>
<field name="location_id" ref="stock.stock_location_locations_virtual"/>
<field name="usage">production</field>
<field name="company_id"></field>
</record>
</data>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 511f773

Please sign in to comment.