Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main
Open

Sourcery refactored main branch#1
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main

Conversation

@sourcery-ai
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot commented Apr 11, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from barackvn April 11, 2023 04:36
Copy link
Copy Markdown
Author

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -22 to +27
if not duration:
duration = _("unknown")
else:
duration = str(duration)
duration = str(duration) if duration else _("unknown")
meet_date = fields.Datetime.from_string(meeting_date)
meeting_usertime = fields.Datetime.to_string(
fields.Datetime.context_timestamp(self, meet_date)
)
html_time = "<time datetime='%s+00:00'>%s</time>" % (
meeting_date,
meeting_usertime,
)
html_time = f"<time datetime='{meeting_date}+00:00'>{meeting_usertime}</time>"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Event.log_meeting refactored with the following changes:

Comment on lines -42 to +36
description = "Event: " + self.name
description = f"Event: {self.name}"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Event.action_schedule_meeting refactored with the following changes:

Comment on lines -13 to -22
# event_id = details.get("_event_id")
registrations = super(
return super(
ExtendedWebsiteEventController, self
)._process_registration_details(details)
# event_id = request.env["event.registration"].sudo().browse([int(event_id)])

# for registration in registrations:
# registration["event_id"] = event_id.id
# registration["is_a_template"] = True
return registrations
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function AttTemplateWebsiteEvent._process_registration_details refactored with the following changes:

This removes the following comments ( why? ):

# event_id = request.env["event.registration"].sudo().browse([int(event_id)])
# event_id = details.get("_event_id")
# for registration in registrations:
#     registration["event_id"] = event_id.id
#     registration["is_a_template"] = True

Comment on lines -60 to +55
_logger.info("Available Events:{} - {}".format(all_attendee_ids.ids, all_attendee_ids.mapped('event_id')))
_logger.info(
f"Available Events:{all_attendee_ids.ids} - {all_attendee_ids.mapped('event_id')}"
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function AttTemplateLateReg.website_registration_complete refactored with the following changes:

Comment on lines -101 to +96
registrations.setdefault(att_id, dict())[field_name] = value
registrations.setdefault(att_id, {})[field_name] = value
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function AttTemplateLateReg.website_registration_complete_submit refactored with the following changes:

Comment on lines -147 to +139
"A reminder containing the following link has been sent to the attendee's related partner: %s"
% self.event_token_url
f"A reminder containing the following link has been sent to the attendee's related partner: {self.event_token_url}"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function SaleOrder.send_late_reg_event_notification refactored with the following changes:

Comment on lines -159 to +151
event_template = product_id.event_template_id
if product_id.product_tmpl_id.is_event_product:
event_template = product_id.event_template_id
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function SaleOrderLine.create_event_from_order_line refactored with the following changes:

Comment on lines -249 to -250
event_template = product_id.event_template_id

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function SaleOrderLine.join_event_from_order_line refactored with the following changes:

Comment on lines -314 to +308
event_template_id = (
if event_template_id := (
order_line.event_id
or order_line.product_id.product_tmpl_id.event_template_id
)
if event_template_id:
):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function SaleOrderLine._update_registrations refactored with the following changes:

Comment on lines -103 to -104
event_template = product_id.product_tmpl_id.event_template_id

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Task.join_event_from_task refactored with the following changes:

Comment on lines -30 to +33
attendee_template_id = a.template_id if a.template_id else a
attendee_template_id = a.template_id or a
attendee_ids = a
#event_ids = a.event_id

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function CertificateReport._get_report_values refactored with the following changes:

view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
_logger.info('Context %s'%self.env.context)
_logger.info(f'Context {self.env.context}')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function AccountInvoiceSend.fields_view_get refactored with the following changes:

Comment on lines -64 to +87
if self.generate_certificates and self.event_ids:
so_line_ids = []
active_id = self.env.context.get('active_id', False)
if self.env.context.get('params', False):
params = self.env.context.get('params', False)
if params['model'] == 'account.move':
active_id = params['id']
invoice_id = self.env["account.move"].browse(active_id)
for inv_line in invoice_id.invoice_line_ids:
so_line_ids += inv_line.sale_line_ids.ids
cert_ids = self.event_ids.generate_event_certificates(
invoice_id.id, so_line_ids
)
_logger.info('Certificate %s'%cert_ids)
if cert_ids:
cert_attachment_ids = self.env["ir.attachment"].search(
[
("res_model", "in", ["event.certificate"]),
("res_id", "in", cert_ids.ids)
]
)
if cert_attachment_ids:
self.attachment_ids = [(6,0,self.attachment_ids.ids + cert_attachment_ids.ids)] No newline at end of file
if not self.generate_certificates or not self.event_ids:
return
so_line_ids = []
active_id = self.env.context.get('active_id', False)
if self.env.context.get('params', False):
params = self.env.context.get('params', False)
if params['model'] == 'account.move':
active_id = params['id']
invoice_id = self.env["account.move"].browse(active_id)
for inv_line in invoice_id.invoice_line_ids:
so_line_ids += inv_line.sale_line_ids.ids
cert_ids = self.event_ids.generate_event_certificates(
invoice_id.id, so_line_ids
)
_logger.info(f'Certificate {cert_ids}')
if cert_ids:
if cert_attachment_ids := self.env["ir.attachment"].search(
[
("res_model", "in", ["event.certificate"]),
("res_id", "in", cert_ids.ids),
]
):
self.attachment_ids = [(6,0,self.attachment_ids.ids + cert_attachment_ids.ids)] No newline at end of file
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function AccountInvoiceSend.button_generate_certificates refactored with the following changes:

Comment on lines -24 to +30
order.has_event_product = False
for line in order.order_line:
if (
order.has_event_product = any(
(
line.product_id.is_event_product
and line.product_id.event_template_id
):
order.has_event_product = True
break
)
for line in order.order_line
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function SaleOrder._compute_has_event_product refactored with the following changes:

  • Use any() instead of for loop (use-any)

product_id = line.product_id
event_template = product_id.event_template_id
if product_id.is_event_product:
event_template = product_id.event_template_id
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function SaleOrder.button_create_event refactored with the following changes:

Comment on lines -57 to +56
event_template = product_id.event_template_id
if product_id.is_event_product:
event_template = product_id.event_template_id
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function SaleOrderLine.create_event_from_order_line refactored with the following changes:

Comment on lines -43 to +59
if not self.sale_order_line_id:
return {"domain": {"event_id": []}}
return {
"domain": {
"event_id": [
(
"event_template_id.id",
"=",
self.sale_order_line_id.product_id.event_template_id.id,
),
("state", "!=", "cancel"),
("date_begin", ">=", datetime.today().strftime("%Y-%m-%d")),
]
return (
{
"domain": {
"event_id": [
(
"event_template_id.id",
"=",
self.sale_order_line_id.product_id.event_template_id.id,
),
("state", "!=", "cancel"),
("date_begin", ">=", datetime.now().strftime("%Y-%m-%d")),
]
}
}
}
if self.sale_order_line_id
else {"domain": {"event_id": []}}
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function EventJoinExisting.onchange_sale_order_line_id refactored with the following changes:

Comment on lines -62 to +72
if not self.event_id:
return {"domain": {"ticket_id": []}}
return {
"domain": {"ticket_id": [("id", "in", self.event_id.event_ticket_ids.ids)]}
}
return (
{
"domain": {
"ticket_id": [("id", "in", self.event_id.event_ticket_ids.ids)]
}
}
if self.event_id
else {"domain": {"ticket_id": []}}
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function EventJoinExisting.onchange_event_id refactored with the following changes:

Comment on lines -74 to +87
if self.event_id:
if self.ticket_id:
self.sale_order_line_id.join_event_from_order_line(
self.event_id, self.ticket_id
)
else:
raise UserError(_("Please select a ticket."))
else:
if not self.event_id:
raise UserError(_("Please select an event to join."))
if self.ticket_id:
self.sale_order_line_id.join_event_from_order_line(
self.event_id, self.ticket_id
)
else:
raise UserError(_("Please select a ticket."))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function EventJoinExisting.button_manage_events refactored with the following changes:

Comment on lines -28 to +44
if not self.task_id:
return {"domain": {"event_id": []}}
return {
"domain": {
"event_id": [
(
"event_template_id.id",
"=",
self.task_id.sale_line_id.product_id.event_template_id.id,
),
("state", "!=", "cancel"),
("date_begin", ">=", datetime.today()),
]
return (
{
"domain": {
"event_id": [
(
"event_template_id.id",
"=",
self.task_id.sale_line_id.product_id.event_template_id.id,
),
("state", "!=", "cancel"),
("date_begin", ">=", datetime.now()),
]
}
}
}
if self.task_id
else {"domain": {"event_id": []}}
)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function EventJoinExisting.onchange_sale_order_line_id refactored with the following changes:

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.

0 participants