[IMP] sale useability, fix stock, better uom handling

bzr revid: fp@tinyerp.com-20100626151523-40k3eqmegon0ovqg
This commit is contained in:
Fabien Pinckaers 2010-06-26 17:15:23 +02:00
parent e2ff3fb555
commit 7369085786
15 changed files with 231 additions and 251 deletions

View File

@ -52,7 +52,7 @@ class crm_phonecall(osv.osv, crm_case):
('draft', 'Draft'),
('open', 'Todo'),
('cancel', 'Cancelled'),
('done', 'Closed'),
('done', 'Done'),
('pending', 'Pending'),
], 'State', size=16, readonly=True,
help='The state is set to \'Draft\', when a case is created.\
@ -89,7 +89,7 @@ class crm_phonecall(osv.osv, crm_case):
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'state': lambda *a: 'draft',
'state': lambda *a: 'open',
'user_id': lambda self,cr,uid,ctx: uid,
'active': lambda *a: 1,
}

View File

@ -67,7 +67,7 @@
<field name="view_mode">tree,calendar</field>
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="domain" eval="'[(\'categ_id\',\'=\','+str(ref('categ_phone1'))+')]'"/>
<field name="context">{'set_editable':True,'default_state':'open'}</field>
<field name="context">{'set_editable':True,'default_state':'open','search_default_current':1,'search_default_today':1}</field>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
</record>
@ -103,7 +103,7 @@
<field name="view_mode">tree,calendar</field>
<field name="view_id" ref="crm_case_phone_tree_view"/>
<field name="domain" eval="'[(\'categ_id\',\'=\','+str(ref('categ_phone2'))+')]'"/>
<field name="context">{'default_state':'open'}</field>
<field name="context">{'default_state':'open','search_default_current':1}</field>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
</record>

View File

@ -245,17 +245,22 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Phonecalls">
<filter icon="terp-go-today" string="Current"
name="current"
domain="[('state','in', ('draft','open','pending'))]"/>
<separator orientation="vertical"/>
<filter icon="terp-go-today" string="Today"
domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')),\
('date','&gt;=',datetime.strftime('%%Y-%%m-%%d 00:00:00'))]"
name="today"
help="Todays's Phonecalls"
/>
<filter icon="terp-go-week"
string="7 Days"
help="Phonecalls during last 7 days"
domain="[('date','&lt;', time.strftime('%%Y-%%m-%%d')),\
('date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
domain="[('date','&gt;=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
/>
<separator orientation="vertical"/>
<field name="name" string="Call Summary"/>
<field name="partner_id"/>

View File

