Commit 7bfade61 by Odoo

Prevent gone and associated status to be lost where _compute_cooperative_state is called

parent b00fcdad
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
{ {
'name': 'Coop - Membership', 'name': 'Coop - Membership',
'version': '9.0.2.0.0', 'version': '9.0.2.0.1',
'category': 'Custom', 'category': 'Custom',
'summary': 'Custom settings for membership', 'summary': 'Custom settings for membership',
'author': 'La Louve', 'author': 'La Louve',
......
...@@ -16,7 +16,6 @@ from openerp import SUPERUSER_ID ...@@ -16,7 +16,6 @@ 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'),
...@@ -28,13 +27,15 @@ EXTRA_COOPERATIVE_STATE_SELECTION = [ ...@@ -28,13 +27,15 @@ 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'] COOPERATIVE_STATE_CUSTOMER = ['up_to_date', 'alert', 'delay', 'exempted', 'gone', 'associated']
SEX_SELECTION = [ SEX_SELECTION = [
('m', 'male'), ('m', 'male'),
...@@ -328,7 +329,9 @@ class ResPartner(models.Model): ...@@ -328,7 +329,9 @@ 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.is_associated_people: if partner.working_state in ['gone', 'associated']:
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:
......
...@@ -21,6 +21,8 @@ On Partners, it creates a new state 'working_state' with the following value: ...@@ -21,6 +21,8 @@ On Partners, it creates a new state 'working_state' with the following value:
('suspended', 'Suspended'), ('suspended', 'Suspended'),
('delay', 'Delay'), ('delay', 'Delay'),
('blocked', 'Blocked'), ('blocked', 'Blocked'),
('gone', 'Gone'),
('associated', 'Associated')
Configuration Configuration
============= =============
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{ {
'name': 'Coop Shift', 'name': 'Coop Shift',
'version': '9.0.7.0.0', 'version': '9.0.7.0.1',
'category': 'Tools', 'category': 'Tools',
'author': 'Julien WESTE, Sylvain LE GAL, Cyril Gaspard, La Louve', 'author': 'Julien WESTE, Sylvain LE GAL, Cyril Gaspard, La Louve',
'website': 'http://www.lalouve.net', 'website': 'http://www.lalouve.net',
......
...@@ -30,7 +30,6 @@ from openerp.exceptions import ValidationError ...@@ -30,7 +30,6 @@ 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'
...@@ -48,6 +47,8 @@ class ResPartner(models.Model): ...@@ -48,6 +47,8 @@ class ResPartner(models.Model):
('suspended', 'Suspended'), ('suspended', 'Suspended'),
('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
......
...@@ -172,7 +172,7 @@ class ResPartner(models.Model): ...@@ -172,7 +172,7 @@ class ResPartner(models.Model):
def set_special_state(self, cr, uid, partner, context=None): def set_special_state(self, cr, uid, partner, context=None):
if partner['state'] == 'cancel_special': if partner['state'] == 'cancel_special':
partner['state'] = 'unsubscribed' partner['state'] = 'unsubscribed'
return self.write(cr, uid, [partner['id']], {'cooperative_state': partner['state']} , context=context) return self.write(cr, uid, [partner['id']], {'cooperative_state': partner['state'], 'working_state': partner['state']} , context=context)
def _write_state_change(self, state): def _write_state_change(self, state):
data = {'member_id': self.id, 'state': state} data = {'member_id': self.id, 'state': state}
......
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