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
Conversation
There was a problem hiding this 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
sale_order_project/models/sale.py
Outdated
}) | ||
else: | ||
project = project_obj.create(vals) | ||
order.write({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
sale_order_project/models/sale.py
Outdated
}) | ||
return True | ||
if order.project_template_id: | ||
new_date_start = time.strftime('%Y-%m-%d') |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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 😸
There was a problem hiding this comment.
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.
…ct into sale_order_project_template
Hey @rubencabrera, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
@@ -30,6 +30,10 @@ | |||
class SaleOrder(models.Model): | |||
_inherit = "sale.order" | |||
|
|||
description = fields.Char( | |||
string = 'Descripción del proyecto' |
There was a problem hiding this comment.
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
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. |
Added the possibility of setting a project template to allow salesperson to directly create related project from it.