[MERGE]: Merged with lp:~openerp-dev/openobject-addons/ron-dev-addons2

bzr revid: rpa@tinyerp.com-20101222110542-j33o6xe24p4dy0tb
This commit is contained in:
rpa (Open ERP) 2010-12-22 16:35:42 +05:30
commit 6c514475ca
15 changed files with 321 additions and 45 deletions

View File

@ -602,6 +602,11 @@
string="Consume Products" type="action"
icon="gtk-go-forward" context="{'consume': True}"
states="draft,waiting,confirmed,assigned" />
<button
name="%(stock.track_line)d"
string="Split in production lots"
type="action" icon="gtk-justify-fill"
states="draft,waiting,confirmed,assigned" />
<button name="%(stock.move_scrap)d"
string="Scrap Products" type="action"
icon="gtk-convert" context="{'scrap': True}"
@ -619,11 +624,6 @@
<field name="prodlot_id" context="{'product_id': product_id}"/>
<field name="state" invisible="1"/>
<field name="scrapped" invisible="1"/>
<button
name="%(stock.track_line)d"
string="Split in production lots"
type="action" icon="gtk-justify-fill"
states="done,cancel" />
<button
name="%(stock.move_scrap)d"
string="Scrap Products" type="action"

View File

@ -35,6 +35,7 @@
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom" string="UOM"/>
<field name="state" invisible = "1"/>
<field name="message"/>
</tree>
</field>

View File

@ -53,7 +53,7 @@ def check_ean(eancode):
evensum += int(finalean[i])
total=(oddsum * 3) + evensum
check = int(10 - math.ceil(total % 10.0))
check = int(10 - math.ceil(total % 10.0)) %10
if check != int(eancode[-1]):
return False

View File

@ -188,7 +188,7 @@
<field name="state" readonly="1"/>
<button name="purchase_cancel" states="draft,confirmed,wait_auth" string="Cancel" icon="gtk-cancel"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
<button name="action_cancel" states="approved,except_picking,except_invoice" string="Cancel Purchase Order" type="object" icon="gtk-cancel"/>
<button name="action_cancel" states="approved,except_picking,except_invoice,wait" string="Cancel Purchase Order" type="object" icon="gtk-cancel"/>
<button name="picking_ok" states="except_picking" string="Manually Corrected" icon="gtk-convert"/>
<button name="invoice_ok" states="except_invoice" string="Manually Corrected" icon="gtk-convert"/>
<button name="purchase_confirm" states="draft" string="Convert to Purchase Order" icon="gtk-go-forward"/>
@ -234,7 +234,7 @@
<group col='10' colspan='4'>
<filter icon="terp-document-new" name="draft" string="Quotations" domain="[('state','=','draft')]" separator="1" help="Purchase order which are in draft state"/>
<filter icon="terp-camera_test" name="confirmed" string="To Approve" domain="[('state','in',('wait','confirmed'))]" separator="1" help="Purchase order to be approved"/>
<filter icon="terp-check" name="approved" string="Approved" domain="[('state','in',('approved','done'))]" separator="1" help="Approved purchase order"/>
<filter icon="terp-check" name="approved" string="Approved" domain="[('state','=','approved')]" separator="1" help="Approved purchase order"/>
<separator orientation="vertical"/>
<filter icon="terp-emblem-important" name="exception" string="Exception" domain="[('state','in',('except_invoice','except_picking'))]" separator="1" help="Purchase order which are in the exception state"/>
<separator orientation="vertical"/>

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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/>.
#
##############################################################################
import purchase_double_validation_installer
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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/>.
#
##############################################################################
{
"name" : "purchase_double_validation",
"version" : "1.1",
"category": 'Generic Modules/Sales & Purchases',
"depends" : ["base","purchase"],
"author" : 'OpenERP SA',
"description": """
This module modifies purchase workflow in order to validate purchases that exceeds minimum amount set by configuration wizard
""",
'website': 'http://www.openerp.com',
'init_xml': [],
'update_xml': [
'purchase_double_validation_view.xml',
'purchase_double_validation_workflow.xml',
'purchase_double_validation_installer.xml'
],
'demo_xml': [],
'installable': True,
'active': False,
}

