[MERGE] improvements on config wizards

bzr revid: qdp-launchpad@openerp.com-20110610102723-0bexzin6fcg1m3hg
This commit is contained in:
Quentin (OpenERP)
2011-06-10 12:27:23 +02:00
10 changed files with 220 additions and 37 deletions
+75 -6
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -40,6 +40,7 @@ class delivery_carrier(osv.osv):
currency = order.pricelist_id.currency_id.name or ''
res = [(r['id'], r['name']+' ('+(str(r['price']))+' '+currency+')') for r in self.read(cr, uid, ids, ['name', 'price'], context)]
return res
def get_price(self, cr, uid, ids, field_name, arg=None, context=None):
res={}
if context is None:
@@ -58,17 +59,27 @@ class delivery_carrier(osv.osv):
price = 0.0
res[carrier.id]=price
return res
_columns = {
'name': fields.char('Carrier', size=64, required=True),
'partner_id': fields.many2one('res.partner', 'Carrier Partner', required=True),
'product_id': fields.many2one('product.product', 'Delivery Product', required=True),
'grids_id': fields.one2many('delivery.grid', 'carrier_id', 'Delivery Grids'),
'price' : fields.function(get_price, method=True,string='Price'),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the delivery carrier without removing it.")
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the delivery carrier without removing it."),
'normal_price': fields.float('Normal Price'),
'free_if_more_than': fields.boolean('Free If More Than'),
'amount': fields.float('Amount'),
'use_detailed_pricelist': fields.boolean('Use Detailed Pricelist'),
'pricelist_ids': fields.one2many('delivery.grid', 'carrier_id', 'Price List'),
}
_defaults = {
'active': lambda *args:1
'active': 1,
'free_if_more_than': False,
}
def grid_get(self, cr, uid, ids, contact_id, context=None):
contact = self.pool.get('res.partner.address').browse(cr, uid, contact_id, context=context)
for carrier in self.browse(cr, uid, ids, context=context):
@@ -86,6 +97,63 @@ class delivery_carrier(osv.osv):
continue
return grid.id
return False
def create_grid_lines(self, cr, uid, ids, vals, context=None):
if context == None:
context = {}
grid_line_pool = self.pool.get('delivery.grid.line')
grid_pool = self.pool.get('delivery.grid')
for record in self.browse(cr, uid, ids, context=context):
grid_id = grid_pool.search(cr, uid, [('carrier_id', '=', record.id)], context=context)
if not grid_id:
record_data = {
'name': vals.get('name', False),
'carrier_id': record.id,
'seqeunce': 10,
}
new_grid_id = grid_pool.create(cr, uid, record_data, context=context)
grid_id = [new_grid_id]
#delete all existing grid lines
grid_lines = [line.id for line in grid_pool.browse(cr, uid, grid_id[0]).line_ids if line.type == 'price']
grid_line_pool.unlink(cr, uid, grid_lines, context=context)
#create the grid lines
if record.free_if_more_than:
data = {
'grid_id': grid_id and grid_id[0],
'name': _('Free if more than %d') % record.amount,
'type': 'price',
'operator': '>=',
'max_value': record.amount,
'standard_price': 0.0,
'list_price': 0.0,
}
grid_line_pool.create(cr, uid, data, context=context)
if record.normal_price:
default_data = {
'grid_id': grid_id and grid_id[0],
'name': _('Default price'),
'type': 'price',
'operator': '>=',
'max_value': 0.0,
'standard_price': record.normal_price,
'list_price': record.normal_price,
}
grid_line_pool.create(cr, uid, default_data, context=context)
return True
def write(self, cr, uid, ids, vals, context=None):
res_id = super(delivery_carrier, self).write(cr, uid, ids, vals, context=context)
self.create_grid_lines(cr, uid, ids, vals, context=context)
return res_id
def create(self, cr, uid, vals, context=None):
res_id = super(delivery_carrier, self).create(cr, uid, vals, context=context)
self.create_grid_lines(cr, uid, [res_id], vals, context=context)
return res_id
delivery_carrier()
class delivery_grid(osv.osv):
@@ -151,7 +219,9 @@ class delivery_grid_line(osv.osv):
_columns = {
'name': fields.char('Name', size=32, required=True),
'grid_id': fields.many2one('delivery.grid', 'Grid',required=True),
'type': fields.selection([('weight','Weight'),('volume','Volume'),('wv','Weight * Volume'), ('price','Price')], 'Variable', required=True),
'type': fields.selection([('weight','Weight'),('volume','Volume'),\
('wv','Weight * Volume'), ('price','Price')],\
'Variable', required=True),
'operator': fields.selection([('==','='),('<=','<='),('>=','>=')], 'Operator', required=True),
'max_value': fields.float('Maximum Value', required=True),
'price_type': fields.selection([('fixed','Fixed'),('variable','Variable')], 'Price Type', required=True),
@@ -167,7 +237,6 @@ class delivery_grid_line(osv.osv):
}
_order = 'list_price'
delivery_grid_line()
+65 -13
View File
@@ -4,9 +4,6 @@
<!-- Delivery Carriers -->
<menuitem id="menu_delivery" name="Delivery" parent="stock.menu_stock_configuration" sequence="4"/>
<record id="view_delivery_carrier_tree" model="ir.ui.view">
<field name="name">delivery.carrier.tree</field>
<field name="model">delivery.carrier</field>
@@ -25,10 +22,46 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Carrier">
<field name="name" select="1"/>
<field name="active" select="1"/>
<field name="partner_id" select="1"/>
<field name="product_id" select="1"/>
<group colspan="4" col="4" name="general">
<field name="name" select="1"/>
<field name="active" select="1"/>
<field name="partner_id" select="1"/>
<field name="product_id" select="1"/>
<separator string="Pricing Information" colspan="6"/>
<group colspan="2" col="4">
<field name="normal_price" select="1" colspan="4"/>
<newline/>
<field name="free_if_more_than"/>
<field name="amount" attrs="{'invisible':[('free_if_more_than','=',False)]}"/>
</group>
<newline/>
<field name="use_detailed_pricelist" />
</group>
<field name="pricelist_ids" nolabel="1" attrs="{'invisible':[('use_detailed_pricelist','=',False)]}" mode="tree,form">
<tree string="Delivery grids">
<field name="sequence"/>
<field name="carrier_id"/>
<field name="name"/>
</tree>
<form string="Delivery grids">
<field name="name" select="1"/>
<field name="active" select="1"/>
<field name="sequence" groups="base.group_extended" select="1"/>
<notebook colspan="4">
<page string="Grid definition">
<field colspan="4" name="line_ids" nolabel="1" select="1"/>
</page>
<page string="Destination">
<separator colspan="4" string="Countries"/>
<field colspan="4" name="country_ids" nolabel="1"/>
<separator colspan="4" string="States"/>
<field colspan="4" name="state_ids" nolabel="1"/>
<field name="zip_from"/>
<field name="zip_to"/>
</page>
</notebook>
</form>
</field>
</form>
</field>
</record>
@@ -40,6 +73,15 @@
<field name="view_mode">tree,form</field>
<field name="help">Create and manage the delivery methods you need for your sales activities. Each delivery method can be assigned to a price list which computes the price of the delivery according to the products sold or delivered.</field>
</record>
<record id="action_delivery_carrier_form1" model="ir.actions.act_window">
<field name="name">Delivery Method</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">delivery.carrier</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<menuitem action="action_delivery_carrier_form" id="menu_action_delivery_carrier_form" parent="menu_delivery" groups="base.group_extended"/>
<!-- Delivery Grids -->
@@ -98,13 +140,17 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Grid Lines">
<field colspan="4" name="name" select="1"/>
<field name="type" string="Condition"/>
<field name="operator" nolabel="1"/>
<field name="max_value" nolabel="1"/>
<group colspan="5" col="5">
<field colspan="4" name="name" select="1"/>
<newline/>
<field name="type" string="Condition"/>
<field name="operator" nolabel="1" />
<field name="max_value" nolabel="1"/>
</group>
<newline/>
<field name="list_price"/>
<field name="standard_price" groups="base.group_extended"/>
<field name="price_type" />
<field name="price_type"/>
<field name="variable_factor" attrs="{'invisible':[('price_type','=','fixed')]}"/>
</form>
</field>
@@ -118,7 +164,7 @@
<field name="name"/>
<field name="type"/>
<field name="operator"/>
<field name="max_value"/>
<field name="max_value" nolabel="1"/>
<field name="list_price"/>
<field name="standard_price" groups="base.group_extended"/>
</tree>
@@ -286,6 +332,12 @@
</field>
</record>
<record id="delivery_method_form_view_todo" model="ir.actions.todo">
<field name="action_id" ref="action_delivery_carrier_form1"/>
<field name="sequence">10</field>
<field name="type">normal</field>
<field name="state">skip</field>
</record>
</data>
</openerp>
+7 -3
View File
@@ -80,7 +80,7 @@ class hr_holidays_status(osv.osv):
'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the leave type without removing it."),
'max_leaves': fields.function(_user_left_days, method=True, string='Maximum Allowed', help='This value is given by the sum of all holidays requests with a positive value.', multi='user_left_days'),
'leaves_taken': fields.function(_user_left_days, method=True, string='Leaves Already Taken', help='This value is given by the sum of all holidays requests with a negative value.', multi='user_left_days'),
'remaining_leaves': fields.function(_user_left_days, method=True, string='Remaining Leaves', help='Maximum Leaves Allowed - Leaves Already Taken', multi='user_left_days'),
'remaining_leaves': fields.function(_user_left_days, method=True, string='Remaining Legal Leaves', help='Maximum Leaves Allowed - Leaves Already Taken', multi='user_left_days'),
'double_validation': fields.boolean('Apply Double Validation', help="If its True then its Allocation/Request have to be validated by second validator")
}
_defaults = {
@@ -334,7 +334,7 @@ class hr_employee(osv.osv):
# Find for holidays status
status_ids = type_obj.search(cr, uid, [('limit', '=', False)], context=context)
if len(status_ids) != 1 :
raise osv.except_osv(('Warning !'),_("To use this feature, you must have only one leave type without the option 'Allow to Override Limit' set. (%s Found).") % (len(status_ids)))
raise osv.except_osv(_('Warning !'),_("To use this feature, you must have only one leave type without the option 'Allow to Override Limit' set. (%s Found).") % (len(status_ids)))
status_id = status_ids and status_ids[0] or False
if not status_id:
return False
@@ -349,6 +349,10 @@ class hr_employee(osv.osv):
return True
def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
type_obj = self.pool.get('hr.holidays.status')
status_ids = type_obj.search(cr, uid, [('limit', '=', False)], context=context)
if len(status_ids) != 1 :
raise osv.except_osv(_('Warning !'),_("You should have only one leave type without the option 'Allow to Override Limit' set. (%s Found).") % (len(status_ids)))
cr.execute("SELECT sum(h.number_of_days_temp) as days, h.employee_id from hr_holidays h join hr_holidays_status s on (s.id=h.holiday_status_id) where h.type='add' and h.state='validate' and s.limit=False group by h.employee_id")
res = cr.dictfetchall()
remaining = {}
@@ -361,7 +365,7 @@ class hr_employee(osv.osv):
_columns = {
'remaining_leaves': fields.function(_get_remaining_days, method=True, string='Remaining Leaves', fnct_inv=_set_remaining_days, type="float", help='Total number of legal leaves allocated to this employee, change this value to create allocation request.', store=True),
'remaining_leaves': fields.function(_get_remaining_days, method=True, string='Remaining Leaves', fnct_inv=_set_remaining_days, type="float", help='Total number of legal leaves allocated to this employee, change this value to create allocation/leave requests.', store=True),
}
hr_employee()
@@ -346,6 +346,7 @@
<field name="res_model">hr.recruitment.stage</field>
<field name="view_type">form</field>
<field name="view_id" ref="hr_recruitment_stage_tree"/>
<field name="help"> Check if the following stages are matching your recruitment process. Don't forget to specify the department if your recruitment process is different according to the job position.</field>
</record>
<menuitem
+1 -1
View File
@@ -7,7 +7,7 @@
<field name="standard_price">30.0</field>
<field name="uom_id" ref="product.uom_hour"/>
<field name="uom_po_id" ref="product.uom_hour"/>
<field name="name">Service on Timesheet</field>
<field name="name">Consultant</field>
<field name="categ_id" ref="product.cat0"/>
<field name="type">service</field>
<field eval="False" name="purchase_ok"/>
@@ -8,7 +8,7 @@
<field name="arch" type="xml">
<form string="Employee Invoice Data">
<field colspan="4" name="emp_ids" nolabel="1" mode="tree,form">
<tree string="Employee Invoice Data" editable="top">
<tree string="Employee Invoice Data" editable="bottom">
<field name="employee_id"/>
<field name="product_id"/>
<field name="journal_id"/>
+12 -10
View File
@@ -24,15 +24,19 @@
<field name="model">lunch.order</field>
<field name="arch" type="xml">
<form string="Order">
<group colspan="2" col="4">
<field name="user_id" select="1"/>
<field name="date" select="1"/>
<field name="product" select="1" on_change="onchange_product(product)"/>
<field name="category"/>
<field name="descript"/>
<field name="price"/>
<field name="cashmove"/>
<field name="user_id" select="1"/>
<field name="date" select="1"/>
<field name="product" select="1" on_change="onchange_product(product)"/>
<field name="category"/>
<field name="descript"/>
<field name="price"/>
<field name="cashmove"/>
<newline/>
<separator string="" colspan="4"/>
<group colspan="4" col="4">
<field name="state"/>
<button name="%(action_lunch_order_confirm)d" string="Confirm Order" type="action" icon="gtk-ok" attrs="{'invisible':[('state','=','confirmed')]}"/>
<button name="%(action_lunch_order_cancel)d" string="Cancel Order" type="action" icon="gtk-cancel"/>
</group>
</form>
</field>
@@ -187,7 +191,6 @@
<search string="Search CashMove">
<filter icon="terp-go-today" name="Today" string="Today" domain="[('create_date','&lt;=',time.strftime('%%Y-%%m-%%d 23:59:59'))]"/>
<separator orientation="vertical"/>
<field name="name"/>
<field name="user_cashmove"/>
<field name="create_date"/>
<newline/>
@@ -276,7 +279,6 @@
<tree string="Products">
<field name="name"/>
<field name="category_id"/>
<field name="description"/>
<field name="price"/>
</tree>
</field>
@@ -30,11 +30,11 @@
<field name="view_id" ref="view_lunch_order_cancel"/>
<field name="target">new</field>
</record>
<act_window id="action_lunch_order_cancel_values"
key2="client_action_multi" name="Cancel Order"
res_model="lunch.order.cancel" src_model="lunch.order"
view_mode="form" target="new" view_type="form"/>
view_mode="form" target="new" view_type="form"/>
</data>
</openerp>
+1
View File
@@ -40,6 +40,7 @@ This module only works with Unix/Linux.
],
"update_xml" : [
"users_ldap_view.xml",
"user_ldap_installer.xml",
],
"active": False,
"installable": True,
+54
View File
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- ldap installer Form View -->
<record model="ir.ui.view" id="view_ldap_installer_form">
<field name="name">ldap.installer.form</field>
<field name="model">res.company.ldap</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="LDAP Configuration">
<group col="2" colspan="2">
<separator string="Server Information" colspan="2"/>
<field name="ldap_server"/>
<field name="ldap_server_port"/>
</group>
<group col="2" colspan="2">
<separator string="Login Information" colspan="2"/>
<field name="ldap_binddn"/>
<field name="ldap_password"/>
</group>
<group col="2" colspan="2">
<separator string="Process Parameter" colspan="2"/>
<field name="ldap_base"/>
<field name="ldap_filter"/>
<field name="sequence"/>
</group>
<group col="2" colspan="2">
<separator string="User Information" colspan="2"/>
<field name="create_user"/>
<field name="user"/>
</group>
</form>
</field>
</record>
<!-- ldap installer action -->
<record id="action_ldap_installer" model="ir.actions.act_window">
<field name="name">Setup your LDAP Server</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.company.ldap</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_ldap_installer_form"/>
</record>
<record id="config_wizard_action_ldap_installer" model="ir.actions.todo">
<field name="action_id" ref="action_ldap_installer"/>
<field name="type">normal</field>
<field name="target">current</field>
<field name="state">skip</field>
</record>
</data>
</openerp>