diff --git a/addons/account/account.py b/addons/account/account.py index fee6d951e9a..1f8428527ae 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1734,7 +1734,6 @@ class account_chart_template(osv.osv): 'property_account_payable': fields.many2one('account.account.template','Payable Account'), 'property_account_expense_categ': fields.many2one('account.account.template','Expense Category Account'), 'property_account_income_categ': fields.many2one('account.account.template','Income Category Account'), - 'property_account_tax': fields.many2one('account.account.template','Default Tax on Partner'), 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), } @@ -2035,7 +2034,6 @@ class wizard_multi_charts_accounts(osv.osv_memory): ('property_account_payable','res.partner','account.account'), ('property_account_expense_categ','product.category','account.account'), ('property_account_income_categ','product.category','account.account'), - ('property_account_tax','res.partner','account.tax'), ('property_account_expense','product.template','account.account'), ('property_account_income','product.template','account.account') ] diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 0e1949f9554..1c4ef5546c7 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -124,6 +124,7 @@ + @@ -198,7 +199,7 @@ - + @@ -208,17 +209,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -280,7 +281,7 @@ - + @@ -290,17 +291,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index f2573a71f9b..7be194e2f65 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -48,19 +48,19 @@ - + - + - + - - + + diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index e75b7c3bc9b..606440020d0 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -149,15 +149,9 @@ your own chart of account. - - property_account_supplier_tax - - - - - - property_account_tax - + + property_account_position + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index e7d92587b3d..4b9ab3f10d5 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -858,7 +858,8 @@ class account_invoice_line(osv.osv): lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang'] tax_obj = self.pool.get('account.tax') if type in ('out_invoice', 'out_refund'): - taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax + part = self.pool.get('res.partner').browse(cr, uid, partner_id) + taxep = part.property_account_position and part.property_account_position.account_tax if not taxep or not taxep.id: tax_id = map(lambda x: x.id, res.taxes_id) else: @@ -867,7 +868,8 @@ class account_invoice_line(osv.osv): if not t.tax_group==taxep.tax_group: tax_id.append(t.id) else: - taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_supplier_tax + part = self.pool.get('res.partner').browse(cr, uid, partner_id) + taxep = part.property_account_position and part.property_account_position.account_supplier_tax if not taxep or not taxep.id: tax_id = map(lambda x: x.id, res.supplier_taxes_id) else: @@ -891,6 +893,8 @@ class account_invoice_line(osv.osv): a = res.product_tmpl_id.property_account_expense.id if not a: a = res.categ_id.property_account_expense_categ.id + + a = self.pool.get('account.fiscal.position').map_account(cr, uid, part, a) if a: result['account_id'] = a @@ -963,7 +967,8 @@ class account_invoice_line(osv.osv): if not (partner_id and account_id): return {} taxes = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids - taxep = self.pool.get('res.partner').browse(cr, uid, partner_id).property_account_tax + part = self.pool.get('res.partner').browse(cr, uid, partner_id) + taxep = partner.property_account_position and partner.property_account_position.account_tax if not taxep.id: return {'value': {'invoice_line_tax_id': map(lambda x: x.id, taxes or []) }} res = [taxep.id] diff --git a/addons/account/partner.py b/addons/account/partner.py index a47aae0d792..fbb4839f452 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -31,6 +31,44 @@ from osv import fields, osv import ir +class account_fiscal_position(osv.osv): + _name = 'account.fiscal.position' + _description = 'Fiscal Position' + _columns = { + 'name': fields.char('Fiscal Position', size=64, translate=True, required=True), + 'company_id': fields.many2one('res.company', 'Company'), + 'account_tax': fields.many2one( + 'account.tax', 'Customer Tax', + help="This account will be used as the receivable account for partners in this position", + ), + 'account_supplier_tax': fields.many2one( + 'account.tax', 'Supplier Tax', + help="This account will be used as the payable account for partners in this position", + ), + 'account_ids': fields.one2many('account.fiscal.position.account', 'position_id', 'Accounts Mapping') + } + def map_account(self, cr, uid, partner, account_id, context={}): + if (not partner) or (not partner.property_account_position) : + return account_id + for pos in partner.property_account_position.account_ids: + if pos.account_src_id.id==account_id: + account_id = pos.account_dest_id.id + break + return account_id +account_fiscal_position() + + +class account_fiscal_position_account(osv.osv): + _name = 'account.fiscal.position.account' + _description = 'Fiscal Position Accounts Mapping' + _rec_name = 'position_id' + _columns = { + 'position_id': fields.many2one('account.fiscal.position', 'Fiscal Position', required=True, ondelete='cascade'), + 'account_src_id': fields.many2one('account.account', 'Account Source', required=True), + 'account_dest_id': fields.many2one('account.account', 'Account Destination', required=True) + } +account_fiscal_position_account() + class res_partner(osv.osv): _name = 'res.partner' _inherit = 'res.partner' @@ -109,24 +147,15 @@ class res_partner(osv.osv): domain="[('type', '=', 'receivable')]", help="This account will be used, instead of the default one, as the receivable account for the current partner", required=True), - 'property_account_supplier_tax': fields.property( - 'account.tax', + 'property_account_position': fields.property( + 'account.fiscal.position', type='many2one', - relation='account.tax', - string="Default Supplier Tax", + relation='account.fiscal.position', + string="Fiscal Position", method=True, view_load=True, - domain=[('parent_id','=',False)], - help="This tax will be used, instead of the default one for supplier invoices."), - 'property_account_tax': fields.property( - 'account.tax', - type='many2one', - relation='account.tax', - string="Default Tax", - method=True, - view_load=True, - domain=[('parent_id','=',False)], - help="This tax will be used, instead of the default one for customers."), + help="The fiscal position will determine taxes and the accounts used for the the partner.", + ), 'property_payment_term': fields.property( 'account.payment.term', type='many2one', diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index d580ff02285..bfe4e80ced0 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -1,6 +1,57 @@ + + + account.fiscal.position.form + account.fiscal.position + form + +
+ + + + + + + + + + + + + + + + + +
+ + account.fiscal.position.tree + account.fiscal.position + tree + + + + + + + + + + + + Fiscal Positions + account.fiscal.position + form + tree,form + + + + @@ -17,13 +68,12 @@ - + - diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index d55331b13d4..18183dd0313 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -75,3 +75,7 @@ "access_account_payment_term_line_partner_manager","account.payment.term.line partner manager","model_account_payment_term_line","base.group_user",1,0,0,0 "access_account_account_product_manager","account.account product manager","model_account_account","product.group_product_manager",1,0,0,0 "access_account_journal_product_manager","account.journal product manager","model_account_journal","product.group_product_manager",1,0,0,0 +"access_account_fiscal_position_product_manager","account.fiscal.position account.manager","model_account_fiscal_position","account.group_account_manager",1,1,1,1 +"access_account_fiscal_position_account_product_manager","account.fiscal.position account.manager","model_account_fiscal_position_account","account.group_account_manager",1,1,1,1 +"access_account_fiscal_position","account.fiscal.position all","model_account_fiscal_position","base.group_user",1,0,0,0 +"access_account_fiscal_position_account","account.fiscal.position all","model_account_fiscal_position_account","base.group_user",1,0,0,0 diff --git a/addons/account/wizard/wizard_partner_balance_report.py b/addons/account/wizard/wizard_partner_balance_report.py index d90a68a99f0..5b28e10ceb9 100644 --- a/addons/account/wizard/wizard_partner_balance_report.py +++ b/addons/account/wizard/wizard_partner_balance_report.py @@ -59,7 +59,7 @@ period_fields = { 'string':"Date/Period Filter", 'type':'selection', 'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')], - 'default': lambda *a:'all' + 'default': lambda *a:'bydate' }, 'fiscalyear': { 'string':'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py index 7a638f3d0db..298cf910275 100755 --- a/addons/account/wizard/wizard_third_party_ledger.py +++ b/addons/account/wizard/wizard_third_party_ledger.py @@ -65,7 +65,7 @@ period_fields = { 'string':"Date/Period Filter", 'type':'selection', 'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')], - 'default': lambda *a:'all' + 'default': lambda *a:'bydate' }, 'fiscalyear': { 'string':'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', @@ -81,7 +81,7 @@ period_fields = { 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'}, 'reconcil':{'string':" Include Reconciled Entries",'type':'boolean'}, 'page_split':{'string':"One Partner Per Page",'type':'boolean'}, - 'date1': {'string':' Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, + 'date1': {'string':' Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, 'date2': {'string':'End date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, } diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index 6fd1df8228e..2a6dc558963 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -133,10 +133,14 @@ class res_partner_job(osv.osv): 'sequence_partner':fields.integer('Sequence (Partner)',help='order of importance of this function in the list of functions of the linked partner'), 'email': fields.char('E-Mail', size=240), 'phone': fields.char('Phone', size=64), + 'date_start' : fields.date('Date Start'), + 'date_stop' : fields.date('Date Stop'), + 'state' : fields.selection([('past', 'Past'),('current', 'Current')], 'State', required=True), } _defaults = { 'sequence_contact' : lambda *a: 0, + 'state' : lambda *a: 'current', } res_partner_job() diff --git a/addons/base_contact/base_contact_view.xml b/addons/base_contact/base_contact_view.xml index 817135a8571..5cc819d8dea 100644 --- a/addons/base_contact/base_contact_view.xml +++ b/addons/base_contact/base_contact_view.xml @@ -23,10 +23,10 @@ form
- + + + - - @@ -37,20 +37,24 @@ - - + + + + + - + + diff --git a/addons/base_vat/base_vat_data.xml b/addons/base_vat/base_vat_data.xml index d61201f93d8..d0f1de72732 100644 --- a/addons/base_vat/base_vat_data.xml +++ b/addons/base_vat/base_vat_data.xml @@ -7,7 +7,7 @@ res.partner - +