[MERGE]: Merge with lp:openobject-trunk-dev-addons2

bzr revid: aag@tinyerp.co.in-20110112043106-liyf9ufydzeh3jew
This commit is contained in:
aag (OpenERP)
2011-01-12 10:01:06 +05:30
12 changed files with 180 additions and 178 deletions
@@ -23,33 +23,15 @@ from osv import fields, osv
from tools.translate import _
from tools import ustr
class report_creator(osv.osv):
class report_result(osv.osv):
"""
Report Creator
"""
_name = "base_report_creator.report"
_name = "base_report_creator_report.result"
_description = "Report"
model_set_id = False
#
# Should request only used fields
#
def export_data(self, cr, uid, ids, fields_to_export, context=None):
if context is None:
context = {}
data_l = self.read(cr, uid, ids, ['sql_query'], context=context)
final_datas = []
#start Loop
for record in data_l:
datas = []
for key in fields_to_export:
value = record.get(key,'')
if isinstance(value, tuple):
datas.append(ustr(value[1]))
else:
datas.append(ustr(value))
final_datas += [datas]
#End Loop
return {'datas': final_datas}
def fields_get(self, cr, user, fields=None, context=None):
"""
@@ -64,9 +46,9 @@ class report_creator(osv.osv):
data = context and context.get('report_id', False) or False
if (not context) or 'report_id' not in context:
return super(report_creator, self).fields_get(cr, user, fields, context)
return super(report_result, self).fields_get(cr, user, fields, context)
if data:
report = self.browse(cr, user, data)
report = self.pool.get('base_report_creator.report').browse(cr, user, data,context=context)
models = {}
#Start Loop
for model in report.model_ids:
@@ -80,12 +62,8 @@ class report_creator(osv.osv):
i += 1
else:
fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'}
return fields
#
# Should Call self.fields_get !
#
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
"""
Overrides orm field_view_get.
@@ -98,8 +76,8 @@ class report_creator(osv.osv):
data = context and context.get('report_id', False) or False
if (not context) or 'report_id' not in context:
return super(report_creator, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
report = self.browse(cr, user, data)
return super(report_result, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
report = self.pool.get('base_report_creator.report').browse(cr, user, context.get('report_id'), context=context)
models = {}
for model in report.model_ids:
models[model.model] = self.pool.get(model.model).fields_get(cr, user, context=context)
@@ -192,31 +170,11 @@ class report_creator(osv.osv):
"""
if context is None:
context = {}
data = context.get('report_id', False)
res = super(report_creator, self).read(cr, user, ids, fields, context, load)
if (not context) or 'report_id' not in context:
return res
wp = ''
for data in res:
if not data.get('sql_query'):
return res
if self.model_set_id:
wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))]
cr.execute(data['sql_query'])
res = cr.dictfetchall()
fields_get = self.fields_get(cr, user, None, context)
for r in res:
for k in r:
r[k] = r[k] or False
field_dict = fields_get.get(k)
field_type = field_dict and field_dict.get('type', False) or False
if field_type and field_type == 'many2one':
if r[k] == False:
continue
related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0]
r[k] = related_name
return res
report_id = context.get('active_id', False)
report = self.pool.get('base_report_creator.report').browse(cr, user, context.get('report_id'), context=context)
cr.execute(report.sql_query)
result = cr.dictfetchall()
return result
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
"""
@@ -231,9 +189,9 @@ class report_creator(osv.osv):
context_id = context.get('report_id', False)
if (not context) or 'report_id' not in context:
return super(report_creator, self).search(cr, user, args, offset, limit, order, context, count)
return {}
if context_id:
report = self.browse(cr, user, context_id)
report = self.pool.get('base_report_creator.report').browse(cr, user, context_id, context=context)
i = 0
fields = {}
for f in report.field_ids:
@@ -254,10 +212,42 @@ class report_creator(osv.osv):
ctx = context or {}
ctx['getid'] = True
sql_query = report.sql_query
cr.execute(sql_query, newargs2)
cr.execute(sql_query) # TODO: FILTER
result = cr.fetchall()
return map(lambda x: x[0], result)
report_result()
class report_creator(osv.osv):
"""
Report Creator
"""
_name = "base_report_creator.report"
_description = "Report"
model_set_id = False
#
# Should request only used fields
#
def export_data(self, cr, uid, ids, fields_to_export, context=None):
if context is None:
context = {}
data_l = self.read(cr, uid, ids, ['sql_query'], context=context)
final_datas = []
#start Loop
for record in data_l:
datas = []
for key in fields_to_export:
value = record.get(key,'')
if isinstance(value, tuple):
datas.append(ustr(value[1]))
else:
datas.append(ustr(value))
final_datas += [datas]
#End Loop
return {'datas': final_datas}
def _path_get(self, cr, uid, models, filter_ids=[]):
"""
@param cr: the current row, from the database cursor,
@@ -465,7 +455,7 @@ class report_creator(osv.osv):
'name': rep.name,
'view_type': 'form',
'view_mode': view_mode,
'res_model': 'base_report_creator.report',
'res_model': 'base_report_creator_report.result',
'type': 'ir.actions.act_window',
'context': "{'report_id':%d}" % (rep.id,),
'nodestroy': True,
@@ -596,3 +586,4 @@ class report_creator_filter(osv.osv):
}
report_creator_filter()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+5 -4
View File
@@ -41,7 +41,7 @@ appropriate staff, and make sure all future correspondence gets to the right
place.
The CRM module has a email gateway for the synchronisation interface
between mails and OpenERP.
between mails and OpenERP.
Create dashboard for CRM that includes:
* My Leads (list)
* Leads by Stage (graph)
@@ -95,6 +95,7 @@ Create dashboard for CRM that includes:
'crm_meeting_view.xml',
'crm_meeting_menu.xml',
'crm_meeting_shortcut_data.xml',
'crm_phonecall_view.xml',
'crm_phonecall_menu.xml',
@@ -106,12 +107,12 @@ Create dashboard for CRM that includes:
'report/crm_phonecall_report_view.xml',
'process/crm_configuration_process.xml',
'crm_installer_view.xml',
'crm_installer_view.xml',
'res_partner_view.xml',
'board_crm_view.xml',
'board_crm_statistical_view.xml',
],
'demo_xml': [
'crm_demo.xml',
-6
View File
@@ -92,12 +92,6 @@
action="crm_case_categ_meet" parent="menu_meeting_sale"
sequence="1" />
<record id="ir_ui_view_sc_calendar0" model="ir.ui.view_sc">
<field name="name">Meetings</field>
<field name="resource">ir.ui.menu</field>
<field name="user_id" ref="base.user_root"/>
<field name="res_id" ref="crm.menu_crm_case_categ_meet"/>
</record>
<record id="action_view_attendee_form" model="ir.actions.act_window">
<field name="name">Meeting Invitations</field>
<field name="type">ir.actions.act_window</field>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<openerp>
<data noupdate="1">
<record id="ir_ui_view_sc_calendar0" model="ir.ui.view_sc">
<field name="name">Meetings</field>
<field name="resource">ir.ui.menu</field>
<field name="user_id" ref="base.user_root"/>
<field name="res_id" ref="crm.menu_crm_case_categ_meet"/>
</record>
</data>
</openerp>
+11 -5
View File
@@ -342,7 +342,7 @@ class mrp_bom(osv.osv):
if context is None:
context = {}
bom_data = self.read(cr, uid, id, [], context=context)
default.update({'name': bom_data['name'] + ' ' + _('Copy')})
default.update({'name': bom_data['name'] + ' ' + _('Copy'), 'bom_id':False})
return super(mrp_bom, self).copy_data(cr, uid, id, default, context=context)
mrp_bom()
@@ -444,7 +444,7 @@ class mrp_production(osv.osv):
'bom_id': fields.many2one('mrp.bom', 'Bill of Material', domain=[('bom_id','=',False)]),
'routing_id': fields.many2one('mrp.routing', string='Routing', on_delete='set null', help="The list of operations (list of work centers) to produce the finished product. The routing is mainly used to compute work center costs during operations and to plan future loads on work centers based on production plannification."),
'picking_id': fields.many2one('stock.picking', 'Picking list', readonly=True,
'picking_id': fields.many2one('stock.picking', 'Picking list', readonly=True, ondelete="restrict",
help="This is the internal picking list that brings the finished product to the production plan"),
'move_prod_id': fields.many2one('stock.move', 'Move product', readonly=True),
'move_lines': fields.many2many('stock.move', 'mrp_production_move_ids', 'production_id', 'move_id', 'Products to Consume', domain=[('state','not in', ('done', 'cancel'))], states={'done':[('readonly',True)]}),
@@ -602,12 +602,18 @@ class mrp_production(osv.osv):
workcenter_line_obj.create(cr, uid, line)
return len(results)
def action_cancel(self, cr, uid, ids):
def action_cancel(self, cr, uid, ids, context=None):
""" Cancels the production order and related stock moves.
@return: True
"""
if context is None:
context = {}
move_obj = self.pool.get('stock.move')
for production in self.browse(cr, uid, ids):
for production in self.browse(cr, uid, ids, context=context):
if production.state == 'confirmed' and production.picking_id.state not in ('draft', 'cancel'):
raise osv.except_osv(
_('Could not cancel manufacturing order !'),
_('You must first cancel related internal picking attached to this manufacturing order.'))
if production.move_created_ids:
move_obj.action_cancel(cr, uid, [x.id for x in production.move_created_ids])
move_obj.action_cancel(cr, uid, [x.id for x in production.move_lines])
@@ -664,7 +670,7 @@ class mrp_production(osv.osv):
"""
stock_mov_obj = self.pool.get('stock.move')
production = self.browse(cr, uid, production_id, context=context)
final_product_todo = []
produced_qty = 0
+2 -1
View File
@@ -630,7 +630,8 @@
<separator colspan="4"/>
<group col="9" colspan="4">
<field name="state"/>
<button name="button_cancel" states="draft,ready,confirmed,in_production,picking_except" string="Cancel" icon="gtk-stop"/>
<button name="button_cancel" states="draft,ready,in_production,picking_except" string="Cancel" icon="gtk-stop"/>
<button name="action_cancel" type="object" states="confirmed" string="Cancel" icon="gtk-stop"/>
<button name="button_confirm" states="draft" string="Confirm Production" icon="gtk-apply"/>
<button name="button_produce" states="ready" string="Start Production" icon="terp-gtk-jump-to-ltr"/>
<button name="%(act_mrp_product_produce)d" states="in_production" string="Produce" icon="gtk-ok" type="action"/>
+1
View File
@@ -53,6 +53,7 @@
'product_data.xml',
'product_report.xml',
'product_view.xml',
'product_shortcut_data.xml',
'pricelist_view.xml',
'partner_view.xml',
'process/product_process.xml'
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="ir_ui_view_sc_product0" model="ir.ui.view_sc">
<field name="name">Products</field>
<field name="resource">ir.ui.menu</field>
<field name="user_id" ref="base.user_root"/>
<field name="res_id" ref="product.menu_products"/>
</record>
</data>
</openerp>
+2 -8
View File
@@ -9,7 +9,7 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Product">
<filter string="Services" icon="terp-accessories-archiver" domain="[('type','=','service')]"/>
<filter string="Services" icon="terp-accessories-archiver" domain="[('type','=','service')]"/>
<filter string="Stockable" icon="terp-accessories-archiver" domain="['|',('type','=','product'),('type','=','consu')]"/>
<separator orientation="vertical"/>
<filter string="To Sell" icon="terp-accessories-archiver-minus" domain="[('sale_ok','=',1)]"/>
@@ -30,7 +30,7 @@
<separator orientation="vertical"/>
<filter string='Type' icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'type'}" />
</group>
</search>
</field>
</record>
@@ -635,12 +635,6 @@
<field name="view_type">form</field>
<field name="view_id" ref="product_template_tree_view"/>
</record>
<record id="ir_ui_view_sc_product0" model="ir.ui.view_sc">
<field name="name">Products</field>
<field name="resource">ir.ui.menu</field>
<field name="user_id" ref="base.user_root"/>
<field name="res_id" ref="product.menu_products"/>
</record>
</data>
</openerp>
@@ -4,6 +4,9 @@
<record id="base.de" model="res.country">
<field eval="True" name="intrastat"/>
</record>
<record id="base.be" model="res.country">
<field eval="True" name="intrastat"/>
</record>
<record id="base.at" model="res.country">
<field eval="True" name="intrastat"/>
</record>
+1 -1
View File
@@ -106,7 +106,7 @@
<separator string="Stocks" colspan="4"/>
<field name="qty_available"/>
<button name="%(action_view_change_product_quantity)d" string="Update" attrs="{'invisible': [('type', '=', 'service')]}"
type="action" icon="gtk-execute" groups = "stock.group_stock_manager,base.group_sale_manager,purchase.group_purchase_manager,stock.group_stock_manager,mrp.group_mrp_manager"/>
type="action" icon="gtk-execute" groups = "stock.group_stock_manager,stock.group_stock_user"/>
<newline/>
<field name="virtual_available"/>
</group>
+81 -96
View File
@@ -28,54 +28,74 @@ class stock_partial_picking(osv.osv_memory):
_name = "stock.partial.picking"
_description = "Partial Picking"
_columns = {
'date': fields.datetime('Date', required=True),
'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'),
'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'),
'date': fields.datetime('Date', required=True),
'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'),
'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'),
}
def __is_in(self,cr, uid, pick_ids):
def get_picking_type(self, cr, uid, picking, context=None):
picking_type = picking.type
for move in picking.move_lines:
if picking.type == 'in' and move.product_id.cost_method == 'average':
picking_type = 'in'
break
else:
picking_type = 'out'
return picking_type
def default_get(self, cr, uid, fields, context=None):
""" To get default values for the object.
@param self: The object pointer.
@param cr: A database cursor
@param uid: ID of the user currently logged in
@param fields: List of fields for which we want default values
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
@return: True if one of the moves has as picking type 'in'
"""
if not pick_ids:
return False
if context is None:
context = {}
pick_obj = self.pool.get('stock.picking')
pick_ids = pick_obj.search(cr, uid, [('id','in',pick_ids)])
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
picking_ids = context.get('active_ids', [])
if not picking_ids:
return res
result = []
for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
pick_type = self.get_picking_type(cr, uid, pick, context=context)
for m in pick.move_lines:
if m.state in ('done', 'cancel'):
continue
result.append(self.__create_partial_picking_memory(m, pick_type))
for pick in pick_obj.browse(cr, uid, pick_ids):
for move in pick.move_lines:
if pick.type == 'in' and move.product_id.cost_method == 'average':
return True
return False
def __get_picking_type(self, cr, uid, pick_ids):
if self.__is_in(cr, uid, pick_ids):
return "product_moves_in"
else:
return "product_moves_out"
def view_init(self, cr, uid, fields_list, context=None):
res = super(stock_partial_picking, self).view_init(cr, uid, fields_list, context=context)
if 'product_moves_in' in fields:
res.update({'product_moves_in': result})
if 'product_moves_out' in fields:
res.update({'product_moves_out': result})
if 'date' in fields:
res.update({'date': time.strftime('%Y-%m-%d %H:%M:%S')})
return res
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False):
result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
pick_obj = self.pool.get('stock.picking')
picking_ids = context.get('active_ids', False)
picking_type = self.__get_picking_type(cr, uid, picking_ids)
for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
picking_type = self.get_picking_type(cr, uid, pick, context=context)
_moves_arch_lst = """<form string="%s">
<field name="date" invisible="1"/>
<separator colspan="4" string="%s"/>
<field name="%s" colspan="4" nolabel="1" mode="tree,form" width="550" height="200" ></field>
""" % (_('Process Document'), _('Products'), picking_type)
""" % (_('Process Document'), _('Products'), "product_moves_" + picking_type)
_moves_fields = result['fields']
# add field related to picking type only
_moves_fields.update({
'product_moves_in' : {'relation': 'stock.move.memory.in', 'type' : 'one2many', 'string' : 'Product Moves'},
'product_moves_out' : {'relation': 'stock.move.memory.out', 'type' : 'one2many', 'string' : 'Product Moves'}
'product_moves_' + picking_type: {'relation': 'stock.move.memory.'+picking_type, 'type' : 'one2many', 'string' : 'Product Moves'},
})
_moves_arch_lst += """
@@ -92,44 +112,22 @@ class stock_partial_picking(osv.osv_memory):
result['fields'] = _moves_fields
return result
def __create_partial_picking_memory(self, picking, is_in):
def __create_partial_picking_memory(self, picking, pick_type):
move_memory = {
'product_id' : picking.product_id.id,
'quantity' : picking.product_qty,
'product_uom' : picking.product_uom.id,
'prodlot_id' : picking.prodlot_id.id,
'move_id' : picking.id,
'product_id' : picking.product_id.id,
'quantity' : picking.product_qty,
'product_uom' : picking.product_uom.id,
'prodlot_id' : picking.prodlot_id.id,
'move_id' : picking.id,
}
if is_in:
if pick_type == 'in':
move_memory.update({
'cost' : picking.product_id.standard_price,
'currency' : picking.product_id.company_id and picking.product_id.company_id.currency_id and picking.product_id.company_id.currency_id.id or False,
'cost' : picking.product_id.standard_price,
'currency' : picking.product_id.company_id.currency_id.id,
})
return move_memory
def __get_active_stock_pickings(self, cr, uid, context=None):
pick_obj = self.pool.get('stock.picking')
if not context:
context = {}
res = []
for pick in pick_obj.browse(cr, uid, context.get('active_ids', []), context):
need_product_cost = (pick.type == 'in')
for m in pick.move_lines:
if m.state in ('done', 'cancel'):
continue
res.append(self.__create_partial_picking_memory(m, need_product_cost))
return res
_defaults = {
'product_moves_in' : __get_active_stock_pickings,
'product_moves_out' : __get_active_stock_pickings,
'date' : lambda *a : time.strftime('%Y-%m-%d %H:%M:%S'),
}
def do_partial(self, cr, uid, ids, context=None):
""" Makes partial moves and pickings done.
@param self: The object pointer.
@@ -140,6 +138,9 @@ class stock_partial_picking(osv.osv_memory):
@return: A dictionary which of fields with values.
"""
pick_obj = self.pool.get('stock.picking')
move_obj = self.pool.get('stock.move')
location_obj = self.pool.get('stock.location')
picking_ids = context.get('active_ids', False)
partial = self.browse(cr, uid, ids[0], context=context)
partial_datas = {
@@ -147,40 +148,24 @@ class stock_partial_picking(osv.osv_memory):
}
for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
need_product_cost = (pick.type == 'in')
moves_list = need_product_cost and partial.product_moves_in or partial.product_moves_out
p_moves = {}
for product_move in moves_list:
p_moves[product_move.move_id.id] = product_move
picking_type = self.get_picking_type(cr, uid, pick, context=context)
moves_list = picking_type == 'in' and partial.product_moves_in or partial.product_moves_out
for move in pick.move_lines:
if move.state in ('done', 'cancel'):
continue
if not p_moves.get(move.id):
continue
partial_datas['move%s' % (move.id)] = {
'product_id' : p_moves[move.id].id,
'product_qty' : p_moves[move.id].quantity,
'product_uom' :p_moves[move.id].product_uom.id,
'prodlot_id' : p_moves[move.id].prodlot_id.id,
for move in moves_list:
partial_datas['move%s' % (move.move_id.id)] = {
'product_id': move.id,
'product_qty': move.quantity,
'product_uom': move.product_uom.id,
'prodlot_id': move.prodlot_id.id,
}
if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'):
partial_datas['move%s' % (move.id)].update({
'product_price' : p_moves[move.id].cost,
'product_currency': p_moves[move.id].currency.id,
if (picking_type == 'in') and (move.product_id.cost_method == 'average'):
partial_datas['move%s' % (move.move_id.id)].update({
'product_price' : move.cost,
'product_currency': move.currency.id,
})
pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
return {'type': 'ir.actions.act_window_close'}
return {}
stock_partial_picking()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: