Browse Source

-> access rule, lint & typos

pull/21/head
blaggacao 11 years ago
parent
commit
f537a6c534
  1. 2
      res_partner_fiscal_document/__init__.py
  2. 2
      res_partner_fiscal_document/__openerp__.py
  3. 88
      res_partner_fiscal_document/res_partner.py
  4. 37
      res_partner_fiscal_document/res_partner_idtype.py
  5. 0
      res_partner_fiscal_document/res_partner_view.xml
  6. 3
      res_partner_fiscal_document/security/ir.model.access.csv

2
res_partner_fiscal_document/__init__.py

@ -29,4 +29,4 @@
#
##############################################################################
from . import res_partner_document
from . import res_partner, res_partner_idtype

2
res_partner_fiscal_document/__openerp__.py

@ -49,10 +49,8 @@
'res_partner_document_view.xml',
],
'demo': [
#,
],
'test': [
#,
],
'installable': True,
'auto_install': False,

88
res_partner_fiscal_document/res_partner_document.py → res_partner_fiscal_document/res_partner.py

@ -23,40 +23,33 @@
from openerp import models, fields, api, _
class ResPartnerIDtype(models.Model):
_name = 'res.partner.idtype'
_description = 'Identification Document Type'
_order = 'sequence'
name = fields.Char(required=True)
code = fields.Char(required=True)
sequence = fields.Integer()
active = fields.Boolean(default=True)
note = fields.Text()
on_company = fields.Boolean(string=u'On Company?')
on_contact = fields.Boolean(string=u'On Contact?', default=True)
class ResPartnerIdent(models.Model):
_name = 'res.partner'
class ResPartner(models.Model):
_inherit = 'res.partner'
dom = "['|', ('on_company', '=', is_company), ('on_contact', '!=', " \
"is_company)]"
fiscal_id_type = fields.Many2one('res.partner.idtype',
string=u'Document Type', domain=dom, )
dom = "[ '|', " \
" ('on_company', '=', is_company), " \
" ('on_contact', '!=', is_company) ]"
fiscal_id_type = fields.Many2one(
'res.partner.idtype',
string=u'Document Type',
domain=dom,
)
fiscal_id = fields.Char(string=u'Document ID')
fiscal_id_doc = fields.Binary(string=u'Document Scan',
fiscal_id_doc = fields.Binary(
string=u'Document Scan',
help="Upload the supporting Document "
"preferably as size-optimized PDF. "
"This might "
"help save disk space and PDF allows "
"you to concatenate multiple documents.")
"you to concatenate multiple documents."
)
@api.one
@api.onchange('fiscal_id_type', 'fiscal_id',
# 'is_company', # https://github.com/odoo/odoo/issues/1530)
@api.onchange(
'fiscal_id_type',
'fiscal_id',
)
# 'is_company', # https://github.com/odoo/odoo/issues/1530
def validateformatcopy(self):
# CASE: Current ID Type is not applicable on company
if self.is_company and not self.fiscal_id_type.on_company:
@ -78,10 +71,8 @@ class ResPartnerIdent(models.Model):
self.fiscal_id_type, self.fiscal_id = res['output_type'], res[
'output_id']
# Procedure for Copying
self._copyid(self)
_copyid(self)
@staticmethod
def _validateandformatid(self):
"""
Hook method to be inherited for custom validation methods.
@ -100,20 +91,23 @@ class ResPartnerIdent(models.Model):
Find below a suggested basic outline.
"""
f_type, f_id, is_company = self.fiscal_id_type, self.fiscal_id, \
self.is_company
f_type = self.fiscal_id_type
f_id = self.fiscal_id
is_company = self.is_company
def default(): return {'output_type': f_type, 'output_id': f_id}
return {'CODE1': {'output_type': f_type, 'output_id': f_id},
'CODE2': {'output_type': f_type, 'output_id': f_id},
"""
Define your cases with the index being the doctype id to match
Note you can work inline (lambda), or call subfunctions at will
"""
def default():
return {'output_type': f_type, 'output_id': f_id}
return {
# Define your cases
# The index to match is self.fiscal_id_type.code
# Note: You can change this index below.
# Example assignation using two functions
# {'output_type': func_type1(), 'output_id': funct_id1()}
'CODE1': {""" put your assignation here """},
'CODE2': {""" put your assignation here """},
}.get(self.fiscal_id_type.code, default())
@staticmethod
def _copyid(self):
"""
Hook Method to be inherited for custom copy methods based on the
@ -126,8 +120,9 @@ class ResPartnerIdent(models.Model):
Find below a suggested basic outline.
"""
f_type, f_id, is_company = self.fiscal_id_type, self.fiscal_id, \
self.is_company
f_type = self.fiscal_id_type
f_id = self.fiscal_id
is_company = self.is_company
def stringop_def(s): return s
@ -140,11 +135,10 @@ class ResPartnerIdent(models.Model):
# self.vat is a Boolean until base_vat is installed.
# self.vat = self.country_id.code + sringop_def(f_id)
{'CODE1': {
# self.vat_subjected: True,
# self.vat: self.country_id.code + stringop_1(f_id)
},
'CODE2': {
{
# Some examples to consider...
# seld.vat_subjected: True,
# self.vat: self.country_id.code + stringop_1(f_id)
},}.get(self.fiscal_id_type.code, default())
'CODE1': {""" put your statments here """},
'CODE2': {""" put your statments here """},
}.get(self.fiscal_id_type.code, default())

37
res_partner_fiscal_document/res_partner_idtype.py

@ -0,0 +1,37 @@
# -*- encoding: utf-8 -*-
# #############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) Odoo Colombia (Community).
# Author David Arnold (devCO)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, _
class ResPartnerIDtype(models.Model):
_name = 'res.partner.idtype'
_description = 'Identification Document Type'
_order = 'sequence'
name = fields.Char(required=True)
code = fields.Char(required=True)
sequence = fields.Integer()
active = fields.Boolean(default=True)
note = fields.Text()
on_company = fields.Boolean(string=u'On Company?')
on_contact = fields.Boolean(string=u'On Contact?', default=True)

0
res_partner_fiscal_document/res_partner_document_view.xml → res_partner_fiscal_document/res_partner_view.xml

3
res_partner_fiscal_document/security/ir.model.access.csv

@ -0,0 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_res_partner_idtype","res_res_partner_idtype_user","model_res_partner_idtype","group_account_user",1,0,0,0
"access_res_partner_idtype_manager","res_res_partner_idtype_manager","model_res_partner_idtype","account.group_account_manager",1,1,1,1
Loading…
Cancel
Save