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

TA#70584 [14.0][IMP] project_material #447

Open
wants to merge 23 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d523be4
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
c30f187
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
fc36311
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
f67c6ed
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
9d0442a
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
5877377
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
a44126a
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
247355c
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
2ce99fb
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
4f4b551
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Oct 30, 2024
a57ad79
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
ec8352b
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
72eecf5
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
79c6557
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
8c38261
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
ca9260a
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
230aa7a
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
8569d01
TA#70584 [14.0][DEL] stock_location_production
abenzbiria Nov 1, 2024
da1a8c7
Merge branch '14.0' into TA#70584
majouda Nov 10, 2024
0a7df5a
TA#70584 [14.0][FIX] project_material: Multico Issues
majouda Nov 11, 2024
940ec2b
TA#70584 [14.0][IMP] project_material
majouda Nov 19, 2024
aec2bd7
TA#70584 [14.0][IMP] project_material
majouda Nov 19, 2024
2fd5edd
Merge branch '14.0' into TA#70584
majouda Nov 19, 2024
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
1 change: 0 additions & 1 deletion .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"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: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ 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: 1 addition & 2 deletions 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.2.1",
"version": "14.0.1.4.0",
"author": "Numigi",
"maintainer": "Numigi",
"website": "https://bit.ly/numigi-com",
Expand All @@ -12,7 +12,6 @@
"summary": "Consume material on projects",
"depends": [
"project_task_date_planned",
"stock_location_production",
"stock_account",
"purchase_stock",
],
Expand Down
7 changes: 7 additions & 0 deletions project_material/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,10 @@ 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."
1 change: 1 addition & 0 deletions project_material/init_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ def _setup_warehouses_consumption_routes(env):
for warehouse in warehouses:
warehouse._create_or_update_consumption_picking_types()
warehouse._create_or_update_consumption_route()
warehouse._create_consumption_mto_pull()
13 changes: 5 additions & 8 deletions project_material/models/project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,22 @@ def write(self, vals):

def copy(self, vals=None):
task = super().copy(vals)

if self.material_line_ids:
task.procurement_disabled = True
task._copy_material_lines_from(self)

return task

@api.onchange("project_id")
def _onchange_project_enable_procurements(self):
if self.project_id:
self.procurement_disabled = False

def _copy_material_lines_from(self, task):
if not self.date_planned:
self.date_planned = date(2099, 1, 1)

for line in task.material_line_ids:
line.copy({"task_id": self.id})

@api.onchange("project_id")
def _onchange_project_enable_procurements(self):
if self.project_id:
self.procurement_disabled = False

def _run_procurements(self):
for line in self.mapped("material_line_ids"):
line._run_procurements()
Expand Down
4 changes: 0 additions & 4 deletions project_material/models/project_task_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,9 @@ def _propagate_planned_date_to_stock_moves(self):
moves_to_update = moves.filtered(
lambda m: m.state not in ("done", "cancel")
)

delay = moves_to_update.mapped("rule_id.delay")
if delay:
date_planned = date_planned - timedelta(delay[0])

# FIX ME : update date_expected on v12 but use what field on v14 instead
# Maybe `date` ?
moves_to_update.with_context(do_not_propagate=True).write(
{"date": date_planned}
)
Expand Down
4 changes: 4 additions & 0 deletions project_material/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ class StockMove(models.Model):
index=True,
ondelete="restrict",
readonly=True,
check_company=True,
)

project_id = fields.Many2one(
related="task_id.project_id",
store=True,
readonly=True,
check_company=True,
)
material_line_id = fields.Many2one(
"project.task.material",
"Material Line",
index=True,
ondelete="restrict",
check_company=True,
)

def _get_new_picking_values(self):
Expand Down Expand Up @@ -51,6 +54,7 @@ class StockMoveWithNoAggregation(models.Model):
"Destination Material Line",
compute="_compute_destination_material_line_id",
store=True,
check_company=True,
)

@api.depends("material_line_id", "move_dest_ids")
Expand Down
2 changes: 2 additions & 0 deletions project_material/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class StockPicking(models.Model):
"project.task",
index=True,
ondelete="restrict",
check_company=True,
)
project_id = fields.Many2one(
related="task_id.project_id",
store=True,
readonly=True,
check_company=True,
)