@ -48,35 +48,25 @@ class product_uom(osv.osv):
_name = 'product.uom'
_description = 'Product Unit of Measure'
def _factor(self, cursor, user, ids, name, arg, context):
def _factor_inv(self, cursor, user, ids, name, arg, context):
res = {}
for uom in self.browse(cursor, user, ids, context=context):
if uom.factor:
if uom.factor_inv_data:
res[uom.id] = uom.factor_inv_data
else:
res[uom.id] = round(1 / uom.factor, 6)
res[uom.id] = round(1 / uom.factor, 6)
else:
res[uom.id] = 0.0
return res
def _factor_inv(self, cursor, user, id, name, value, arg, context):
ctx = context.copy()
if 'read_delta' in ctx:
del ctx['read_delta']
def _factor_inv_write(self, cursor, user, id, name, value, arg, context):
if value:
data = 0.0
if round(1 / round(1/value, 6), 6) != value:
data = value
self.write(cursor, user, id, {
'factor': round(1/value, 6),
'factor_inv_data': data,
}, context=ctx)
}, context=context)
else:
self.write(cursor, user, id, {
'factor': 0.0,
'factor_inv_data': 0.0,
}, context=ctx)
}, context=context)
return True
_columns = {
'name': fields.char('Name', size=64, required=True, translate=True),
@ -85,17 +75,17 @@ class product_uom(osv.osv):
'factor': fields.float('Ratio', digits=(12, 6), required=True,
help='The coefficient for the formula:\n' \
'1 (base unit) = coeff (this unit). Ratio = 1 / Factor.'),
'factor_inv': fields.function(_factor, digits=(12, 6),
'factor_inv': fields.function(_factor_inv, digits=(12, 6),
fnct_inv=_factor_inv_write,
method=True, string='Factor',
help='The coefficient for the formula:\n' \
'coeff (base unit) = 1 (this unit). Factor = 1 / Rate.'),
'factor_inv_data': fields.float('Factor', digits=(12, 6)),
'rounding': fields.float('Rounding Precision', digits=(16, 3), required=True,
help="The computed quantity will be a multiple of this value. Use 1.0 for products that can not be split."),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the unit of measure without removing it."),
'uom_factor': fields.selection([('bigger','Bigger than the Default'),
('smaller','Smaller than the Default'),
('','')],'UoM Factor'),
'uom_factor': fields.selection([('bigger','Bigger than the default'),
('smaller','Smaller than the default'),
('default','The Default unit of measure')],'Type of Unit', required=1),
}
_defaults = {
@ -103,12 +93,11 @@ class product_uom(osv.osv):
'factor_inv': lambda *a: 1.0,
'active': lambda *a: 1,
'rounding': lambda *a: 0.01,
'uom_factor': lambda *a: 'smaller',
'uom_factor': lambda *a: 'default',
}
_sql_constraints = [
('factor_gt_zero', 'CHECK (factor!=0)', 'Value of the factor can never be 0 !'),
('factor_inv_data_gt_zero', 'CHECK (factor_inv_data!=0)', 'Value of the factor_inv_data can never be 0 !'),
]
def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False):
@ -124,15 +113,9 @@ class product_uom(osv.osv):
def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, context={}):
if from_unit.category_id.id <> to_unit.category_id.id:
return qty
if from_unit.factor_inv_data:
amount = qty * from_unit.factor_inv_data
else:
amount = qty / from_unit.factor
amount = qty / from_unit.factor
if to_unit:
if to_unit.factor_inv_data:
amount = rounding(amount / to_unit.factor_inv_data, to_unit.rounding)
else:
amount = rounding(amount * to_unit.factor, to_unit.rounding)
amount = rounding(amount * to_unit.factor, to_unit.rounding)
return amount
def _compute_price(self, cr, uid, from_uom_id, price, to_uom_id=False):
@ -145,26 +128,15 @@ class product_uom(osv.osv):
from_unit, to_unit = uoms[-1], uoms[0]
if from_unit.category_id.id <> to_unit.category_id.id:
return price
if from_unit.factor_inv_data:
amount = price / from_unit.factor_inv_data
else:
amount = price * from_unit.factor
amount = price * from_unit.factor
if to_uom_id:
if to_unit.factor_inv_data:
amount = amount * to_unit.factor_inv_data
else:
amount = amount / to_unit.factor
amount = amount / to_unit.factor
return amount
def onchange_factor_inv(self, cursor, user, ids, value):
if value == 0.0:
return {'value': {'factor': 0}}
return {'value': {'factor': round(1/value, 6)}}
def onchange_factor(self, cursor, user, ids, value):
if value == 0.0:
return {'value': {'factor_inv': 0}}
return {'value': {'factor_inv': round(1/value, 6)}}
if value == 'default':
return {'value': {'factor': 1, 'factor_inv': 1}}
return {}
product_uom()

View File

@ -30,7 +30,7 @@
<record id="product_uom_kgm" model="product.uom">
<field name="category_id" ref="product_uom_categ_kgm"/>
<field name="name">KGM</field>
<field name="factor">1000.0</field>
<field name="factor">1</field>
</record>
<record id="uom_hour" model="product.uom">
<field name="name">Hour</field>
@ -45,7 +45,7 @@
<record id="product_uom_ton" model="product.uom">
<field name="category_id" ref="product_uom_categ_kgm"/>
<field name="name">TON</field>
<field name="factor">1.0</field>
<field name="factor">0.001</field>
</record>
<record id="product_uom_meter" model="product.uom">
<field name="category_id" ref="uom_categ_length"/>

View File

@ -298,7 +298,6 @@
<field name="name"/>
<field name="category_id"/>
<field name="factor"/>
<field name="factor_inv"/>
<field name="rounding"/>
</tree>
</field>
@ -310,14 +309,18 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Units of Measure">
<field name="name" select="1"/>
<field name="category_id" select="1"/>
<field name="factor" select="1" attrs="{'readonly':[('uom_factor','=','bigger')]}"/>
<field name="factor_inv_data" select="1" string="Factor Data" attrs="{'readonly':[('uom_factor','=','smaller')]}"/>
<field name="factor_inv" invisible="1"/>
<field name="rounding"/>
<field name="uom_factor"/>
<field name="active"/>
<group col="6" colspan="4">
<field name="name" select="1"/>
<field name="category_id" select="1"/>
<field name="active"/>
<field name="uom_factor" on_change="onchange_factor(uom_factor)"/>
<group colspan="2" col="2">
<field name="factor" select="1" attrs="{'invisible':[('uom_factor','&lt;&gt;','smaller')]}"/>
<field name="factor_inv" select="1" string="Factor Data" attrs="{'invisible':[('uom_factor','&lt;&gt;','bigger')]}"/>
</group>
<newline/>
<field name="rounding"/>
</group>
</form>
</field>
</record>

