From f537a6c53416dddd11926fecb26180669dd508f3 Mon Sep 17 00:00:00 2001 From: blaggacao Date: Wed, 6 Aug 2014 20:44:14 -0500 Subject: [PATCH] -> access rule, lint & typos --- res_partner_fiscal_document/__init__.py | 2 +- res_partner_fiscal_document/__openerp__.py | 2 - ...res_partner_document.py => res_partner.py} | 98 +++++++++---------- .../res_partner_idtype.py | 37 +++++++ ...document_view.xml => res_partner_view.xml} | 0 .../security/ir.model.access.csv | 3 + 6 files changed, 87 insertions(+), 55 deletions(-) rename res_partner_fiscal_document/{res_partner_document.py => res_partner.py} (63%) create mode 100644 res_partner_fiscal_document/res_partner_idtype.py rename res_partner_fiscal_document/{res_partner_document_view.xml => res_partner_view.xml} (100%) create mode 100644 res_partner_fiscal_document/security/ir.model.access.csv diff --git a/res_partner_fiscal_document/__init__.py b/res_partner_fiscal_document/__init__.py index 4711b6bc0..3064589a7 100644 --- a/res_partner_fiscal_document/__init__.py +++ b/res_partner_fiscal_document/__init__.py @@ -29,4 +29,4 @@ # ############################################################################## -from . import res_partner_document \ No newline at end of file +from . import res_partner, res_partner_idtype diff --git a/res_partner_fiscal_document/__openerp__.py b/res_partner_fiscal_document/__openerp__.py index 025299635..66211af00 100644 --- a/res_partner_fiscal_document/__openerp__.py +++ b/res_partner_fiscal_document/__openerp__.py @@ -49,10 +49,8 @@ 'res_partner_document_view.xml', ], 'demo': [ - #, ], 'test': [ - #, ], 'installable': True, 'auto_install': False, diff --git a/res_partner_fiscal_document/res_partner_document.py b/res_partner_fiscal_document/res_partner.py similarity index 63% rename from res_partner_fiscal_document/res_partner_document.py rename to res_partner_fiscal_document/res_partner.py index 75ba18e05..d7e2d4eb3 100644 --- a/res_partner_fiscal_document/res_partner_document.py +++ b/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', - help="Upload the supporting Document " - "preferably as size-optimized PDF. " - "This might " - "help save disk space and PDF allows " - "you to concatenate multiple documents.") - + 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." + ) @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 - - def default(): return {'output_type': f_type, 'output_id': f_id} + f_type = self.fiscal_id_type + f_id = self.fiscal_id + is_company = self.is_company - 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, + { + # Some examples to consider... + # seld.vat_subjected: True, # self.vat: self.country_id.code + stringop_1(f_id) - }, - 'CODE2': { - # 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()) diff --git a/res_partner_fiscal_document/res_partner_idtype.py b/res_partner_fiscal_document/res_partner_idtype.py new file mode 100644 index 000000000..18cb79a89 --- /dev/null +++ b/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 . +# +############################################################################## + +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) diff --git a/res_partner_fiscal_document/res_partner_document_view.xml b/res_partner_fiscal_document/res_partner_view.xml similarity index 100% rename from res_partner_fiscal_document/res_partner_document_view.xml rename to res_partner_fiscal_document/res_partner_view.xml diff --git a/res_partner_fiscal_document/security/ir.model.access.csv b/res_partner_fiscal_document/security/ir.model.access.csv new file mode 100644 index 000000000..b5490859f --- /dev/null +++ b/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