-
Notifications
You must be signed in to change notification settings - Fork 12
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
[8.0.1.0.0][hr_timesheet_auto_input] T0040 #213
Conversation
<label for="current_timesheet_account_id"/> | ||
<div> | ||
<field name="current_timesheet_account_id"/> | ||
</div> | ||
|
||
<label for="current_product_id"/> | ||
<div> | ||
<field name="current_product_id"/> | ||
</div> | ||
|
||
<label for="current_task_id"/> | ||
<div> | ||
<field name="current_task_id"/> | ||
</div> | ||
|
||
<label for="state_attendance"/> | ||
<div> |
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.
Biasakan untuk memberikan attribute name pada element group ataupun div
@api.multi | ||
@api.onchange( | ||
"timesheet_account_id", | ||
) | ||
def onchange_task_id(self): | ||
self.task_id = False | ||
if self.timesheet_account_id: | ||
obj_project = self.env["project.project"] | ||
criteria = [ | ||
("analytic_account_id", "=", self.timesheet_account_id.id) | ||
] | ||
project_ids = obj_project.search(criteria) | ||
if project_ids: | ||
task_id = project_ids.tasks.ids | ||
return {"domain": {"task_id": [("id", "in", task_id)]}} |
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.
@api.multi | |
@api.onchange( | |
"timesheet_account_id", | |
) | |
def onchange_task_id(self): | |
self.task_id = False | |
if self.timesheet_account_id: | |
obj_project = self.env["project.project"] | |
criteria = [ | |
("analytic_account_id", "=", self.timesheet_account_id.id) | |
] | |
project_ids = obj_project.search(criteria) | |
if project_ids: | |
task_id = project_ids.tasks.ids | |
return {"domain": {"task_id": [("id", "in", task_id)]}} | |
@api.multi | |
@api.onchange( | |
"timesheet_account_id", | |
) | |
def onchange_task_id(self): | |
self.task_id = False |
Onchangenya cukup itu aja mike. Domainnya nanti tinggal dikontrol dari domain di view
obj_hr_timesheet_sheet =\ | ||
self.env["hr_timesheet_sheet.sheet"] | ||
active_id = self.env.context.get("active_id", False) | ||
|
||
criteria = [ | ||
("id", "=", active_id) | ||
] | ||
hr_timesheet_sheet_ids =\ | ||
obj_hr_timesheet_sheet.search(criteria) |
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.
Ini lo cukup buat field sheet_id di wizardnya. Kemudian buat method defaultnya
<group> | ||
<field name="timesheet_account_id" attrs="{'required':[('state_attendance', '=', 'present')], 'invisible':[('state_attendance', '=', 'absent')]}"/> | ||
<field name="task_id" domain="[('id', '=', 0)]" attrs="{'invisible':[('state_attendance', '=', 'absent')]}"/> | ||
<field name="product_id" attrs="{'required':[('state_attendance', '=', 'present')], 'invisible':[('state_attendance', '=', 'absent')]}"/> | ||
<field name="description" attrs="{'required':[('state_attendance', '=', 'absent')], 'invisible':[('state_attendance', '=', 'present')]}"/> | ||
<field name="state_attendance" invisible="1"/> | ||
</group> |
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.
Berikan attribute name untuk elemen group
} | ||
|
||
@api.multi | ||
def create_analytic_timesheet(self, sheet_ids): |
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.
Param sheet_ids tidak diperlukan jika field sheet_id ditambahkan di wizard
sheet_ids.current_timesheet_account_id.id | ||
task_id =\ | ||
sheet_ids.current_task_id.id | ||
product_id =\ |
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.
Jika tidak ada conditional nilai ini bisa langsung diberikan di return
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.
@andhit-r nilai ini sudah dibuat required dari awal, jadi pasti ga mungkin ga ada isinya mas
sheet_ids.current_task_id.id | ||
product_id =\ | ||
sheet_ids.current_product_id.id | ||
journal_id =\ |
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.
Jika tidak ada conditional nilai ini bisa langsung diberikan di return
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.
@andhit-r nilai ini tergatung dari sheet employee_id dimana isinya tidak mungkin kosong, jadi pasti ga mungkin ga ada isinya mas
sheet_ids.current_product_id.id | ||
journal_id =\ | ||
sheet_ids.employee_id.journal_id.id | ||
difference =\ |
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.
Jika tidak ada conditional nilai ini bisa langsung diberikan di return
timesheet_account_id = fields.Many2one( | ||
string="Timesheet Account", | ||
comodel_name="account.analytic.account", | ||
domain=[("type", "<>", "view")], |
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.
Tidak perlu domain. Gunakan strategi allowed_timesheet_account_ids.
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.
@andhit-r kalau menggunakan strategi allowed_timesheet_account_ids, berarti untuk pengisian manual di timesheet pun harus dibuat allowednya, domain disini gw samakan sama domain awal form timesheet biar ga ada perbedaan
product_id = fields.Many2one( | ||
string="Product", | ||
comodel_name="product.product", | ||
domain=[("type", "=", "service")], |
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.
Tidak perlu domain. Gunakan allowed_product_categ_ids atau allowed_product_ids dari modul hr_timesheet_product_policy
No description provided.