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

IMP Create related project from template #337

Closed
wants to merge 10 commits into from

Conversation

rubencabrera
Copy link

Added the possibility of setting a project template to allow salesperson to directly create related project from it.

@rubencabrera
Copy link
Author

@carlosap92

Copy link
Sponsor Member

@dreispt dreispt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT, just a few improvement suggestions

})
else:
project = project_obj.create(vals)
order.write({
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order.write is repeated in the if and else. You can have it only once, outside the if-else.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, seems github doesn't take the change as done but it's out of the if/else now. Thanks for pointing it out!

})
return True
if order.project_template_id:
new_date_start = time.strftime('%Y-%m-%d')
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more correct to use fields.Date. context_today(). See http://www.odoo.com/documentation/10.0/reference/orm.html

new_date_end = (datetime(*time.strptime(
new_date_start,
'%Y-%m-%d'
)[:3])+(end_date-start_date)).strftime('%Y-%m-%d')
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT if the template has start and end dates, you take the duration from it and apply it to the new project.
This feature should be documented, at least in the README.
You get bonus points if you can improve the readability to make this evident 😸

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to the README, with the text to datetime conversions I find it quite difficult to make the code readable. But if you have any idea of how to tackle it, I'd like to try.

@oca-clabot
Copy link

Hey @rubencabrera, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/website.cla
Here is a list of the users:

  • Sergio Díaz (no github login found)

Appreciation of efforts,
OCA CLAbot

@@ -30,6 +30,10 @@
class SaleOrder(models.Model):
_inherit = "sale.order"

description = fields.Char(
string = 'Descripción del proyecto'
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in english

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 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 PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jan 30, 2022
@github-actions github-actions bot closed this Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants