[FIX] l10n_be_invoice_bba: correct fix of algorithm stuff, previous commit was pure bullshit

bzr revid: qdp-launchpad@openerp.com-20120718122636-3njcyy79d35k3rnt
This commit is contained in:
Quentin (OpenERP) 2012-07-18 14:26:36 +02:00
parent 803220f3b7
commit a93a1a0937
2 changed files with 10 additions and 15 deletions

View File

@ -12,7 +12,7 @@
<field name="payment_term" position="after">
<group col="4" colspan="2">
<field name="reference_type" nolabel="1" size="0" attrs="{'readonly':[('state','!=','draft')]}"
on_change="generate_bbacomm(type,reference_type, partner_id.out_inv_comm_algorithm, partner_id,reference)" colspan="1"/>
on_change="generate_bbacomm(type,reference_type, partner_id,reference, context)" colspan="1"/>
<field name="reference" nolabel="1" colspan="3" attrs="{'readonly':[('state','!=','draft')]}"/>
</group>
</field>

View File

@ -44,7 +44,7 @@ class account_invoice(osv.osv):
#l_logger.warning('reference_type = %s' %res )
return res
def check_bbacomm(self, val):
def check_bbacomm(self, val):
supported_chars = '0-9+*/ '
pattern = re.compile('[^' + supported_chars + ']')
if pattern.findall(val or ''):
@ -64,7 +64,7 @@ class account_invoice(osv.osv):
return True
def onchange_partner_id(self, cr, uid, ids, type, partner_id,
date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id,
date_invoice, payment_term, partner_bank_id, company_id)
# reference_type = self.default_get(cr, uid, ['reference_type'])['reference_type']
@ -75,10 +75,7 @@ class account_invoice(osv.osv):
if (type == 'out_invoice'):
reference_type = self.pool.get('res.partner').browse(cr, uid, partner_id).out_inv_comm_type
if reference_type:
algorithm = self.pool.get('res.partner').browse(cr, uid, partner_id).out_inv_comm_algorithm
if not algorithm:
algorithm = 'random'
reference = self.generate_bbacomm(cr, uid, ids, type, reference_type, algorithm, partner_id, '')['value']['reference']
reference = self.generate_bbacomm(cr, uid, ids, type, reference_type, partner_id, '', context={})['value']['reference']
res_update = {
'reference_type': reference_type or 'none',
'reference': reference,
@ -86,17 +83,15 @@ class account_invoice(osv.osv):
result['value'].update(res_update)
return result
def generate_bbacomm(self, cr, uid, ids, type, reference_type, algorithm, partner_id, reference):
def generate_bbacomm(self, cr, uid, ids, type, reference_type, partner_id, reference, context=None):
partner_obj = self.pool.get('res.partner')
reference = reference or ''
reference = reference or ''
algorithm = False
if partner_id:
algorithm = partner_obj.browse(cr, uid, partner_id, context=context).out_inv_comm_algorithm
algorithm = algorithm or 'random'
if (type == 'out_invoice'):
if reference_type == 'bba':
if not algorithm:
if partner_id:
algorithm = partner_obj.browse(cr, uid, partner_id).out_inv_comm_algorithm
if not algorithm:
if not algorithm:
algorithm = 'random'
if algorithm == 'date':
if not self.check_bbacomm(reference):
doy = time.strftime('%j')