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

[15.0][IMP] project_stock: Avoid defining the project in the analytic items to avoid incoherence. #1048

Merged
merged 1 commit into from
Dec 12, 2022
Merged
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
3 changes: 3 additions & 0 deletions project_stock/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def _prepare_analytic_line_from_task(self):
vals["ref"] = task.name
if "product_id" in analytic_line_fields:
vals["product_id"] = product.id
# Prevent incoherence when hr_timesheet addon is installed.
if "project_id" in analytic_line_fields:
vals["project_id"] = False
# tags + distributions
if task.stock_analytic_tag_ids:
vals["tag_ids"] = [(6, 0, task.stock_analytic_tag_ids.ids)]
Expand Down
3 changes: 3 additions & 0 deletions project_stock/tests/test_project_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def _test_task_analytic_lines_from_task(self, amount):
self.analytic_account,
stock_analytic_lines.mapped("account_id"),
)
# Prevent incoherence when hr_timesheet addon is installed.
if "project_id" in self.task.stock_analytic_line_ids._fields:
self.assertFalse(self.task.stock_analytic_line_ids.project_id)

def test_project_task_without_analytic_account(self):
self.task = self.env["project.task"].browse(self.task.id)
Expand Down