Browse Source

[REF] abide by line length rules

pull/142/head
robin.keunen 5 years ago
parent
commit
88a977d1f8
  1. 6
      beesdoo_base/models/partner.py
  2. 7
      beesdoo_product/models/beesdoo_product.py
  3. 9
      beesdoo_shift/models/cooperative_status.py
  4. 10
      beesdoo_shift/models/planning.py
  5. 15
      beesdoo_shift/models/task.py
  6. 6
      beesdoo_shift/wizard/extension.py
  7. 3
      beesdoo_shift/wizard/holiday.py
  8. 6
      beesdoo_shift/wizard/temporary_exemption.py
  9. 25
      beesdoo_shift_attendance/models/attendance_sheet.py
  10. 8
      beesdoo_shift_attendance/wizard/validate_attendance_sheet.py
  11. 3
      beesdoo_stock_coverage/__manifest__.py
  12. 3
      beesdoo_stock_coverage/models/product_template.py
  13. 8
      beesdoo_stock_coverage/tests/test_stock_coverage.py
  14. 27
      beesdoo_website_shift/controllers/main.py
  15. 6
      beesdoo_worker_status/models/cooperative_status.py
  16. 3
      purchase_order_generator/models/purchase_order_generator.py
  17. 7
      website_portal_restrict_modification/controllers/main.py

6
beesdoo_base/models/partner.py

@ -53,11 +53,13 @@ class Partner(models.Model):
):
raise ValidationError(
_(
"You try to assign a eater to a worker but this eater is already assign to %s please remove it before"
"You try to assign a eater to a worker but this eater "
"is already assign to %s please remove it before "
)
% rec.parent_eater_id.name
)
# replace many2many command when writing on child_eater_ids to just remove the link
# replace many2many command when writing on child_eater_ids to just
# remove the link
if "child_eater_ids" in values:
for command in values["child_eater_ids"]:
if command[0] == 2:

7
beesdoo_product/models/beesdoo_product.py

@ -151,10 +151,9 @@ class BeesdooProduct(models.Model):
@api.depends("seller_ids", "seller_ids.date_start")
def _compute_main_seller_id(self):
self.ensure_one()
# Calcule le vendeur associé qui a la date de début la plus récente et plus petite qu’aujourd’hui
sellers_ids = (
self._get_main_supplier_info()
) # self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True)
# Calcule le vendeur associé qui a la date de début la plus récente
# et plus petite qu’aujourd’hui
sellers_ids = self._get_main_supplier_info()
self.main_seller_id = sellers_ids and sellers_ids[0].name or False
@api.multi

9
beesdoo_shift/models/cooperative_status.py