View File

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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/>.
#
##############################################################################
import time
from osv import fields, osv
class purchase_double_validation_installer(osv.osv_memory):
_name = 'purchase.double.validation.installer'
_inherit = 'res.config'
_columns = {
'limit_amount': fields.integer('Limit Amount', required=True, help="Minimum amount after which validation of purchase is required."),
}
_defaults = {
'limit_amount': 1000,
}
def execute(self, cr, uid, ids, context=None):
data = self.read(cr, uid, ids, context=context)
if not data:
return {}
amt = data[0]['limit_amount']
data_pool = self.pool.get('ir.model.data')
transition_obj = self.pool.get('workflow.transition')
waiting = data_pool._get_id(cr, uid, 'purchase_double_validation', 'trans_router1_waiting')
waiting_id = data_pool.browse(cr, uid, waiting, context=context).res_id
confirm = data_pool._get_id(cr, uid, 'purchase', 'trans_draft_confirmed')
confirm_id = data_pool.browse(cr, uid, confirm, context=context).res_id
transition_obj.write(cr, uid, waiting_id, {'condition': 'amount_total>%s' % (amt), 'signal': False})
transition_obj.write(cr, uid, confirm_id, {'condition': 'amount_total<=%s' % (amt), 'signal': False})
return {}
purchase_double_validation_installer()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- configartion view -->
<record id="view_config_purchase_limit_amount" model="ir.ui.view">
<field name="name">Configure Limit Amount for Purchase</field>
<field name="model">purchase.double.validation.installer</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml">
<data>
<form position="attributes">
<attribute name="string">Purchase Application Configuration</attribute>
</form>
<separator string="title" position="attributes">
<attribute name="string">Configure Limit Amount for Purchase</attribute>
</separator>
<xpath expr="//label[@string='description']" position="attributes">
<attribute name="string">Define minimum amount after which puchase is needed to be validated.</attribute>
</xpath>
<xpath expr='//separator[@string="vsep"]' position='attributes'>
<attribute name='rowspan'>15</attribute>
<attribute name='string'></attribute>
</xpath>
<group string="res_config_contents" position="replace">
<field name="limit_amount"/>
<newline/>
</group>
</data>
</field>
</record>
<record id="action_config_purchase_limit_amount" model="ir.actions.act_window">
<field name="name">Configure Limit Amount for Purchase</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.double.validation.installer</field>
<field name="view_id" ref="view_config_purchase_limit_amount"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- register configuration wizard -->
<record id="config_wizard_step_purchase_limit_amount" model="ir.actions.todo">
<field name="action_id" ref="action_config_purchase_limit_amount"/>
<field name="restart">onskip</field>
<field name="groups_id" eval="[(6,0,[ref('base.group_extended')])]"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_purchase_form_inherit" model="ir.ui.view">
<field name="name">purchase.order.form.inherit</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="//button[@string='Convert to Purchase Order']" position="replace">
<button name="draft_router1" states="draft" string="Confirm" icon="gtk-go-forward"/>
</xpath>
<xpath expr="//button[@string='Approve Purchase']" position="replace">
<button name="waiting_confirmed" states="wait" string="Convert to Purchase Order" icon="gtk-go-forward"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="act_waiting" model="workflow.activity">
<field name="wkf_id" ref="purchase.purchase_order"/>
<field name="name">waiting</field>
<field name="kind">function</field>
<field name="action">write({'state':'wait'})</field>
</record>
<record id="act_router1" model="workflow.activity">
<field name="wkf_id" ref="purchase.purchase_order"/>
<field name="name">router1</field>
<field name="split_mode">OR</field>
<field name="kind">dummy</field>
</record>
<record id="trans_draft_router1" model="workflow.transition">
<field name="act_from" ref="purchase.act_draft"/>
<field name="act_to" ref="act_router1"/>
<field name="condition">True</field>
<field name="signal">draft_router1</field>
</record>
<record id="trans_router1_waiting" model="workflow.transition">
<field name="act_from" ref="act_router1"/>
<field name="act_to" ref="act_waiting"/>
<field name="condition">True</field>
</record>
<record id="purchase.trans_draft_confirmed" model="workflow.transition">
<field name="act_from" ref="act_router1"/>
<field name="act_to" ref="purchase.act_confirmed"/>
<field name="condition">True</field>
<field name="signal">waiting_confirmed</field>
</record>
<record id="trans_waiting_confirmed" model="workflow.transition">
<field name="act_from" ref="act_waiting"/>
<field name="act_to" ref="purchase.act_confirmed"/>
<field name="condition">True</field>
<field name="signal">waiting_confirmed</field>
</record>
</data>
</openerp>

View File

@ -2279,14 +2279,12 @@ class stock_move(osv.osv):
context = {}
if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
res = []
for move in self.browse(cr, uid, ids, context=context):
move_qty = move.product_qty
if move_qty <= 0:
raise osv.except_osv(_('Error!'), _('Can not consume a move with negative or zero quantity !'))
quantity_rest = move.product_qty
quantity_rest -= quantity
uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
if quantity_rest <= 0:
@ -2303,7 +2301,7 @@ class stock_move(osv.osv):
'state': move.state,
'location_id': location_id or move.location_id.id,
}
if move.product_id.track_production and location_id:
if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
# IF product has checked track for production lot, move lines will be split by 1
res += self.action_split(cr, uid, [move.id], quantity, split_by_qty=1, context=context)
else:
@ -2317,7 +2315,7 @@ class stock_move(osv.osv):
else:
quantity_rest = quantity
uos_qty_rest = uos_qty
if move.product_id.track_production and location_id:
if (not move.prodlot_id.id) and (move.product_id.track_production and location_id):
res += self.action_split(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
else:
res += [move.id]
@ -2464,7 +2462,8 @@ class stock_inventory(osv.osv):
'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', states={'done': [('readonly', True)]}),
'move_ids': fields.many2many('stock.move', 'stock_inventory_move_rel', 'inventory_id', 'move_id', 'Created Moves'),
'state': fields.selection( (('draft', 'Draft'), ('done', 'Done'), ('confirm','Confirmed'),('cancel','Cancelled')), 'State', readonly=True, select=True),
'company_id': fields.many2one('res.company','Company',required=True,select=True),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
}
_defaults = {
'date': time.strftime('%Y-%m-%d %H:%M:%S'),

View File

@ -27,8 +27,10 @@ class stock_change_product_qty(osv.osv_memory):
_name = "stock.change.product.qty"
_description = "Change Product Quantity"
_columns = {
'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'),
'location_id': fields.many2one('stock.location', 'Location', required=True, ondelete="cascade", domain="[('usage', '=', 'internal')]"),
'product_id' : fields.many2one('product.product', 'Product'),
'new_quantity': fields.float('Quantity', required=True, help='This quantity is expressed in the Default UoM of the product.'),
'prodlot_id': fields.many2one('stock.production.lot', 'Production Lot', domain="[('product_id','=',product_id)]"),
'location_id': fields.many2one('stock.location', 'Location', required=True, domain="[('usage', '=', 'internal')]"),
}
def default_get(self, cr, uid, fields, context):
@ -40,10 +42,14 @@ class stock_change_product_qty(osv.osv_memory):
@param context: A standard dictionary
@return: A dictionary which of fields with values.
"""
product_id = context and context.get('active_id', False) or False
prod_obj =self.pool.get('product.product')
res = super(stock_change_product_qty, self).default_get(cr, uid, fields, context=context)
if 'new_quantity' in fields:
res.update({'new_quantity': 1})
if 'product_id' in fields:
res.update({'product_id': product_id})
return res
def change_product_qty(self, cr, uid, ids, context=None):
@ -70,18 +76,27 @@ class stock_change_product_qty(osv.osv_memory):
for data in self.browse(cr, uid, ids, context=context):
inventory_id = inventry_obj.create(cr , uid, {'name': _('INV: ') + str(res_original.name)}, context=context)
line_data ={
'inventory_id' : inventory_id,
'product_qty' : data.new_quantity,
'location_id' : data.location_id.id,
'product_id' : rec_id,
'product_uom' : res_original.uom_id.id,
'inventory_id' : inventory_id,
'product_qty' : data.new_quantity,
'location_id' : data.location_id.id,
'product_id' : rec_id,
'product_uom' : res_original.uom_id.id,
'prod_lot_id' : data.prodlot_id.id
}
line_id = inventry_line_obj.create(cr , uid, line_data, context=context)
inventry_obj.action_confirm(cr, uid, [inventory_id], context=context)
inventry_obj.action_done(cr, uid, [inventory_id], context=context)
return {}
return {
'domain': "[('id','=', %s)]" % (inventory_id),
'name' : _('Physical Inventories'),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'stock.inventory',
'context': context,
'type': 'ir.actions.act_window',
}
stock_change_product_qty()

View File

@ -10,7 +10,10 @@
<separator string="Select Quantity" colspan="4"/>
<newline/>
<field name="new_quantity" />
<newline/>
<field name="product_id" invisible="1"/>
<field name="location_id" />
<field name="prodlot_id" />
<separator string="" colspan="4" />
<label string="" colspan="2"/>
<group col="2" colspan="2">

View File

@ -40,7 +40,7 @@
</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>
@ -178,10 +178,10 @@
</graph>
</field>
</record>
<!-- Forecast section -->
<menuitem id="menu_stock_sale_forecast" name="Sales Forecasts"
<menuitem id="menu_stock_sale_forecast" name="Sales Forecasts"
parent="base.menu_base_partner" sequence="6" groups="base.group_extended"/>
<record id="view_stock_sale_forecast_filter" model="ir.ui.view">
@ -224,7 +224,7 @@
action="action_view_stock_sale_forecast_form"/>
<!-- Planning section -->
<menuitem id="menu_stock_planning_main" name="Stock Planning" parent="stock.menu_stock_root" sequence="2"/>
<record id="view_stock_planning_form" model="ir.ui.view">
@ -319,6 +319,7 @@
<field name="arch" type="xml">
<tree string="Master Procurement Schedule" colors ="blue:line_time=='Past';black:line_time=='Future'">
<field name="period_id"/>
<field name="company_id" invisible="1"/>
<field name="product_id" on_change="product_id_change(product_id)" />
<field name="product_uom"/>
<field name="warehouse_forecast" string="Forecast"/>

View File

@ -21,7 +21,7 @@
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from dateutil.relativedelta import relativedelta
from osv import osv, fields
@ -35,7 +35,7 @@ class stock_period_createlines(osv.osv_memory):
result = cr.fetchone()
last_date = result and result[0] or False
if last_date:
period_start = datetime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
period_start = datetime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ relativedelta(days=1)
period_start = period_start - relativedelta(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second)
else:
period_start = datetime.today()
@ -51,7 +51,7 @@ class stock_period_createlines(osv.osv_memory):
_defaults={
'date_start': _get_new_period_start,
}
def create_stock_periods(self, cr, uid, ids, context=None):
if context is None:
context = {}
@ -60,37 +60,50 @@ class stock_period_createlines(osv.osv_memory):
period_obj = self.pool.get('stock.period')
lines = []
for p in self.browse(cr, uid, ids, context=context):
dt = p.date_start
dt_stp = datetime.strptime(p.date_stop, '%Y-%m-%d')
ds = datetime.strptime(p.date_start, '%Y-%m-%d')
while ds.strftime('%Y-%m-%d') < p.date_stop:
while ds <= dt_stp:
if name =='Daily':
de = ds + relativedelta(days=interval, minutes =-1)
new_name = de.strftime('%Y-%m-%d')
de = ds + relativedelta(days=(interval + 1), seconds =-1)
new_id = period_obj.create(cr, uid, {
'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'),
'name': de.strftime('%Y-%m-%d'),
'date_start': ds.strftime('%Y-%m-%d %H:%M:%S'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
})
ds = ds + relativedelta(days=interval) + 1
ds = ds + relativedelta(days=(interval + 1))
if name =="Weekly":
de = ds + relativedelta(days=interval, minutes =-1)
new_name = de.strftime('%Y, week %W')
de = ds + relativedelta(days=(interval + 1), seconds =-1)
if dt_stp < de:
de = dt_stp + relativedelta(days=1, seconds =-1)
else:
de = ds + relativedelta(days=(interval + 1), seconds =-1)
new_name = ds.strftime('Week %W-%Y')
if ds.strftime('%Y') != de.strftime('%Y'):
new_name = ds.strftime('Week %W-%Y') + ', ' + de.strftime('Week %W-%Y')
new_id = period_obj.create(cr, uid, {
'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'),
'date_start': ds.strftime('%Y-%m-%d %H:%M:%S'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
})
ds = ds + relativedelta(days=interval) + 1
ds = ds + relativedelta(days=(interval + 1))
if name == "Monthly":
de = ds + relativedelta(months=interval, minutes=-1)
de = ds + relativedelta(months=interval, seconds=-1)
if dt_stp < de:
de = dt_stp + relativedelta(days=1, seconds =-1)
else:
de = ds + relativedelta(months=interval, seconds=-1)
new_name = ds.strftime('%Y/%m')
if ds.strftime('%m') != de.strftime('%m'):
new_name = ds.strftime('%Y/%m') + '-' + de.strftime('%Y/%m')
new_id =period_obj.create(cr, uid, {
'name': new_name,
'date_start': ds.strftime('%Y-%m-%d'),
'name': new_name,
'date_start': ds.strftime('%Y-%m-%d %H:%M:%S'),
'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'),
})
ds = ds + relativedelta(months=interval)
lines.append(new_id)
return {
'domain': "[('id','in', ["+','.join(map(str, lines))+"])]",
'view_type': 'form',