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

[8.0.1.0.0][hr_timesheet_auto_input] T0040 #213

Closed
wants to merge 4 commits into from
Closed

Conversation

mikevhe18
Copy link
Contributor

No description provided.

@mikevhe18 mikevhe18 requested a review from andhit-r April 22, 2020 02:41
@coveralls
Copy link

coveralls commented Apr 22, 2020

Coverage Status

Coverage decreased (-0.09%) to 56.968% when pulling 5999b20 on 8.0-T0040 into 57d54a1 on 8.0.

Comment on lines 18 to 34
<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>
Copy link
Member

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

Comment on lines 30 to 44
@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)]}}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@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

Comment on lines 114 to 122
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)
Copy link
Member

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

Comment on lines 10 to 16
<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>
Copy link
Member

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):
Copy link
Member

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 =\
Copy link
Member

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

Copy link
Contributor Author

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 =\
Copy link
Member

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

Copy link
Contributor Author

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 =\
Copy link
Member

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")],
Copy link
Member

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.

Copy link
Contributor Author

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")],
Copy link
Member

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

@andhit-r andhit-r closed this Nov 10, 2020
@andhit-r andhit-r deleted the 8.0-T0040 branch October 23, 2022 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants