diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index b0671e501ae..80a406bb0b7 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -457,7 +457,7 @@ class account_invoice(osv.osv): invoice_addr_id = res['invoice'] p = self.pool.get('res.partner').browse(cr, uid, partner_id) if company_id: - if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id: + if (p.property_account_receivable.company_id and (p.property_account_receivable.company_id.id != company_id)) and (p.property_account_payable.company_id and (p.property_account_payable.company_id.id != company_id)): property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)]) @@ -958,9 +958,14 @@ class account_invoice(osv.osv): }) date = inv.date_invoice or time.strftime('%Y-%m-%d') - part = inv.partner_id.id - line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context=ctx)),iml) + #if the chosen partner is not a company and has a parent company, use the parent for the journal entries + #because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait' + part = inv.partner_id + if part.parent_id and not part.is_company: + part = part.parent_id + + line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part.id, date, context=ctx)),iml) line = self.group_lines(cr, uid, iml, line, inv) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index d3697b13ea9..5c5a25880cb 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -61,7 +61,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -199,7 +199,7 @@ domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '!=', 'view')]" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/> + domain="[('type','!=','view'), ('company_id', '=', parent.company_id)]"/> @@ -229,7 +229,7 @@ - + @@ -292,7 +292,7 @@
- +
@@ -387,12 +387,12 @@ - + - + @@ -510,7 +510,7 @@ at - + / @@ -584,7 +584,7 @@ - + diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index ad7563140b2..97ef98bb8cd 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -175,8 +175,8 @@ class purchase_order(osv.osv): help="Put an address if you want to deliver directly from the supplier to the customer. " \ "Otherwise, keep empty to deliver to your own company." ), - 'warehouse_id': fields.many2one('stock.warehouse', 'Destination Warehouse', states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}), - 'location_id': fields.many2one('stock.location', 'Destination', required=True, domain=[('usage','<>','view')]), + 'warehouse_id': fields.many2one('stock.warehouse', 'Destination Warehouse'), + 'location_id': fields.many2one('stock.location', 'Destination', required=True, domain=[('usage','<>','view')], states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]} ), 'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, help="The pricelist sets the currency used for this purchase order. It also computes the supplier price for the selected products/quantities."), 'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", readonly=True, required=True), 'state': fields.selection(STATE_SELECTION, 'Status', readonly=True, help="The status of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' status. Then the order has to be confirmed by the user, the status switch to 'Confirmed'. Then the supplier must confirm the order to change the status to 'Approved'. When the purchase order is paid and received, the status becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the status becomes in exception.", select=True), @@ -189,7 +189,7 @@ class purchase_order(osv.osv): 'shipped_rate': fields.function(_shipped_rate, string='Received', type='float'), 'invoiced': fields.function(_invoiced, string='Invoice Received', 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','Based on Purchase Order lines'),('order','Based on generated draft invoice'),('picking','Based on incoming shipments')], 'Invoicing Control', required=True, + 'invoice_method': fields.selection([('manual','Based on Purchase Order lines'),('order','Based on generated draft invoice'),('picking','Based on incoming shipments')], 'Invoicing Control', required=True,states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}, help="Based on Purchase Order lines: place individual lines in 'Invoice Control > Based on P.O. lines' from where you can selectively create an invoice.\n" \ "Based on generated invoice: create a draft invoice you can validate later.\n" \ "Bases on incoming shipments: let you create an invoice when receptions are validated." @@ -214,13 +214,13 @@ class purchase_order(osv.osv): 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position'), 'product_id': fields.related('order_line','product_id', type='many2one', relation='product.product', string='Product'), 'create_uid': fields.many2one('res.users', 'Responsible'), - 'company_id': fields.many2one('res.company','Company',required=True,select=1), + 'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), 'journal_id': fields.many2one('account.journal', 'Journal'), } _defaults = { 'date_order': fields.date.context_today, 'state': 'draft', - 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order'), + 'name': lambda obj, cr, uid, context: '/', 'shipped': 0, 'invoice_method': 'order', 'invoiced': 0, @@ -237,6 +237,8 @@ class purchase_order(osv.osv): _order = "name desc" def create(self, cr, uid, vals, context=None): + if vals.get('name','/')=='/': + vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'purchase.order') or '/' order = super(purchase_order, self).create(cr, uid, vals, context=context) if order: self.create_send_note(cr, uid, [order], context=context) diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 4c7aea1caac..4f8fc34b038 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -262,8 +262,7 @@
-