bzr revid: fp@tinyerp.com-20081106165655-0m3mbe64mvevbugh
This commit is contained in:
Fabien Pinckaers 2008-11-06 17:56:55 +01:00
commit 842bd1e101
17 changed files with 196 additions and 169 deletions

View File

@ -648,7 +648,7 @@ class account_move(osv.osv):
data_move = self.pool.get('account.move').browse(cursor,user,ids)
for move in data_move:
if move.state=='draft':
name = '*' + move.name
name = '*' + str(move.id)
else:
name = move.name
res.append((move.id, name))
@ -671,7 +671,7 @@ class account_move(osv.osv):
return result
_columns = {
'name': fields.char('Entry Name', size=64, required=True),
'name': fields.char('Entry Number', size=64, required=True),
'ref': fields.char('Ref', size=64),
'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}),
@ -680,10 +680,22 @@ class account_move(osv.osv):
'to_check': fields.boolean('To Be Verified'),
'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True),
'amount': fields.function(_amount_compute, method=True, string='Amount', digits=(16,2), store=True),
'type': fields.selection([
('pay_voucher','Cash Payment'),
('bank_pay_voucher','Bank Payment'),
('rec_voucher','Cash Receipt'),
('bank_rec_voucher','Bank Receipt'),
('cont_voucher','Contra'),
('journal_sale_vou','Journal Sale'),
('journal_pur_voucher','Journal Purchase'),
('journal_voucher','Journal Voucher'),
],'Type', readonly=True, select=True, states={'draft':[('readonly',False)]}),
}
_defaults = {
'name': lambda *a: '/',
'state': lambda *a: 'draft',
'period_id': _get_period,
'type' : lambda *a : 'journal_voucher',
}
def _check_centralisation(self, cursor, user, ids):
@ -716,6 +728,17 @@ class account_move(osv.osv):
]
def post(self, cr, uid, ids, context=None):
if self.validate(cr, uid, ids, context) and len(ids):
for move in self.browse(cr, uid, ids):
if move.name =='/':
new_name = False
journal = move.journal_id
if journal.sequence_id:
new_name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
if new_name:
self.write(cr, uid, [move.id], {'name':new_name})
cr.execute('update account_move set state=%s where id in ('+','.join(map(str,ids))+')', ('posted',))
else:
raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non balanced entry !'))
@ -761,12 +784,6 @@ class account_move(osv.osv):
l[2]['period_id'] = default_period
context['period_id'] = default_period
if not 'name' in vals:
journal = self.pool.get('account.journal').browse(cr, uid, context.get('journal_id', vals.get('journal_id', False)))
if journal.sequence_id:
vals['name'] = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv(_('Error'), _('No sequence defined in the journal !'))
accnt_journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id'])
if 'line_id' in vals:
c = context.copy()
@ -777,6 +794,13 @@ class account_move(osv.osv):
result = super(account_move, self).create(cr, uid, vals, context)
return result
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default = default.copy()
default.update({'state':'draft', 'name':'/',})
return super(account_move, self).copy(cr, uid, id, default, context)
def unlink(self, cr, uid, ids, context={}, check=True):
toremove = []
for move in self.browse(cr, uid, ids, context):

View File

@ -797,7 +797,8 @@
<field name="name"/>
<field name="period_id"/>
<field name="journal_id"/>
<field name="partner_id"/>
<field name="amount"/>
<field name="line_id"/>
<field name="state"/>
</tree>
@ -812,13 +813,12 @@
<form string="Account Entry">
<separator colspan="4" string="General Information"/>
<group colspan="4" col="6">
<field name="name" select="1" readonly="True"/>
<field name="period_id" select="2"/>
<field name="journal_id" select="1"/>
<field name="name" select="1"/>
<field name="partner_id" select="2"/>
<field name="amount" select="2"/>
<field name="ref" select="1" groups="base.group_extended"/>
<field name="to_check" select="2" groups="base.group_extended"/>
<field name="type" select="1" groups="base.group_extended"/>
</group>
<separator colspan="4" string="Entry Lines"/>
@ -854,8 +854,8 @@
<field name="account_id"/>
<field name="date_maturity"/>
<field name="ref"/>
<field name="debit"/>
<field name="credit"/>
<field name="debit" sum="Total Debit"/>
<field name="credit" sum="Total Credit"/>
<field name="state"/>
</tree>
</field>

View File

@ -191,6 +191,7 @@ class account_invoice(osv.osv):
'move_lines':fields.function(_get_lines , method=True,type='many2many' , relation='account.move.line',string='Move Lines'),
'residual': fields.function(_amount_residual, method=True, digits=(16,2),string='Residual', store=True, help="Remaining amount due."),
'payment_ids': fields.function(_compute_lines, method=True, relation='account.move.line', type="many2many", string='Payments'),
'move_name': fields.char('Account Move', size=64),
}
_defaults = {
'type': _get_type,
@ -323,7 +324,7 @@ class account_invoice(osv.osv):
if default is None:
default = {}
default = default.copy()
default.update({'state':'draft', 'number':False, 'move_id':False})
default.update({'state':'draft', 'number':False, 'move_id':False, 'move_name':False,})
if 'date_invoice' not in default:
default['date_invoice'] = False
if 'date_due' not in default:
@ -568,8 +569,10 @@ class account_invoice(osv.osv):
journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']})
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
if journal.sequence_id:
if journal.sequence_id and not inv.move_name:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
name = inv.move_name
if journal.centralisation:
raise osv.except_osv(_('UserError'),
_('Can not create invoice move on centralized journal'))
@ -585,8 +588,9 @@ class account_invoice(osv.osv):
for i in line:
i[2]['period_id'] = period_id
move_id = self.pool.get('account.move').create(cr, uid, move)
new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name
# make the invoice point to that move
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id})
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name})
self.pool.get('account.move').post(cr, uid, [move_id])
self._log_event(cr, uid, ids)
return True

View File

@ -39,7 +39,6 @@ class account_balance(report_sxw.rml_parse):
self.localcontext.update({
'time': time,
'lines': self.lines,
'moveline':self.moveline,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'get_fiscalyear':self.get_fiscalyear,
@ -134,27 +133,16 @@ class account_balance(report_sxw.rml_parse):
self.transform_both_into_date_array(form)
elif form['state'] == 'none' :
self.transform_none_into_date_array(form)
# ctx['date_from'] = form['date_from']
# ctx['date_to'] = form['date_to']
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
def cmp_code(x, y):
return cmp(x.code, y.code)
accounts.sort(cmp_code)
for account in accounts:
if account.id in done:
continue
done[account.id] = 1
res = {
# 'lid' :'',
# 'date':'',
# 'jname':'',
# 'ref':'',
# 'lname':'',
# 'debit1':'',
# 'credit1':'',
# 'balance1' :'',
'id' : account.id,
'type' : account.type,
'code': account.code,
@ -168,15 +156,12 @@ class account_balance(report_sxw.rml_parse):
}
self.sum_debit += account.debit
self.sum_credit += account.credit
# if not (res['credit'] or res['debit']) and not account.child_id:
# continue
if account.child_id:
def _check_rec(account):
if not account.child_id:
return bool(account.credit or account.debit)
for c in account.child_id:
if not _check_rec(c):
if not _check_rec(c) or _check_rec(c):
return True
return False
if not _check_rec(account) :
@ -191,57 +176,18 @@ class account_balance(report_sxw.rml_parse):
result_acc.append(res)
else:
result_acc.append(res)
res1 = self.moveline(form, account.id,res['level'])
if res1:
for r in res1:
result_acc.append(r)
# if account.code=='0':
# result_acc.pop(-1)
if account.child_id:
ids2 = [(x.code,x.id) for x in account.child_id]
ids2.sort()
result_acc += self.lines(form, [x[1] for x in ids2], done, level+1)
acc_id = [acc.id for acc in account.child_id]
lst_string = ''
lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\''
self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string))
a_id = self.cr.fetchall()
a_id.sort()
ids2 = [x[1] for x in a_id]
result_acc += self.lines(form, ids2, done, level+1)
return result_acc
def moveline(self,form,ids,level):
res={}
self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
self.cr.execute(
"SELECT l.id as lid,l.date,j.code as jname, l.ref, l.name as lname, l.debit as debit1, l.credit as credit1 " \
"FROM account_move_line l " \
"LEFT JOIN account_journal j " \
"ON (l.journal_id = j.id) " \
"WHERE l.account_id = '"+str(ids)+"' " \
"AND l.date >= '"+self.date_lst[0]+"' " \
"AND l.date <= '"+self.date_lst[-1]+"' " \
"ORDER BY l.id")
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum = r['debit1'] - r['credit1']
r['balance1'] = sum
r['type']= ''
r['id'] =''
r['code']= ''
r['name']=''
r['level']=level
r['debit']=''
r['credit']=''
r['balance']=''
r['leef']=''
if sum >= 0.0:
r['bal_type']=" Dr."
else:
r['bal_type']=" Cr."
return res or ''
def date_range(self,start,end):
start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d")))

