Created
November 28, 2014 16:43
-
-
Save eLBati/cb50cc060c3c6b54be10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/l10n_it_vat_registries/account.py b/l10n_it_vat_registries/account.py | |
index 6065f1d..39f144d 100644 | |
--- a/l10n_it_vat_registries/account.py | |
+++ b/l10n_it_vat_registries/account.py | |
@@ -19,17 +19,14 @@ | |
# | |
# | |
-from openerp.osv import fields, osv | |
+from openerp import models, fields, api, _ | |
- | |
-class account_tax_code(osv.osv): | |
+class account_tax_code(models.Model): | |
_inherit = "account.tax.code" | |
- | |
- _columns = { | |
- 'is_base': fields.boolean( | |
- 'Is base', | |
- help="This tax code is used for base amounts (field used by " | |
- "VAT registries)"), | |
- 'exclude_from_registries': fields.boolean( | |
- 'Exclude from VAT registries'), | |
- } | |
+ | |
+ is_base = fields.Boolean( | |
+ string='Is base', | |
+ help="This tax code is used for base amounts \ | |
+ (field used by VAT registries)") | |
+ exclude_from_registries = fields.Boolean( | |
+ string='Exclude from VAT registries') | |
diff --git a/l10n_it_vat_registries/invoice.py b/l10n_it_vat_registries/invoice.py | |
index d55f3b8..42b1263 100644 | |
--- a/l10n_it_vat_registries/invoice.py | |
+++ b/l10n_it_vat_registries/invoice.py | |
@@ -19,8 +19,8 @@ | |
# | |
# | |
-from report import report_sxw | |
-from tools.translate import _ | |
+from openerp.report import report_sxw | |
+from openerp import _ | |
import logging | |
from datetime import datetime | |
diff --git a/l10n_it_vat_registries/wizard/print_registro_iva.py b/l10n_it_vat_registries/wizard/print_registro_iva.py | |
index 1a219b7..f5ed63e 100644 | |
--- a/l10n_it_vat_registries/wizard/print_registro_iva.py | |
+++ b/l10n_it_vat_registries/wizard/print_registro_iva.py | |
@@ -19,104 +19,105 @@ | |
# | |
# | |
-from osv import fields, osv | |
-from tools.translate import _ | |
+from openerp import models, fields, api, _ | |
+class wizard_registro_iva(models.TransientModel): | |
-class wizard_registro_iva(osv.osv_memory): | |
- | |
- def _get_period(self, cr, uid, context=None): | |
- ctx = dict(context or {}, account_period_prefer_normal=True) | |
- period_ids = self.pool.get('account.period').find(cr, uid, context=ctx) | |
+ @api.model | |
+ def _get_period(self): | |
+ ctx = dict(self._context or {}, account_period_prefer_normal=True) | |
+ period_ids = self.env[ | |
+ 'account.period'].find(self._cr, self.env.user, context=ctx) | |
return period_ids | |
_name = "wizard.registro.iva" | |
- _columns = { | |
- 'period_ids': fields.many2many( | |
- 'account.period', 'registro_iva_periods_rel', 'period_id', | |
- 'registro_id', 'Periods', | |
- help='Select periods you want retrieve documents from', | |
- required=True), | |
- 'type': fields.selection([ | |
- ('customer', 'Customer Invoices'), | |
- ('supplier', 'Supplier Invoices'), | |
- ('corrispettivi', 'Corrispettivi'), | |
- ], 'Layout', required=True), | |
- 'journal_ids': fields.many2many( | |
- 'account.journal', 'registro_iva_journals_rel', 'journal_id', | |
- 'registro_id', 'Journals', | |
- help='Select journals you want retrieve documents from', | |
- required=True), | |
- 'tax_sign': fields.float( | |
- 'Tax amount sign', | |
- help="Use -1 you have negative tax amounts and you want to print " | |
- "them prositive"), | |
- 'message': fields.char('Message', size=64, readonly=True), | |
- 'fiscal_page_base': fields.integer('Last printed page', required=True), | |
- } | |
- _defaults = { | |
- 'type': 'customer', | |
- 'period_ids': _get_period, | |
- 'tax_sign': 1.0, | |
- 'fiscal_page_base': 0, | |
- } | |
- def print_registro(self, cr, uid, ids, context=None): | |
- if context is None: | |
- context = {} | |
- wizard = self.browse(cr, uid, ids)[0] | |
- move_obj = self.pool.get('account.move') | |
- obj_model_data = self.pool.get('ir.model.data') | |
- move_ids = move_obj.search(cr, uid, [ | |
- ('journal_id', 'in', [j.id for j in wizard.journal_ids]), | |
- ('period_id', 'in', [p.id for p in wizard.period_ids]), | |
+ period_ids = fields.Many2many( | |
+ 'account.period', | |
+ 'registro_iva_periods_rel', | |
+ 'period_id', | |
+ 'registro_id', | |
+ string='Periods', | |
+ default=_get_period, | |
+ help='Select periods you want retrieve documents from', | |
+ required=True) | |
+ type = fields.Selection([ | |
+ ('customer', 'Customer Invoices'), | |
+ ('supplier', 'Supplier Invoices'), | |
+ ('corrispettivi', 'Corrispettivi'), | |
+ ], 'Layout', required=True, | |
+ default='customer') | |
+ journal_ids = fields.Many2many( | |
+ 'account.journal', | |
+ 'registro_iva_journals_rel', | |
+ 'journal_id', | |
+ 'registro_id', | |
+ string='Journals', | |
+ help='Select journals you want retrieve documents from', | |
+ required=True) | |
+ tax_sign = fields.Float( | |
+ string='Tax amount sign', | |
+ default=1.0, | |
+ help="Use -1 you have negative tax \ | |
+ amounts and you want to print them prositive") | |
+ message = fields.Char(string='Message', size=64, readonly=True) | |
+ fiscal_page_base = fields.Integer( | |
+ string='Last printed page', | |
+ default=0, | |
+ required=True) | |
+ | |
+ @api.one | |
+ def print_registro(self): | |
+ move_obj = self.env('account.move') | |
+ obj_model_data = self.env('ir.model.data') | |
+ move_ids = move_obj.search([ | |
+ ('journal_id', 'in', [j.id for j in self.journal_ids]), | |
+ ('period_id', 'in', [p.id for p in self.period_ids]), | |
('state', '=', 'posted'), | |
- ], order='date, name') | |
+ ], order='date, name') | |
if not move_ids: | |
- self.write( | |
- cr, uid, ids, | |
- {'message': _('No documents found in the current selection')}) | |
+ self.message = _('No documents found in the current selection') | |
model_data_ids = obj_model_data.search( | |
- cr, uid, [ | |
- ('model', '=', 'ir.ui.view'), | |
- ('name', '=', 'wizard_registro_iva') | |
- ]) | |
+ [('model', '=', 'ir.ui.view'), | |
+ ('name', '=', 'wizard_registro_iva')]) | |
resource_id = obj_model_data.read( | |
- cr, uid, model_data_ids, fields=['res_id'])[0]['res_id'] | |
+ self._cr, | |
+ self.env, | |
+ model_data_ids, | |
+ fields=['res_id'])[0]['res_id'] | |
return { | |
'name': _('No documents'), | |
- 'res_id': ids[0], | |
+ 'res_id': self.id, | |
'view_type': 'form', | |
'view_mode': 'form', | |
'res_model': 'wizard.registro.iva', | |
'views': [(resource_id, 'form')], | |
- 'context': context, | |
+ 'context': self._context, | |
'type': 'ir.actions.act_window', | |
'target': 'new', | |
} | |
datas = {'ids': move_ids} | |
datas['model'] = 'account.move' | |
- datas['fiscal_page_base'] = wizard.fiscal_page_base | |
- datas['period_ids'] = [p.id for p in wizard.period_ids] | |
- datas['layout'] = wizard['type'] | |
- datas['tax_sign'] = wizard['tax_sign'] | |
+ datas['fiscal_page_base'] = self.fiscal_page_base | |
+ datas['period_ids'] = [p.id for p in self.period_ids] | |
+ datas['layout'] = self.type | |
+ datas['tax_sign'] = self.tax_sign | |
res = { | |
'type': 'ir.actions.report.xml', | |
'datas': datas, | |
} | |
- if wizard['type'] == 'customer': | |
+ if self.type == 'customer': | |
res['report_name'] = 'registro_iva_vendite' | |
- elif wizard['type'] == 'supplier': | |
- res['report_name'] = 'registro_iva_acquisti' | |
- elif wizard['type'] == 'corrispettivi': | |
+ elif self.type == 'supplier': | |
+ res.report_name = 'registro_iva_acquisti' | |
+ elif self.type == 'corrispettivi': | |
res['report_name'] = 'registro_iva_corrispettivi' | |
return res | |
- def on_type_changed(self, cr, uid, ids, j_type, context=None): | |
- res = {} | |
- if j_type: | |
- if j_type == 'supplier': | |
- res['value'] = {'tax_sign': -1} | |
+ @api.onchange('type') | |
+ def on_type_changed(self): | |
+ if self.type: | |
+ if self.type == 'supplier': | |
+ self.tax_sign = -1 | |
else: | |
- res['value'] = {'tax_sign': 1} | |
- return res | |
+ self.tax_sign = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment