From 095558d2a6252fab1d65981c1cea7b91caa6e4e7 Mon Sep 17 00:00:00 2001 From: "mra (Open ERP)" Date: Mon, 19 Jan 2009 19:29:11 +0530 Subject: [PATCH] account bzr revid: mra@tinyerp.com-20090119135911-haorjopuozgsxght --- addons/account/account_invoice_view.xml | 2 ++ addons/account/invoice.py | 6 +++++- addons/purchase/purchase.py | 14 ++++++++------ addons/purchase/purchase_view.xml | 11 ++++++----- addons/sale/sale.py | 6 ++++-- addons/sale/sale_view.xml | 1 + 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 7e99762a5ac..eb196fa6a8e 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -197,6 +197,7 @@ + @@ -283,6 +284,7 @@ + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index e0854cf3eae..a560b094b40 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -270,6 +270,7 @@ class account_invoice(osv.osv): help="Remaining amount due."), 'payment_ids': fields.function(_compute_lines, method=True, relation='account.move.line', type="many2many", string='Payments'), 'move_name': fields.char('Account Move', size=64), + 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position') } _defaults = { 'type': _get_type, @@ -305,6 +306,7 @@ class account_invoice(osv.osv): partner_payment_term = False acc_id = False bank_id = False + fiscal_position = False opt = [('uid', str(uid))] if partner_id: @@ -318,7 +320,8 @@ class account_invoice(osv.osv): acc_id = p.property_account_receivable.id else: acc_id = p.property_account_payable.id - + if p.property_account_position: + fiscal_position = p.property_account_position.id partner_payment_term = p.property_payment_term and p.property_payment_term.id or False if p.bank_ids: bank_id = p.bank_ids[0].id @@ -328,6 +331,7 @@ class account_invoice(osv.osv): 'address_invoice_id': invoice_addr_id, 'account_id': acc_id, 'payment_term': partner_payment_term, + 'fiscal_position': fiscal_position } } diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 3385b3eafe3..80e32bcfa42 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -184,6 +184,7 @@ class purchase_order(osv.osv): store={ 'purchase.order.line': (_get_order, None, 10), }, multi="sums"), + 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position') } _defaults = { 'date_order': lambda *a: time.strftime('%Y-%m-%d'), @@ -198,7 +199,7 @@ class purchase_order(osv.osv): _name = "purchase.order" _description = "Purchase order" _order = "name desc" - + def unlink(self, cr, uid, ids): purchase_orders = self.read(cr, uid, ids, ['state']) unlink_ids = [] @@ -207,8 +208,8 @@ class purchase_order(osv.osv): unlink_ids.append(s['id']) else: raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state'])) - return osv.osv.unlink(self, cr, uid, unlink_ids) - + return osv.osv.unlink(self, cr, uid, unlink_ids) + def button_dummy(self, cr, uid, ids, context={}): return True @@ -227,11 +228,12 @@ class purchase_order(osv.osv): def onchange_partner_id(self, cr, uid, ids, part): if not part: - return {'value':{'partner_address_id': False}} + return {'value':{'partner_address_id': False, 'fiscal_position': False}} addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default']) part = self.pool.get('res.partner').browse(cr, uid, part) pricelist = part.property_product_pricelist_purchase.id - return {'value':{'partner_address_id': addr['default'], 'pricelist_id': pricelist}} + fiscal_position = part.property_account_position and part.property_account_position.id or False + return {'value':{'partner_address_id': addr['default'], 'pricelist_id': pricelist, 'fiscal_position': fiscal_position}} def wkf_approve_order(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state': 'approved', 'date_approve': time.strftime('%Y-%m-%d')}) diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index dfe3f205c16..c0398b8bd5a 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -82,6 +82,7 @@ + @@ -206,11 +207,11 @@ diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 907dbe775ab..165979976f4 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -250,6 +250,7 @@ class sale_order(osv.osv): 'invoice_quantity': fields.selection([('order','Ordered Quantities'),('procurement','Shipped Quantities')], 'Invoice on', help="The sale order will automatically create the invoice proposition (draft invoice). Ordered and delivered quantities may not be the same. You have to choose if you invoice based on ordered or shipped quantities. If the product is a service, shipped quantities means hours spent on the associated tasks.",required=True), 'payment_term' : fields.many2one('account.payment.term', 'Payment Term'), + 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position') } _defaults = { 'picking_policy': lambda *a: 'direct', @@ -303,12 +304,13 @@ class sale_order(osv.osv): def onchange_partner_id(self, cr, uid, ids, part): if not part: - return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False, 'payment_term' : False}} + return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False, 'payment_term' : False, 'fiscal_position': False}} addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery','invoice','contact']) part = self.pool.get('res.partner').browse(cr, uid, part) pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False payment_term = part.property_payment_term and part.property_payment_term.id or False - return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist, 'payment_term' : payment_term}} + fiscal_position = part.property_account_position and part.property_account_position.id or False + return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist, 'payment_term' : payment_term, 'fiscal_position': fiscal_position}} def shipping_policy_change(self, cr, uid, ids, policy, context={}): if not policy: diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 609ac3b6590..5ef60c4e2ad 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -206,6 +206,7 @@ +