Skip to content

Commit

Permalink
[REF] l10n_ve_withholding_muni: Basic migration to v8
Browse files Browse the repository at this point in the history
  • Loading branch information
suniagajose committed Dec 17, 2015
1 parent 284342a commit 0fb92a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
8 changes: 4 additions & 4 deletions l10n_ve_withholding_muni/model/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#############################################################################

from openerp import api
from openerp.osv import fields, osv
from openerp.tools.translate import _


class AccountInvoice(osv.osv):
_inherit = 'account.invoice'

def copy(self, cr, uid, ids, default=None, context=None):
@api.multi
def copy(self, default=None):
""" Initialized fields to the copy a register
"""
# NOTE: use ids argument instead of id for fix the pylint error W0622.
# Redefining built-in 'id'
context = context or {}
default = default or {}
default = default.copy()
default.update({'wh_local': False, 'wh_muni_id': False})
return super(AccountInvoice, self).copy(cr, uid, ids, default,
context)
return super(AccountInvoice, self).copy(default)

def _get_move_lines(self, cr, uid, ids, to_wh, period_id,
pay_journal_id, writeoff_acc_id,
Expand Down
41 changes: 20 additions & 21 deletions l10n_ve_withholding_muni/model/wh_muni.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def _get_currency(self, cr, uid, context=None):
return self.pool.get('res.currency').search(
cr, uid, [('rate', '=', 1.0)])[0]

def _get_company(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid)
return user.company_id.id

_name = "account.wh.munici"
_description = "Local Withholding"
_columns = {
Expand All @@ -85,13 +89,16 @@ def _get_currency(self, cr, uid, context=None):
'type': fields.selection([
('out_invoice', 'Customer Invoice'),
('in_invoice', 'Supplier Invoice'),
], 'Type', readonly=True, help="Withholding type"),
], string='Type', readonly=True,
default=lambda s: s._get_type(),
help="Withholding type"),
'state': fields.selection([
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('done', 'Done'),
('cancel', 'Cancelled')
], 'State', readonly=True, help="Estado del Comprobante"),
], string='State', readonly=True, default='draft',
help="Estado del Comprobante"),
'date_ret': fields.date('Withholding date', readonly=True,
states={'draft': [('readonly', False)]},
help="Keep empty to use the current date"),
Expand All @@ -109,16 +116,22 @@ def _get_currency(self, cr, uid, context=None):
" date) date."),
'currency_id': fields.many2one(
'res.currency', 'Currency', required=True, readonly=True,
states={'draft': [('readonly', False)]}, help="Currency"),
states={'draft': [('readonly', False)]},
default=lambda s: s._get_currency(),
help="Currency"),
'partner_id': fields.many2one(
'res.partner', 'Partner', readonly=True, required=True,
states={'draft': [('readonly', False)]},
help="Withholding customer/supplier"),
'company_id': fields.many2one(
'res.company', 'Company', required=True, help="Company"),
'res.company', 'Company', required=True,
default=lambda s: s._get_company(),
help="Company"),
'journal_id': fields.many2one(
'account.journal', 'Journal', required=True, readonly=True,
states={'draft': [('readonly', False)]}, help="Journal entry"),
states={'draft': [('readonly', False)]},
default=lambda s: s._get_journal(),
help="Journal entry"),
'munici_line_ids': fields.one2many(
'account.wh.munici.line', 'retention_id',
'Local withholding lines', readonly=True,
Expand All @@ -133,16 +146,6 @@ def _get_currency(self, cr, uid, context=None):
help='account entry for the invoice'),
}

_defaults = {
'type': _get_type,
'state': lambda *a: 'draft',
'journal_id': _get_journal,
'currency_id': _get_currency,
'company_id': lambda self, cr, uid, context:
self.pool.get('res.users').browse(cr, uid, uid,
context=context).company_id.id,
}

_sql_constraints = [
('ret_num_uniq', 'unique (number)', 'number must be unique !')
]
Expand Down Expand Up @@ -436,14 +439,10 @@ def default_get(self, cr, uid, field_list, context=None):
'wh_loc_rate': fields.float(
'Rate', help="Local withholding rate"),
'concepto_id': fields.integer(
'Concept', size=3, help="Local withholding concept"),


'Concept', size=3, default=1,
help="Local withholding concept"),
}
_defaults = {
'concepto_id': lambda *a: 1,

}
_sql_constraints = [
('munici_fact_uniq', 'unique (invoice_id)',
'The invoice has already assigned in local withholding, you'
Expand Down

0 comments on commit 0fb92a0

Please sign in to comment.