project
project copied to clipboard
[13.0][project_key] unable to change key for project already created from a template (and having tasks)
current module doesn't play nice with project_template.
use case:
- create a project and set it as a template. Set key = "BRX"
- using a service product configured with "Service Tracking" as "Create a task in sales" and select the template in point 1.
- On SO (having the product of point 2) confirmation, the project is created with not nice key while would expect template provided key with either increment (BRX1, BRX2) or other addition to the provided key to render it unique.
- unable to change the project key once there are existing tasks. getting error: "Task key must be unique!"
This is solved by adding the key to the task's form view and manually modifying the task's keys before having the project new key accepted.
We have the same problems using sale_timesheet and project_key addons. I started to look at the code of project_key addon and AFAIU I think it's not a problem caused by the project_template addon. Fixed/Improved some functionality of project_key addon with PR #756 After this I would like to start a new addon sale_timesheet_project_key (like glue addon) to generate proper project keys for service tracking functionality.
This should work:
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
def _timesheet_create_project_prepare_values(self):
values = super()._timesheet_create_project_prepare_values()
if values and "name" in values:
values["key"] = values["name"] # sales order sequence number as project key (uniq)
return values
Still have some problems that ir.sequence number of product template project is still changing, too
This PR fixes some problems of project_key addon. Would be nice to support this PR. Thank you.
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.