To use constraints on unique records creation with account_number and company_id in avalara-salestax in OpenERP/Odoo follow below steps-
Step-1 Go to avalara_salestax module.
Step-2 avalara_salestax->avalara_salestax.py.
Step-3 After that used below code in avalara_salestax.py file.
_sql_constraints = [
('code_company_uniq', 'unique (company_code)', 'Avalara setting is already available for this company code'),
('account_number_company_uniq', 'unique (account_number, company_id)', 'The account number must be unique per company!'),
]
def _get_avatax_config_company(self, cr, uid, context=None):
""" Returns the AvaTax configuration for the user company """
user_obj = self.pool.get('res.users')
user = user_obj.browse(cr, uid, uid, context=context)
avatax_config_ids = self.search(cr, uid, [('company_id', '=', user.company_id.id)], context=context)
return avatax_config_ids and self.browse(cr, uid, avatax_config_ids[0], context=context) or False
avalara_salestax()
0 Comment(s)