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 @@