task_readonly = fields.Boolean(compute="_compute_task_modifiers")
Expand Down
31 changes: 4 additions & 27 deletions project_material/models/stock_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,7 @@
class StockRule(models.Model):
_inherit = "stock.rule"

def _get_stock_move_values(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
):
result = super()._get_stock_move_values(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)
result["material_line_id"] = values.get("material_line_id")
result["task_id"] = values.get("task_id")
if self.group_propagation_option == "propagate":
group_id = values.get("group_id", False) and values["group_id"].id
result["group_id"] = group_id
return result
def _get_custom_move_fields(self):
fields = super(StockRule, self)._get_custom_move_fields()
fields += ["material_line_id", "task_id"]
return fields
55 changes: 40 additions & 15 deletions project_material/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ 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 @@ -28,27 +23,51 @@ def _has_one_step_consumption(self):
consu_location_id = fields.Many2one(
"stock.location",
"Consumption Location",
domain=[("usage", "=", "production")],
domain="[('usage', '=', 'production'), ('company_id', '=', company_id)]",
compute='_compute_consu_location_id',
ondelete="restrict",
default=_get_default_consumption_location_id,
store=True,
check_company=True,
)

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

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

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

consu_mto_pull_id = fields.Many2one(
"stock.rule", "Consumption MTO Pull", ondelete="restrict"
"stock.rule",
"Consumption MTO Pull",
ondelete="restrict",
domain="[('company_id', '=', company_id)]",
check_company=True,
)

@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 @@ -83,7 +102,6 @@ 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 @@ -302,16 +320,23 @@ def _has_two_steps_consumption(self):
consu_prep_location_id = fields.Many2one(
"stock.location",
"Preparation Picking Location",
domain=[("usage", "=", "internal")],
domain="[('usage', '=', 'internal'), ('company_id', '=', company_id)]",
ondelete="restrict",
check_company=True,
)

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

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

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

class TestConsumptionStep(ConsumptionRouteCase):
def test_default_consumption_location(self):
assert self.new_warehouse.consu_location_id == self.env.ref(
"stock_location_production.location_production"
consu_location_id = (
self.env["ir.property"]
.with_company(self.new_company.id)
._get("property_stock_production", "product.template")
)
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
17 changes: 12 additions & 5 deletions project_material/views/stock_warehouse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
<field name="arch" type="xml">
<field name="delivery_steps" position="after">
<field name="consu_steps" string="Consumption" widget="radio"/>
<field name="view_location_id" invisible="1" required="0"/>
<field name="consu_prep_location_id" string="Preparation Location"
attrs="{'required': [('consu_steps', '=', 'two_steps')],
'invisible': [('consu_steps', '!=', 'two_steps')]}"
context="{'default_usage': 'internal',
</field>
<field name="wh_output_stock_loc_id" position="after">
<field name="consu_location_id" readonly="1"/>
<field name="consu_prep_location_id" string="Preparation Location" attrs="{'required': [('consu_steps', '=', 'two_steps')],
'invisible': [('consu_steps', '!=', 'two_steps')]}" context="{'default_usage': 'internal',
'default_location_id': view_location_id}"/>
</field>
<field name="out_type_id" position="after">
<field name="consu_type_id" readonly="1"/>
<field name="consu_return_type_id" readonly="1"/>
<field name="consu_prep_type_id" readonly="1"
attrs="{'invisible': [('consu_steps', '!=', 'two_steps')]}"/>
<field name="consu_prep_return_type_id" readonly="1" attrs="{'invisible': [('consu_steps', '!=', 'two_steps')]}"/>
</field>
</field>
</record>

Expand Down
7 changes: 0 additions & 7 deletions stock_location_production/README.rst

This file was deleted.

2 changes: 0 additions & 2 deletions stock_location_production/__init__.py

This file was deleted.

18 changes: 0 additions & 18 deletions stock_location_production/__manifest__.py

This file was deleted.

11 changes: 0 additions & 11 deletions stock_location_production/data/stock_data.xml

This file was deleted.

Empty file.
Loading