[MERGE] various changes

analytic_user_function: fix traceback with non-existant variable
lunch: name_get and remove create button on you lunch account view
mail: being more permissive on check to also allow creating message when have create access rights on model

bzr revid: mat@openerp.com-20130821155818-ktljx5c1my4w540j
This commit is contained in:
Martin Trigaux
2013-08-21 17:58:18 +02:00
4 changed files with 66 additions and 36 deletions
@@ -42,6 +42,7 @@ class analytic_user_funct_grid(osv.osv):
return {}
value = {}
prod = False
if product_id:
prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
emp = emp_obj.browse(cr, uid, emp_id[0], context=context)
+10
View File
@@ -35,6 +35,16 @@ class lunch_order(osv.Model):
_description = 'Lunch Order'
_order = 'date desc'
def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
res = []
for elmt in self.browse(cr, uid, ids, context=context):
name = _("Lunch Order")
name = name + ' ' + str(elmt.id)
res.append((elmt.id, name))
return res
def _price_get(self, cr, uid, ids, name, arg, context=None):
"""
get and sum the order lines' price
+50 -32
View File
@@ -84,6 +84,39 @@
</field>
</record>
<!--view for cashmove-->
<record model="ir.ui.view" id="casmove_tree_view">
<field name="name">cashmove tree</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<tree string="cashmove tree">
<field name="date"/>
<field name="user_id"/>
<field name="description"/>
<field name="amount" sum="Total"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="casmove_form_view">
<field name="name">cashmove form</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<form string="cashmove form" version="7.0">
<sheet>
<group>
<field name="user_id"/>
<field name="date"/>
<field name="amount"/>
</group>
<label for='description'/>
<field name="description"/>
</sheet>
</form>
</field>
</record>
<!--Action for Your Orders-->
<record model="ir.actions.act_window" id="action_lunch_order_form">
<field name="name">New Order</field>
@@ -110,6 +143,19 @@
</field>
</record>
<menuitem name="Previous Orders" parent="menu_lunch_title" id="menu_lunch_order_tree" action="action_lunch_order_tree" sequence="2"/>
<record model="ir.ui.view" id="casmove_tree">
<field name="name">cashmove tree</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<tree string="cashmove tree" version="7.0" create='false'>
<field name="date"/>
<field name="user_id"/>
<field name="description"/>
<field name="amount" sum="Total"/>
</tree>
</field>
</record>
<!--Action for Lunch cashmoves-->
<record model="ir.actions.act_window" id="action_lunch_cashmove_form">
@@ -118,6 +164,7 @@
<field name="view_mode">tree</field>
<field name="search_view_id" ref="view_lunch_employee_payment_filter"/>
<field name="context">{"search_default_is_mine_group":1}</field>
<field name="view_id" ref="casmove_tree"/>
<field name="help" type="html">
<p>
Here you can see your cash moves.<br/>A cash moves can be either an expense or a payment.
@@ -174,6 +221,7 @@
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_lunch_cashmove_filter"/>
<field name="context">{"search_default_group_by_user":1}</field>
<field name="view_id" ref="casmove_tree_view"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a new payment.
@@ -195,6 +243,7 @@
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_lunch_employee_payment_filter"/>
<field name="context">{"search_default_is_payment":1}</field>
<field name="view_id" ref="casmove_tree_view"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a payment.
@@ -386,38 +435,7 @@
</field>
</record>
<!--view for cashmove-->
<record model="ir.ui.view" id="casmove_tree_view">
<field name="name">cashmove tree</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<tree string="cashmove tree">
<field name="date"/>
<field name="user_id"/>
<field name="description"/>
<field name="amount" sum="Total"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="casmove_form_view">
<field name="name">cashmove form</field>
<field name="model">lunch.cashmove</field>
<field name="arch" type="xml">
<form string="cashmove form" version="7.0">
<sheet>
<group>
<field name="user_id"/>
<field name="date"/>
<field name="amount"/>
</group>
<label for='description'/>
<field name="description"/>
</sheet>
</form>
</field>
</record>
<!--view for alerts-->
<record model="ir.ui.view" id="alert_tree_view">
<field name="name">alert tree</field>
+5 -4
View File
@@ -641,14 +641,14 @@ class mail_message(osv.Model):
- no model, no res_id, I create a private message OR
- pid in message_follower_ids if model, res_id OR
- mail_notification (parent_id.id, pid) exists, uid has been notified of the parent, OR
- uid have write access on the related document if model, res_id, OR
- uid have write or create access on the related document if model, res_id, OR
- otherwise: raise
- write: if
- author_id == pid, uid is the author, OR
- uid has write access on the related document if model, res_id
- uid has write or create access on the related document if model, res_id
- otherwise: raise
- unlink: if
- uid has write access on the related document if model, res_id
- uid has write or create access on the related document if model, res_id
- otherwise: raise
"""
def _generate_model_record_ids(msg_val, msg_ids=[]):
@@ -722,7 +722,8 @@ class mail_message(osv.Model):
model_obj = self.pool.get(model)
mids = model_obj.exists(cr, uid, doc_dict.keys())
if operation in ['create', 'write', 'unlink']:
model_obj.check_access_rights(cr, uid, 'write')
if not model_obj.check_access_rights(cr, uid, 'write', raise_exception=False):
model_obj.check_access_rights(cr, uid, 'create')
model_obj.check_access_rule(cr, uid, mids, 'write', context=context)
else:
model_obj.check_access_rights(cr, uid, operation)