Commit 13c541f0 by François C.

Merge branch '6821-stabilisation_statuts' into 'dev_cooperatic'

Surchage complète des champs cooperative_state et working_state dans module Cagette

Les opérations suivantes doivent être faites en base de données pour un bon fonctionnement :
UPDATE res_partner SET working_state = 'gone' WHERE cooperative_state = 'gone';
UPDATE res_partner SET working_state = 'associated' WHERE cooperative_state = 'associated';

See merge request !78
parents ab06aeca 6c4c7353
...@@ -16,6 +16,7 @@ from openerp import SUPERUSER_ID ...@@ -16,6 +16,7 @@ from openerp import SUPERUSER_ID
from lxml import etree from lxml import etree
from openerp.osv.orm import setup_modifiers from openerp.osv.orm import setup_modifiers
EXTRA_COOPERATIVE_STATE_SELECTION = [ EXTRA_COOPERATIVE_STATE_SELECTION = [
('not_concerned', 'Not Concerned'), ('not_concerned', 'Not Concerned'),
('unsubscribed', 'Unsubscribed'), ('unsubscribed', 'Unsubscribed'),
...@@ -27,15 +28,13 @@ EXTRA_COOPERATIVE_STATE_SELECTION = [ ...@@ -27,15 +28,13 @@ EXTRA_COOPERATIVE_STATE_SELECTION = [
('delay', 'Delay'), ('delay', 'Delay'),
('blocked', 'Blocked'), ('blocked', 'Blocked'),
('unpayed', 'Unpayed'), ('unpayed', 'Unpayed'),
('gone', 'Gone'), # Used by LaCagette and followers
('associated', 'Associated') # Used by LaCagette and followers
] ]
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
COOPERATIVE_STATE_CUSTOMER = ['up_to_date', 'alert', 'delay', 'exempted', 'unsubscribed', 'gone', 'associated'] COOPERATIVE_STATE_CUSTOMER = ['up_to_date', 'alert', 'delay', 'exempted']
SEX_SELECTION = [ SEX_SELECTION = [
('m', 'male'), ('m', 'male'),
...@@ -329,9 +328,7 @@ class ResPartner(models.Model): ...@@ -329,9 +328,7 @@ class ResPartner(models.Model):
@api.multi @api.multi
def _compute_cooperative_state(self): def _compute_cooperative_state(self):
for partner in self: for partner in self:
if partner.working_state in ['gone', 'associated']: if partner.is_associated_people:
partner.cooperative_state = partner.working_state
elif partner.is_associated_people:
# Associated People # Associated People
partner.cooperative_state = partner.parent_id.cooperative_state partner.cooperative_state = partner.parent_id.cooperative_state
elif partner.is_worker_member: elif partner.is_worker_member:
...@@ -350,7 +347,7 @@ class ResPartner(models.Model): ...@@ -350,7 +347,7 @@ class ResPartner(models.Model):
def _compute_customer(self): def _compute_customer(self):
for partner in self: for partner in self:
partner.customer =\ partner.customer =\
partner.cooperative_state in ['up_to_date', 'alert', 'delay', 'exempted'] partner.cooperative_state in self.COOPERATIVE_STATE_CUSTOMER
@api.depends('child_ids') @api.depends('child_ids')
@api.multi @api.multi
...@@ -695,3 +692,4 @@ class ResPartner(models.Model): ...@@ -695,3 +692,4 @@ class ResPartner(models.Model):
str(tpl_reg_line_fr_partner_tree_id)) str(tpl_reg_line_fr_partner_tree_id))
res['arch'] = etree.tostring(doc) res['arch'] = etree.tostring(doc)
return res return res
...@@ -30,6 +30,7 @@ from openerp.exceptions import ValidationError ...@@ -30,6 +30,7 @@ from openerp.exceptions import ValidationError
from .date_tools import conflict_period from .date_tools import conflict_period
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
...@@ -45,11 +46,8 @@ class ResPartner(models.Model): ...@@ -45,11 +46,8 @@ class ResPartner(models.Model):
('up_to_date', 'Up to date'), ('up_to_date', 'Up to date'),
('alert', 'Alert'), ('alert', 'Alert'),
('suspended', 'Suspended'), ('suspended', 'Suspended'),
('unsubscribed', 'Unsubscribed'),
('delay', 'Delay'), ('delay', 'Delay'),
('blocked', 'Blocked'), ('blocked', 'Blocked'),
('gone', 'Gone'), # Used by La Cagette and followers
('associated', 'Associated') # Used by La Cagette and followers
] ]
# Columns Section # Columns Section
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# #
'category': 'Uncategorized', 'category': 'Uncategorized',
'version': '0.0.7.3', 'version': '0.0.7.4',
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
'depends': ['base', 'coop_membership', 'coop_shift'], 'depends': ['base', 'coop_membership', 'coop_shift'],
......
...@@ -28,6 +28,18 @@ EXTRA_COOPERATIVE_STATE_SELECTION = [ ...@@ -28,6 +28,18 @@ EXTRA_COOPERATIVE_STATE_SELECTION = [
('associated', 'Associated') ('associated', 'Associated')
] ]
WORKING_STATE_SELECTION = [
('exempted', 'Exempted'),
('vacation', 'On Vacation'),
('up_to_date', 'Up to date'),
('alert', 'Alert'),
('suspended', 'Suspended'),
('delay', 'Delay'),
('blocked', 'Blocked'),
('gone', 'Gone'),
('associated', 'Associated')
]
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
...@@ -39,15 +51,29 @@ class ResPartner(models.Model): ...@@ -39,15 +51,29 @@ class ResPartner(models.Model):
target_status = fields.Selection( target_status = fields.Selection(
selection=TARGET_STATUS_SELECTION, default='') selection=TARGET_STATUS_SELECTION, default='')
# override cooperative_state and working_state with own compute methods, in order to unsure their stored values
cooperative_state = fields.Selection( cooperative_state = fields.Selection(
selection=EXTRA_COOPERATIVE_STATE_SELECTION, default='not_concerned') selection=EXTRA_COOPERATIVE_STATE_SELECTION, default='not_concerned', store=True,
compute='_compute_lacagette_cooperative_state'
)
working_state = fields.Selection(
selection=WORKING_STATE_SELECTION, string='Working State', store=True,
compute='_compute_lacagette_working_state', help="This state depends on the"
" shifts realized by the partner."
)
extra_shift_done = fields.Integer( extra_shift_done = fields.Integer(
"Number of shift done with both of the associate", "Number of shift done with both of the associate",
default= 0) default= 0)
@api.multi
def _compute_lacagette_working_state(self): def _compute_lacagette_working_state(self):
_logger.debug("Dans _compute_lacagette_working_state")
for partner in self: for partner in self:
_logger.debug("partner_id = %s, cooperative_state = %s", str(partner.id), str(partner.cooperative_state))
if partner.is_associated_people is True: if partner.is_associated_people is True:
partner.working_state = partner.parent_id.cooperative_state partner.working_state = partner.parent_id.cooperative_state
else: else:
...@@ -57,14 +83,22 @@ class ResPartner(models.Model): ...@@ -57,14 +83,22 @@ class ResPartner(models.Model):
potential_associated_record = self.env['res.partner'].search([('email','=',self.email), ('is_associated_people', '=', True)]) potential_associated_record = self.env['res.partner'].search([('email','=',self.email), ('is_associated_people', '=', True)])
if potential_associated_record: if potential_associated_record:
partner.working_state = 'associated' partner.working_state = 'associated'
# Not sure, it is useful, but _compute_working_state is overriden, calling our own method
@api.multi
def _compute_working_state(self):
self._compute_lacagette_working_state()
@api.depends( @api.depends(
'working_state', 'is_unpayed', 'is_unsubscribed', 'working_state', 'is_unpayed', 'is_unsubscribed',
'is_worker_member', 'is_associated_people', 'is_worker_member', 'is_associated_people',
'parent_id.cooperative_state') 'parent_id.cooperative_state')
@api.multi @api.multi
def _compute_cooperative_state(self): def _compute_lacagette_cooperative_state(self):
_logger.debug("Dans _compute_lacagette_cooperative_state")
for partner in self: for partner in self:
# _logger.debug("Partner = %s", str(partner.read()))
_logger.debug("partner_id = %s, working_state = %s", str(partner.id), str(partner.working_state))
if partner.is_member is False and partner.is_associated_people is False and partner.is_worker_member is False: if partner.is_member is False and partner.is_associated_people is False and partner.is_worker_member is False:
partner.cooperative_state = 'not_concerned' partner.cooperative_state = 'not_concerned'
else: else:
...@@ -80,6 +114,18 @@ class ResPartner(models.Model): ...@@ -80,6 +114,18 @@ class ResPartner(models.Model):
else: else:
partner.cooperative_state = partner.working_state partner.cooperative_state = partner.working_state
# Not sure, it is useful, but _compute_cooperative_state is overriden, calling our own method
@api.depends(
'working_state', 'is_unpayed', 'is_unsubscribed',
'is_worker_member', 'is_associated_people',
'parent_id.cooperative_state')
@api.multi
def _compute_cooperative_state(self):
self._compute_lacagette_cooperative_state()
@api.multi @api.multi
def recompute_member_states(self): def recompute_member_states(self):
for record in self: for record in self:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment