bzr revid: fp@tinyerp.com-20080825222458-r9l3i3lvyss1vzep
This commit is contained in:
Fabien Pinckaers 2008-08-26 00:24:58 +02:00
commit 765fdf49df
14 changed files with 1230 additions and 50 deletions

View File

@ -139,7 +139,7 @@ class account_account(osv.osv):
context=None, count=False):
if context is None:
context = {}
pos = 0
pos = 0
while pos<len(args):
if args[pos][0]=='code' and args[pos][1] in ('like','ilike'):
args[pos][1]='=like'
@ -156,7 +156,7 @@ class account_account(osv.osv):
ids1 = super(account_account,self).search(cr, uid, [('type','in',ids3)])
ids1 += map(lambda x: x.id, jour.account_control_ids)
args[pos] = ('id','in',ids1)
pos+=1
pos+=1
return super(account_account,self).search(cr, uid, args, offset, limit,
order, context=context, count=count)
@ -346,7 +346,7 @@ class account_account(osv.osv):
res.append((record['id'],name ))
return res
def copy(self, cr, uid, id, default={}, context={}):
def copy(self, cr, uid, id, default={}, context={}):
account = self.browse(cr, uid, id, context=context)
new_child_ids = []
default['parent_id'] = False
@ -423,6 +423,7 @@ class account_journal(osv.osv):
'user_id': fields.many2one('res.users', 'User', help="The responsible user of this journal"),
'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'),
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want that new account moves pass through the \'draft\' state and goes direclty to the \'posted state\' without any manual validation.'),
}
_defaults = {
'active': lambda *a: 1,
@ -715,6 +716,7 @@ class account_move(osv.osv):
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()
c['novalidate'] = True
@ -1782,7 +1784,7 @@ class account_chart_template(osv.osv):
account_chart_template()
class wizard_account_chart_duplicate(osv.osv_memory):
"""
"""
Create a new account chart for a new company.
Wizards ask:
* an accuont chart (parent_id,=,False)
@ -1790,27 +1792,27 @@ class wizard_account_chart_duplicate(osv.osv_memory):
Then, the wizard:
* duplicates all accounts and assign to the right company
* duplicates all taxes, changing account assignations
* duplicate all accounting properties and assign correctly
* duplicate all accounting properties and assign correctly
"""
_name = 'wizard.account.chart.duplicate'
_columns = {
'name':fields.char('Name',size=64),
'account_id':fields.many2one('account.account','Account Chart',required=True,domain=[('parent_id','=',False)]),
'company_id':fields.many2one('res.company','Company',required=True),
}
'company_id':fields.many2one('res.company','Company',required=True),
}
def action_create(self, cr, uid,ids, context=None):
res=self.read(cr,uid,ids)[0]
if res.get('account_id',False) and res.get('company_id',False):
account_obj=self.pool.get('account.account')
account_obj=self.pool.get('account.account')
account_tax_obj=self.pool.get('account.tax')
property_obj=self.pool.get('ir.property')
# duplicate all accounts
account_obj.copy(cr,uid,res['account_id'],default={'company_id':res['company_id']})
# duplicate all taxes
# duplicate all taxes
tax_ids=account_tax_obj.search(cr,uid,[])
for tax in account_tax_obj.browse(cr,uid,tax_ids):
for tax in account_tax_obj.browse(cr,uid,tax_ids):
val={'company_id':res['company_id']}
if tax.account_collected_id:
new_invoice_account_ids=account_obj.search(cr,uid,[('name','=',tax.account_collected_id.name),('company_id','=',res['company_id'])])
@ -1818,7 +1820,7 @@ class wizard_account_chart_duplicate(osv.osv_memory):
if tax.account_paid_id:
new_refund_account_ids=account_obj.search(cr,uid,[('name','=',tax.account_paid_id.name),('company_id','=',res['company_id'])])
val['account_paid_id']=len(new_refund_account_ids) and new_refund_account_ids[0] or False
account_tax_obj.copy(cr,uid,tax.id,default=val)
account_tax_obj.copy(cr,uid,tax.id,default=val)
# duplicate all accouting properties
property_ids=property_obj.search(cr,uid,[('value','=like','account.account,%')])
for property in property_obj.browse(cr,uid,property_ids):
@ -1830,7 +1832,7 @@ class wizard_account_chart_duplicate(osv.osv_memory):
'value':'account.account,'+str(new_account_ids[0]),
'company_id':res['company_id']
})
return {'type':'ir.actions.act_window_close'}
wizard_account_chart_duplicate()

View File

@ -138,7 +138,7 @@ class account_bank_statement(osv.osv):
'currency': fields.function(_currency, method=True, string='Currency',
type='many2one', relation='res.currency'),
}
_defaults = {
'name': lambda self, cr, uid, context=None: \
self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement'),
@ -289,6 +289,8 @@ class account_bank_statement(osv.osv):
except:
raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount))
if st.journal_id.entry_posted:
account_move_obj.write(cr, uid, [move_id], {'state':'posted'})
done.append(st.id)
self.write(cr, uid, done, {'state':'confirm'}, context=context)
return True

View File

@ -404,7 +404,11 @@ class account_move_line(osv.osv):
account_id = line['account_id']['id']
partner_id = (line['partner_id'] and line['partner_id']['id']) or False
writeoff = debit - credit
date = time.strftime('%Y-%m-%d')
# Ifdate_p in context => take this date
if context.has_key('date_p') and context['date_p']:
date=context['date_p']
else:
date = time.strftime('%Y-%m-%d')
cr.execute('SELECT account_id, reconcile_id \
FROM account_move_line \
@ -435,9 +439,15 @@ class account_move_line(osv.osv):
self_credit = 0.0
self_debit = -writeoff
# If comment exist in context, take it
if context['comment']:
libelle=context['comment']
else:
libelle='Write-Off'
writeoff_lines = [
(0, 0, {
'name':'Write-Off',
'name':libelle,
'debit':self_debit,
'credit':self_credit,
'account_id':account_id,
@ -447,7 +457,7 @@ class account_move_line(osv.osv):
'amount_currency': account.currency_id.id and -currency or 0.0
}),
(0, 0, {
'name':'Write-Off',
'name':libelle,
'debit':debit,
'credit':credit,
'account_id':writeoff_acc_id,
@ -735,7 +745,9 @@ class account_move_line(osv.osv):
}
self.create(cr, uid, data, context)
if check:
self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context)
tmp = self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context)
if journal.entry_posted and tmp:
self.pool.get('account.move').write(cr,uid, [vals['move_id']],{'state':'posted'})
return result
account_move_line()

View File

@ -256,6 +256,7 @@
<newline/>
<field name="centralisation"/>
<field name="update_posted"/>
<field name="entry_posted"/>
</page>
<page string="Entry Controls">
<separator colspan="4" string="Accounts Type Allowed (empty for no control)"/>

View File

@ -499,14 +499,18 @@ class account_invoice(osv.osv):
_('Can not create invoice move on centralized journal'))
move = {'name': name, 'line_id': line, 'journal_id': journal_id}
if inv.period_id:
move['period_id'] = inv.period_id.id
period_id=inv.period_id and inv.period_id.id or False
if not period_id:
period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice),('date_stop','>=',inv.date_invoice)])
if len(period_ids):
period_id=period_ids[0]
if period_id:
move['period_id'] = period_id
for i in line:
i[2]['period_id'] = inv.period_id.id
i[2]['period_id'] = period_id
move_id = self.pool.get('account.move').create(cr, uid, move)
# make the invoice point to that move
self.write(cr, uid, [inv.id], {'move_id': move_id})
self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id})
self.pool.get('account.move').post(cr, uid, [move_id])
self._log_event(cr, uid, ids)
return True
@ -681,20 +685,30 @@ class account_invoice(osv.osv):
invoice = self.browse(cr, uid, ids[0])
src_account_id = invoice.account_id.id
journal = self.pool.get('account.journal').browse(cr, uid, pay_journal_id)
if not name:
if journal.sequence_id:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.'))
if journal.sequence_id:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.'))
# Take the seq as name for move
if journal.sequence_id:
seq = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
else:
raise osv.except_osv('No piece number !', 'Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')
types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
direction = types[invoice.type]
#take the choosen date
if context.has_key('date_p') and context['date_p']:
date=context['date_p']
else:
date=time.strftime('%Y-%m-%d')
l1 = {
'name': name,
'debit': direction * pay_amount>0 and direction * pay_amount,
'credit': direction * pay_amount<0 and - direction * pay_amount,
'account_id': src_account_id,
'partner_id': invoice.partner_id.id,
'date': time.strftime('%Y-%m-%d'),
'date': date,
'ref':invoice.number,
}
l2 = {
'name':name,
@ -702,11 +716,12 @@ class account_invoice(osv.osv):
'credit': direction * pay_amount>0 and direction * pay_amount,
'account_id': pay_account_id,
'partner_id': invoice.partner_id.id,
'date': time.strftime('%Y-%m-%d'),
'date': date,
'ref':invoice.number,
}
lines = [(0, 0, l1), (0, 0, l2)]
move = {'name': name, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id}
move = {'name': seq, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id}
move_id = self.pool.get('account.move').create(cr, uid, move)
line_ids = []

View File

@ -68,6 +68,13 @@ def _pay_and_reconcile(self, cr, uid, data, context):
ctx = {'date':data['form']['date']}
amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
# Take the choosen date
if form.has_key('comment'):
context={'date_p':form['date'],'comment':form['comment']}
else:
context={'date_p':form['date'],'comment':False}
acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
if not acc_id:
raise wizard.except_wizard(_('Error !'), _('Your journal must have a default credit and debit account.'))
@ -80,7 +87,7 @@ def _wo_check(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
if invoice.company_id.currency_id.id<>journal.currency.id:
if invoice.company_id.currency_id.id<>journal.currency.id or journal.currency.id <> invoice.currency_id.id:
return 'addendum'
if pool.get('res.currency').is_zero(cr, uid, invoice.currency_id,
(data['form']['amount'] - invoice.amount_total)):
@ -92,11 +99,13 @@ _transaction_add_form = '''<?xml version="1.0"?>
<separator string="Write-Off Move" colspan="4"/>
<field name="writeoff_acc_id"/>
<field name="writeoff_journal_id"/>
<field name="comment"/>
</form>'''
_transaction_add_fields = {
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'comment': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
}
def _get_value_addendum(self, cr, uid, data, context={}):

View File

@ -62,6 +62,20 @@ view_form_charts = """<?xml version="1.0"?>
</group>
</form>"""
view_form_vatcheck = """<?xml version="1.0"?>
<form string="Setup">
<image name="gtk-dialog-info" colspan="2"/>
<group>
<separator string="Install 'base_vat_check' module" colspan="2"/>
<newline/>
<field name="vatcheck" align="0.0"/>
<newline/>
<label string="This module allow you to force the validation of the VAT number. This module is optional but highly recommanded." colspan="2" align="0.0"/>
<newline/>
<label string="If you don't install it now, you'll be able to install it through the Administration menu." colspan="2" align="0.0"/>
</group>
</form>"""
view_form_company = """<?xml version="1.0"?>
<form string="Setup">
<image name="gtk-dialog-info" colspan="2"/>
@ -97,6 +111,8 @@ view_form_update = """<?xml version="1.0"?>
<newline/>
<field name="charts" align="0.0" readonly="1"/>
<newline/>
<field name="vatcheck" align="0.0" readonly="1"/>
<newline/>
<field name="name" align="0.0" readonly="1"/>
</group>
</form>
@ -185,12 +201,16 @@ class wizard_base_setup(wizard.interface):
def _update(self, cr, uid, data, context):
pool=pooler.get_pool(cr.dbname)
form=data['form']
if 'profile' in data['form'] and data['form']['profile'] > 0:
module_obj=pool.get('ir.module.module')
module_obj.state_update(cr, uid, [data['form']['profile']], 'to install', ['uninstalled'], context)
if 'charts' in data['form'] and data['form']['charts'] > 0:
module_obj=pool.get('ir.module.module')
module_obj.state_update(cr, uid, [data['form']['charts']], 'to install', ['uninstalled'], context)
module_obj=pool.get('ir.module.module')
if 'profile' in form and form['profile'] > 0:
module_obj.state_update(cr, uid, [form['profile']], 'to install', ['uninstalled'], context)
if 'charts' in form and form['charts'] > 0:
module_obj.state_update(cr, uid, [form['charts']], 'to install', ['uninstalled'], context)
if 'vatcheck' in form and form['vatcheck']:
mid = module_obj.search(cr, uid, [('name', '=', 'base_vat_check')], context=context)
if mid:
module_obj.state_update(cr, uid, mid, 'to install', ['uninstalled'], context)
company_obj=pool.get('res.company')
partner_obj=pool.get('res.partner')
@ -271,7 +291,7 @@ class wizard_base_setup(wizard.interface):
def _previous(self, cr, uid, data, context):
if 'profile' not in data['form'] or data['form']['profile'] <= 0:
return 'init'
return 'charts'
return 'vatcheck'
def _config(self, cr, uid, data, context=None):
users_obj=pooler.get_pool(cr.dbname).get('res.users')
@ -307,6 +327,11 @@ class wizard_base_setup(wizard.interface):
'default': -1,
'required': True,
},
'vatcheck':{
'string': "Install 'base_vat_check' module",
'type': 'boolean',
'default': False,
},
'name':{
'string': 'Company Name',
'type': 'char',
@ -402,6 +427,15 @@ IBAN: BE74 1262 0121 6907 - SWIFT: CPDF BE71 - VAT: BE0477.472.701""",
'result': {'type': 'form', 'arch': view_form_charts, 'fields': fields,
'state':[
('init', 'Previous', 'gtk-go-back'),
('vatcheck', 'Next', 'gtk-go-forward', True)
]
}
},
'vatcheck':{
'actions':[],
'result': {'type': 'form', 'arch': view_form_vatcheck, 'fields': fields,
'state': [
('charts', 'Previous', 'gtk-go-back'),
('company', 'Next', 'gtk-go-forward', True)
]
}
@ -424,7 +458,7 @@ IBAN: BE74 1262 0121 6907 - SWIFT: CPDF BE71 - VAT: BE0477.472.701""",
'result': {'type': 'form', 'arch': view_form_update, 'fields': fields,
'state': [
('company', 'Previous', 'gtk-go-back'),
('finish', 'Install', 'gtk-ok', True)
('finish', 'Install', 'gtk-save', True)
]
}
},

View File

@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import partner
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,42 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
###############################################################################
{
"name": "VAT Check",
"description": "Add a check of the VAT Number. Idea and code from Tryton (c2bk)",
"version": "1.0",
"author": "Tiny",
"category": "Generic Modules/Base",
"depends": ["base", "base_vat"],
"update_xml": [],
"active": False,
"installable": True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
"version":"1.0",
"author":"Tiny",
"category":"Profile",
"depends":["account","report_analytic","board_account","account_followup"],
"depends":["account","report_analytic","board_account","account_followup",'invoice_payment_tab'],
"demo_xml":[],
"update_xml":[],
"active":False,

View File

@ -239,6 +239,7 @@ class sale_order(osv.osv):
'amount_tax': fields.function(_amount_tax, method=True, string='Taxes'),
'amount_total': fields.function(_amount_total, method=True, string='Total'),
'invoice_quantity': fields.selection([('order','Ordered Quantities'),('procurement','Shipped Quantities')], 'Invoice on', help="The sale order will automatically create the invoice proposition (draft invoice). Ordered and delivered quantities may not be the same. You have to choose if you invoice based on ordered or shipped quantities. If the product is a service, shipped quantities means hours spent on the associated tasks."),
'payment_term' : fields.many2one('account.payment.term', 'Payment Term'),
}
_defaults = {
'picking_policy': lambda *a: 'direct',
@ -281,10 +282,11 @@ class sale_order(osv.osv):
def onchange_partner_id(self, cr, uid, ids, part):
if not part:
return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False}}
return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False, 'payment_term' : False}}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery','invoice','contact'])
pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist.id
return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist}}
payment_term = self.pool.get('res.partner').browse(cr, uid, part).property_payment_term.id
return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist, 'payment_term' : payment_term}}
def button_dummy(self, cr, uid, ids, context={}):
return True
@ -298,8 +300,8 @@ class sale_order(osv.osv):
def _make_invoice(self, cr, uid, order, lines):
a = order.partner_id.property_account_receivable.id
if order.partner_id and order.partner_id.property_payment_term.id:
pay_term = order.partner_id.property_payment_term.id
if order.payment_term:
pay_term = order.payment_term.id
else:
pay_term = False
for preinv in order.invoice_ids:

View File

@ -167,6 +167,7 @@
<field name="order_policy"/>
<field groups="base.group_extended" name="origin"/>
<field groups="base.group_extended" name="invoice_quantity" attrs="{'readonly':[('order_policy','=','picking')]}"/>
<field name="payment_term"/>
<separator colspan="4" string="Notes"/>
<field colspan="4" name="note" nolabel="1"/>
</page>

View File

@ -606,15 +606,14 @@ class stock_picking(osv.osv):
for picking in self.browse(cursor, user, ids, context=context):
if picking.invoice_state != '2binvoiced':
continue
payment_term_id = False
partner = picking.address_id.partner_id
if type in ('out_invoice', 'out_refund'):
account_id = partner.property_account_receivable.id
payment_term_id= picking.sale_id.payment_term.id
else:
account_id = partner.property_account_payable.id
payment_term_id = False
if partner.property_payment_term:
payment_term_id = partner.property_payment_term.id
# payment_term_id = picking.purchase_id.payment_term.id
address_contact_id, address_invoice_id = \
self._get_address_invoice(cursor, user, picking).values()