How to duplicate the project and tasks (using button) without using the Duplicate option present in default odoo?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
Hi,
For your previous questions on the same, there is some solution provided and seems the answer is marked as resolved: https://www.odoo.com/forum/help-1/question/project-and-task-duplication-146234
if you are not looking to use the copy function, you can use create methods and create the record in the corresponding model.
Add a button:
<button type="object" name="copy_pro" string="copy button"/>
Then in Python:
@api.multi
def copy_pro(self):
for rec in self:
# add all the necessary fields to pro_vals dict
pro_vals = {
'name': rec.name
}
new_pro = self.env['project.project'].create(pro_vals)
# search tasks of this project
task_rec = self.env['project.task'].search([('project_id', '=', rec.id)])
for task in task_rec:
# add all the necessary fields to task_vals dict
task_vals = {
'project_id': new_pro.id
}
new_task = self.env['project.task'].create(task_vals)
Thanks
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się
it worked. Thank you