[IMP]stock:Improvement in yml

bzr revid: mma@tinyerp.com-20110729111953-0mbb9za6nhn0hhl9
This commit is contained in:
Mayur Maheshwari (OpenERP)
2011-07-29 16:49:53 +05:30
parent 78491dfe17
commit 4f149e642b
9 changed files with 231 additions and 226 deletions
+1
View File
@@ -79,6 +79,7 @@ Thanks to the double entry management, the inventory controlling is powerful and
],
'test': ['test/stock_test.yml',
'test/stock_report.yml',
'test/stock_test_wizard.yml',
],
'installable': True,
'active': False,
-28
View File
@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<OpenShipments>
<OpenShipment ShipmentOption="" ProcessStatus="">
<Receiver>
<CompanyName type="field" name="address_id.partner_id.name" />
<ContactPerson type="field" name="address_id.name" />
<AddressLine1 type="field" name="address_id.street" />
<AddressLine2 type="field" name="address_id.street2" />
<City type="field" name="address_id.city" />
<CountryCode type="field" name="address_id.country_id.code" />
<PostalCode type="field" name="address_id.zip" />
<StateOrProvince type="field" name="address_id.state_id.name" />
<Phone type="field" name="address_id.phone" />
</Receiver>
<Shipment>
<ServiceLevel>ES</ServiceLevel>
<PackageType/>
<NumberOfPackages>1</NumberOfPackages>
<ShipmentActualWeight type="data" name="weight"/>
<DescriptionOfGoods type="field" name="name" />
<BillingOption>PP</BillingOption>
</Shipment>
</OpenShipment>
</OpenShipments>
-1
View File
@@ -20,7 +20,6 @@
##############################################################################
import product_stock
import ups
import picking
import lot_overview_all
import report_stock
-39
View File
@@ -1,39 +0,0 @@
# -*- 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/>.
#
##############################################################################
from report.interface import report_rml
class report_custom(report_rml):
def create(self, uid, ids, datas, context):
datas.setdefault('form', {})
datas['form'].setdefault('weight', 3.0)
datas['model'] = 'stock.move.lot'
datas['ids'] = ids
del datas['id']
return (super(report_custom, self).create(uid, ids, datas, context), 'pdf')
report_custom('report.stock.move.lot.ups_xml', 'stock.move.lot', 'addons/stock/report/UPS.xml', None)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+110 -6
View File
@@ -205,8 +205,9 @@
-
!record {model: product.product, id: product_product_hpcdwriters0}:
categ_id: stock.product_category_computer0
cost_method: standard
list_price: 1000.0
cost_method: average
list_price: 1500.0
standard_price: 1500.0
mes_type: fixed
name: HP CD writers
procure_method: make_to_stock
@@ -220,7 +221,47 @@
uom_po_id: product.product_uom_unit
property_account_expense: account_account_productpurchase0
property_account_income: account_account_productsale0
-
I create change product quantity for product HP CD writers.
-
!record {model: stock.change.product.qty, id: stock_change_product_qty0}:
product_id: stock.product_product_hpcdwriters0
new_quantity: 10
location_id: stock.stock_location_stock
-
I apply the new quantity on product HP CD writers.
-
!python {model: stock.change.product.qty }: |
self.change_product_qty(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model":
"stock.change.product.qty", "active_ids": ref("stock.product_product_hpcdwriters0"), "tz": False, "active_id":ref('stock.product_product_hpcdwriters0')})
-
I Read quantity on product HP CD writers.
-
!python {model: stock.location }: |
self.read(cr, uid, [ref("stock.stock_location_stock")],['stock_real_value','stock_virtual'], {'lang': 'en_GB', 'tz': False, 'active_model': 'product.product', 'bin_size': True, 'active_ids': [ref("stock.product_product_hpcdwriters0")], 'product_id':ref("stock.product_product_hpcdwriters0"), 'active_id': ref("stock.product_product_hpcdwriters0")})
-
I create change location.
-
!python {model: stock.location }: |
to=self.browse(cr,uid,ref('stock.stock_location_stock'))
form=self.browse(cr,uid,ref('stock.stock_location_locations'))
self.picking_type_get(cr, uid, to, form)
-
I create change product standard price for product HP CD writers.
-
!record {model: stock.change.standard.price, id: stock_change_standard_price0}:
new_price: 15
stock_account_input: account_account_receivable0
stock_account_output: account_account_payable0
stock_journal: account_journal_purchasejournal0
enable_stock_in_out_acc: True
-
I apply the new product standard price on product HP CD writers.
-
!python {model: stock.change.standard.price }: |
self.change_price(cr, uid, [ref("stock_change_product_qty0")], {"lang": 'en_US', "active_model":
"product.product", "active_ids": [ref("stock.product_product_hpcdwriters0")], "tz": False, "active_id":ref('stock.product_product_hpcdwriters0')})
-
I create Physical Inventory for the products.
-
@@ -241,14 +282,62 @@
product_uom: product.product_uom_unit
name: Physical inventory
state: draft
-
I create merge Inventory for the products.
-
!record {model: stock.inventory, id: stock_inventory_mergeinventoy0}:
company_id: base.main_company
date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
date_done: !eval time.strftime('%Y-%m-%d %H:%M:%S')
inventory_line_id:
- company_id: base.main_company
location_id: stock.stock_location_stock
product_id: stock.product_product_hpcdwriters0
product_qty: 20.0
product_uom: product.product_uom_unit
- company_id: base.main_company
location_id: stock.stock_location_stock
product_id: stock.product_product_hppaviliondesktoppcs0
product_qty: 20.0
product_uom: product.product_uom_unit
name: Physical inventory
state: draft
-
I merge inventory .
-
!python {model: stock.inventory.merge}: |
self.do_merge(cr, uid, [ref("stock_inventory_mergeinventoy0")], {"lang": 'en_US',
"full": "1", "tz": False, "active_model": "stock.inventory", "active_ids":
[ref("stock_inventory_physicalinventoy0"), ref("stock_inventory_mergeinventoy0")], "active_id": ref("stock_inventory_physicalinventoy0"), })
-
I confirm the Inventory for HP CD writers.
-
!python {model: stock.inventory}: |
self.action_confirm(cr,uid,[ref('stock_inventory_physicalinventoy0')])
self.action_done(cr,uid,[ref('stock_inventory_physicalinventoy0')])
-
I create stock.inventory.line.split record.
-
!record {model: stock.inventory.line.split, id: stock_inventory_line_0}:
line_ids:
- name: '00002-stock-test'
quantity: 5
use_exist: False
product_id: stock.product_product_hpcdwriters0
product_uom: product.product_uom_unit
use_exist: False
qty: 10
-
I Split stock.inventory.line into production line.
-
!python {model: stock.inventory.line.split}: |
move_obj=self.pool.get('stock.inventory.line')
product_obj=self.pool.get('product.product')
product_id=product_obj.search(cr,uid,[('name','=','HP CD writers')])
move_ids=move_obj.search(cr,uid,[('product_id','in',product_id)])
self.split_lot(cr, uid, [ref("stock_inventory_line_0")], {"lang": 'en_US', "active_model":
"stock.inventory.line", "active_ids": move_ids, "tz": False, "active_id":move_ids[0]
})
-
I create stock.fill.inventory .
-
@@ -284,7 +373,6 @@
"stock.move", "active_ids": move_ids, "tz": False, "active_id":move_ids[0]
})
-
In Order to test the picking I create picking with move lines.
-
!record {model: stock.picking, id: stock_picking_0}:
@@ -307,7 +395,22 @@
move_type: direct
type: internal
-
I create stock split.into quantity record.
-
!record {model: stock.split.into, id: stock_split_into0}:
quantity: 1
-
I apply the split quantity.
-
!python {model: stock.split.into}: |
move_obj=self.pool.get('stock.move')
product_obj=self.pool.get('product.product')
product_id=product_obj.search(cr,uid,[('name','=','HP CD writers')])
move_ids=move_obj.search(cr,uid,[('product_id','in',product_id)])
self.split(cr, uid, [ref("stock_split_into0")], {"lang": 'en_US', "active_model":
"stock.move", "active_ids": move_ids, "tz": False, "active_id":move_ids[0]
})
-
I click on draft_force_assign on picking.
-
@@ -345,3 +448,4 @@
'product_uom': move.product_uom.id,
}
self.do_partial(cr, uid, [ref('stock_picking_0')],partial_datas)
+120
View File
@@ -0,0 +1,120 @@
-
In order to test picking i created picking record with move lines
-
!record {model: stock.picking, id: stock_picking_in0}:
address_id: base.main_address
company_id: base.main_company
invoice_state: 2binvoiced
move_lines:
- location_dest_id: stock.stock_location_shop0
product_id: product.product_product_pc1
product_qty: 30.0
product_uom: product.product_uom_unit
date_expected : '2011-01-05 12:58:07'
location_id : stock.stock_location_suppliers
name : '[PC1] Basic PC'
product_uos_qty : 30.0
name: IN/00010
type: in
-
I performed an osv_memory action draft_validate on module stock.picking
-
!python {model: stock.picking}: |
self.draft_validate(cr, uid, [ref("stock_picking_in0")], {"lang": "en_US", "search_default_available":
1, "tz": False, "active_model": "ir.ui.menu", "section_id": False, "contact_display":
"partner_address", "active_ids": [ref("stock.menu_action_picking_tree4")],
"active_id": ref("stock.menu_action_picking_tree4"), })
-
I confirm the picking.
-
!python {model: stock.picking }: |
import time
pick=self.browse(cr,uid,ref('stock_picking_in0'))
partial_datas={}
for move in pick.move_lines:
partial_datas['move%s'%(move.id)]= {
'product_id': move.product_id,
'product_qty': move.product_qty,
}
self.do_partial(cr, uid, [pick.id],partial_datas)
-
I Performing an osv_memory action create_invoice on module stock.invoice.onshipping
-
!python {model: stock.invoice.onshipping}: |
pick=self.browse(cr,uid,ref('stock_picking_in0'))
invoice_line_id = self.pool.get('stock.invoice.onshipping').create(cr, uid,{}, {"lang": 'en_US', "active_model":
"stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id})
self.open_invoice(cr, uid, [invoice_line_id], {"lang": "en_US",
"search_default_available": 1, "inv_type": "in_invoice" , "tz": False, "active_model": "stock.picking",
"contact_display": "partner_address", "active_ids": [ref("stock_picking_in0")],
"active_id": ref("stock_picking_in0"), })
-
I Performed an osv_memory action move_scrap and consume move on module stock.move.scrap
-
!python {model: stock.picking }: |
import time
location_obj = self.pool.get('stock.location')
scrpaed_location_ids = location_obj.search(cr, uid, [('scrap_location','=',True)])
pick=self.browse(cr,uid,ref('stock_picking_in0'))
scrap_obj=self.pool.get('stock.move.scrap')
consume_obj=self.pool.get('stock.move.consume')
partial_datas={}
move=pick.move_lines[0]
partial_datas= {
'product_id': move.product_id.id,
'location_id': scrpaed_location_ids[0],
'product_qty': move.product_qty,
'product_uom': move.product_uom.id,
}
scrap_id = self.pool.get('stock.move.scrap').create(cr, uid, partial_datas)
scrap_obj.move_scrap(cr, uid, [scrap_id], {"lang": "en_US", "tz":
False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id],
"active_id": move.id, })
consume_id = self.pool.get('stock.move.consume').create(cr, uid, partial_datas)
consume_obj.do_move_consume(cr, uid, [consume_id], {"lang": "en_US", "tz":
False, "active_model": "stock.move", "scrap": True, "active_ids": [move.id],
"active_id": move.id, })
-
I return the picking.
-
!python {model: stock.picking }: |
import time
pick=self.browse(cr,uid,ref('stock_picking_in0'))
partial_datas={}
partial_pick_id = self.pool.get('stock.return.picking').create(cr, uid,{}, {"lang": 'en_US', "active_model":
"stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id})
for move in pick.move_lines:
partial_datas= {
'product_id': move.product_id.id,
'quantity': move.product_qty,
}
self.pool.get('stock.return.picking').create_returns(cr, uid, [partial_pick_id], {"lang": 'en_US', "active_model":
"stock.picking", "active_ids": [pick.id], "tz": False, "active_id":pick.id})
-
I create stock.move record.
-
!python {model: stock.move }: |
import time
pick_obj = self.pool.get('stock.picking')
pick=pick_obj.browse(cr,uid,ref('stock_picking_in0'))
partial_move_id = self.pool.get('stock.partial.move').create(cr, uid,{})
search_id = self.search(cr, uid, [('picking_id', '=', pick.id)])
partial_datas={}
for move in pick.move_lines:
partial_datas['move%s'%(move.id)]= {
'quantity': move.product_qty,
'product_uom': move.product_uom.id,
'prodlot_id': move.prodlot_id and move.prodlot_id.id or False,
'wizard_id': partial_move_id,
}
self.do_partial(cr, uid, [partial_move_id],partial_datas,{"lang": 'en_US', "active_model":
"stock.move", 'search_default_receive': 1, 'product_receive': True, "active_ids": search_id, "tz": False, "active_id":search_id[0]})
-1
View File
@@ -25,7 +25,6 @@ import stock_splitinto
import stock_partial_picking
import stock_partial_move
import stock_replacement
import stock_ups
import stock_inventory_merge
import stock_fill_inventory
import stock_inventory_line_split
-95
View File
@@ -1,95 +0,0 @@
# -*- 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 netsvc
from osv import fields, osv
from tools.translate import _
class stock_ups(osv.osv_memory):
_name = "stock.ups"
_description = "Stock ups"
def ups_save(self, cr, uid, ids, context=None):
return {
'name': False,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.ups.final',
'type': 'ir.actions.act_window',
'target':'new',
}
def ups_upload(self, cr, uid, ids, context=None):
return {
'name': False,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.ups.upload',
'type': 'ir.actions.act_window',
'target':'new',
}
_columns = {
'weight': fields.float('Lot weight', required=True),
}
_defaults = {
'weight': lambda *a: 3.0,
}
stock_ups()
class stock_ups_final(osv.osv_memory):
_name = "stock.ups.final"
_description = "Stock ups final"
def create_xmlfile(self, cr, uid, ids, context=None):
""" Creates xml report file.
@return: xml file
"""
data={}
report = netsvc._group['report']['report.stock.move.lot.ups_xml']
data['report_type'] = 'raw'
return {'xmlfile' : report.create(uid, context['active_id'], ids, {})}
_columns = {
'xmlfile': fields.binary('XML File'),
}
stock_ups_final()
class stock_ups_upload(osv.osv_memory):
_name = "stock.ups.upload"
_description = "Stock ups upload"
def upload_xmlfile(self, cr, uid, ids, context=None):
""" Uploads xml report file.
@return:
"""
data={}
report = netsvc._group['report']['report.stock.move.lot.ups_xml']
data['report_type'] = 'raw'
fp = file('/tmp/test.xml', 'w').write(report.create(uid, context['active_id'], ids, {}))
return {'type': 'ir.actions.act_window_close'}
stock_ups_upload()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-56
View File
@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_stock_ups" model="ir.ui.view">
<field name="name">Stock ups</field>
<field name="model">stock.ups</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="UPS XML generator">
<separator string="UPS generator" colspan="4"/>
<field name="weight" />
<separator string="" colspan="4" />
<button icon='gtk-cancel' special="cancel" string="_Cancel" />
<button name="ups_save" string="Get xml file" type="object" />
<button name="ups_upload" string="Upload xml file" type="object" />
</form>
</field>
</record>
<record id="view_stock_ups_final" model="ir.ui.view">
<field name="name">Stock ups</field>
<field name="model">stock.ups.final</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="UPS XML generator">
<separator string="Save the attached file" colspan="4" />
<field name="xmlfile" />
<button special="cancel" string="End" />
<button name="create_xmlfile" string="create xml file" type="object" />
</form>
</field>
</record>
<record id="view_stock_ups_upload" model="ir.ui.view">
<field name="name">Stock ups</field>
<field name="model">stock.ups.upload</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="UPS XML generator">
<separator string="File uploaded" colspan="4" />
<button special="cancel" string="End" />
<button name="upload_xmlfile" string="Upload xml file" type="object" />
</form>
</field>
</record>
<act_window name="Stock ups"
res_model="stock.ups"
src_model=""
view_mode="form"
target="new"
key2="client_action_multi"
id="action_view_stock_ups"/>
</data>
</openerp>