Commit 6c4c7353 by François C.

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

parent ab06aeca
......@@ -16,6 +16,7 @@ from openerp import SUPERUSER_ID
from lxml import etree
from openerp.osv.orm import setup_modifiers
EXTRA_COOPERATIVE_STATE_SELECTION = [
('not_concerned', 'Not Concerned'),
('unsubscribed', 'Unsubscribed'),
......@@ -27,15 +28,13 @@ EXTRA_COOPERATIVE_STATE_SELECTION = [
('delay', 'Delay'),
('blocked', 'Blocked'),
('unpayed', 'Unpayed'),
('gone', 'Gone'), # Used by LaCagette and followers
('associated', 'Associated') # Used by LaCagette and followers
]
class ResPartner(models.Model):
_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 = [
('m', 'male'),
......@@ -329,9 +328,7 @@ class ResPartner(models.Model):
@api.multi
def _compute_cooperative_state(self):
for partner in self:
if partner.working_state in ['gone', 'associated']:
partner.cooperative_state = partner.working_state
elif partner.is_associated_people:
if partner.is_associated_people:
# Associated People
partner.cooperative_state = partner.parent_id.cooperative_state
elif partner.is_worker_member:
......@@ -350,7 +347,7 @@ class ResPartner(models.Model):
def _compute_customer(self):
for partner in self:
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.multi
......@@ -695,3 +692,4 @@ class ResPartner(models.Model):
str(tpl_reg_line_fr_partner_tree_id))
res['arch'] = etree.tostring(doc)
return res
......@@ -30,6 +30,7 @@ from openerp.exceptions import ValidationError
from .date_tools import conflict_period
class ResPartner(models.Model):
_inherit = 'res.partner'
......@@ -45,11 +46,8 @@ class ResPartner(models.Model):
('up_to_date', 'Up to date'),
('alert', 'Alert'),
('suspended', 'Suspended'),
('unsubscribed', 'Unsubscribed'),
('delay', 'Delay'),
('blocked', 'Blocked'),
('gone', 'Gone'), # Used by La Cagette and followers
('associated', 'Associated') # Used by La Cagette and followers
]
# Columns Section
......
......@@ -16,7 +16,7 @@
#
'category': 'Uncategorized',
'version': '0.0.7.3',
'version': '0.0.7.4',
# any module necessary for this one to work correctly
'depends': ['base', 'coop_membership', 'coop_shift'],
......
......@@ -28,6 +28,18 @@ EXTRA_COOPERATIVE_STATE_SELECTION = [
('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):
_inherit = 'res.partner'
......@@ -39,15 +51,29 @@ class ResPartner(models.Model):
target_status = fields.Selection(
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(
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(
"Number of shift done with both of the associate",
default= 0)
@api.multi
def _compute_lacagette_working_state(self):
_logger.debug("Dans _compute_lacagette_working_state")
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:
partner.working_state = partner.parent_id.cooperative_state
else:
......@@ -57,14 +83,22 @@ class ResPartner(models.Model):
potential_associated_record = self.env['res.partner'].search([('email','=',self.email), ('is_associated_people', '=', True)])
if potential_associated_record:
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(
'working_state', 'is_unpayed', 'is_unsubscribed',
'is_worker_member', 'is_associated_people',
'parent_id.cooperative_state')
@api.multi
def _compute_cooperative_state(self):
def _compute_lacagette_cooperative_state(self):
_logger.debug("Dans _compute_lacagette_cooperative_state")
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:
partner.cooperative_state = 'not_concerned'
else:
......@@ -80,6 +114,18 @@ class ResPartner(models.Model):
else:
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
def recompute_member_states(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