View File

@ -97,6 +97,7 @@ class sale_order(osv.osv):
res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
return res
# This is False
def _picked_rate(self, cr, uid, ids, name, arg, context=None):
if context is None:
context = {}
@ -1021,6 +1022,7 @@ class sale_order_line(osv.osv):
}
result['product_uom_qty'] = qty
uom2 = False
if uom:
uom2 = product_uom_obj.browse(cr, uid, uom)
if product_obj.uom_id.category_id.id != uom2.category_id.id:
@ -1076,6 +1078,19 @@ class sale_order_line(osv.osv):
result['product_uos_qty'] = qty
result['th_weight'] = q * product_obj.weight # Round the quantity up
if not uom2:
uom2 = product_obj.uom_id
if (product_obj.type=='product') and (product_obj.virtual_available * product_obj.uom_id.factor < qty * uom2.factor) \
and (product_obj.procure_method=='make_to_stock'):
warning = {
'title': _('Not enough stock !'),
'message': _('You plan to sell %.2f %s but you only have %.2f %s available !\nThe real stock is %.2f %s. (without reservations)') %
(qty, uom2 and uom2.name or product_obj.uom_id.name,
max(0,product_obj.virtual_available), product_obj.uom_id.name,
max(0,product_obj.qty_available), product_obj.uom_id.name)
}
# get unit price
if not pricelist:

View File

@ -134,7 +134,7 @@
<field colspan="4"
context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
name="product_id"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], True, parent.date_order, product_packaging, parent.fiscal_position)"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], True, parent.date_order, product_packaging, parent.fiscal_position, False)"
/>
<field
context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
@ -147,7 +147,7 @@
<field
name="product_packaging"
context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging, parent.fiscal_position)"
on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging, parent.fiscal_position, False)"
domain="[('product_id','=',product_id)]"
groups="base.group_extended"/>

View File

@ -408,7 +408,7 @@ stock_location()
class stock_tracking(osv.osv):
_name = "stock.tracking"
_description = "Stock Tracking Lots"
_description = "Packs"
def checksum(sscc):
salt = '31' * 8 + '3'
@ -424,7 +424,7 @@ class stock_tracking(osv.osv):
_columns = {
'name': fields.char('Tracking ID', size=64, required=True),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the tracking lots without removing it."),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the pack without removing it."),
'serial': fields.char('Reference', size=64),
'move_ids': fields.one2many('stock.move', 'tracking_id', 'Moves Tracked'),
'date': fields.datetime('Created Date', required=True),
@ -1308,7 +1308,7 @@ class stock_move(osv.osv):
return (res and res[0]) or False
_name = "stock.move"
_description = "Stock Move"
_order = 'date_planned desc'
_order = 'date_expected desc, id'
_log_create = False
def name_get(self, cr, uid, ids, context={}):
@ -1362,7 +1362,7 @@ class stock_move(osv.osv):
'address_id': fields.many2one('res.partner.address', 'Dest. Address', help="Address where goods are to be delivered"),
'prodlot_id': fields.many2one('stock.production.lot', 'Production Lot', help="Production lot is used to put a serial number on the production"),
'tracking_id': fields.many2one('stock.tracking', 'Tracking Lot', select=True, help="Tracking lot is the code that will be put on the logistical unit/pallet"),
'tracking_id': fields.many2one('stock.tracking', 'Pack', select=True, help="This is the code that will be put on the logistical unit: pallet, box, pack."),
# 'lot_id': fields.many2one('stock.lot', 'Consumer lot', select=True, readonly=True),
'auto_validate': fields.boolean('Auto Validate'),

View File

