1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from osv import fields, osv
25
class account_fiscal_position_rule(osv.osv):
26
_name = "account.fiscal.position.rule"
28
'name': fields.char('Name', size=64, required=True),
29
'description': fields.char('Description', size=128),
30
'from_country': fields.many2one('res.country','Country Form'),
31
'from_state': fields.many2one('res.country.state', 'State To', domain="[('country_id','=',from_country)]"),
32
'to_country': fields.many2one('res.country', 'Country To'),
33
'to_state': fields.many2one('res.country.state', 'State To', domain="[('country_id','=',to_country)]"),
34
'company_id': fields.many2one('res.company', 'Company', required=True),
35
'fiscal_position_id': fields.many2one('account.fiscal.position', 'Fiscal Position', domain="[('company_id','=',company_id)]", required=True),
36
'use_sale' : fields.boolean('Use in sales order'),
37
'use_invoice' : fields.boolean('Use in Invoices'),
39
account_fiscal_position_rule()
41
class account_fiscal_position_rule_template(osv.osv):
42
_name = "account.fiscal.position.rule.template"
44
'name': fields.char('Name', size=64, required=True),
45
'description': fields.char('Description', size=128),
46
'from_country': fields.many2one('res.country','Country Form'),
47
'from_state': fields.many2one('res.country.state', 'State From', domain="[('country_id','=',from_country)]"),
48
'to_country': fields.many2one('res.country', 'Country To'),
49
'to_state': fields.many2one('res.country.state', 'State To', domain="[('country_id','=',to_country)]"),
50
'fiscal_position_id': fields.many2one('account.fiscal.position.template', 'Fiscal Position', required=True),
51
'use_sale' : fields.boolean('Use in sales order'),
52
'use_invoice' : fields.boolean('Use in Invoices'),
54
account_fiscal_position_rule_template()
56
class wizard_account_fiscal_position_rule(osv.osv_memory):
57
_name='wizard.account.fiscal.position.rule'
60
'company_id':fields.many2one('res.company','Company',required=True),
64
'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.id,
67
def action_create(self, cr, uid, ids, context=None):
68
obj_wizard = self.browse(cr,uid,ids[0])
69
obj_fiscal_position_rule = self.pool.get('account.fiscal.position.rule')
70
obj_fiscal_position_rule_template = self.pool.get('account.fiscal.position.rule.template')
72
company_id = obj_wizard.company_id.id
74
pfr_ids = obj_fiscal_position_rule_template.search(cr, uid, [])
76
for fpr_template in obj_fiscal_position_rule_template.browse(cr, uid, pfr_ids):
78
'name': fpr_template.name,
79
'description': fpr_template.description,
80
'from_country': fpr_template.from_country.id,
81
'from_state': fpr_template.from_state.id,
82
'to_country': fpr_template.to_country.id,
83
'to_state': fpr_template.to_state.id,
84
'company_id': company_id,
85
'fiscal_position_id': fpr_template.fiscal_position_id.id,
86
'fiscal_operaton_id': fpr_template.fiscal_operation_id.id,
87
'use_sale' : fpr_template.use_sale,
88
'use_invoice' : fpr_template.use_invoice
90
obj_fiscal_position_rule.create(cr,uid,vals)
95
'res_model': 'ir.actions.configuration.wizard',
96
'type': 'ir.actions.act_window',
99
def action_cancel(self,cr,uid,ids,conect=None):
103
'res_model': 'ir.actions.configuration.wizard',
104
'type': 'ir.actions.act_window',
109
wizard_account_fiscal_position_rule()
b'\\ No newline at end of file'