View File

@ -345,8 +345,6 @@ class partner_balance(report_sxw.rml_parse):
tot_scredit = r['scredit']
tot_sdebit = r['sdebit']
tot_enlitige = (r['enlitige'] or 0.0)
#
##
new_header = {}
@ -362,7 +360,7 @@ class partner_balance(report_sxw.rml_parse):
new_header['type'] = 3
##
##
completearray.append(new_header)
##
#
@ -371,7 +369,7 @@ class partner_balance(report_sxw.rml_parse):
r['balance'] = float(r['sdebit']) - float(r['scredit'])
#
print "=========r",r
completearray.append(r)
if cleanarray[i]['account_id'] == cleanarray[i-1]['account_id']:
@ -403,6 +401,7 @@ class partner_balance(report_sxw.rml_parse):
#
r['balance'] = float(r['sdebit']) - float(r['scredit'])
#
completearray.append(r)
i = i + 1
@ -604,4 +603,4 @@ class partner_balance(report_sxw.rml_parse):
report_sxw.report_sxw('report.account.partner.balance', 'res.partner',
'account/report/partner_balance.rml',parser=partner_balance,
header=False)
header=False)

View File

@ -381,4 +381,4 @@
</tr>
</blockTable>
</story>
</document>
</document>

View File

@ -54,7 +54,7 @@ period_fields = {
'string':"Date/Period Filter",
'type':'selection',
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
'default': lambda *a:'bydate'
'default': lambda *a:'none'
},
'fiscalyear': {
'string':'Fiscal year',
@ -63,8 +63,8 @@ period_fields = {
'help':'Keep empty for all open fiscal year'
},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With Movements'),('bal_solde','With Balance != 0'),('bal_all','All')]},
'date_from': {'string':" Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]},
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
@ -89,6 +89,7 @@ class wizard_report(wizard.interface):
periods_obj=pooler.get_pool(cr.dbname).get('account.period')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
data['form']['fiscalyear'] = False
data['form']['display_account']='bal_all'
return data['form']

View File

@ -48,7 +48,7 @@ _aged_trial_fields = {
'type':'selection',
'selection':[('customer','Receivable'),('supplier','Payable'),('all','Receivable and Payable')],
'required':True,
'default': lambda *a: 'customer',
'default': lambda *a: 'all',
},
'direction_selection':{
'string':"Analysis Direction",

View File

@ -100,7 +100,7 @@ period_fields = {
'string':"Date/Period Filter",
'type':'selection',
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
'default': lambda *a:'bydate'
'default': lambda *a:'none'
},
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
@ -168,6 +168,7 @@ class wizard_report(wizard.interface):
data['form']['sortbydate'] = 'sort_date'
data['form']['display_account']='bal_all'
data['form']['landscape']=True
data['form']['fiscalyear'] = False
data['form']['amount_currency'] = True
return data['form']

View File

@ -54,10 +54,11 @@ period_fields = {
'string':"Date/Period Filter",
'type':'selection',
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
'default': lambda *a:'bydate'
'default': lambda *a:'none'
},
'fiscalyear': {
'string':'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'default': lambda *a:False,
'help': 'Keep empty for all open fiscal year'
},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty','states':{'none':[('readonly',True)],'bydate':[('readonly',True)]}},
@ -87,6 +88,7 @@ class wizard_report(wizard.interface):
data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
data['form']['company_id'] = company_id
data['form']['soldeinit'] = True
data['form']['fiscalyear'] = False
data['form']['result_selection'] = 'all'
return data['form']

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -27,16 +27,16 @@ import pooler
period_form = '''<?xml version="1.0"?>
<form string="Select Date-Period">
<field name="company_id"/>
<field name="company_id"/>
<field name="result_selection"/>
<newline/>
<field name="fiscalyear"/>
<label colspan="2" string="(Keep empty for all open fiscal years)" align="0.0"/>
<group colspan = "4" >
<field name="reconcil"/>
<field name="page_split"/>
</group>
<field name="reconcil"/>
<field name="page_split"/>
</group>
<newline/>
<separator string="Filters" colspan="4"/>
<field name="state" required="True"/>
@ -55,16 +55,17 @@ period_form = '''<?xml version="1.0"?>
</form>'''
period_fields = {
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'state':{
'string':"Date/Period Filter",
'type':'selection',
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
'default': lambda *a:'bydate'
'default': lambda *a:'none'
},
'fiscalyear': {
'string':'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'
'help': 'Keep empty for all open fiscal year',
'default': lambda *a:False,
},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty','states':{'none':[('readonly',True)],'bydate':[('readonly',True)]}},
'result_selection':{
@ -73,70 +74,70 @@ period_fields = {
'selection':[('customer','Receivable Accounts'),('supplier','Payable Accounts'),('all','Receivable and Payable Accounts')],
'required':True
},
'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
'reconcil':{'string':" Include Reconciled Entries",'type':'boolean'},
'page_split':{'string':"One Partner Per Page",'type':'boolean'},
'date1': {'string':' Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
'reconcil':{'string':" Include Reconciled Entries",'type':'boolean'},
'page_split':{'string':"One Partner Per Page",'type':'boolean'},
'date1': {'string':' Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['display_account']='bal_all'
data['form']['result_selection'] = 'all'
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
periods_obj=pooler.get_pool(cr.dbname).get('account.period')
data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
data['form']['page_split'] = False
data['form']['reconcil'] = False
data['form']['soldeinit'] = True
return data['form']
def _check_date(self, cr, uid, data, context):
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
else:
return 'report'
else:
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
def _check_state(self, cr, uid, data, context):
if data['form']['state'] == 'bydate' or data['form']['state'] == 'all' or data['form']['state'] == 'none':
data['form']['fiscalyear'] = False
else :
data['form']['fiscalyear'] = True
self._check_date(cr, uid, data, context)
return data['form']
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['display_account']='bal_all'
data['form']['result_selection'] = 'all'
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
periods_obj=pooler.get_pool(cr.dbname).get('account.period')
data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
data['form']['fiscalyear'] =False
data['form']['page_split'] = False
data['form']['reconcil'] = False
data['form']['soldeinit'] = True
return data['form']
def _check_date(self, cr, uid, data, context):
sql = """
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1'])
cr.execute(sql)
res = cr.dictfetchall()
if res:
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
else:
return 'report'
else:
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
def _check_state(self, cr, uid, data, context):
if data['form']['state'] == 'bydate' or data['form']['state'] == 'all':
data['form']['fiscalyear'] = False
else :
data['form']['fiscalyear'] = True
self._check_date(cr, uid, data, context)
return data['form']
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
},
'report': {
'actions': [_check_state],
'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
}
}
states = {
'init': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]}
},
'report': {
'actions': [_check_state],
'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
}
}
wizard_report('account.third_party_ledger.report')

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -102,8 +102,16 @@ class account_analytic_plan_instance(osv.osv):
'account4_ids':False, 'account5_ids':False, 'account6_ids':False})
return super(account_analytic_plan_instance, self).copy(cr, uid, id, default, context)
def _default_journal(self, cr, uid, context={}):
if context.has_key('journal_id') and context['journal_id']:
journal = self.pool.get('account.journal').browse(cr, uid, context['journal_id'])
if journal.analytic_journal_id:
return journal.analytic_journal_id.id
return False
_defaults = {
'plan_id': lambda *args: False,
'journal_id': _default_journal,
}
def name_get(self, cr, uid, ids, context={}):
res = []

View File

@ -12,7 +12,7 @@ import pooler
import sys
from mx.DateTime import *
import tools
from report.render import render
from report.render import render
from report.interface import report_int
import os
import pdf_ext
@ -49,7 +49,6 @@ class external_pdf(render):
class report_custom(report_int):
def create(self, cr, uid, ids, datas, context={}):
print datas, ids, uid
pool = pooler.get_pool(cr.dbname)
@ -70,7 +69,7 @@ class report_custom(report_int):
result['info_address'] = partner.address[0].street
result['info_address2'] = str(partner.address[0].zip) + ' ' + str(partner.address[0].city)
pdf_ext.fill_pdf('addons/l10n_lu/wizard/2008_DECL_F_M10.pdf', '/tmp/output.pdf', result)
pdf_ext.fill_pdf(tools.config['addons_path']+'/l10n_lu/wizard/2008_DECL_F_M10.pdf', '/tmp/output.pdf', result)
self.obj = external_pdf(file('/tmp/output.pdf').read())
self.obj.render()
return (self.obj.pdf, 'pdf')

View File

@ -410,6 +410,15 @@ class mrp_production(osv.osv):
'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.production') or '/',
}
_order = 'date_planned asc, priority desc';
def unlink(self, cr, uid, ids):
productions = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in productions:
if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Production Order(s) which are in %s State!' % s['state']))
return osv.osv.unlink(self, cr, uid, unlink_ids)
def location_id_change(self, cr, uid, ids, src, dest, context={}):
if dest:
@ -771,6 +780,17 @@ class mrp_procurement(osv.osv):
'close_move': lambda *a: 0,
'procure_method': lambda *a: 'make_to_order',
}
def unlink(self, cr, uid, ids):
procurements = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in procurements:
if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!' % s['state']))
return osv.osv.unlink(self, cr, uid, unlink_ids)
def onchange_product_id(self, cr, uid, ids, product_id, context={}):
if product_id:
w=self.pool.get('product.product').browse(cr,uid,product_id, context)

View File

@ -198,7 +198,17 @@ class purchase_order(osv.osv):
_name = "purchase.order"
_description = "Purchase order"
_order = "name desc"
def unlink(self, cr, uid, ids):
purchase_orders = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in purchase_orders:
if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Purchase Order(s) which are in %s State!' % s['state']))
return osv.osv.unlink(self, cr, uid, unlink_ids)
def button_dummy(self, cr, uid, ids, context={}):
return True

View File

@ -253,6 +253,16 @@ class sale_order(osv.osv):
_order = 'name desc'
# Form filling
def unlink(self, cr, uid, ids):
sale_orders = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in sale_orders:
if s['state'] in ['draft','canceled']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Sale Order(s) which are already confirmed !'))
return osv.osv.unlink(self, cr, uid, unlink_ids)
def onchange_shop_id(self, cr, uid, ids, shop_id):
v={}
if shop_id:

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -48,8 +48,10 @@ class sale_order(osv.osv):
message=False
partner = self.pool.get('res.partner').browse(cr, uid, part)
if partner.sale_warn:
title= "Message",
message=partner.sale_warn_msg
warning={
'title': "Message",
'message': partner.sale_warn_msg
}
result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)['value']
if result.get('warning',False):
@ -127,7 +129,7 @@ class product_product(osv.osv):
'sale_line_warn_msg' : fields.text('Message for Sale Order Line'),
'purchase_line_warn' : fields.boolean('Purchase Order Line'),
'purchase_line_warn_msg' : fields.text('Message for Purchase Order Line'),
}
}
product_product()
class sale_order_line(osv.osv):