@ -61,11 +61,11 @@
Sequences from tracking numbers
-->
<record id="sequence_type_serial" model="ir.sequence.type">
<field name="name">Stock Production Lots</field>
<field name="name">Production Lots</field>
<field name="code">stock.lot.serial</field>
</record>
<record id="sequence_production_lots" model="ir.sequence">
<field name="name">Stock Production Lots</field>
<field name="name">Production Lots</field>
<field name="code">stock.lot.serial</field>
<field name="prefix"></field>
<field name="padding">7</field>
@ -74,12 +74,12 @@
</record>
<record id="sequence_type_tracking" model="ir.sequence.type">
<field name="name">Stock Tracking Lots</field>
<field name="name">Packs</field>
<field name="code">stock.lot.tracking</field>
</record>
<record id="sequence_tracking" model="ir.sequence">
<field name="name">Stock Tracking Lots</field>
<field name="name">Packs</field>
<field name="code">stock.lot.tracking</field>
<field name="prefix"></field>
<field name="padding">7</field>

View File

@ -154,7 +154,7 @@
<field name="model">stock.tracking</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Tracking/Serial">
<form string="Packs">
<field name="name" select="1"/>
<field name="serial" select="1"/>
<field name="date" select="1"/>
@ -167,7 +167,7 @@
<field name="model">stock.tracking</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Tracking/Serial">
<tree string="Packs">
<field name="name"/>
<field name="serial"/>
<field name="date"/>
@ -176,7 +176,7 @@
</field>
</record>
<record id="action_tracking_form" model="ir.actions.act_window">
<field name="name">Tracking Lots</field>
<field name="name">Packs</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.tracking</field>
<field name="view_type">form</field>
@ -193,7 +193,7 @@
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="arch" type="xml">
<tree colors="grey:not active" string="Tracking Number">
<tree colors="grey:not active" string="Packs">
<field name="name" />
<field name="serial" />
<field name="date" />
@ -637,15 +637,14 @@
type="action" icon="terp-stock_effects-object-colorize"
states="draft,waiting,confirmed,assigned" />
<field groups="base.group_extended" name="tracking_id"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
<button name="setlast_tracking" string="Put in current pack" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
groups="base.group_extended"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
icon="terp-stock_effects-object-colorize"
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
@ -688,9 +687,8 @@
states="draft,waiting,confirmed,assigned"
type="action" icon="terp-stock_effects-object-colorize"
groups="base.group_extended" />
<button name="%(move_scrap)d" string="Scrap Move Line" type="action" icon="gtk-justify-fill"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
<button name="%(move_scrap)d" string="Scrap" type="action" icon="gtk-justify-fill"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
states="draft,assigned,confirmed,done"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" />
@ -804,15 +802,15 @@
<field name="picking_id" />
<field name="prodlot_id" groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"
groups="base.group_extended"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
<button name="setlast_tracking" string="Put in current pack" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"
groups="base.group_extended"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<field name="date_planned"/>
@ -859,9 +857,8 @@
states="draft,waiting,confirmed,assigned"
type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<separator colspan="4" string="Move State"/>
@ -1014,16 +1011,15 @@
states="draft,assigned,confirmed,done"
groups="base.group_extended"/>
<field name="tracking_id" groups="base.group_extended"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
<button name="setlast_tracking" string="Put in current pack" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
icon="terp-stock_effects-object-colorize"
groups="base.group_extended"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="date_planned"/>
<field name="state"/>
@ -1059,8 +1055,7 @@
groups="base.group_extended"
/>
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
@ -1082,7 +1077,7 @@
<button name="draft_validate" states="draft" string="Process Now" type="object" icon="gtk-yes"/>
<button name="action_assign" states="confirmed" string="Check Availability" type="object" groups="base.group_extended" icon="gtk-apply"/>
<button name="force_assign" states="confirmed" string="Force Availability" type="object" icon="gtk-jump-to"/>
<button name="%(action_partial_picking)d" states="assigned" string="Picking Done" type="action" icon="gtk-execute"/>
<button name="%(action_partial_picking)d" states="assigned" string="Done" type="action" icon="gtk-execute"/>
<button name="button_cancel" states="assigned,confirmed,draft" string="Cancel" icon="gtk-cancel"/>
</group>
</page>
@ -1215,16 +1210,16 @@
type="action" icon="terp-stock_effects-object-colorize"
states="draft,waiting,confirmed,assigned" />
<field name="tracking_id" groups="base.group_extended"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
<button name="setlast_tracking" string="Put in current pack" type="object"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="state"/>
<button name="%(stock.move_scrap)d"
<button name="%(stock.move_scrap)d"
string="Scrap Products" type="action"
icon="gtk-convert" context="{'scrap': True}"
states="draft,waiting,confirmed,assigned" />
@ -1409,13 +1404,13 @@
states="draft,waiting,confirmed,assigned"
groups="base.group_extended"/>
<field groups="base.group_extended" name="tracking_id"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
<button name="setlast_tracking" string="Put in current pack" type="object"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="location_id"/>
<field name="location_dest_id"/>
@ -1480,9 +1475,9 @@
states="draft,waiting,confirmed,assigned"
string="Split in production lots" type="action" icon="terp-stock_effects-object-colorize" colspan="2" />
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
</group>
</group>
@ -1573,15 +1568,15 @@
context="{'default_use_exist': picking_id.type=='in'}"
groups="base.group_extended"/>
<field name="tracking_id" groups="base.group_extended"/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
states="draft,assigned,confirmed,done"/>
<button name="setlast_tracking" string="Set Last Tracking" type="object"
<button name="setlast_tracking" string="Put in current pack" type="object"
attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<field name="date_planned"/>
<field name="backorder_id" groups="base.group_extended"/>
<field name="state"/>
@ -1629,9 +1624,9 @@
groups="base.group_extended"
type="action" icon="terp-stock_effects-object-colorize"/>
<label/>
<button name="%(split_into)d" string="Split Stock Moves" type="action"
<button name="%(split_into)d" string="Put in a new pack" type="action"
groups="base.group_extended"
icon="terp-stock_effects-object-colorize" attrs="{'invisible': [('tracking_id','&lt;&gt;',False)]}"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed,done"/>
<label/>
<button name="%(track_line)d" string="Split in production lots"

