diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py
index c756bf05128..2c999cdabe9 100644
--- a/addons/purchase/purchase.py
+++ b/addons/purchase/purchase.py
@@ -188,7 +188,7 @@ class purchase_order(osv.osv):
'shipped_rate': fields.function(_shipped_rate, string='Received', type='float'),
'invoiced': fields.function(_invoiced, string='Invoiced & Paid', type='boolean', help="It indicates that an invoice has been paid"),
'invoiced_rate': fields.function(_invoiced_rate, string='Invoiced', type='float'),
- 'invoice_method': fields.selection([('manual','Manual'),('order','From Order'),('picking','From Reception')], 'Invoicing Control', required=True,
+ 'invoice_method': fields.selection([('manual','From PO/PO lines'),('order','Draft invoices pre-generated'),('picking','From receptions')], 'Invoicing Control', required=True,
help="From Order: a draft invoice will be generated based on the purchase order. The accountant " \
"will just have to validate this invoice for control.\n" \
"From Reception: a draft invoice will be generated based on validated receptions.\n" \
@@ -612,6 +612,14 @@ class purchase_order_line(osv.osv):
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
return res
+ def _get_uom_id(self, cr, uid, context=None):
+ try:
+ proxy = self.pool.get('ir.model.data')
+ result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit')
+ return result[1]
+ except Exception, ex:
+ return False
+
_columns = {
'name': fields.char('Description', size=256, required=True),
'product_qty': fields.float('Quantity', required=True, digits=(16,2)),
@@ -639,6 +647,7 @@ class purchase_order_line(osv.osv):
}
_defaults = {
+ 'product_uom' : _get_uom_id,
'product_qty': lambda *a: 1.0,
'state': lambda *args: 'draft',
'invoiced': lambda *a: 0,
diff --git a/addons/purchase/stock_view.xml b/addons/purchase/stock_view.xml
index e02aa4dbf66..538d0b81ab7 100644
--- a/addons/purchase/stock_view.xml
+++ b/addons/purchase/stock_view.xml
@@ -70,11 +70,11 @@
domain="[('state','=','assigned')]" help="Incoming Shipments Available"/>
-
+
@@ -103,13 +103,13 @@
- Pickings to Invoice
+ On Incoming Shipments
stock.picking
ir.actions.act_window
form
tree,form,calendar
[('type','=','in')]
- {'search_default_done':1,'search_default_to_invoice':1}
+ {'contact_display': 'partner_address',"search_default_available":1}
Create invoice from reception of products. If you selected this invoice control method in the purchase order, all receptions done are available here to be invoiced.
diff --git a/addons/purchase/wizard/purchase_line_invoice.py b/addons/purchase/wizard/purchase_line_invoice.py
index d13d2fac66b..236cde7dde5 100644
--- a/addons/purchase/wizard/purchase_line_invoice.py
+++ b/addons/purchase/wizard/purchase_line_invoice.py
@@ -55,18 +55,6 @@ class purchase_line_invoice(osv.osv_memory):
invoice_line_obj=self.pool.get('account.invoice.line')
account_jrnl_obj=self.pool.get('account.journal')
- def multiple_order_invoice_name(orders):
- name = "PO";
- for order in orders:
- name += "-%d" % order.id
- return name
-
- def multiple_order_invoice_reference(partner, orders):
- reference = "P%dPO" % partner.id
- for order in orders:
- reference += "-%d" % order.id
- return reference
-
def multiple_order_invoice_notes(orders):
notes = ""
for order in orders:
@@ -82,6 +70,7 @@ class purchase_line_invoice(osv.osv_memory):
@param orders : The set of orders to add in the invoice
@param lines : The list of line's id
"""
+ name = orders and orders[0].name or ''
journal_id = account_jrnl_obj.search(cr, uid, [('type', '=', 'purchase')], context=None)
journal_id = journal_id and journal_id[0] or False
a = partner.property_account_payable.id
@@ -90,11 +79,11 @@ class purchase_line_invoice(osv.osv_memory):
else:
pay_term = False
inv = {
- 'name': multiple_order_invoice_name(orders),
- 'origin': multiple_order_invoice_name(orders),
+ 'name': name,
+ 'origin': name,
'type': 'in_invoice',
'journal_id':journal_id,
- 'reference': multiple_order_invoice_reference(partner, orders),
+ 'reference' : partner.ref,
'account_id': a,
'partner_id': partner.id,
'address_invoice_id': orders[0].partner_address_id.id,
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index a37c9331c71..8fb259b1d0f 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -838,6 +838,14 @@ class sale_order_line(osv.osv):
res[line.id] = 1
return res
+ def _get_uom_id(self, cr, uid, *args):
+ try:
+ proxy = self.pool.get('ir.model.data')
+ result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit')
+ return result[1]
+ except Exception, ex:
+ return False
+
_name = 'sale.order.line'
_description = 'Sales Order Line'
_columns = {
@@ -877,6 +885,7 @@ class sale_order_line(osv.osv):
}
_order = 'sequence, id'
_defaults = {
+ 'product_uom' : _get_uom_id,
'discount': 0.0,
'delay': 0.0,
'product_uom_qty': 1,
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 7b2dae600d0..c04ac9ef62c 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -698,6 +698,7 @@
+
@@ -708,7 +709,7 @@
-
+
@@ -737,7 +738,6 @@
groups="base.group_extended"
icon="terp-stock_effects-object-colorize"
states="draft,assigned,confirmed"/>
-
@@ -760,7 +760,7 @@
-
+
@@ -810,7 +810,6 @@
-
@@ -1112,7 +1111,7 @@
-
+
@@ -1573,7 +1572,7 @@
-
+
diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py
index 42add8019c4..395758b121b 100644
--- a/addons/stock/wizard/stock_invoice_onshipping.py
+++ b/addons/stock/wizard/stock_invoice_onshipping.py
@@ -25,6 +25,12 @@ from tools.translate import _
class stock_invoice_onshipping(osv.osv_memory):
+ def _get_journal(self, cr, uid, context=None):
+ res = self._get_journal_id(cr, uid, context=context)
+ if res:
+ return res[0]
+ return False
+
def _get_journal_id(self, cr, uid, context=None):
if context is None:
context = {}
@@ -61,7 +67,6 @@ class stock_invoice_onshipping(osv.osv_memory):
vals.append(t1)
return vals
-
_name = "stock.invoice.onshipping"
_description = "Stock Invoice Onshipping"
@@ -70,7 +75,11 @@ class stock_invoice_onshipping(osv.osv_memory):
'group': fields.boolean("Group by partner"),
'invoice_date': fields.date('Invoiced date'),
}
-
+
+ _defaults = {
+ 'journal_id' : _get_journal,
+ }
+
def view_init(self, cr, uid, fields_list, context=None):
if context is None:
context = {}
diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py
index 874b22844d1..234133c02ce 100644
--- a/addons/stock/wizard/stock_partial_move.py
+++ b/addons/stock/wizard/stock_partial_move.py
@@ -32,6 +32,8 @@ class stock_partial_move_memory_out(osv.osv_memory):
'quantity' : fields.float("Quantity", required=True),
'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True),
'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot'),
+ 'location_id': fields.many2one('stock.location', 'Location', required=True),
+ 'location_dest_id': fields.many2one('stock.location', 'Dest. Location', required=True),
'move_id' : fields.many2one('stock.move', "Move"),
'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"),
'cost' : fields.float("Cost", help="Unit Cost for this product line"),
diff --git a/addons/stock/wizard/stock_partial_move_view.xml b/addons/stock/wizard/stock_partial_move_view.xml
index ec33dff083b..8d4be66b243 100644
--- a/addons/stock/wizard/stock_partial_move_view.xml
+++ b/addons/stock/wizard/stock_partial_move_view.xml
@@ -30,6 +30,8 @@
+
+
@@ -46,6 +48,8 @@
+
+
@@ -62,6 +66,8 @@
+
+
@@ -76,6 +82,8 @@
+
+
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index 421bcae10ba..6549b71773d 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -122,7 +122,9 @@ class stock_partial_picking(osv.osv_memory):
'quantity' : picking.product_qty,
'product_uom' : picking.product_uom.id,
'prodlot_id' : picking.prodlot_id.id,
- 'move_id' : picking.id,
+ 'move_id' : picking.id,
+ 'location_id' : picking.location_id.id,
+ 'location_dest_id' : picking.location_dest_id.id,
}
if pick_type == 'in':
@@ -142,19 +144,32 @@ class stock_partial_picking(osv.osv_memory):
@return: A dictionary which of fields with values.
"""
pick_obj = self.pool.get('stock.picking')
-
+ stock_move_obj = self.pool.get('stock.move')
picking_ids = context.get('active_ids', False)
partial = self.browse(cr, uid, ids[0], context=context)
partial_datas = {
'delivery_date' : partial.date
}
-
for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
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 moves_list:
- partial_datas['move%s' % (move.move_id.id)] = {
+ if not move.move_id.id:
+ seq_obj_name = 'stock.picking.' + picking_type
+ move_id = stock_move_obj.create(cr,uid,{'name' : self.pool.get('ir.sequence').get(cr, uid, seq_obj_name),
+ 'product_id': move.product_id.id,
+ 'product_qty': move.quantity,
+ 'product_uom': move.product_uom.id,
+ 'prodlot_id': move.prodlot_id.id,
+ 'location_id' : move.location_id.id,
+ 'location_dest_id' : move.location_dest_id.id,
+ 'picking_id': pick.id
+ },context=context)
+ stock_move_obj.action_done(cr, uid, [move_id], context)
+ else:
+ move_id = move.move_id.id
+
+ partial_datas['move%s' % (move_id)] = {
'product_id': move.id,
'product_qty': move.quantity,
'product_uom': move.product_uom.id,