[MERGE] Merge stock_planning module changes for view,code lp:~openerp-commiter/openobject-addons/trunk-addons-cleaning

bzr revid: sbh@tinyerp.com-20100803133303-ch89peq0wxan356q
This commit is contained in:
UCO(OpenERP]
2010-08-03 19:03:03 +05:30
committed by sbh (Open ERP)
6 changed files with 56 additions and 30 deletions
+20 -12
View File
@@ -48,6 +48,14 @@ class stock_period(osv.osv):
_defaults = {
'state': 'draft'
}
def button_open(self, cr, uid, ids, context):
self.write(cr, uid, ids, {'state': 'open'})
return True
def button_close(self, cr, uid, ids, context):
self.write(cr, uid, ids, {'state': 'close'})
return True
stock_period()
@@ -60,14 +68,14 @@ class stock_sale_forecast(osv.osv):
'company_id':fields.many2one('res.company', 'Company', required=True),
'create_uid': fields.many2one('res.users', 'Responsible'),
'name': fields.char('Name', size=64, readonly=True, states={'draft': [('readonly',False)]}),
'user_id': fields.many2one('res.users' , 'Created/Validated by',readonly=True, \
'user_id': fields.many2one('res.users', 'Created/Validated by',readonly=True, \
help='Shows who created this forecast, or who validated.'),
'warehouse_id': fields.many2one('stock.warehouse' , 'Warehouse', required=True, readonly=True, states={'draft': [('readonly',False)]}, \
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True, readonly=True, states={'draft': [('readonly',False)]}, \
help='Shows which warehouse this forecast concerns. '\
'If during stock planning you will need sales forecast for all warehouses choose any warehouse now.'),
'period_id': fields.many2one('stock.period' , 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}, \
'period_id': fields.many2one('stock.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}, \
help = 'Shows which period this forecast concerns.'),
'product_id': fields.many2one('product.product' , 'Product', readonly=True, required=True, states={'draft':[('readonly',False)]}, \
'product_id': fields.many2one('product.product', 'Product', readonly=True, required=True, states={'draft':[('readonly',False)]}, \
help = 'Shows which product this forecast concerns.'),
'product_qty': fields.float('Product Quantity', required=True, readonly=True, states={'draft':[('readonly',False)]}, \
help= 'Forecasted quantity.'),
@@ -81,13 +89,13 @@ class stock_sale_forecast(osv.osv):
# Field used in onchange_uom to check what uom was before change and recalculate quantities acording to old uom (active_uom) and new uom.
'active_uom': fields.many2one('product.uom', string = "Active UoM"),
'state': fields.selection([('draft','Draft'),('validated','Validated')],'State',readonly=True),
'analyzed_period1_id': fields.many2one('stock.period' , 'Period1', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period2_id': fields.many2one('stock.period' , 'Period2', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period3_id': fields.many2one('stock.period' , 'Period3', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period4_id': fields.many2one('stock.period' , 'Period4', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period1_id': fields.many2one('stock.period', 'Period1', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period2_id': fields.many2one('stock.period', 'Period2', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period3_id': fields.many2one('stock.period', 'Period3', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period4_id': fields.many2one('stock.period', 'Period4', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_period5_id': fields.many2one('stock.period' , 'Period5', readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_user_id': fields.many2one('res.users' , 'This User', required=False, readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_dept_id': fields.many2one('hr.department' , 'This Department', required=False, \
'analyzed_user_id': fields.many2one('res.users', 'This User', required=False, readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_dept_id': fields.many2one('hr.department', 'This Department', required=False, \
readonly=True, states={'draft':[('readonly',False)]},),
'analyzed_warehouse_id': fields.many2one('stock.warehouse' , 'This Warehouse', required=False, \
readonly=True, states={'draft':[('readonly',False)]}),
@@ -192,7 +200,7 @@ class stock_sale_forecast(osv.osv):
def _to_default_uom_factor(self, cr, uid, val, uom_id, context=None):
uom_obj = self.pool.get('product.uom')
uom = uom_obj.browse(cr, uid, uom_id, context=context)
coef = uom.factor
coef = uom.factor
if uom.category_id.id <> val.product_id.uom_id.category_id.id:
coef = coef / val.product_id.uos_coeff
return val.product_id.uom_id.factor / coef
@@ -245,7 +253,7 @@ class stock_sale_forecast(osv.osv):
dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)])
# dept_ids_set = ','.join(map(str,dept_ids))
# cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" ,(tuple(dept_ids),))
cr.execute("SELECT id FROM hr_employee WHERE (department_id IN %s)" ,(tuple(dept_ids),))
cr.execute("SELECT user_id FROM resource_resource rsc, hr_employee emp WHERE (emp.resource_id = rsc.id and emp.department_id IN %s)" ,(tuple(dept_ids),))
dept_users = [x for x, in cr.fetchall()]
# dept_users_set = ','.join(map(str,dept_users))
dept_users_set = map(str,dept_users)
+27 -3
View File
@@ -13,10 +13,16 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Stock and Sales Periods">
<field name="name"/>
<field name="name" colspan="2"/>
<newline/>
<field name="date_start"/>
<field name="state" select="1"/>
<field name="date_stop"/>
<separator string="State" colspan="4"/>
<group col="4" colspan="4">
<field name="state" select="1" readonly="1"/>
<button name="button_open" string="Open" icon="gtk-ok" states="draft" type="object"/>
<button name="button_close" string="Close" icon="gtk-stop" states="open" type="object"/>
</group>
</form>
</field>
</record>
@@ -26,7 +32,7 @@
<field name="model">stock.period</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Stock and Sales Period" editable="bottom">
<tree string="Stock and Sales Period" editable="bottom" colors="gray:state == 'close';black:state in ('draft','open')">
<field name="name"/>
<field name="date_start"/>
<field name="date_stop"/>
@@ -34,12 +40,29 @@
</tree>
</field>
</record>
<record id="view_stock_period_search" model="ir.ui.view">
<field name="name">stock.period.search</field>
<field name="model">stock.period</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Stock and Sales Period">
<filter string="Current" domain="[('state','in',['draft','open'])]" icon="terp-check" help="Current Periods"/>
<filter string="Closed" domain="[('state','=','close')]" icon="gtk-stop" help="Closed Periods"/>
<separator orientation="vertical"/>
<field name="name"/>
<field name="date_start"/>
<field name="date_stop"/>
</search>
</field>
</record>
<record id="action_stock_period_form" model="ir.actions.act_window">
<field name="name">Stock and Sales Periods</field>
<field name="res_model">stock.period</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_stock_period_search"/>
</record>
<menuitem
@@ -302,6 +325,7 @@
<field name="warehouse_forecast" string="Forecast"/>
<field name="planned_outgoing"/>
<field name="to_procure"/>
<field name="line_time" invisible="1"/>
<field name="stock_simulation" string="Stock"/> <!-- previously stock_start -->
<field name="warehouse_id" domain = "[('company_id','=',company_id)] " />
</tree>
@@ -44,8 +44,8 @@ class stock_period_createlines(osv.osv_memory):
_columns = {
'name': fields.char('Period Name', size=64),
'date_start': fields.date('Start Date', required=True),
'date_stop': fields.date('End Date', required=True),
'date_start': fields.date('Start Date', required=True, help="Starting date for planning period."),
'date_stop': fields.date('End Date', required=True, help="Ending date for planning period."),
'period_ids': fields.one2many('stock.period', 'planning_id', 'Periods'),
}
_defaults={
@@ -13,10 +13,11 @@
<field name="date_start"/>
<field name="date_stop"/>
<separator colspan="4" string=""/>
<group col="3" colspan="4">
<button name="create_stock_periods" icon="gtk-execute" string="Create Daily Periods" type="object"/>
<button name="create_stock_periods" icon="gtk-execute" string="Create Weekly Periods" type="object" context="{'interval': 6, 'name': 'Weekly'}"/>
<button name="create_stock_periods" icon="gtk-execute" string="Create Monthly Periods" type="object" context="{'interval': 1, 'name': 'Monthly'}"/>
<group col="4" colspan="4">
<button string="Cancel" special="cancel" icon="gtk-cancel"/>
<button name="create_stock_periods" icon="gtk-dnd" string="Create Daily Periods" type="object"/>
<button name="create_stock_periods" icon="gtk-dnd" string="Create Weekly Periods" type="object" context="{'interval': 6, 'name': 'Weekly'}"/>
<button name="create_stock_periods" icon="gtk-dnd" string="Create Monthly Periods" type="object" context="{'interval': 1, 'name': 'Monthly'}"/>
</group>
</form>
</field>
@@ -62,7 +62,7 @@ class stock_planning_createlines(osv.osv_memory):
if f.forecasted_products:
cr.execute("SELECT product_id \
FROM stock_sale_forecast \
WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id2.id, f.warehouse_id2.id))
WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id.id, f.warehouse_id.id))
products_id1 = [x for x, in cr.fetchall()]
else:
categ_ids = f.product_categ_id.id and [f.product_categ_id.id] or []
@@ -27,20 +27,13 @@ class stock_sale_forecast_createlines(osv.osv_memory):
_name = "stock.sale.forecast.createlines"
_description = "stock.sale.forecast.createlines"
# FIXME Add some period sugestion like below
# def _get_latest_period(self,cr,uid,context={}):
# cr.execute("select max(date_stop) from stock_period")
# result=cr.fetchone()
# return result and result[0] or False
_columns = {
'company_id': fields.many2one('res.company', 'Company', required=True, select=1),
'warehouse_id': fields.many2one('stock.warehouse' , 'Warehouse', required=True, \
help='Warehouse which forecasts will concern. '\
'If during stock planning you will need sales forecast for all warehouses choose any warehouse now.'),
'period_id': fields.many2one('stock.period' , 'Period', required=True, help = 'Period which forecasts will concern.' ),
'period_id': fields.many2one('stock.period', 'Period', required=True, help='Period which forecasts will concern.'),
'product_categ_id': fields.many2one('product.category' , 'Product Category', required=True, \
help ='Product Category of products which created forecasts will concern.'),
'copy_forecast': fields.boolean('Copy Last Forecast', help="Copy quantities from last Stock and Sale Forecast."),