@ -56,7 +56,8 @@ class CooperativeStatus(models.Model):
]
today = fields.Date(
help="Field that allow to compute field and store them even if they are based on the current date",
help="Field that allow to compute field and store them even if they "
"are based on the current date",
default=fields.Date.today,
)
cooperator_id = fields.Many2one("res.partner")
@ -71,7 +72,8 @@ class CooperativeStatus(models.Model):
time_extension = fields.Integer(
"Extension Days NB",
default=0,
help="Addtional days to the automatic extension, 5 mean that you have a total of 15 extension days of default one is set to 10",
help="Addtional days to the automatic extension, 5 mean that you have "
"a total of 15 extension days of default one is set to 10",
)
holiday_start_time = fields.Date("Holidays Start Day")
holiday_end_time = fields.Date("Holidays End Day")
@ -240,7 +242,8 @@ class CooperativeStatus(models.Model):
def get_status_value(self):
"""
Workararound to get translated selection value instead of key in mail template.
Workararound to get translated selection value instead of key in mail
template.
"""
state_list = (
self.env["cooperative.status"]

10
beesdoo_shift/models/planning.py

@ -42,7 +42,9 @@ class DayNumber(models.Model):
name = fields.Char()
number = fields.Integer(
"Day Number",
help="From 1 to N, When you will instanciate your planning, Day 1 will be the start date of the instance, Day 2 the second, etc...",
help="From 1 to N, When you will instanciate your planning, Day 1 "
"will be the start date of the instance, Day 2 the second, "
"etc...",
)
active = fields.Boolean(default=True)
@ -99,7 +101,8 @@ class TaskTemplate(models.Model):
"beesdoo.shift.daynumber", string="Day", required=True
)
task_type_id = fields.Many2one("beesdoo.shift.type", string="Type")
# attendance_sheet_id = fields.Many2one('beesdoo.shift.sheet', string="Attendance Sheet") FIXME removed because beesdoo.shift.sheet is from another module.
# FIXME removed because beesdoo.shift.sheet is from another module.
# attendance_sheet_id = fields.Many2one('beesdoo.shift.sheet', string="Attendance Sheet") # noqa
start_time = fields.Float(required=True)
end_time = fields.Float(required=True)
super_coop_id = fields.Many2one(
@ -177,7 +180,8 @@ class TaskTemplate(models.Model):
if len(rec.worker_ids) > rec.worker_nb:
raise UserError(
_(
"You cannot assign more workers than the maximal number defined on template."
"You cannot assign more workers than the maximal "
"number defined on template. "
)
)

15
beesdoo_shift/models/task.py

@ -163,9 +163,12 @@ class Task(models.Model):
self, worker_ids, today=None, end_date=None, now=None
):
"""
Unsubscribe workers from *worker_ids* from all shift that start *today* and later.
If *end_date* is given, unsubscribe workers from shift between *today* and *end_date*.
If *now* is given workers are unsubscribed from all shifts starting *now* and later.
Unsubscribe workers from *worker_ids* from all shift that start
*today* and later.
If *end_date* is given, unsubscribe workers from shift between *today*
and *end_date*.
If *now* is given workers are unsubscribed from all shifts starting
*now* and later.
If *now* is given, *end_date* is not taken into account.
:type today: date
@ -278,7 +281,8 @@ class Task(models.Model):
):
raise UserError(
_(
"You cannot change to the status %s if no worker is defined for the shift"
"You cannot change to the status %s if no worker is "
"defined for the shift "
)
% new_state
)
@ -294,7 +298,8 @@ class Task(models.Model):
if not (self.worker_id.working_mode in ["regular", "irregular"]):
raise UserError(
_(
"Working mode is not properly defined. Please check if the worker is subscribed"
"Working mode is not properly defined. Please check if "
"the worker is subscribed "
)
)

6
beesdoo_shift/wizard/extension.py

@ -46,7 +46,8 @@ class Subscribe(models.TransientModel):
if not status_id.extension_start_time:
raise UserError(
_(
"You should not make a manual extension when the grace delay has not been triggered yet"
"You should not make a manual extension when the grace "
"delay has not been triggered yet "
)
)
today_delay = (
@ -55,7 +56,8 @@ class Subscribe(models.TransientModel):
if today_delay < 0:
raise UserError(
_(
"You should not start a manual extension during the grace delay"
"You should not start a manual extension during the grace "
"delay "
)
)
status_id.sudo().write(

3
beesdoo_shift/wizard/holiday.py

@ -24,7 +24,8 @@ class Subscribe(models.TransientModel):
):
raise ValidationError(
_(
"You cannot encode new holidays since the previous holidays encoded are not over yet"
"You cannot encode new holidays since the previous "
"holidays encoded are not over yet "
)
)
status_id.sudo().write(

6
beesdoo_shift/wizard/temporary_exemption.py

@ -27,14 +27,16 @@ class TemporaryExemption(models.TransientModel):
):
raise ValidationError(
_(
"You cannot encode new temporary exemptuon since the previous one are not over yet"
"You cannot encode new temporary exemption since the "
"previous one are not over yet "
)
)
reason = self.temporary_exempt_reason_id
status_id.sudo().write(
{
"temporary_exempt_start_date": self.temporary_exempt_start_date,
"temporary_exempt_end_date": self.temporary_exempt_end_date,
"temporary_exempt_reason_id": self.temporary_exempt_reason_id.id,
"temporary_exempt_reason_id": reason.id,
}
)
self.env["beesdoo.shift.shift"].sudo().unsubscribe_from_today(

25
beesdoo_shift_attendance/models/attendance_sheet.py

@ -218,7 +218,8 @@ class AttendanceSheet(models.Model):
_sql_constraints = [
(
"check_not_annotated_mark_as_read",
"CHECK ((is_annotated=FALSE AND is_read=FALSE) OR is_annotated=TRUE)",
"CHECK"
" ((is_annotated=FALSE AND is_read=FALSE) OR is_annotated=TRUE)",
_("Non-annotated sheets can't be marked as read."),
)
]
@ -295,7 +296,8 @@ class AttendanceSheet(models.Model):
if (len(ids) - len(set(ids))) > 0:
raise UserError(
_(
"You can't add the same worker more than once to an attendance sheet."
"You can't add the same worker more than once to an "
"attendance sheet. "
)
)
@ -333,14 +335,16 @@ class AttendanceSheet(models.Model):
if not len(worker):
raise UserError(
_(
"Worker not found (invalid barcode or status). \nBarcode : %s"
"Worker not found (invalid barcode or status). \n"
"Barcode : %s"
)
% barcode
)
if len(worker) > 1:
raise UserError(
_(
"Multiple workers are corresponding this barcode. \nBarcode : %s"
"Multiple workers are corresponding this barcode. \n"
"Barcode : %s"
)
% barcode
)
@ -363,13 +367,15 @@ class AttendanceSheet(models.Model):
raise UserError(
_(
"Beware, you are recorded as resigning. "
"Please contact member's office if this is incorrect. Thank you."
"Please contact member's office if this is incorrect. "
"Thank you. "
)
)
if worker.working_mode not in ("regular", "irregular"):
raise UserError(
_(
"%s's working mode is %s and should be regular or irregular."
"%s's working mode is %s and should be regular or "
"irregular. "
)
% (worker.name, worker.working_mode)
)
@ -395,7 +401,9 @@ class AttendanceSheet(models.Model):
# Added shift creation
self.added_shift_ids |= self.added_shift_ids.new(
{
"task_type_id": self.added_shift_ids.pre_filled_task_type_id(),
"task_type_id": (
self.added_shift_ids.pre_filled_task_type_id()
),
"state": "done",
"attendance_sheet_id": self._origin.id,
"worker_id": worker.id,
@ -537,7 +545,8 @@ class AttendanceSheet(models.Model):
if self.start_time > datetime.now():
raise UserError(
_(
"Attendance sheet can only be validated once the shifts have started."
"Attendance sheet can only be validated once the shifts "
"have started. "
)
)

8
beesdoo_shift_attendance/wizard/validate_attendance_sheet.py

@ -45,8 +45,9 @@ class ValidateAttendanceSheet(models.TransientModel):
if is_regular_worker and not is_compensation:
warning_message += (
_(
"\n%s attended its shift as a normal one but was not expected. "
"Something may be wrong in his/her personnal informations.\n"
"\n%s attended its shift as a normal one but was "
"not expected. Something may be wrong in his/her "
"personnal informations.\n "
)
% added_shift.worker_id.name
)
@ -124,7 +125,8 @@ class ValidateAttendanceSheet(models.TransientModel):
if not partner.super and not can_validate:
raise UserError(
_(
"Only super-cooperators and administrators can validate attendance sheets."
"Only super-cooperators and administrators can validate "
"attendance sheets. "
)
)

3
beesdoo_stock_coverage/__manifest__.py

@ -5,7 +5,8 @@
"name": "Product - Stock Coverage",
"version": "12.0.0.0.1",
"category": "Product",
"summary": "Compute estimated stock coverage based on product sales over a date range.",
"summary": "Compute estimated stock coverage based on product sales over "
"a date range.",
"author": "Coop IT Easy SCRLfs",
"website": "https://www.coopiteasy.be",
"license": "AGPL-3",

3
beesdoo_stock_coverage/models/product_template.py

@ -38,7 +38,8 @@ class ProductTemplate(models.Model):
from pos_order_line pol
join pos_order po ON pol.order_id = po.id
join product_product product ON pol.product_id = product.id
join product_template template ON product.product_tmpl_id = template.id
join product_template template
ON product.product_tmpl_id = template.id
where po.state in ('done', 'invoiced', 'paid')
and template.active
and po.date_order

8
beesdoo_stock_coverage/tests/test_stock_coverage.py

@ -44,6 +44,8 @@ class TestModule(TransactionCase):
def _create_order(self):
date = fields.Date.today() - timedelta(days=1)
date_str = fields.Date.to_string(date)
account = self.env.user.partner_id.property_account_receivable_id
statement = self.pos_config.current_session_id.statement_ids[0]
order_data = {
"id": u"0006-001-0010",
"to_invoice": True,
@ -75,10 +77,8 @@ class TestModule(TransactionCase):
"journal_id": self.pos_config.journal_ids[0].id,
"amount": 0.9,
"name": fields.Datetime.now(),
"account_id": self.env.user.partner_id.property_account_receivable_id.id,
"statement_id": self.pos_config.current_session_id.statement_ids[
0
].id,
"account_id": account.id,
"statement_id": statement.id,
},
]
],

27
beesdoo_website_shift/controllers/main.py

@ -161,7 +161,8 @@ class WebsiteShiftController(http.Controller):
@http.route("/shift_irregular_worker", auth="public", website=True)
def public_shift_irregular_worker(self, **kw):
"""
Show a public access page that show all the available shifts for irregular worker.
Show a public access page that show all the available shifts for
irregular worker.
"""
nexturl = "/shift_irregular_worker"
irregular_enable_sign_up = False
@ -182,7 +183,8 @@ class WebsiteShiftController(http.Controller):
@http.route("/shift_template_regular_worker", auth="public", website=True)
def public_shift_template_regular_worker(self, **kw):
"""
Show a public access page that show all the available shift templates for regular worker.
Show a public access page that show all the available shift templates
for regular worker.
"""
# Get all the task template
template = request.env["beesdoo.shift.template"]
@ -207,7 +209,8 @@ class WebsiteShiftController(http.Controller):
def my_shift_irregular_worker(self, nexturl=""):
"""
Return template variables for 'beesdoo_website_shift.my_shift_irregular_worker' template
Return template variables for
'beesdoo_website_shift.my_shift_irregular_worker' template
"""
# Get config
irregular_enable_sign_up = request.website.irregular_enable_sign_up
@ -243,13 +246,15 @@ class WebsiteShiftController(http.Controller):
def my_shift_regular_worker_without_shift(self):
"""
Return template variables for 'beesdoo_website_shift.my_shift_regular_worker_without_shift' template
Return template variables for
'beesdoo_website_shift.my_shift_regular_worker_without_shift' template
"""
return self.my_shift_worker_status()
def my_shift_regular_worker(self):
"""
Return template variables for 'beesdoo_website_shift.my_shift_regular_worker' template
Return template variables for
'beesdoo_website_shift.my_shift_regular_worker' template
"""
# Create template context
template_context = {}
@ -270,7 +275,8 @@ class WebsiteShiftController(http.Controller):
def my_shift_exempted_worker(self):
"""
Return template variables for 'beesdoo_website_shift.my_shift_exempted_worker' template
Return template variables for
'beesdoo_website_shift.my_shift_exempted_worker' template
"""
return self.my_shift_worker_status()
@ -372,7 +378,8 @@ class WebsiteShiftController(http.Controller):
def my_shift_next_shifts(self):
"""
Return template variables for 'beesdoo_website_shift.my_shift_next_shifts' template
Return template variables for
'beesdoo_website_shift.my_shift_next_shifts' template
"""
# Get current user
cur_user = request.env["res.users"].browse(request.uid)
@ -462,7 +469,8 @@ class WebsiteShiftController(http.Controller):
def my_shift_past_shifts(self):
"""
Return template variables for 'beesdoo_website_shift.my_shift_past_shifts' template
Return template variables for
'beesdoo_website_shift.my_shift_past_shifts' template
"""
# Get current user
cur_user = request.env["res.users"].browse(request.uid)
@ -512,7 +520,8 @@ class WebsiteShiftController(http.Controller):
def my_shift_worker_status(self):
"""
Return template variables for 'beesdoo_website_shift.my_shift_worker_status_*' template
Return template variables for
'beesdoo_website_shift.my_shift_worker_status_*' template
"""
cur_user = request.env["res.users"].browse(request.uid)
return {"status": cur_user.partner_id.cooperative_status_ids}

6
beesdoo_worker_status/models/cooperative_status.py

@ -171,7 +171,8 @@ class CooperativeStatus(models.Model):
):
return "exempted"
# Transition to alert sr < 0 or stay in alert sr < 0 or sc < 0 and thus alert time is defined
# Transition to alert sr < 0 or stay in alert sr < 0 or sc < 0 and
# thus alert time is defined
if (
not ok
and self.alert_start_time
@ -237,7 +238,8 @@ class CooperativeStatus(models.Model):
or self.today <= self.temporary_exempt_end_date
):
return "exempted"
# Transition to alert sr < 0 or stay in alert sr < 0 or sc < 0 and thus alert time is defined
# Transition to alert sr < 0 or stay in alert sr < 0 or sc < 0 and
# thus alert time is defined
elif (
not ok
and self.alert_start_time

3
purchase_order_generator/models/purchase_order_generator.py

@ -126,10 +126,11 @@ class PurchaseOrderGenerator(models.Model):
for cpo_line in self.pog_line_ids:
if cpo_line.purchase_quantity > 0:
product = cpo_line.product_template_id.product_variant_id
pol = self.env["purchase.order.line"].create(
{
"name": cpo_line.name,
"product_id": cpo_line.product_template_id.product_variant_id.id,
"product_id": product.id,
"product_qty": cpo_line.purchase_quantity,
"price_unit": cpo_line.product_price,
"product_uom": cpo_line.uom_po_id.id,

7
website_portal_restrict_modification/controllers/main.py

@ -20,9 +20,10 @@ class CustomerPortalRestrictModification(CustomerPortal):
def details_form_validate(self, data):
error, error_message = super().details_form_validate(data)
# since we override mandatory and optional billing fields,
# parent method will insert the following key/value in `error` dict and `error_message` list,
# preventing from saving the form. Workaround is to remove them from both dict and list.
# since we override mandatory and optional billing fields, parent
# method will insert the following key/value in `error` dict and
# `error_message` list, preventing from saving the form. Workaround
# is to remove them from both dict and list.
if (
error.get("common")
and error["common"].lower() == "unknown field"

Loading…
Cancel
Save