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

12.0 polln #275

Open
wants to merge 31 commits into
base: 12.0
Choose a base branch
from
Open

12.0 polln #275

wants to merge 31 commits into from

Conversation

tfrancoi
Copy link
Contributor

Do not merge just base for discussion

tfrancoi and others added 30 commits August 21, 2021 01:19
Add lambda so there is no more need to redefine field states
Add parameter today to _get_irregular_worker_domain

Move specific constrains to beesdoo_worker_status
The module beesdoo_product does not need to depend on bessdoo base that introduce a lot of specific field (ie: for the beescard on res.partner)
Don't raise an error in computed field, if the value does not allow
to compute the field properly fallbaclk on default value

raise an error may forbid the installation of the module
print label that take module specific field into account
with the different criteria: Geo, ethic, bio etc..
- Migrate code from V9
- Replace deleted standard qweb report by a new one
Add lambda so there is no more need to redefine field states
Add parameter today to _get_irregular_worker_domain

Move specific constrains to beesdoo_worker_status

[WIP]

[FIX] open instead as draft doesnt exist anymore

[ADD] send (un)subscribed mail when worker is
changed.

[WIP] 2

[FIX] can unsubscribe

delta is between date in the future and now not the opposite
To get the full timedelta in hours we should get the days number and the seconds

[WIP] final wip to clean

[WIP] 4

[FIX] prod fix
Work in progress
View cleaning done
@@ -41,18 +41,22 @@
<group
attrs="{'invisible': ['|', ('customer', '=', False), ('eater', '!=', 'worker_eater')]}"
>
<separator string="Eaters" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in #284

@@ -138,10 +138,11 @@ def _new_eater(self, surname, name, email):
partner_data = {
"lastname": name,
"firstname": surname,
"is_customer": True,
"customer": True,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -23,7 +23,7 @@ def _cooperator_share_type(self):
Return the share.type that correspond to the cooperator_type.
"""
self.ensure_one()
share_type = None
share_type = self.env['product.template']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -38,6 +38,7 @@ def _cooperator_share_type(self):
"share_ids.share_product_id.default_code",
"share_ids.share_product_id.allow_working",
"share_ids.share_number",
"worker_store",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

else:
rec.is_worker = False
is_worker = False
Copy link
Contributor Author

Choose a reason for hiding this comment

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


def _search_worker(self, operator, value):
lines = self.env["share.line"].search(
[("share_product_id.allow_working", "=", "True")]
)
partner_ids = lines.mapped("partner_id").ids
partner_ids = lines.mapped("partner_id")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -351,8 +351,7 @@ def _change_counter(self, data):
# Irregular Cron implementation #
###############################################

def _get_irregular_worker_domain(self, **kwargs):
today = kwargs.get("today") or self.today
def _get_irregular_worker_domain(self, today):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -96,7 +96,7 @@ def _get_status(self):
comodel_name="cooperative.exempt.reason", string="Exempt Reason"
)
status = fields.Selection(
selection=_get_status,
selection=lambda x: x._get_status(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -112,11 +112,10 @@ def _get_status(self):
)

# Specific to irregular
irregular_start_date = fields.Date() # TODO migration script
irregular_start_date = fields.Date()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

discard

irregular_absence_counter = (
fields.Integer()
) # TODO unsubscribe when reach -2
irregular_absence_counter = fields.Integer()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

discard

Overwrite write to historize the change
"""
for field in [
def _get_watched_fields(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -356,7 +358,7 @@ def _cron_compute_counter_irregular(self, today=False):
if not journal:
journal = self.env["beesdoo.shift.journal"].create({"date": today})

domain = self._get_irregular_worker_domain(today=today)
domain = self._get_irregular_worker_domain(today)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -445,7 +447,7 @@ def _change_counter(self, data):
# Irregular Cron implementation #
###############################################

def _get_irregular_worker_domain(self):
def _get_irregular_worker_domain(self, today):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -61,7 +61,7 @@ def _get_final_state(self):
)
end_time = fields.Datetime(track_visibility="always", required=True)
state = fields.Selection(
selection=_get_selection_status,
selection=lambda x: x._get_selection_status(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -214,10 +214,19 @@ def _nb_worker_max(self):
)
)

@api.constrains("start_time", "end_time")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@api.onchange("start_time", "end_time")
def _get_duration(self):
if self.start_time and self.end_time:
self.duration = self.end_time - self.start_time
self.duration = (self.end_time or 0.0) - (self.start_time or 0.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -1,10 +1,50 @@
from odoo import fields, models
from odoo import api, fields, models
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -98,20 +98,6 @@ def _compute_color(self):
for rec in self:
rec.color = self._get_color_mapping(rec.state)

def _compensation_validation(self, task):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

<field name="alert_start_time" />
<field name="extension_start_time" />
<field name="status" widget="statusbar" />
<field name="cooperator_id"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

<field name="start_time" />
<field name="end_time" />
<field name="duration" />
<field name="start_time" widget="float_time" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -5,7 +5,7 @@
<field name="arch" type="xml">
<form>
<group>
<field name="planning_id" />
<field name="planning_ids" widget="many2many_tags" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -17,7 +17,7 @@ class GenerateShiftTemplate(models.TransientModel):
column1="wizard_id",
column2="day_id",
)
planning_id = fields.Many2one("beesdoo.shift.planning", required=True)
planning_ids = fields.Many2many("beesdoo.shift.planning", 'generate_shift_planning_rel', 'planning_id', 'wizard_id', required=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

shift_template_data
)
ids.append(new_rec.id)
for planning_id in self.planning_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.

# Last step should be the shift subscription because we check working mode in shift
# It may raise an error you subscribe to a creanu with already existing shift
# and the coop is subscribed before have the proper working mode
if self.shift_id and self.working_mode == "regular":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already Done

@@ -169,14 +170,6 @@ def subscribe(self):
# when going to irregular.
if self.shift_id and self.shift_id.remaining_worker <= 0:
raise UserError(_("There is no remaining spot in this shift"))
if self.shift_id:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

already done

@@ -140,6 +140,7 @@ def _get_reset_counter_default(self):
resigning = fields.Boolean(
default=False, help="Want to leave the beescoop"
)
create_user = fields.Boolean(defaul=False, help="Create a portal user for the new worker")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -211,4 +204,24 @@ def subscribe(self):
# to a shift to keep information like "Worker mode, session info
# ,...
status_id.sudo().write(data)
if self.create_user:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

return True

def _create_user(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -31,6 +31,7 @@
name="irregular_start_date"
attrs="{'invisible': [('working_mode', '!=', 'irregular')]}"
/>
<field name="create_user" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -20,28 +20,28 @@

class WebsiteShiftController(http.Controller):
def is_user_worker(self):
user = request.env["res.users"].browse(request.uid)
user = request.env["res.users"].browse(request.uid).sudo()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -46,8 +46,8 @@

<template id="my_shift_worker_status_common" name="My Shift Worker Status Common">

<p>
<label class="font-weight-bold">Working Mode:</label>
<p id="working_mode">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -871,7 +861,7 @@
</h2>

<div class="row">
<div class="col-12 col-md-6 text-justify">
<div class="col-12 col-md-12 text-justify">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@polchampion
Copy link
Collaborator

@tfrancoi Salut Thibaut, pour te signaler que le refacto beesdoo_shift est en cours et sera mergé courant février. Pour info, on a vu un impact sur la surcharge de is_worker avec un conflit de priorité entre le module cooperator_worker et le module polln_shift, quand les deux sont installés (en tous cas si polln_shift est installé en dernier). On laisse comme ça pour le moment car on peut s'en sortir grâce au "force worker".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants