Commit 540be0cd by François C.

#1730 : Add listener on shift_template_registration_line to fit…

#1730 : Add listener on shift_template_registration_line to fit cooperative_state with cooperative rules
parent 1cf1eb56
......@@ -26,7 +26,7 @@
</record>
<record id="committees_shift_id" model="ir.config_parameter">
<field name="key">lacagette_membership.committees_shift_id</field>
<field name="value"> </field>
<field name="value">0</field>
</record>
<record id="shift_creation_days" model="ir.config_parameter">
<field name="key">lacagette_membership.shift_creation_days</field>
......
......@@ -6,3 +6,4 @@ from . import shift_counter_event
from . import shift_shift
from . import member_state_change
from . import shift_template
from . import shift_template_registration_line
# -*- coding: utf-8 -*-
from openerp import api, models
import logging
_logger = logging.getLogger(__name__)
class ShiftTemplateRegistrationLine(models.Model):
_inherit = 'shift.template.registration.line'
@api.model
def create(self, vals):
super_res = super(ShiftTemplateRegistrationLine, self.with_context(
dict(self.env.context, **{'creation_in_progress': True}))).create(vals)
#_logger.info("valeurs reçues pour create shift.template.registration.line = %s", str(vals))
if 'partner_id' in vals and 'shift_ticket_id' in vals:
conf = self.env['ir.config_parameter']
suspension_limit = int(conf.get_param("lacagette_membership.points_limit_to_get_suspended"))
unsubscribe_limit = int(conf.get_param("lacagette_membership.points_limit_to_get_unsubscribed"))
member = self.env['res.partner'].search([('id', '=', vals['partner_id'])])
shift_ticket = self.env['shift.ticket'].search([('id', '=', vals['shift_ticket_id'])])
if member and shift_ticket:
member = member[0]
shift_ticket = shift_ticket[0]
if shift_ticket.name == "ABCD":
points = member.final_standard_point
else:
points = member.final_ftop_point
if points <= suspension_limit or points <= unsubscribe_limit:
coop_state = 'suspended'
if points <= unsubscribe_limit:
coop_state = 'unsubscribed'
member.update({'cooperative_state': coop_state})
_logger.info("new cooperative_state = %s for %s", coop_state, str(member.id))
return super_res
......@@ -150,6 +150,8 @@ var PosDB = core.Class.extend({
},
/* saves a record store to the database */
save: function(store,data){
console.log(data)
console.log('on stocke une chaine de ' + JSON.stringify(data).length + ' car. dans ' + this.name + '_' + store + ' (' + Date.now() +')')
localStorage[this.name + '_' + store] = JSON.stringify(data);
this.cache[store] = data;
},
......
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