Skip to content

Commit

Permalink
[REF] l10n_ve_imex: 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 8c9cf85 commit 1f563f0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 53 deletions.
29 changes: 12 additions & 17 deletions l10n_ve_imex/model/customs_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,23 @@ def _gen_account_move_line(self, company_id, account_id, partner_id, name,
'reconcile': False,
})

def _get_company(self, cr, uid, context=None):
company_obj = self.pool.get('res.company')
return company_obj._company_default_get(
cr, uid, 'customs.form', context=context)

_columns = {
'name': fields.char('Form #', size=16, required=True, readonly=True,
states={'draft': [('readonly', False)]}),
'ref': fields.char('Reference', size=64, required=False, readonly=True,
states={'draft': [('readonly', False)]}),
'date': fields.date('Date', required=True, readonly=True,
states={'draft': [('readonly', False)]},
select=True),
select=True, default=time.strftime('%Y-%m-%d')),
'company_id': fields.many2one('res.company', 'Company', required=True,
readonly=True, ondelete='restrict'),
readonly=True,
default=lambda s: s._get_company(),
ondelete='restrict'),
'broker_id': fields.many2one('res.partner', 'Broker',
change_default=True, readonly=True,
states={'draft': [('readonly', False)]},
Expand All @@ -112,7 +119,8 @@ def _gen_account_move_line(self, company_id, account_id, partner_id, name,
ondelete='restrict'),
'cfl_ids': fields.one2many('customs.form.line', 'customs_form_id',
'Tax lines', readonly=True,
states={'draft': [('readonly', False)]}),
states={'draft': [('readonly', False)]},
default=lambda s: s._default_cfl_ids()),
'amount_total': fields.function(_amount_total, method=True,
type='float', string='Amount total',
store=False),
Expand All @@ -124,17 +132,7 @@ def _gen_account_move_line(self, company_id, account_id, partner_id, name,
'state': fields.selection([('draft', 'Draft'), ('open', 'Open'),
('done', 'Done'), ('cancel', 'Cancelled')],
string='State', required=True,
readonly=True),
}

_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),
'company_id': lambda self, cr, uid, c:
self.pool.get('res.company')._company_default_get(cr, uid,
'customs.form',
context=c),
'cfl_ids': _default_cfl_ids,
'state': lambda *a: 'draft',
readonly=True, default='draft'),
}

_sql_constraints = [
Expand Down Expand Up @@ -326,9 +324,6 @@ class CustomsFormLine(osv.osv):
readonly=True)
}

_defaults = {
}

_sql_constraints = [
('code_uniq', 'UNIQUE(customs_form_id,tax_code)',
'The code must be unique! (for this form)'),
Expand Down
64 changes: 31 additions & 33 deletions l10n_ve_imex/model/customs_form_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ class CustomsFormConfig(osv.osv):
_description = ''
_rec_name = "company_id"

_columns = {
'company_id': fields.many2one('res.company', 'Company', required=True,
readonly=True, ondelete='restrict'),
'journal_id': fields.many2one('account.journal', 'Journal',
required=True, ondelete='restrict'),
}
def _get_company(self, cr, uid, context=None):
company_obj = self.pool.get('res.company')
return company_obj._company_default_get(
cr, uid, 'customs.form.config', context=context)

_defaults = {
'company_id': lambda self, cr, uid, c:
self.pool.get('res.company')._company_default_get(
cr, uid, 'customs.form.config', context=c),
_columns = {
'company_id': fields.many2one(
'res.company', string='Company', required=True, readonly=True,
default=lambda s: s._get_company(), ondelete='restrict'),
'journal_id': fields.many2one(
'account.journal', 'Journal',required=True,
ondelete='restrict'),
}

_sql_constraints = [
Expand Down Expand Up @@ -93,9 +94,6 @@ def name_search(self, cr, user, name='', args=None, operator='ilike',
'name': fields.char('Name', size=64, required=True, readonly=False),
}

_defaults = {
}

_sql_constraints = [
('code_uniq', 'UNIQUE(code)', 'The code must be unique!'),
]
Expand All @@ -122,31 +120,31 @@ def name_get(self, cr, uid, ids, context=None):
item.code, item.ref, item.name)))
return res


def _get_company(self, cr, uid, context=None):
company_obj = self.pool.get('res.company')
return company_obj._company_default_get(
cr, uid, 'customs.form.config', context=context)

_columns = {
'code': fields.char('Code', size=16, required=True, readonly=False),
'name': fields.char('Name', size=64, required=True, readonly=False),
'ref': fields.char('Ref', size=16, required=False, readonly=False),
'sequence': fields.integer('Sequence'),
'partner_id': fields.many2one('res.partner', 'Partner',
change_default=True,
ondelete='restrict'),
'account_id': fields.many2one('account.account', 'Account to pay',
domain="[('type','!=','view')]",
ondelete='restrict',
help="This account will be used for \
expenses related to taxes"),
'vat_detail': fields.boolean('Tax detail', help="Set true if this is \
vat related tax"),
'company_id': fields.many2one('res.company', 'Company', required=True,
readonly=True, ondelete='restrict'),
}

_defaults = {
'company_id': lambda self, cr, uid, c:
self.pool.get('res.company')._company_default_get(
cr, uid, 'customs.form.config', context=c),
'vat_detail': False,
}
'partner_id': fields.many2one(
'res.partner', string='Partner', change_default=True,
ondelete='restrict'),
'account_id': fields.many2one(
'account.account', string='Account to pay',
domain="[('type','!=','view')]", ondelete='restrict',
help="This account will be used for expenses related to taxes"),
'vat_detail': fields.boolean(
'Tax detail', default=False,
help="Set true if this is vat related tax"),
'company_id': fields.many2one(
'res.company', string='Company', required=True, readonly=True,
ondelete='restrict',
default=lambda s: s._get_company()),

_sql_constraints = [
('code_uniq', 'UNIQUE(code,company_id)',
Expand Down
3 changes: 0 additions & 3 deletions l10n_ve_imex/model/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ class AccountInvoiceTax(osv.osv):
string='Invoice ref', size=64, store=False, readonly=True),
}

_defaults = {
}

# _sql_constraints = [
# ('base_gt_zero', 'CHECK (base>0)',
# 'The base amount must be > 0!'),
Expand Down

0 comments on commit 1f563f0

Please sign in to comment.