View File

@ -193,7 +193,7 @@ class split_in_production_lot(osv.osv_memory):
'product_uom': fields.many2one('product.uom', 'Product UOM'),
'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number'),
'line_exist_ids': fields.one2many('stock.move.split.lines.exist', 'lot_id', 'Lots Existing Numbers'),
'use_exist' : fields.boolean('Use Exist'),
'use_exist' : fields.boolean('Existing Lot'),
}
def split_lot(self, cr, uid, ids, context=None):
@ -293,7 +293,7 @@ class stock_move_split_lines(osv.osv_memory):
_columns = {
'name': fields.char('Tracking serial', size=64),
'quantity': fields.integer('Quantity'),
'use_exist' : fields.boolean('Use Exist'),
'use_exist' : fields.boolean('Existing Lot'),
'lot_id': fields.many2one('stock.move.split', 'Lot'),
'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'),
}

View File

@ -40,32 +40,25 @@ class stock_split_into(osv.osv_memory):
quantity = self.browse(cr, uid, data[0], context).quantity or 0.0
for move in move_obj.browse(cr, uid, rec_id):
move_qty = move.product_qty
uos_qty_rest = move.product_uos_qty
quantity_rest = move_qty - quantity
if (quantity_rest == 0) or (quantity <= 0) :
continue
move_obj.setlast_tracking(cr, uid, [move.id], context=context)
move_obj.write(cr, uid, [move.id], {
'product_qty': quantity,
'product_uos_qty': quantity,
'product_uos': move.product_uom.id,
})
quantity_rest = move.product_qty - quantity
tracking_id = track_obj.create(cr, uid, {})
default_val = {
'product_qty': quantity_rest,
'product_uos_qty': quantity_rest,
'tracking_id': tracking_id,
'state': move.state,
'product_uos': move.product_uom.id
}
current_move = move_obj.copy(cr, uid, move.id, default_val)
new_move.append(current_move)
update_val['product_qty'] = quantity
update_val['tracking_id'] = tracking_id
update_val['product_uos_qty'] = uos_qty_rest
move_obj.write(cr, uid, [move.id], update_val)
if quantity > 0:
move_obj.setlast_tracking(cr, uid, [move.id], context=context)
move_obj.write(cr, uid, [move.id], {
'product_qty': quantity,
'product_uos_qty': quantity,
'product_uos': move.product_uom.id,
})
if quantity_rest>0:
quantity_rest = move.product_qty - quantity
tracking_id = track_obj.create(cr, uid, {})
default_val = {
'product_qty': quantity_rest,
'product_uos_qty': quantity_rest,
'tracking_id': tracking_id,
'state': move.state,
'product_uos': move.product_uom.id
}
current_move = move_obj.copy(cr, uid, move.id, default_val)
return {}
stock_split_into()

View File

@ -1,31 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_stock_move_split_wizard" model="ir.ui.view">
<field name="name">Split move</field>
<field name="model">stock.split.into</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Split Move">
<separator string="Set quantity to split your palets" colspan="4"/>
<field name="quantity"/>
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="split" string="Ok"
type="object" icon="gtk-ok" />
</form>
</field>
</record>
<record id="split_into" model="ir.actions.act_window">
<field name="name">Split into</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.split.into</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
<record id="view_stock_move_split_wizard" model="ir.ui.view">
<field name="name">Split move</field>
<field name="model">stock.split.into</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Split Move">
<separator string="Quantity for current pack" colspan="4"/>
<field name="quantity"/>
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="split" string="Ok"
type="object" icon="gtk-ok" />
</form>
</field>
</record>
<record id="split_into" model="ir.actions.act_window">
<field name="name">Split into</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.split.into</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>

View File

@ -8,25 +8,25 @@
<field name="model">stock.traceability.downstream</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Downstream traceability">
<label string="It will give information about the stock of a product as per the Tracking Lot" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Downstream traceability" type="object" context="{'type': 'move_history_ids2','field': ''}"/>
</form>
</field>
</record>
<act_window name="Downstream traceability"
res_model="stock.traceability.downstream"
src_model="stock.tracking"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_downstream"/>
<form string="Downstream traceability">
<label string="It will give information about the stock of a product as per the pack" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Downstream traceability" type="object" context="{'type': 'move_history_ids2','field': ''}"/>
</form>
</field>
</record>
<act_window name="Downstream traceability"
res_model="stock.traceability.downstream"
src_model="stock.tracking"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_downstream"/>
<!-- =========stock.traceability.upstream================= -->
@ -35,25 +35,25 @@
<field name="model">stock.traceability.upstream</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Upstream traceability">
<label string="It will give information about the stock of a product as per the Tracking Lot" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Upstream traceability" type="object" context="{'type': '','field': ''}"/>
</form>
</field>
</record>
<act_window name="Upstream traceability"
res_model="stock.traceability.upstream"
src_model="stock.tracking"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_upstream"/>
<form string="Upstream traceability">
<label string="It will give information about the stock of a product as per the pack" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Upstream traceability" type="object" context="{'type': '','field': ''}"/>
</form>
</field>
</record>
<act_window name="Upstream traceability"
res_model="stock.traceability.upstream"
src_model="stock.tracking"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_upstream"/>
<!-- =========stock.traceability.lot.upstream================= -->
@ -62,25 +62,25 @@
<field name="model">stock.traceability.lot.upstream</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Stock traceability lot upstream">
<label string="It will give information about the stock of a product as per the Production Lot" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Upstream traceability" type="object" context="{'type': '', 'field': 'prodlot_id'}"/>
</form>
</field>
</record>
<act_window name="Upstream traceability"
res_model="stock.traceability.lot.upstream"
src_model="stock.production.lot"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_lot_upstream"/>
<form string="Stock traceability lot upstream">
<label string="It will give information about the stock of a product as per the Production Lot" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Upstream traceability" type="object" context="{'type': '', 'field': 'prodlot_id'}"/>
</form>
</field>
</record>
<act_window name="Upstream traceability"
res_model="stock.traceability.lot.upstream"
src_model="stock.production.lot"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_lot_upstream"/>
<!-- =========stock.traceability.lot.downstream================= -->
@ -89,26 +89,26 @@
<field name="model">stock.traceability.lot.downstream</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Stock traceability lot downstream">
<label string="It will give information about the stock of a product as per the Production Lot" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Downstream traceability" type="object" context="{'type': 'move_history_ids2', 'field': 'prodlot_id'}"/>
</form>
</field>
</record>
<act_window name="Downstream traceability"
res_model="stock.traceability.lot.downstream"
src_model="stock.production.lot"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_lot_downstream"/>
<form string="Stock traceability lot downstream">
</data>
<label string="It will give information about the stock of a product as per the Production Lot" colspan="2" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel"
string="Cancel" />
<button name="action_traceability" string="Downstream traceability" type="object" context="{'type': 'move_history_ids2', 'field': 'prodlot_id'}"/>
</form>
</field>
</record>
<act_window name="Downstream traceability"
res_model="stock.traceability.lot.downstream"
src_model="stock.production.lot"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_traceability_lot_downstream"/>
</data>
</openerp>