Commit 1cf1eb56 by François C.

Add 2 coop states to distinguish member who have gone and other which are associated people

parent b6d31ca5
......@@ -24,7 +24,10 @@
'data': [
'security/ir.model.access.csv',
'data/ir_cron.xml',
'data/ir_config_parameter_data.xml'
'data/ir_config_parameter_data.xml',
'static/src/xml/templates.xml',
'views/res_partner.xml',
],
'installable': True,
}
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * lacagette_membership
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo 9.0\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: lacagette_membership
#: selection:res.partner,cooperative_state:0
msgid "Gone"
msgstr "Parti.e"
#. module: lacagette_membership
#: selection:res.partner,cooperative_state:0
msgid "Associated"
msgstr "En binôme"
\ No newline at end of file
......@@ -11,6 +11,21 @@ TARGET_STATUS_SELECTION = [
('suspended', 'Suspended')
]
EXTRA_COOPERATIVE_STATE_SELECTION = [
('not_concerned', 'Not Concerned'),
('unsubscribed', 'Unsubscribed'),
('exempted', 'Exempted'),
('vacation', 'On Vacation'),
('up_to_date', 'Up to date'),
('alert', 'Alert'),
('suspended', 'Suspended'),
('delay', 'Delay'),
('blocked', 'Blocked'),
('unpayed', 'Unpayed'),
('gone', 'Gone'),
('associated', 'Associated')
]
class ResPartner(models.Model):
_inherit = 'res.partner'
......@@ -22,6 +37,9 @@ class ResPartner(models.Model):
target_status = fields.Selection(
selection=TARGET_STATUS_SELECTION, default='')
cooperative_state = fields.Selection(
selection=EXTRA_COOPERATIVE_STATE_SELECTION, default='not_concerned')
@api.model
def run_process_target_status(self):
"""Method called by cron task"""
......@@ -111,6 +129,10 @@ class ResPartner(models.Model):
pass
return answer
def set_special_state(self, cr, uid, partner, context=None):
return self.write(cr, uid, [partner['id']], {'cooperative_state': partner['state']} , context=context)
def _write_state_change(self, state):
data = {'member_id': self.id, 'state': state}
self.env['member.state.change'].create(data)
......
#coop_state_selection {
font-size: medium;
height: 26px;
}
\ No newline at end of file
odoo.define('lacagette_membership.backend', function(require){
"use strict";
var core = require('web.core');
var FormView = require('web.FormView');
var Model = require('web.DataModel');
var framework = require('web.framework');
var _t = core._t;
var partner_id = null;
var last_call = 0;
FormView.include({
load_record: function() {
var self = this;
return this._super.apply(this, arguments)
.then(function() {
partner_id = self.get_fields_values().id;
});
}
});
$(document).on('change', '#coop_state_selection', function(){
var d = new Date()
var elapsed_since_last_call = d.getTime() - last_call
let new_state = $(this).val()
if (elapsed_since_last_call > 5000) {
last_call = d.getTime()
let fields = {id: partner_id, state: new_state}
framework.blockUI();
new Model('res.partner').call('set_special_state',[fields]).then(function(rData){
window.location.reload()
},function(err,event){
event.preventDefault();
var error_body = _t('Your Internet connection is probably down.');
if (err.data) {
var except = err.data;
error_body = except.arguments && except.arguments[0] || except.message || error_body;
}
alert(error_body)
});
}
});
});
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets" name="lacagette_membership assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/lacagette_membership/static/src/css/backend.css" />
<script type="text/javascript" src="/lacagette_membership/static/src/js/backend.js"></script>
</xpath>
</template>
</data>
</openerp>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_partner_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="coop_membership.view_partner_form" />
<field name="arch" type="xml">
<field name="name" position="after">
<select id="coop_state_selection">
<option value="">--Statuts spéciaux--</option>
<option value="gone">Parti.e</option>
<option value="associated">En binôme</option>
</select>
</field>
</field>
</record>
</odoo>
\ No newline at end of file
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