replace tabs with 4 spaces
bzr revid: christophe@tinyerp.com-20080722151128-f5zy75tsn8pgtndd
This commit is contained in:
parent
2dd9723b8b
commit
d2ff95f665
|
@ -26,51 +26,51 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Accounting and financial management",
|
"name" : "Accounting and financial management",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"depends" : ["product", "base"],
|
"depends" : ["product", "base"],
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"description": """Financial and accounting module that covers:
|
"description": """Financial and accounting module that covers:
|
||||||
General accounting
|
General accounting
|
||||||
Cost / Analytic accounting
|
Cost / Analytic accounting
|
||||||
Third party accounting
|
Third party accounting
|
||||||
Taxes management
|
Taxes management
|
||||||
Budgets
|
Budgets
|
||||||
""",
|
""",
|
||||||
"website" : "http://tinyerp.com/module_account.html",
|
"website" : "http://tinyerp.com/module_account.html",
|
||||||
"category" : "Generic Modules/Accounting",
|
"category" : "Generic Modules/Accounting",
|
||||||
"init_xml" : [
|
"init_xml" : [
|
||||||
|
|
||||||
],
|
],
|
||||||
"demo_xml" : [
|
"demo_xml" : [
|
||||||
"account_demo.xml",
|
"account_demo.xml",
|
||||||
"project/project_demo.xml",
|
"project/project_demo.xml",
|
||||||
"project/analytic_account_demo.xml",
|
"project/analytic_account_demo.xml",
|
||||||
"account_unit_test.xml",
|
"account_unit_test.xml",
|
||||||
],
|
],
|
||||||
"update_xml" : [
|
"update_xml" : [
|
||||||
"account_wizard.xml",
|
"account_wizard.xml",
|
||||||
"account_view.xml",
|
"account_view.xml",
|
||||||
"account_end_fy.xml",
|
"account_end_fy.xml",
|
||||||
"account_invoice_view.xml",
|
"account_invoice_view.xml",
|
||||||
"account_report.xml",
|
"account_report.xml",
|
||||||
"partner_view.xml",
|
"partner_view.xml",
|
||||||
"data/account_invoice.xml",
|
"data/account_invoice.xml",
|
||||||
"data/account_data1.xml",
|
"data/account_data1.xml",
|
||||||
"data/account_minimal.xml",
|
"data/account_minimal.xml",
|
||||||
"data/account_data2.xml",
|
"data/account_data2.xml",
|
||||||
"account_invoice_workflow.xml",
|
"account_invoice_workflow.xml",
|
||||||
"project/project_view.xml",
|
"project/project_view.xml",
|
||||||
"project/project_report.xml",
|
"project/project_report.xml",
|
||||||
"product_data.xml",
|
"product_data.xml",
|
||||||
"product_view.xml",
|
"product_view.xml",
|
||||||
"account_security.xml",
|
"account_security.xml",
|
||||||
"project/project_security.xml",
|
"project/project_security.xml",
|
||||||
"account_assert_test.xml",
|
"account_assert_test.xml",
|
||||||
],
|
],
|
||||||
"translations" : {
|
"translations" : {
|
||||||
"fr": "i18n/french_fr.csv"
|
"fr": "i18n/french_fr.csv"
|
||||||
},
|
},
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,97 +35,97 @@ from osv import osv
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
|
|
||||||
class account_analytic_line(osv.osv):
|
class account_analytic_line(osv.osv):
|
||||||
_name = 'account.analytic.line'
|
_name = 'account.analytic.line'
|
||||||
_description = 'Analytic lines'
|
_description = 'Analytic lines'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name' : fields.char('Description', size=256, required=True),
|
'name' : fields.char('Description', size=256, required=True),
|
||||||
'date' : fields.date('Date', required=True),
|
'date' : fields.date('Date', required=True),
|
||||||
'amount' : fields.float('Amount', required=True),
|
'amount' : fields.float('Amount', required=True),
|
||||||
'unit_amount' : fields.float('Quantity'),
|
'unit_amount' : fields.float('Quantity'),
|
||||||
'product_uom_id' : fields.many2one('product.uom', 'UoM'),
|
'product_uom_id' : fields.many2one('product.uom', 'UoM'),
|
||||||
'product_id' : fields.many2one('product.product', 'Product'),
|
'product_id' : fields.many2one('product.product', 'Product'),
|
||||||
'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
|
'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
|
||||||
'general_account_id' : fields.many2one('account.account', 'General account', required=True, ondelete='cascade'),
|
'general_account_id' : fields.many2one('account.account', 'General account', required=True, ondelete='cascade'),
|
||||||
'move_id' : fields.many2one('account.move.line', 'General entry', ondelete='cascade', select=True),
|
'move_id' : fields.many2one('account.move.line', 'General entry', ondelete='cascade', select=True),
|
||||||
'journal_id' : fields.many2one('account.analytic.journal', 'Analytic journal', required=True, ondelete='cascade', select=True),
|
'journal_id' : fields.many2one('account.analytic.journal', 'Analytic journal', required=True, ondelete='cascade', select=True),
|
||||||
'code' : fields.char('Code', size=8),
|
'code' : fields.char('Code', size=8),
|
||||||
'user_id' : fields.many2one('res.users', 'User',),
|
'user_id' : fields.many2one('res.users', 'User',),
|
||||||
'ref': fields.char('Ref.', size=32),
|
'ref': fields.char('Ref.', size=32),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||||
}
|
}
|
||||||
_order = 'date'
|
_order = 'date'
|
||||||
def _check_company(self, cr, uid, ids):
|
def _check_company(self, cr, uid, ids):
|
||||||
lines = self.browse(cr, uid, ids)
|
lines = self.browse(cr, uid, ids)
|
||||||
for l in lines:
|
for l in lines:
|
||||||
if l.move_id and not l.account_id.company_id.id == l.move_id.account_id.company_id.id:
|
if l.move_id and not l.account_id.company_id.id == l.move_id.account_id.company_id.id:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_company, 'You can not create analytic line that is not in the same company than the account line', ['account_id'])
|
(_check_company, 'You can not create analytic line that is not in the same company than the account line', ['account_id'])
|
||||||
]
|
]
|
||||||
|
|
||||||
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,
|
def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,
|
||||||
unit=False, context=None):
|
unit=False, context=None):
|
||||||
uom_obj = self.pool.get('product.uom')
|
uom_obj = self.pool.get('product.uom')
|
||||||
product_obj = self.pool.get('product.product')
|
product_obj = self.pool.get('product.product')
|
||||||
if unit_amount and prod_id:
|
if unit_amount and prod_id:
|
||||||
prod = product_obj.browse(cr, uid, prod_id)
|
prod = product_obj.browse(cr, uid, prod_id)
|
||||||
a = prod.product_tmpl_id.property_account_expense.id
|
a = prod.product_tmpl_id.property_account_expense.id
|
||||||
if not a:
|
if not a:
|
||||||
a = prod.categ_id.property_account_expense_categ.id
|
a = prod.categ_id.property_account_expense_categ.id
|
||||||
if not a:
|
if not a:
|
||||||
raise osv.except_osv(_('Error !'),
|
raise osv.except_osv(_('Error !'),
|
||||||
_('There is no expense account define ' \
|
_('There is no expense account define ' \
|
||||||
'for this product: "%s" (id:%d)') % \
|
'for this product: "%s" (id:%d)') % \
|
||||||
(prod.name, prod.id,))
|
(prod.name, prod.id,))
|
||||||
amount = unit_amount * uom_obj._compute_price(cr, uid,
|
amount = unit_amount * uom_obj._compute_price(cr, uid,
|
||||||
prod.uom_id.id, prod.standard_price, unit)
|
prod.uom_id.id, prod.standard_price, unit)
|
||||||
return {'value': {
|
return {'value': {
|
||||||
'amount': - round(amount, 2),
|
'amount': - round(amount, 2),
|
||||||
'general_account_id': a,
|
'general_account_id': a,
|
||||||
}}
|
}}
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
account_analytic_line()
|
account_analytic_line()
|
||||||
|
|
||||||
|
|
||||||
class timesheet_invoice(osv.osv):
|
class timesheet_invoice(osv.osv):
|
||||||
_name = "report.hr.timesheet.invoice.journal"
|
_name = "report.hr.timesheet.invoice.journal"
|
||||||
_description = "Analytic account costs and revenues"
|
_description = "Analytic account costs and revenues"
|
||||||
_auto = False
|
_auto = False
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.date('Month', readonly=True),
|
'name': fields.date('Month', readonly=True),
|
||||||
'account_id':fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, select=True),
|
'account_id':fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, select=True),
|
||||||
'journal_id': fields.many2one('account.analytic.journal', 'Journal', readonly=True),
|
'journal_id': fields.many2one('account.analytic.journal', 'Journal', readonly=True),
|
||||||
'quantity': fields.float('Quantities', readonly=True),
|
'quantity': fields.float('Quantities', readonly=True),
|
||||||
'cost': fields.float('Credit', readonly=True),
|
'cost': fields.float('Credit', readonly=True),
|
||||||
'revenue': fields.float('Debit', readonly=True)
|
'revenue': fields.float('Debit', readonly=True)
|
||||||
}
|
}
|
||||||
_order = 'name desc, account_id'
|
_order = 'name desc, account_id'
|
||||||
def init(self, cr):
|
def init(self, cr):
|
||||||
cr.execute("""
|
cr.execute("""
|
||||||
create or replace view report_hr_timesheet_invoice_journal as (
|
create or replace view report_hr_timesheet_invoice_journal as (
|
||||||
select
|
select
|
||||||
min(l.id) as id,
|
min(l.id) as id,
|
||||||
date_trunc('month', l.date)::date as name,
|
date_trunc('month', l.date)::date as name,
|
||||||
sum(
|
sum(
|
||||||
CASE WHEN l.amount>0 THEN 0 ELSE l.amount
|
CASE WHEN l.amount>0 THEN 0 ELSE l.amount
|
||||||
END
|
END
|
||||||
) as cost,
|
) as cost,
|
||||||
sum(
|
sum(
|
||||||
CASE WHEN l.amount>0 THEN l.amount ELSE 0
|
CASE WHEN l.amount>0 THEN l.amount ELSE 0
|
||||||
END
|
END
|
||||||
) as revenue,
|
) as revenue,
|
||||||
sum(l.unit_amount* COALESCE(u.factor, 1)) as quantity,
|
sum(l.unit_amount* COALESCE(u.factor, 1)) as quantity,
|
||||||
journal_id,
|
journal_id,
|
||||||
account_id
|
account_id
|
||||||
from account_analytic_line l
|
from account_analytic_line l
|
||||||
LEFT OUTER join product_uom u on (u.id=l.product_uom_id)
|
LEFT OUTER join product_uom u on (u.id=l.product_uom_id)
|
||||||
group by
|
group by
|
||||||
date_trunc('month', l.date),
|
date_trunc('month', l.date),
|
||||||
journal_id,
|
journal_id,
|
||||||
account_id
|
account_id
|
||||||
)""")
|
)""")
|
||||||
timesheet_invoice()
|
timesheet_invoice()
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -32,94 +32,94 @@ from osv import fields, osv
|
||||||
import ir
|
import ir
|
||||||
|
|
||||||
class res_partner(osv.osv):
|
class res_partner(osv.osv):
|
||||||
_name = 'res.partner'
|
_name = 'res.partner'
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
_description = 'Partner'
|
_description = 'Partner'
|
||||||
def _credit_get(self, cr, uid, ids, name, arg, context):
|
def _credit_get(self, cr, uid, ids, name, arg, context):
|
||||||
res={}
|
res={}
|
||||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||||
for id in ids:
|
for id in ids:
|
||||||
cr.execute("select sum(debit-credit) from account_move_line as l where account_id in (select id from account_account where type = %s and active) and partner_id=%d and reconcile_id is null and "+query, ('receivable', id))
|
cr.execute("select sum(debit-credit) from account_move_line as l where account_id in (select id from account_account where type = %s and active) and partner_id=%d and reconcile_id is null and "+query, ('receivable', id))
|
||||||
res[id]=cr.fetchone()[0] or 0.0
|
res[id]=cr.fetchone()[0] or 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _debit_get(self, cr, uid, ids, name, arg, context):
|
def _debit_get(self, cr, uid, ids, name, arg, context):
|
||||||
res={}
|
res={}
|
||||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||||
for id in ids:
|
for id in ids:
|
||||||
cr.execute("select sum(debit-credit) from account_move_line as l where account_id in (select id from account_account where type = %s and active) and partner_id=%d and reconcile_id is null and "+query, ('payable', id))
|
cr.execute("select sum(debit-credit) from account_move_line as l where account_id in (select id from account_account where type = %s and active) and partner_id=%d and reconcile_id is null and "+query, ('payable', id))
|
||||||
res[id]=cr.fetchone()[0] or 0.0
|
res[id]=cr.fetchone()[0] or 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _credit_search(self, cr, uid, obj, name, args):
|
def _credit_search(self, cr, uid, obj, name, args):
|
||||||
if not len(args):
|
if not len(args):
|
||||||
return []
|
return []
|
||||||
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
|
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
|
||||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
||||||
cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('receivable',) )
|
cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('receivable',) )
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
if not len(res):
|
if not len(res):
|
||||||
return [('id','=','0')]
|
return [('id','=','0')]
|
||||||
return [('id','in',map(lambda x:x[0], res))]
|
return [('id','in',map(lambda x:x[0], res))]
|
||||||
|
|
||||||
def _debit_search(self, cr, uid, obj, name, args):
|
def _debit_search(self, cr, uid, obj, name, args):
|
||||||
if not len(args):
|
if not len(args):
|
||||||
return []
|
return []
|
||||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
query = self.pool.get('account.move.line')._query_get(cr, uid, context={})
|
||||||
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
|
where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args))
|
||||||
cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('payable',) )
|
cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('payable',) )
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
if not len(res):
|
if not len(res):
|
||||||
return [('id','=','0')]
|
return [('id','=','0')]
|
||||||
return [('id','in',map(lambda x:x[0], res))]
|
return [('id','in',map(lambda x:x[0], res))]
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'credit': fields.function(_credit_get, fnct_search=_credit_search, method=True, string='Total Receivable'),
|
'credit': fields.function(_credit_get, fnct_search=_credit_search, method=True, string='Total Receivable'),
|
||||||
'debit': fields.function(_debit_get, fnct_search=_debit_search, method=True, string='Total Payable'),
|
'debit': fields.function(_debit_get, fnct_search=_debit_search, method=True, string='Total Payable'),
|
||||||
'debit_limit': fields.float('Payable Limit'),
|
'debit_limit': fields.float('Payable Limit'),
|
||||||
'property_account_payable': fields.property(
|
'property_account_payable': fields.property(
|
||||||
'account.account',
|
'account.account',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.account',
|
relation='account.account',
|
||||||
string="Account Payable",
|
string="Account Payable",
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
domain="[('type', '=', 'payable')]",
|
domain="[('type', '=', 'payable')]",
|
||||||
help="This account will be used, instead of the default one, as the payable account for the current partner",
|
help="This account will be used, instead of the default one, as the payable account for the current partner",
|
||||||
required=True),
|
required=True),
|
||||||
'property_account_receivable': fields.property(
|
'property_account_receivable': fields.property(
|
||||||
'account.account',
|
'account.account',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.account',
|
relation='account.account',
|
||||||
string="Account Receivable",
|
string="Account Receivable",
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
domain="[('type', '=', 'receivable')]",
|
domain="[('type', '=', 'receivable')]",
|
||||||
help="This account will be used, instead of the default one, as the receivable account for the current partner",
|
help="This account will be used, instead of the default one, as the receivable account for the current partner",
|
||||||
required=True),
|
required=True),
|
||||||
'property_account_tax': fields.property(
|
'property_account_tax': fields.property(
|
||||||
'account.tax',
|
'account.tax',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.tax',
|
relation='account.tax',
|
||||||
string="Default Tax",
|
string="Default Tax",
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
help="This tax will be used, instead of the default one."),
|
help="This tax will be used, instead of the default one."),
|
||||||
'property_payment_term': fields.property(
|
'property_payment_term': fields.property(
|
||||||
'account.payment.term',
|
'account.payment.term',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.payment.term',
|
relation='account.payment.term',
|
||||||
string ='Payment Term',
|
string ='Payment Term',
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
help="This payment term will be used, instead of the default one, for the current partner"),
|
help="This payment term will be used, instead of the default one, for the current partner"),
|
||||||
'ref_companies': fields.one2many('res.company', 'partner_id',
|
'ref_companies': fields.one2many('res.company', 'partner_id',
|
||||||
'Companies that refers to partner'),
|
'Companies that refers to partner'),
|
||||||
}
|
}
|
||||||
res_partner()
|
res_partner()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,58 +33,58 @@ import netsvc
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
|
||||||
class product_category(osv.osv):
|
class product_category(osv.osv):
|
||||||
_inherit = "product.category"
|
_inherit = "product.category"
|
||||||
_columns = {
|
_columns = {
|
||||||
'property_account_income_categ': fields.property(
|
'property_account_income_categ': fields.property(
|
||||||
'account.account',
|
'account.account',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.account',
|
relation='account.account',
|
||||||
string="Income Account",
|
string="Income Account",
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
help="This account will be used, instead of the default one, to value incoming stock for the current product category"),
|
help="This account will be used, instead of the default one, to value incoming stock for the current product category"),
|
||||||
'property_account_expense_categ': fields.property(
|
'property_account_expense_categ': fields.property(
|
||||||
'account.account',
|
'account.account',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.account',
|
relation='account.account',
|
||||||
string="Expense Account",
|
string="Expense Account",
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
help="This account will be used, instead of the default one, to value outgoing stock for the current product category"),
|
help="This account will be used, instead of the default one, to value outgoing stock for the current product category"),
|
||||||
}
|
}
|
||||||
product_category()
|
product_category()
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# Products
|
# Products
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
class product_template(osv.osv):
|
class product_template(osv.osv):
|
||||||
_inherit = "product.template"
|
_inherit = "product.template"
|
||||||
_columns = {
|
_columns = {
|
||||||
'taxes_id': fields.many2many('account.tax', 'product_taxes_rel',
|
'taxes_id': fields.many2many('account.tax', 'product_taxes_rel',
|
||||||
'prod_id', 'tax_id', 'Customer Taxes',
|
'prod_id', 'tax_id', 'Customer Taxes',
|
||||||
domain=[('parent_id','=',False)]),
|
domain=[('parent_id','=',False)]),
|
||||||
'supplier_taxes_id': fields.many2many('account.tax',
|
'supplier_taxes_id': fields.many2many('account.tax',
|
||||||
'product_supplier_taxes_rel', 'prod_id', 'tax_id',
|
'product_supplier_taxes_rel', 'prod_id', 'tax_id',
|
||||||
'Supplier Taxes', domain=[('parent_id', '=', False)]),
|
'Supplier Taxes', domain=[('parent_id', '=', False)]),
|
||||||
'property_account_income': fields.property(
|
'property_account_income': fields.property(
|
||||||
'account.account',
|
'account.account',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.account',
|
relation='account.account',
|
||||||
string="Income Account",
|
string="Income Account",
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
help="This account will be used, instead of the default one, to value incoming stock for the current product"),
|
help="This account will be used, instead of the default one, to value incoming stock for the current product"),
|
||||||
'property_account_expense': fields.property(
|
'property_account_expense': fields.property(
|
||||||
'account.account',
|
'account.account',
|
||||||
type='many2one',
|
type='many2one',
|
||||||
relation='account.account',
|
relation='account.account',
|
||||||
string="Expense Account",
|
string="Expense Account",
|
||||||
method=True,
|
method=True,
|
||||||
view_load=True,
|
view_load=True,
|
||||||
group_name="Accounting Properties",
|
group_name="Accounting Properties",
|
||||||
help="This account will be used, instead of the default one, to value outgoing stock for the current product"),
|
help="This account will be used, instead of the default one, to value outgoing stock for the current product"),
|
||||||
}
|
}
|
||||||
product_template()
|
product_template()
|
||||||
|
|
|
@ -38,202 +38,202 @@ from osv import osv
|
||||||
#
|
#
|
||||||
|
|
||||||
class account_analytic_account(osv.osv):
|
class account_analytic_account(osv.osv):
|
||||||
_name = 'account.analytic.account'
|
_name = 'account.analytic.account'
|
||||||
_description = 'Analytic Accounts'
|
_description = 'Analytic Accounts'
|
||||||
|
|
||||||
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
|
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
acc_set = ",".join(map(str, ids))
|
acc_set = ",".join(map(str, ids))
|
||||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE l.amount<0 and a.id IN (%s) GROUP BY a.id" % acc_set)
|
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE l.amount<0 and a.id IN (%s) GROUP BY a.id" % acc_set)
|
||||||
r= dict(cr.fetchall())
|
r= dict(cr.fetchall())
|
||||||
for i in ids:
|
for i in ids:
|
||||||
r.setdefault(i,0.0)
|
r.setdefault(i,0.0)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
|
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
|
|
||||||
acc_set = ",".join(map(str, ids))
|
acc_set = ",".join(map(str, ids))
|
||||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % acc_set)
|
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % acc_set)
|
||||||
r= dict(cr.fetchall())
|
r= dict(cr.fetchall())
|
||||||
for i in ids:
|
for i in ids:
|
||||||
r.setdefault(i,0.0)
|
r.setdefault(i,0.0)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _balance_calc(self, cr, uid, ids, name, arg, context={}):
|
def _balance_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
||||||
acc_set = ",".join(map(str, ids2))
|
acc_set = ",".join(map(str, ids2))
|
||||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE a.id IN (%s) GROUP BY a.id" % acc_set)
|
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE a.id IN (%s) GROUP BY a.id" % acc_set)
|
||||||
res = {}
|
res = {}
|
||||||
for account_id, sum in cr.fetchall():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = sum
|
res[account_id] = sum
|
||||||
|
|
||||||
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set)
|
cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set)
|
||||||
|
|
||||||
currency= dict(cr.fetchall())
|
currency= dict(cr.fetchall())
|
||||||
|
|
||||||
res_currency= self.pool.get('res.currency')
|
res_currency= self.pool.get('res.currency')
|
||||||
for id in ids:
|
for id in ids:
|
||||||
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
||||||
if child <> id:
|
if child <> id:
|
||||||
res.setdefault(id, 0.0)
|
res.setdefault(id, 0.0)
|
||||||
if currency[child]<>currency[id] :
|
if currency[child]<>currency[id] :
|
||||||
res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context)
|
res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context)
|
||||||
else:
|
else:
|
||||||
res[id] += res.get(child, 0.0)
|
res[id] += res.get(child, 0.0)
|
||||||
|
|
||||||
cur_obj = res_currency.browse(cr,uid,currency.values(),context)
|
cur_obj = res_currency.browse(cr,uid,currency.values(),context)
|
||||||
cur_obj = dict([(o.id, o) for o in cur_obj])
|
cur_obj = dict([(o.id, o) for o in cur_obj])
|
||||||
for id in ids:
|
for id in ids:
|
||||||
res[id] = res_currency.round(cr,uid,cur_obj[currency[id]],res.get(id,0.0))
|
res[id] = res_currency.round(cr,uid,cur_obj[currency[id]],res.get(id,0.0))
|
||||||
|
|
||||||
return dict([(i, res[i]) for i in ids ])
|
return dict([(i, res[i]) for i in ids ])
|
||||||
|
|
||||||
def _quantity_calc(self, cr, uid, ids, name, arg, context={}):
|
def _quantity_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
#XXX must convert into one uom
|
#XXX must convert into one uom
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
||||||
acc_set = ",".join(map(str, ids2))
|
acc_set = ",".join(map(str, ids2))
|
||||||
cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
|
cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
|
||||||
FROM account_analytic_account a \
|
FROM account_analytic_account a \
|
||||||
LEFT JOIN account_analytic_line l ON (a.id = l.account_id) \
|
LEFT JOIN account_analytic_line l ON (a.id = l.account_id) \
|
||||||
WHERE a.id IN ('+acc_set+') GROUP BY a.id')
|
WHERE a.id IN ('+acc_set+') GROUP BY a.id')
|
||||||
res = {}
|
res = {}
|
||||||
for account_id, sum in cr.fetchall():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = sum
|
res[account_id] = sum
|
||||||
|
|
||||||
for id in ids:
|
for id in ids:
|
||||||
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
||||||
if child <> id:
|
if child <> id:
|
||||||
res.setdefault(id, 0.0)
|
res.setdefault(id, 0.0)
|
||||||
res[id] += res.get(child, 0.0)
|
res[id] += res.get(child, 0.0)
|
||||||
return dict([(i, res[i]) for i in ids])
|
return dict([(i, res[i]) for i in ids])
|
||||||
|
|
||||||
def name_get(self, cr, uid, ids, context={}):
|
def name_get(self, cr, uid, ids, context={}):
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return []
|
return []
|
||||||
reads = self.read(cr, uid, ids, ['name','parent_id'], context)
|
reads = self.read(cr, uid, ids, ['name','parent_id'], context)
|
||||||
res = []
|
res = []
|
||||||
for record in reads:
|
for record in reads:
|
||||||
name = record['name']
|
name = record['name']
|
||||||
if record['parent_id']:
|
if record['parent_id']:
|
||||||
name = record['parent_id'][1]+' / '+name
|
name = record['parent_id'][1]+' / '+name
|
||||||
res.append((record['id'], name))
|
res.append((record['id'], name))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
|
def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
|
||||||
res = self.name_get(cr, uid, ids)
|
res = self.name_get(cr, uid, ids)
|
||||||
return dict(res)
|
return dict(res)
|
||||||
|
|
||||||
def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
|
def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
|
||||||
result = {}
|
result = {}
|
||||||
for rec in self.browse(cr, uid, ids, context):
|
for rec in self.browse(cr, uid, ids, context):
|
||||||
result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.code) or False
|
result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.code) or False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name' : fields.char('Account name', size=64, required=True),
|
'name' : fields.char('Account name', size=64, required=True),
|
||||||
'complete_name': fields.function(_complete_name_calc, method=True, type='char', string='Account Name'),
|
'complete_name': fields.function(_complete_name_calc, method=True, type='char', string='Account Name'),
|
||||||
'code' : fields.char('Account code', size=24),
|
'code' : fields.char('Account code', size=24),
|
||||||
'active' : fields.boolean('Active'),
|
'active' : fields.boolean('Active'),
|
||||||
'type': fields.selection([('view','View'), ('normal','Normal')], 'Account type'),
|
'type': fields.selection([('view','View'), ('normal','Normal')], 'Account type'),
|
||||||
'description' : fields.text('Description'),
|
'description' : fields.text('Description'),
|
||||||
'parent_id': fields.many2one('account.analytic.account', 'Parent analytic account', select=2),
|
'parent_id': fields.many2one('account.analytic.account', 'Parent analytic account', select=2),
|
||||||
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Childs Accounts'),
|
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Childs Accounts'),
|
||||||
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic entries'),
|
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic entries'),
|
||||||
'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance'),
|
'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance'),
|
||||||
'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit'),
|
'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit'),
|
||||||
'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit'),
|
'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit'),
|
||||||
'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'),
|
'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'),
|
||||||
'quantity_max': fields.float('Maximal quantity'),
|
'quantity_max': fields.float('Maximal quantity'),
|
||||||
'partner_id' : fields.many2one('res.partner', 'Associated partner'),
|
'partner_id' : fields.many2one('res.partner', 'Associated partner'),
|
||||||
'contact_id' : fields.many2one('res.partner.address', 'Contact'),
|
'contact_id' : fields.many2one('res.partner.address', 'Contact'),
|
||||||
'user_id' : fields.many2one('res.users', 'Account Manager'),
|
'user_id' : fields.many2one('res.users', 'Account Manager'),
|
||||||
'date_start': fields.date('Date Start'),
|
'date_start': fields.date('Date Start'),
|
||||||
'date': fields.date('Date End'),
|
'date': fields.date('Date End'),
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||||
'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Currency'),
|
'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Currency'),
|
||||||
'state': fields.selection([('draft','Draft'), ('open','Open'), ('pending','Pending'), ('close','Close'),], 'State', required=True),
|
'state': fields.selection([('draft','Draft'), ('open','Open'), ('pending','Pending'), ('close','Close'),], 'State', required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _default_company(self, cr, uid, context={}):
|
def _default_company(self, cr, uid, context={}):
|
||||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||||
if user.company_id:
|
if user.company_id:
|
||||||
return user.company_id.id
|
return user.company_id.id
|
||||||
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'active' : lambda *a : True,
|
'active' : lambda *a : True,
|
||||||
'type' : lambda *a : 'normal',
|
'type' : lambda *a : 'normal',
|
||||||
'company_id': _default_company,
|
'company_id': _default_company,
|
||||||
'state' : lambda *a : 'draft',
|
'state' : lambda *a : 'draft',
|
||||||
'user_id' : lambda self,cr,uid,ctx : uid
|
'user_id' : lambda self,cr,uid,ctx : uid
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_recursion(self, cr, uid, ids, parent=None):
|
def check_recursion(self, cr, uid, ids, parent=None):
|
||||||
return super(account_analytic_account, self).check_recursion(cr, uid, ids, parent=parent)
|
return super(account_analytic_account, self).check_recursion(cr, uid, ids, parent=parent)
|
||||||
|
|
||||||
_order = 'parent_id desc,code'
|
_order = 'parent_id desc,code'
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(check_recursion, 'Error! You can not create recursive account.', ['parent_id'])
|
(check_recursion, 'Error! You can not create recursive account.', ['parent_id'])
|
||||||
]
|
]
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
parent_id = vals.get('parent_id', 0)
|
parent_id = vals.get('parent_id', 0)
|
||||||
if ('code' not in vals or not vals['code']) and not parent_id:
|
if ('code' not in vals or not vals['code']) and not parent_id:
|
||||||
vals['code'] = self.pool.get('ir.sequence').get(cr, uid, 'account.analytic.account')
|
vals['code'] = self.pool.get('ir.sequence').get(cr, uid, 'account.analytic.account')
|
||||||
return super(account_analytic_account, self).create(cr, uid, vals, context=context)
|
return super(account_analytic_account, self).create(cr, uid, vals, context=context)
|
||||||
|
|
||||||
def copy(self, cr, uid, id, default=None, context={}):
|
def copy(self, cr, uid, id, default=None, context={}):
|
||||||
if not default:
|
if not default:
|
||||||
default = {}
|
default = {}
|
||||||
default['code'] = False
|
default['code'] = False
|
||||||
return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)
|
return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)
|
||||||
|
|
||||||
|
|
||||||
def on_change_parent(self, cr, uid, id, parent_id):
|
def on_change_parent(self, cr, uid, id, parent_id):
|
||||||
if not parent_id:
|
if not parent_id:
|
||||||
return {}
|
return {}
|
||||||
parent = self.read(cr, uid, [parent_id], ['partner_id','code'])[0]
|
parent = self.read(cr, uid, [parent_id], ['partner_id','code'])[0]
|
||||||
childs = self.search(cr, uid, [('parent_id', '=', parent_id), ('active', 'in', [True, False])])
|
childs = self.search(cr, uid, [('parent_id', '=', parent_id), ('active', 'in', [True, False])])
|
||||||
numchild = len(childs)
|
numchild = len(childs)
|
||||||
if parent['partner_id']:
|
if parent['partner_id']:
|
||||||
partner = parent['partner_id'][0]
|
partner = parent['partner_id'][0]
|
||||||
else:
|
else:
|
||||||
partner = False
|
partner = False
|
||||||
res = {'value' : {'code' : '%s - %03d' % (parent['code'] or '', numchild + 1),}}
|
res = {'value' : {'code' : '%s - %03d' % (parent['code'] or '', numchild + 1),}}
|
||||||
if partner:
|
if partner:
|
||||||
res['value']['partner_id'] = partner
|
res['value']['partner_id'] = partner
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=80):
|
||||||
if not args:
|
if not args:
|
||||||
args=[]
|
args=[]
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context={}
|
||||||
account = self.search(cr, uid, [('code', '=', name)]+args, limit=limit, context=context)
|
account = self.search(cr, uid, [('code', '=', name)]+args, limit=limit, context=context)
|
||||||
if not account:
|
if not account:
|
||||||
account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context)
|
account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context)
|
||||||
newacc = account
|
newacc = account
|
||||||
while newacc:
|
while newacc:
|
||||||
newacc = self.search(cr, uid, [('parent_id', 'in', newacc)]+args, limit=limit, context=context)
|
newacc = self.search(cr, uid, [('parent_id', 'in', newacc)]+args, limit=limit, context=context)
|
||||||
account+=newacc
|
account+=newacc
|
||||||
return self.name_get(cr, uid, account, context=context)
|
return self.name_get(cr, uid, account, context=context)
|
||||||
|
|
||||||
account_analytic_account()
|
account_analytic_account()
|
||||||
|
|
||||||
|
|
||||||
class account_analytic_journal(osv.osv):
|
class account_analytic_journal(osv.osv):
|
||||||
_name = 'account.analytic.journal'
|
_name = 'account.analytic.journal'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name' : fields.char('Journal name', size=64, required=True),
|
'name' : fields.char('Journal name', size=64, required=True),
|
||||||
'code' : fields.char('Journal code', size=8),
|
'code' : fields.char('Journal code', size=8),
|
||||||
'active' : fields.boolean('Active'),
|
'active' : fields.boolean('Active'),
|
||||||
'type': fields.selection([('sale','Sale'), ('purchase','Purchase'), ('cash','Cash'), ('general','General'), ('situation','Situation')], 'Type', size=32, required=True, help="Gives the type of the analytic journal. When a document (eg: an invoice) needs to create analytic entries, Tiny ERP will look for a matching journal of the same type."),
|
'type': fields.selection([('sale','Sale'), ('purchase','Purchase'), ('cash','Cash'), ('general','General'), ('situation','Situation')], 'Type', size=32, required=True, help="Gives the type of the analytic journal. When a document (eg: an invoice) needs to create analytic entries, Tiny ERP will look for a matching journal of the same type."),
|
||||||
'line_ids' : fields.one2many('account.analytic.line', 'journal_id', 'Lines'),
|
'line_ids' : fields.one2many('account.analytic.line', 'journal_id', 'Lines'),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'active': lambda *a: True,
|
'active': lambda *a: True,
|
||||||
'type': lambda *a: 'general',
|
'type': lambda *a: 'general',
|
||||||
}
|
}
|
||||||
account_analytic_journal()
|
account_analytic_journal()
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,42 +242,42 @@ account_analytic_journal()
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
#class account_analytic_budget_post(osv.osv):
|
#class account_analytic_budget_post(osv.osv):
|
||||||
# _name = 'account.analytic.budget.post'
|
# _name = 'account.analytic.budget.post'
|
||||||
# _description = 'Budget item'
|
# _description = 'Budget item'
|
||||||
# _columns = {
|
# _columns = {
|
||||||
# 'code': fields.char('Code', size=64, required=True),
|
# 'code': fields.char('Code', size=64, required=True),
|
||||||
# 'name': fields.char('Name', size=256, required=True),
|
# 'name': fields.char('Name', size=256, required=True),
|
||||||
# 'sens': fields.selection( [('charge','Charge'), ('produit','Product')], 'Direction', required=True),
|
# 'sens': fields.selection( [('charge','Charge'), ('produit','Product')], 'Direction', required=True),
|
||||||
# 'dotation_ids': fields.one2many('account.analytic.budget.post.dotation', 'post_id', 'Expenses'),
|
# 'dotation_ids': fields.one2many('account.analytic.budget.post.dotation', 'post_id', 'Expenses'),
|
||||||
# 'account_ids': fields.many2many('account.analytic.account', 'account_analytic_budget_rel', 'budget_id', 'account_id', 'Accounts'),
|
# 'account_ids': fields.many2many('account.analytic.account', 'account_analytic_budget_rel', 'budget_id', 'account_id', 'Accounts'),
|
||||||
# }
|
# }
|
||||||
# _defaults = {
|
# _defaults = {
|
||||||
# 'sens': lambda *a: 'produit',
|
# 'sens': lambda *a: 'produit',
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# def spread(self, cr, uid, ids, fiscalyear_id=False, quantity=0.0, amount=0.0):
|
# def spread(self, cr, uid, ids, fiscalyear_id=False, quantity=0.0, amount=0.0):
|
||||||
#
|
#
|
||||||
# dobj = self.pool.get('account.analytic.budget.post.dotation')
|
# dobj = self.pool.get('account.analytic.budget.post.dotation')
|
||||||
# for o in self.browse(cr, uid, ids):
|
# for o in self.browse(cr, uid, ids):
|
||||||
# # delete dotations for this post
|
# # delete dotations for this post
|
||||||
# dobj.unlink(cr, uid, dobj.search(cr, uid, [('post_id','=',o.id)]))
|
# dobj.unlink(cr, uid, dobj.search(cr, uid, [('post_id','=',o.id)]))
|
||||||
#
|
#
|
||||||
# # create one dotation per period in the fiscal year, and spread the total amount/quantity over those dotations
|
# # create one dotation per period in the fiscal year, and spread the total amount/quantity over those dotations
|
||||||
# fy = self.pool.get('account.fiscalyear').browse(cr, uid, [fiscalyear_id])[0]
|
# fy = self.pool.get('account.fiscalyear').browse(cr, uid, [fiscalyear_id])[0]
|
||||||
# num = len(fy.period_ids)
|
# num = len(fy.period_ids)
|
||||||
# for p in fy.period_ids:
|
# for p in fy.period_ids:
|
||||||
# dobj.create(cr, uid, {'post_id': o.id, 'period_id': p.id, 'quantity': quantity/num, 'amount': amount/num})
|
# dobj.create(cr, uid, {'post_id': o.id, 'period_id': p.id, 'quantity': quantity/num, 'amount': amount/num})
|
||||||
# return True
|
# return True
|
||||||
#account_analytic_budget_post()
|
#account_analytic_budget_post()
|
||||||
#
|
#
|
||||||
#class account_analytic_budget_post_dotation(osv.osv):
|
#class account_analytic_budget_post_dotation(osv.osv):
|
||||||
# _name = 'account.analytic.budget.post.dotation'
|
# _name = 'account.analytic.budget.post.dotation'
|
||||||
# _description = "Budget item endowment"
|
# _description = "Budget item endowment"
|
||||||
# _columns = {
|
# _columns = {
|
||||||
# 'name': fields.char('Name', size=64),
|
# 'name': fields.char('Name', size=64),
|
||||||
# 'post_id': fields.many2one('account.analytic.budget.post', 'Item', select=True),
|
# 'post_id': fields.many2one('account.analytic.budget.post', 'Item', select=True),
|
||||||
# 'period_id': fields.many2one('account.period', 'Period'),
|
# 'period_id': fields.many2one('account.period', 'Period'),
|
||||||
# 'quantity': fields.float('Quantity', digits=(16,2)),
|
# 'quantity': fields.float('Quantity', digits=(16,2)),
|
||||||
# 'amount': fields.float('Amount', digits=(16,2)),
|
# 'amount': fields.float('Amount', digits=(16,2)),
|
||||||
# }
|
# }
|
||||||
#account_analytic_budget_post_dotation()
|
#account_analytic_budget_post_dotation()
|
||||||
|
|
|
@ -35,20 +35,20 @@ from report import report_sxw
|
||||||
# Use period and Journal for selection or resources
|
# Use period and Journal for selection or resources
|
||||||
#
|
#
|
||||||
class journal_print(report_sxw.rml_parse):
|
class journal_print(report_sxw.rml_parse):
|
||||||
def lines(self, journal_id, *args):
|
def lines(self, journal_id, *args):
|
||||||
self.cr.execute('select id from account_analytic_line where journal_id=%d order by date,id', (journal_id,))
|
self.cr.execute('select id from account_analytic_line where journal_id=%d order by date,id', (journal_id,))
|
||||||
ids = map(lambda x: x[0], self.cr.fetchall())
|
ids = map(lambda x: x[0], self.cr.fetchall())
|
||||||
res = self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids)
|
res = self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids)
|
||||||
return res
|
return res
|
||||||
def _sum_lines(self, journal_id):
|
def _sum_lines(self, journal_id):
|
||||||
self.cr.execute('select sum(amount) from account_analytic_line where journal_id=%d', (journal_id,))
|
self.cr.execute('select sum(amount) from account_analytic_line where journal_id=%d', (journal_id,))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(journal_print, self).__init__(cr, uid, name, context)
|
super(journal_print, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext = {
|
self.localcontext = {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'sum_lines': self._sum_lines,
|
'sum_lines': self._sum_lines,
|
||||||
}
|
}
|
||||||
report_sxw.report_sxw('report.account.analytic.journal.print', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=journal_print)
|
report_sxw.report_sxw('report.account.analytic.journal.print', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=journal_print)
|
||||||
|
|
||||||
|
|
|
@ -32,137 +32,137 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class account_analytic_balance(report_sxw.rml_parse):
|
class account_analytic_balance(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_analytic_balance, self).__init__(cr, uid, name, context)
|
super(account_analytic_balance, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines_g': self._lines_g,
|
'lines_g': self._lines_g,
|
||||||
'move_sum_debit': self._move_sum_debit,
|
'move_sum_debit': self._move_sum_debit,
|
||||||
'move_sum_credit': self._move_sum_credit,
|
'move_sum_credit': self._move_sum_credit,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit,
|
'sum_credit': self._sum_credit,
|
||||||
'sum_balance': self._sum_balance,
|
'sum_balance': self._sum_balance,
|
||||||
'sum_quantity': self._sum_quantity,
|
'sum_quantity': self._sum_quantity,
|
||||||
'move_sum_balance': self._move_sum_balance,
|
'move_sum_balance': self._move_sum_balance,
|
||||||
'move_sum_quantity': self._move_sum_quantity,
|
'move_sum_quantity': self._move_sum_quantity,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _lines_g(self, account_id, date1, date2):
|
def _lines_g(self, account_id, date1, date2):
|
||||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||||
ids = account_analytic_obj.search(self.cr, self.uid,
|
ids = account_analytic_obj.search(self.cr, self.uid,
|
||||||
[('parent_id', 'child_of', [account_id])])
|
[('parent_id', 'child_of', [account_id])])
|
||||||
self.cr.execute("SELECT aa.name AS name, aa.code AS code, \
|
self.cr.execute("SELECT aa.name AS name, aa.code AS code, \
|
||||||
sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \
|
sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \
|
||||||
FROM account_analytic_line AS aal, account_account AS aa \
|
FROM account_analytic_line AS aal, account_account AS aa \
|
||||||
WHERE (aal.general_account_id=aa.id) \
|
WHERE (aal.general_account_id=aa.id) \
|
||||||
AND (aal.account_id in (" + ','.join(map(str, ids)) + "))\
|
AND (aal.account_id in (" + ','.join(map(str, ids)) + "))\
|
||||||
AND (date>=%s) AND (date<=%s) AND aa.active \
|
AND (date>=%s) AND (date<=%s) AND aa.active \
|
||||||
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \
|
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \
|
||||||
ORDER BY aal.code", (date1, date2))
|
ORDER BY aal.code", (date1, date2))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
for r in res:
|
for r in res:
|
||||||
if r['balance'] > 0:
|
if r['balance'] > 0:
|
||||||
r['debit'] = r['balance']
|
r['debit'] = r['balance']
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
elif r['balance'] < 0:
|
elif r['balance'] < 0:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = -r['balance']
|
r['credit'] = -r['balance']
|
||||||
else:
|
else:
|
||||||
r['balance'] == 0
|
r['balance'] == 0
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def _move_sum_debit(self, account_id, date1, date2):
|
def _move_sum_debit(self, account_id, date1, date2):
|
||||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||||
ids = account_analytic_obj.search(self.cr, self.uid,
|
ids = account_analytic_obj.search(self.cr, self.uid,
|
||||||
[('parent_id', 'child_of', [account_id])])
|
[('parent_id', 'child_of', [account_id])])
|
||||||
self.cr.execute("SELECT sum(amount) \
|
self.cr.execute("SELECT sum(amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
||||||
AND date>=%s AND date<=%s AND amount>0",
|
AND date>=%s AND date<=%s AND amount>0",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _move_sum_credit(self, account_id, date1, date2):
|
def _move_sum_credit(self, account_id, date1, date2):
|
||||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||||
ids = account_analytic_obj.search(self.cr, self.uid,
|
ids = account_analytic_obj.search(self.cr, self.uid,
|
||||||
[('parent_id', 'child_of', [account_id])])
|
[('parent_id', 'child_of', [account_id])])
|
||||||
self.cr.execute("SELECT -sum(amount) \
|
self.cr.execute("SELECT -sum(amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
||||||
AND date>=%s AND date<=%s AND amount<0",
|
AND date>=%s AND date<=%s AND amount<0",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _move_sum_balance(self, account_id, date1, date2):
|
def _move_sum_balance(self, account_id, date1, date2):
|
||||||
debit = self._move_sum_debit(account_id, date1, date2)
|
debit = self._move_sum_debit(account_id, date1, date2)
|
||||||
credit = self._move_sum_credit(account_id, date1, date2)
|
credit = self._move_sum_credit(account_id, date1, date2)
|
||||||
return (debit-credit)
|
return (debit-credit)
|
||||||
|
|
||||||
def _move_sum_quantity(self, account_id, date1, date2):
|
def _move_sum_quantity(self, account_id, date1, date2):
|
||||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||||
ids = account_analytic_obj.search(self.cr, self.uid,
|
ids = account_analytic_obj.search(self.cr, self.uid,
|
||||||
[('parent_id', 'child_of', [account_id])])
|
[('parent_id', 'child_of', [account_id])])
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
|
||||||
AND date>=%s AND date<=%s",
|
AND date>=%s AND date<=%s",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
|
|
||||||
def _sum_debit(self, accounts, date1, date2):
|
def _sum_debit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
return 0.0
|
||||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||||
ids2 = account_analytic_obj.search(self.cr, self.uid,
|
ids2 = account_analytic_obj.search(self.cr, self.uid,
|
||||||
[('parent_id', 'child_of', ids)])
|
[('parent_id', 'child_of', ids)])
|
||||||
self.cr.execute("SELECT sum(amount) \
|
self.cr.execute("SELECT sum(amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
||||||
AND date>=%s AND date<=%s AND amount>0",
|
AND date>=%s AND date<=%s AND amount>0",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, accounts, date1, date2):
|
def _sum_credit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
return 0.0
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||||
ids2 = account_analytic_obj.search(self.cr, self.uid,
|
ids2 = account_analytic_obj.search(self.cr, self.uid,
|
||||||
[('parent_id', 'child_of', ids)])
|
[('parent_id', 'child_of', ids)])
|
||||||
self.cr.execute("SELECT -sum(amount) \
|
self.cr.execute("SELECT -sum(amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
||||||
AND date>=%s AND date<=%s AND amount<0",
|
AND date>=%s AND date<=%s AND amount<0",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_balance(self, accounts, date1, date2):
|
def _sum_balance(self, accounts, date1, date2):
|
||||||
debit = self._sum_debit(accounts, date1, date2) or 0.0
|
debit = self._sum_debit(accounts, date1, date2) or 0.0
|
||||||
credit = self._sum_credit(accounts, date1, date2) or 0.0
|
credit = self._sum_credit(accounts, date1, date2) or 0.0
|
||||||
return (debit-credit)
|
return (debit-credit)
|
||||||
|
|
||||||
def _sum_quantity(self, accounts, date1, date2):
|
def _sum_quantity(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
return 0.0
|
||||||
account_analytic_obj = self.pool.get('account.analytic.account')
|
account_analytic_obj = self.pool.get('account.analytic.account')
|
||||||
ids2 = account_analytic_obj.search(self.cr, self.uid,
|
ids2 = account_analytic_obj.search(self.cr, self.uid,
|
||||||
[('parent_id', 'child_of', ids)])
|
[('parent_id', 'child_of', ids)])
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
WHERE account_id IN ("+','.join(map(str, ids2))+") \
|
||||||
AND date>=%s AND date<=%s",
|
AND date>=%s AND date<=%s",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.analytic.account.balance',
|
report_sxw.report_sxw('report.account.analytic.account.balance',
|
||||||
'account.analytic.account', 'addons/account/project/report/analytic_balance.rml',
|
'account.analytic.account', 'addons/account/project/report/analytic_balance.rml',
|
||||||
parser=account_analytic_balance, header=False)
|
parser=account_analytic_balance, header=False)
|
||||||
|
|
||||||
|
|
|
@ -32,75 +32,75 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class account_analytic_analytic_check(report_sxw.rml_parse):
|
class account_analytic_analytic_check(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_analytic_analytic_check, self).__init__(cr, uid, name, context)
|
super(account_analytic_analytic_check, self).__init__(cr, uid, name, context)
|
||||||
self.sum_gen_deb = 0.0
|
self.sum_gen_deb = 0.0
|
||||||
self.sum_gen_cred = 0.0
|
self.sum_gen_cred = 0.0
|
||||||
self.sum_ana_deb = 0.0
|
self.sum_ana_deb = 0.0
|
||||||
self.sum_ana_cred = 0.0
|
self.sum_ana_cred = 0.0
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines_p': self._lines_p,
|
'lines_p': self._lines_p,
|
||||||
'general_debit': self._gen_deb,
|
'general_debit': self._gen_deb,
|
||||||
'general_credit': self._gen_cred,
|
'general_credit': self._gen_cred,
|
||||||
'analytic_debit': self._ana_deb,
|
'analytic_debit': self._ana_deb,
|
||||||
'analytic_credit': self._ana_cred,
|
'analytic_credit': self._ana_cred,
|
||||||
'delta_debit': self._delta_deb,
|
'delta_debit': self._delta_deb,
|
||||||
'delta_credit': self._delta_cred,
|
'delta_credit': self._delta_cred,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _lines_p(self, date1, date2):
|
def _lines_p(self, date1, date2):
|
||||||
res = []
|
res = []
|
||||||
acc_obj = self.pool.get('account.account')
|
acc_obj = self.pool.get('account.account')
|
||||||
for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code', 'sign']):
|
for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code', 'sign']):
|
||||||
self.cr.execute("SELECT sum(debit), sum(credit) \
|
self.cr.execute("SELECT sum(debit), sum(credit) \
|
||||||
FROM account_move_line \
|
FROM account_move_line \
|
||||||
WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %d", (date1, date2, a['id']))
|
WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %d", (date1, date2, a['id']))
|
||||||
(gd, gc) = self.cr.fetchone()
|
(gd, gc) = self.cr.fetchone()
|
||||||
gd = gd or 0.0
|
gd = gd or 0.0
|
||||||
gc = gc or 0.0
|
gc = gc or 0.0
|
||||||
|
|
||||||
self.cr.execute("SELECT abs(sum(amount)) AS balance \
|
self.cr.execute("SELECT abs(sum(amount)) AS balance \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE date>=%s AND date<=%s AND amount*%d>0 AND general_account_id = %d", (date1, date2, a['sign'], a['id']))
|
WHERE date>=%s AND date<=%s AND amount*%d>0 AND general_account_id = %d", (date1, date2, a['sign'], a['id']))
|
||||||
(ad,) = self.cr.fetchone()
|
(ad,) = self.cr.fetchone()
|
||||||
ad = ad or 0.0
|
ad = ad or 0.0
|
||||||
self.cr.execute("SELECT abs(sum(amount)) AS balance \
|
self.cr.execute("SELECT abs(sum(amount)) AS balance \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE date>=%s AND date<=%s AND amount*%d<0 AND general_account_id = %d", (date1, date2, a['sign'], a['id']))
|
WHERE date>=%s AND date<=%s AND amount*%d<0 AND general_account_id = %d", (date1, date2, a['sign'], a['id']))
|
||||||
(ac,) = self.cr.fetchone()
|
(ac,) = self.cr.fetchone()
|
||||||
ac = ac or 0.0
|
ac = ac or 0.0
|
||||||
|
|
||||||
res.append({'code': a['code'], 'name': a['name'],
|
res.append({'code': a['code'], 'name': a['name'],
|
||||||
'gen_debit': gd,
|
'gen_debit': gd,
|
||||||
'gen_credit': gc,
|
'gen_credit': gc,
|
||||||
'ana_debit': ad,
|
'ana_debit': ad,
|
||||||
'ana_credit': ac,
|
'ana_credit': ac,
|
||||||
'delta_debit': gd - ad,
|
'delta_debit': gd - ad,
|
||||||
'delta_credit': gc - ac,})
|
'delta_credit': gc - ac,})
|
||||||
self.sum_gen_deb += gd
|
self.sum_gen_deb += gd
|
||||||
self.sum_gen_cred += gc
|
self.sum_gen_cred += gc
|
||||||
self.sum_ana_deb += ad
|
self.sum_ana_deb += ad
|
||||||
self.sum_ana_cred += ac
|
self.sum_ana_cred += ac
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _gen_deb(self, date1, date2):
|
def _gen_deb(self, date1, date2):
|
||||||
return self.sum_gen_deb
|
return self.sum_gen_deb
|
||||||
|
|
||||||
def _gen_cred(self, date1, date2):
|
def _gen_cred(self, date1, date2):
|
||||||
return self.sum_gen_cred
|
return self.sum_gen_cred
|
||||||
|
|
||||||
def _ana_deb(self, date1, date2):
|
def _ana_deb(self, date1, date2):
|
||||||
return self.sum_ana_deb
|
return self.sum_ana_deb
|
||||||
|
|
||||||
def _ana_cred(self, date1, date2):
|
def _ana_cred(self, date1, date2):
|
||||||
return self.sum_ana_cred
|
return self.sum_ana_cred
|
||||||
|
|
||||||
def _delta_deb(self, date1, date2):
|
def _delta_deb(self, date1, date2):
|
||||||
return (self._gen_deb(date1,date2)-self._ana_deb(date1,date2))
|
return (self._gen_deb(date1,date2)-self._ana_deb(date1,date2))
|
||||||
|
|
||||||
def _delta_cred(self, date1, date2):
|
def _delta_cred(self, date1, date2):
|
||||||
return (self._gen_cred(date1,date2)-self._ana_cred(date1,date2))
|
return (self._gen_cred(date1,date2)-self._ana_cred(date1,date2))
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.analytic.account.analytic.check', 'account.analytic.account', 'addons/account/project/report/analytic_check.rml',parser=account_analytic_analytic_check, header=False)
|
report_sxw.report_sxw('report.account.analytic.account.analytic.check', 'account.analytic.account', 'addons/account/project/report/analytic_check.rml',parser=account_analytic_analytic_check, header=False)
|
||||||
|
|
||||||
|
|
|
@ -34,35 +34,35 @@ from report import report_sxw
|
||||||
# Use period and Journal for selection or resources
|
# Use period and Journal for selection or resources
|
||||||
#
|
#
|
||||||
class account_analytic_journal(report_sxw.rml_parse):
|
class account_analytic_journal(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_analytic_journal, self).__init__(cr, uid, name, context)
|
super(account_analytic_journal, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self._lines,
|
'lines': self._lines,
|
||||||
'lines_a': self._lines_a,
|
'lines_a': self._lines_a,
|
||||||
'sum_general': self._sum_general,
|
'sum_general': self._sum_general,
|
||||||
'sum_analytic': self._sum_analytic,
|
'sum_analytic': self._sum_analytic,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _lines(self, journal_id, date1, date2):
|
def _lines(self, journal_id, date1, date2):
|
||||||
self.cr.execute('SELECT DISTINCT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%d) AND (move_id is not null)', (date1, date2, journal_id,))
|
self.cr.execute('SELECT DISTINCT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%d) AND (move_id is not null)', (date1, date2, journal_id,))
|
||||||
ids = map(lambda x: x[0], self.cr.fetchall())
|
ids = map(lambda x: x[0], self.cr.fetchall())
|
||||||
return self.pool.get('account.move.line').browse(self.cr, self.uid, ids)
|
return self.pool.get('account.move.line').browse(self.cr, self.uid, ids)
|
||||||
|
|
||||||
def _lines_a(self, move_id, journal_id, date1, date2):
|
def _lines_a(self, move_id, journal_id, date1, date2):
|
||||||
ids = self.pool.get('account.analytic.line').search(self.cr, self.uid, [('move_id','=',move_id), ('journal_id','=',journal_id), ('date','>=',date1), ('date','<=',date2)])
|
ids = self.pool.get('account.analytic.line').search(self.cr, self.uid, [('move_id','=',move_id), ('journal_id','=',journal_id), ('date','>=',date1), ('date','<=',date2)])
|
||||||
if not ids:
|
if not ids:
|
||||||
return []
|
return []
|
||||||
return self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids)
|
return self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids)
|
||||||
|
|
||||||
def _sum_general(self, journal_id, date1, date2):
|
def _sum_general(self, journal_id, date1, date2):
|
||||||
self.cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE id IN (SELECT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%d) AND (move_id is not null))', (date1, date2, journal_id,))
|
self.cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE id IN (SELECT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%d) AND (move_id is not null))', (date1, date2, journal_id,))
|
||||||
return self.cr.fetchall()[0][0] or 0
|
return self.cr.fetchall()[0][0] or 0
|
||||||
|
|
||||||
def _sum_analytic(self, journal_id, date1, date2):
|
def _sum_analytic(self, journal_id, date1, date2):
|
||||||
self.cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE date>=%s AND date<=%s AND journal_id=%d", (date1, date2, journal_id))
|
self.cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE date>=%s AND date<=%s AND journal_id=%d", (date1, date2, journal_id))
|
||||||
res = self.cr.dictfetchone()
|
res = self.cr.dictfetchone()
|
||||||
return res['sum'] or 0
|
return res['sum'] or 0
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.analytic.journal', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=account_analytic_journal)
|
report_sxw.report_sxw('report.account.analytic.journal', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=account_analytic_journal)
|
||||||
|
|
||||||
|
|
|
@ -32,90 +32,90 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class account_analytic_cost_ledger(report_sxw.rml_parse):
|
class account_analytic_cost_ledger(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context)
|
super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines_g': self._lines_g,
|
'lines_g': self._lines_g,
|
||||||
'lines_a': self._lines_a,
|
'lines_a': self._lines_a,
|
||||||
'account_sum_debit': self._account_sum_debit,
|
'account_sum_debit': self._account_sum_debit,
|
||||||
'account_sum_credit': self._account_sum_credit,
|
'account_sum_credit': self._account_sum_credit,
|
||||||
'account_sum_balance': self._account_sum_balance,
|
'account_sum_balance': self._account_sum_balance,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit,
|
'sum_credit': self._sum_credit,
|
||||||
'sum_balance': self._sum_balance,
|
'sum_balance': self._sum_balance,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _lines_g(self, account_id, date1, date2):
|
def _lines_g(self, account_id, date1, date2):
|
||||||
self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id \
|
self.cr.execute("SELECT sum(aal.amount) AS balance, aa.code AS code, aa.name AS name, aa.id AS id \
|
||||||
FROM account_account AS aa, account_analytic_line AS aal \
|
FROM account_account AS aa, account_analytic_line AS aal \
|
||||||
WHERE (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \
|
WHERE (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) AND (aal.general_account_id=aa.id) AND aa.active \
|
||||||
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2))
|
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", (account_id, date1, date2))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
for r in res:
|
for r in res:
|
||||||
if r['balance'] > 0:
|
if r['balance'] > 0:
|
||||||
r['debit'] = r['balance']
|
r['debit'] = r['balance']
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
elif r['balance'] < 0:
|
elif r['balance'] < 0:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = -r['balance']
|
r['credit'] = -r['balance']
|
||||||
else:
|
else:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _lines_a(self, general_account_id, account_id, date1, date2):
|
def _lines_a(self, general_account_id, account_id, date1, date2):
|
||||||
self.cr.execute("SELECT aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj FROM account_analytic_line AS aal, account_analytic_journal AS aaj \
|
self.cr.execute("SELECT aal.name AS name, aal.code AS code, aal.amount AS balance, aal.date AS date, aaj.code AS cj FROM account_analytic_line AS aal, account_analytic_journal AS aaj \
|
||||||
WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) \
|
WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) AND (aal.date>=%s) AND (aal.date<=%s) \
|
||||||
AND (aal.journal_id=aaj.id) \
|
AND (aal.journal_id=aaj.id) \
|
||||||
ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2))
|
ORDER BY aal.date, aaj.code, aal.code", (general_account_id, account_id, date1, date2))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
for r in res:
|
for r in res:
|
||||||
if r['balance'] > 0:
|
if r['balance'] > 0:
|
||||||
r['debit'] = r['balance']
|
r['debit'] = r['balance']
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
elif r['balance'] < 0:
|
elif r['balance'] < 0:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = -r['balance']
|
r['credit'] = -r['balance']
|
||||||
else:
|
else:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _account_sum_debit(self, account_id, date1, date2):
|
def _account_sum_debit(self, account_id, date1, date2):
|
||||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2))
|
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount>0", (account_id, date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _account_sum_credit(self, account_id, date1, date2):
|
def _account_sum_credit(self, account_id, date1, date2):
|
||||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2))
|
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id=%d AND date>=%s AND date<=%s AND amount<0", (account_id, date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _account_sum_balance(self, account_id, date1, date2):
|
def _account_sum_balance(self, account_id, date1, date2):
|
||||||
debit = self._account_sum_debit(account_id, date1, date2)
|
debit = self._account_sum_debit(account_id, date1, date2)
|
||||||
credit = self._account_sum_credit(account_id, date1, date2)
|
credit = self._account_sum_credit(account_id, date1, date2)
|
||||||
return (debit-credit)
|
return (debit-credit)
|
||||||
|
|
||||||
def _sum_debit(self, accounts, date1, date2):
|
def _sum_debit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
|
self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, accounts, date1, date2):
|
def _sum_credit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
return 0.0
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
|
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_balance(self, accounts, date1, date2):
|
def _sum_balance(self, accounts, date1, date2):
|
||||||
debit = self._sum_debit(accounts, date1, date2) or 0.0
|
debit = self._sum_debit(accounts, date1, date2) or 0.0
|
||||||
credit = self._sum_credit(accounts, date1, date2) or 0.0
|
credit = self._sum_credit(accounts, date1, date2) or 0.0
|
||||||
return (debit-credit)
|
return (debit-credit)
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger, header=False)
|
report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger, header=False)
|
||||||
|
|
||||||
|
|
|
@ -32,89 +32,89 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class account_inverted_analytic_balance(report_sxw.rml_parse):
|
class account_inverted_analytic_balance(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_inverted_analytic_balance, self).__init__(cr, uid, name, context)
|
super(account_inverted_analytic_balance, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines_g': self._lines_g,
|
'lines_g': self._lines_g,
|
||||||
'lines_a': self._lines_a,
|
'lines_a': self._lines_a,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit,
|
'sum_credit': self._sum_credit,
|
||||||
'sum_balance': self._sum_balance,
|
'sum_balance': self._sum_balance,
|
||||||
'sum_quantity': self._sum_quantity,
|
'sum_quantity': self._sum_quantity,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _lines_g(self, accounts, date1, date2):
|
def _lines_g(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \
|
self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \
|
||||||
FROM account_analytic_line AS aal, account_account AS aa \
|
FROM account_analytic_line AS aal, account_account AS aa \
|
||||||
WHERE (aal.general_account_id=aa.id) AND (aal.account_id IN ("+','.join(map(str, ids))+")) AND (date>=%s) AND (date<=%s) AND aa.active \
|
WHERE (aal.general_account_id=aa.id) AND (aal.account_id IN ("+','.join(map(str, ids))+")) AND (date>=%s) AND (date<=%s) AND aa.active \
|
||||||
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (date1, date2))
|
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (date1, date2))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
for r in res:
|
for r in res:
|
||||||
if r['balance'] > 0:
|
if r['balance'] > 0:
|
||||||
r['debit'] = r['balance']
|
r['debit'] = r['balance']
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
elif r['balance'] < 0:
|
elif r['balance'] < 0:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = -r['balance']
|
r['credit'] = -r['balance']
|
||||||
else:
|
else:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _lines_a(self, accounts, general_account_id, date1, date2):
|
def _lines_a(self, accounts, general_account_id, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \
|
self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \
|
||||||
FROM account_analytic_line AS aal, account_analytic_account AS aaa \
|
FROM account_analytic_line AS aal, account_analytic_account AS aaa \
|
||||||
WHERE aal.account_id=aaa.id AND aal.account_id IN ("+','.join(map(str, ids))+") AND aal.general_account_id=%d AND aal.date>=%s AND aal.date<=%s \
|
WHERE aal.account_id=aaa.id AND aal.account_id IN ("+','.join(map(str, ids))+") AND aal.general_account_id=%d AND aal.date>=%s AND aal.date<=%s \
|
||||||
GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (general_account_id, date1, date2))
|
GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (general_account_id, date1, date2))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
aaa_obj = self.pool.get('account.analytic.account')
|
aaa_obj = self.pool.get('account.analytic.account')
|
||||||
res2 = aaa_obj.read(self.cr, self.uid, ids, ['complete_name'])
|
res2 = aaa_obj.read(self.cr, self.uid, ids, ['complete_name'])
|
||||||
complete_name = {}
|
complete_name = {}
|
||||||
for r in res2:
|
for r in res2:
|
||||||
complete_name[r['id']] = r['complete_name']
|
complete_name[r['id']] = r['complete_name']
|
||||||
for r in res:
|
for r in res:
|
||||||
r['complete_name'] = complete_name[r['account_id']]
|
r['complete_name'] = complete_name[r['account_id']]
|
||||||
if r['balance'] > 0:
|
if r['balance'] > 0:
|
||||||
r['debit'] = r['balance']
|
r['debit'] = r['balance']
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
elif r['balance'] < 0:
|
elif r['balance'] < 0:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = -r['balance']
|
r['credit'] = -r['balance']
|
||||||
else:
|
else:
|
||||||
r['debit'] = 0.0
|
r['debit'] = 0.0
|
||||||
r['credit'] = 0.0
|
r['credit'] = 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _sum_debit(self, accounts, date1, date2):
|
def _sum_debit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT sum(amount) \
|
self.cr.execute("SELECT sum(amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
|
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount>0", (date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, accounts, date1, date2):
|
def _sum_credit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT -sum(amount) \
|
self.cr.execute("SELECT -sum(amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
|
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s AND amount<0", (date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_balance(self, accounts, date1, date2):
|
def _sum_balance(self, accounts, date1, date2):
|
||||||
debit = self._sum_debit(accounts, date1, date2)
|
debit = self._sum_debit(accounts, date1, date2)
|
||||||
credit = self._sum_credit(accounts, date1, date2)
|
credit = self._sum_credit(accounts, date1, date2)
|
||||||
return (debit-credit)
|
return (debit-credit)
|
||||||
|
|
||||||
def _sum_quantity(self, accounts, date1, date2):
|
def _sum_quantity(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2))
|
WHERE account_id IN ("+','.join(map(str, ids))+") AND date>=%s AND date<=%s", (date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False)
|
report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False)
|
||||||
|
|
||||||
|
|
|
@ -32,109 +32,109 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_analytic_quantity_cost_ledger, self).__init__(cr, uid,
|
super(account_analytic_quantity_cost_ledger, self).__init__(cr, uid,
|
||||||
name, context)
|
name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines_g': self._lines_g,
|
'lines_g': self._lines_g,
|
||||||
'lines_a': self._lines_a,
|
'lines_a': self._lines_a,
|
||||||
'sum_quantity': self._sum_quantity,
|
'sum_quantity': self._sum_quantity,
|
||||||
'account_sum_quantity': self._account_sum_quantity,
|
'account_sum_quantity': self._account_sum_quantity,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _lines_g(self, account_id, date1, date2, journals):
|
def _lines_g(self, account_id, date1, date2, journals):
|
||||||
if not journals or not journals[0][2]:
|
if not journals or not journals[0][2]:
|
||||||
self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \
|
self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \
|
||||||
aa.code AS code, aa.name AS name, aa.id AS id \
|
aa.code AS code, aa.name AS name, aa.id AS id \
|
||||||
FROM account_account AS aa, account_analytic_line AS aal \
|
FROM account_account AS aa, account_analytic_line AS aal \
|
||||||
WHERE (aal.account_id=%d) AND (aal.date>=%s) \
|
WHERE (aal.account_id=%d) AND (aal.date>=%s) \
|
||||||
AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
|
AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
|
||||||
AND aa.active \
|
AND aa.active \
|
||||||
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code",
|
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code",
|
||||||
(account_id, date1, date2))
|
(account_id, date1, date2))
|
||||||
else:
|
else:
|
||||||
journal_ids = journals[0][2]
|
journal_ids = journals[0][2]
|
||||||
self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \
|
self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \
|
||||||
aa.code AS code, aa.name AS name, aa.id AS id \
|
aa.code AS code, aa.name AS name, aa.id AS id \
|
||||||
FROM account_account AS aa, account_analytic_line AS aal \
|
FROM account_account AS aa, account_analytic_line AS aal \
|
||||||
WHERE (aal.account_id=%d) AND (aal.date>=%s) \
|
WHERE (aal.account_id=%d) AND (aal.date>=%s) \
|
||||||
AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
|
AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
|
||||||
AND aa.active \
|
AND aa.active \
|
||||||
AND (aal.journal_id IN (" +
|
AND (aal.journal_id IN (" +
|
||||||
','.join(map(str, journal_ids)) + ")) \
|
','.join(map(str, journal_ids)) + ")) \
|
||||||
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code",
|
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code",
|
||||||
(account_id, date1, date2))
|
(account_id, date1, date2))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _lines_a(self, general_account_id, account_id, date1, date2, journals):
|
def _lines_a(self, general_account_id, account_id, date1, date2, journals):
|
||||||
if not journals or not journals[0][2]:
|
if not journals or not journals[0][2]:
|
||||||
self.cr.execute("SELECT aal.name AS name, aal.code AS code, \
|
self.cr.execute("SELECT aal.name AS name, aal.code AS code, \
|
||||||
aal.unit_amount AS quantity, aal.date AS date, \
|
aal.unit_amount AS quantity, aal.date AS date, \
|
||||||
aaj.code AS cj \
|
aaj.code AS cj \
|
||||||
FROM account_analytic_line AS aal, \
|
FROM account_analytic_line AS aal, \
|
||||||
account_analytic_journal AS aaj \
|
account_analytic_journal AS aaj \
|
||||||
WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) \
|
WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) \
|
||||||
AND (aal.date>=%s) AND (aal.date<=%s) \
|
AND (aal.date>=%s) AND (aal.date<=%s) \
|
||||||
AND (aal.journal_id=aaj.id) \
|
AND (aal.journal_id=aaj.id) \
|
||||||
ORDER BY aal.date, aaj.code, aal.code",
|
ORDER BY aal.date, aaj.code, aal.code",
|
||||||
(general_account_id, account_id, date1, date2))
|
(general_account_id, account_id, date1, date2))
|
||||||
else:
|
else:
|
||||||
journal_ids = journals[0][2]
|
journal_ids = journals[0][2]
|
||||||
self.cr.execute("SELECT aal.name AS name, aal.code AS code, \
|
self.cr.execute("SELECT aal.name AS name, aal.code AS code, \
|
||||||
aal.unit_amount AS quantity, aal.date AS date, \
|
aal.unit_amount AS quantity, aal.date AS date, \
|
||||||
aaj.code AS cj \
|
aaj.code AS cj \
|
||||||
FROM account_analytic_line AS aal, \
|
FROM account_analytic_line AS aal, \
|
||||||
account_analytic_journal AS aaj \
|
account_analytic_journal AS aaj \
|
||||||
WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) \
|
WHERE (aal.general_account_id=%d) AND (aal.account_id=%d) \
|
||||||
AND (aal.date>=%s) AND (aal.date<=%s) \
|
AND (aal.date>=%s) AND (aal.date<=%s) \
|
||||||
AND (aal.journal_id=aaj.id) AND (aaj.id IN (" +
|
AND (aal.journal_id=aaj.id) AND (aaj.id IN (" +
|
||||||
','.join(map(str, journal_ids)) + ")) \
|
','.join(map(str, journal_ids)) + ")) \
|
||||||
ORDER BY aal.date, aaj.code, aal.code",
|
ORDER BY aal.date, aaj.code, aal.code",
|
||||||
(general_account_id, account_id, date1, date2))
|
(general_account_id, account_id, date1, date2))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _account_sum_quantity(self, account_id, date1, date2, journals):
|
def _account_sum_quantity(self, account_id, date1, date2, journals):
|
||||||
if not journals or not journals[0][2]:
|
if not journals or not journals[0][2]:
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id=%d AND date>=%s AND date<=%s",
|
WHERE account_id=%d AND date>=%s AND date<=%s",
|
||||||
(account_id, date1, date2))
|
(account_id, date1, date2))
|
||||||
else:
|
else:
|
||||||
journal_ids = journals[0][2]
|
journal_ids = journals[0][2]
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id = %d AND date >= %s AND date <= %s \
|
WHERE account_id = %d AND date >= %s AND date <= %s \
|
||||||
AND journal_id IN (" +
|
AND journal_id IN (" +
|
||||||
','.join(map(str, journal_ids)) + ")",
|
','.join(map(str, journal_ids)) + ")",
|
||||||
(account_id, date1, date2))
|
(account_id, date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_quantity(self, accounts, date1, date2, journals):
|
def _sum_quantity(self, accounts, date1, date2, journals):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
return 0.0
|
||||||
if not journals or not journals[0][2]:
|
if not journals or not journals[0][2]:
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN (" +
|
WHERE account_id IN (" +
|
||||||
','.join(map(str, ids)) + ") AND date>=%s AND date<=%s",
|
','.join(map(str, ids)) + ") AND date>=%s AND date<=%s",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
else:
|
else:
|
||||||
journal_ids = journals[0][2]
|
journal_ids = journals[0][2]
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
FROM account_analytic_line \
|
||||||
WHERE account_id IN (" +
|
WHERE account_id IN (" +
|
||||||
','.join(map(str, ids)) + ") AND date >= %s AND date <= %s \
|
','.join(map(str, ids)) + ") AND date >= %s AND date <= %s \
|
||||||
AND journal_id IN (" +
|
AND journal_id IN (" +
|
||||||
','.join(map(str, journal_ids)) + ")",
|
','.join(map(str, journal_ids)) + ")",
|
||||||
(date1, date2))
|
(date1, date2))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger',
|
report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger',
|
||||||
'account.analytic.account',
|
'account.analytic.account',
|
||||||
'addons/account/project/report/quantity_cost_ledger.rml',
|
'addons/account/project/report/quantity_cost_ledger.rml',
|
||||||
parser=account_analytic_quantity_cost_ledger, header=False)
|
parser=account_analytic_quantity_cost_ledger, header=False)
|
||||||
|
|
||||||
|
|
|
@ -32,26 +32,26 @@ import wizard
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.analytic.account.analytic.check', 'state':'end'}
|
'result': {'type':'print', 'report':'account.analytic.account.analytic.check', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.analytic.account.analytic.check.report')
|
wizard_report('account.analytic.account.analytic.check.report')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,27 +32,27 @@ import wizard
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.analytic.account.balance', 'state':'end'}
|
'result': {'type':'print', 'report':'account.analytic.account.balance', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.analytic.account.balance.report')
|
wizard_report('account.analytic.account.balance.report')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,42 +32,42 @@ import wizard
|
||||||
|
|
||||||
_form = '''<?xml version="1.0"?>
|
_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<separator string="Cost Legder for period" colspan="4"/>
|
<separator string="Cost Legder for period" colspan="4"/>
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
<separator string="and Journals" colspan="4"/>
|
<separator string="and Journals" colspan="4"/>
|
||||||
<field name="journal" colspan="4"/>
|
<field name="journal" colspan="4"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_fields = {
|
_fields = {
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
'journal': {'string':'Journals','type':'many2many', 'relation':'account.analytic.journal'},
|
'journal': {'string':'Journals','type':'many2many', 'relation':'account.analytic.journal'},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': _form,
|
'arch': _form,
|
||||||
'fields': _fields,
|
'fields': _fields,
|
||||||
'state': [
|
'state': [
|
||||||
('end','Cancel'),
|
('end','Cancel'),
|
||||||
('report','Print')
|
('report','Print')
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'print',
|
'type': 'print',
|
||||||
'report': 'account.analytic.account.quantity_cost_ledger',
|
'report': 'account.analytic.account.quantity_cost_ledger',
|
||||||
'state': 'end'
|
'state': 'end'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard_report('account.analytic.account.quantity_cost_ledger.report')
|
wizard_report('account.analytic.account.quantity_cost_ledger.report')
|
||||||
|
|
|
@ -32,26 +32,26 @@ import wizard
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.analytic.account.cost_ledger', 'state':'end'}
|
'result': {'type':'print', 'report':'account.analytic.account.cost_ledger', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.analytic.account.cost_ledger.report')
|
wizard_report('account.analytic.account.cost_ledger.report')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,26 +32,26 @@ import wizard
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.analytic.account.inverted.balance', 'state':'end'}
|
'result': {'type':'print', 'report':'account.analytic.account.inverted.balance', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.analytic.account.inverted.balance.report')
|
wizard_report('account.analytic.account.inverted.balance.report')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,25 +32,25 @@ import wizard
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Analytic Journal Report">
|
<form string="Analytic Journal Report">
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.analytic.journal', 'state':'end'}
|
'result': {'type':'print', 'report':'account.analytic.journal', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.analytic.account.journal.report')
|
wizard_report('account.analytic.account.journal.report')
|
||||||
|
|
||||||
|
|
|
@ -31,93 +31,93 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class account_balance(report_sxw.rml_parse):
|
class account_balance(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_balance, self).__init__(cr, uid, name, context)
|
super(account_balance, self).__init__(cr, uid, name, context)
|
||||||
self.sum_debit = 0.0
|
self.sum_debit = 0.0
|
||||||
self.sum_credit = 0.0
|
self.sum_credit = 0.0
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit,
|
'sum_credit': self._sum_credit,
|
||||||
'get_fiscalyear':self.get_fiscalyear,
|
'get_fiscalyear':self.get_fiscalyear,
|
||||||
'get_periods':self.get_periods,
|
'get_periods':self.get_periods,
|
||||||
})
|
})
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
def get_fiscalyear(self, form):
|
def get_fiscalyear(self, form):
|
||||||
fisc_id = form['fiscalyear']
|
fisc_id = form['fiscalyear']
|
||||||
if not(fisc_id):
|
if not(fisc_id):
|
||||||
return ''
|
return ''
|
||||||
self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id)))
|
self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id)))
|
||||||
res=self.cr.fetchone()
|
res=self.cr.fetchone()
|
||||||
return res and res[0] or ''
|
return res and res[0] or ''
|
||||||
|
|
||||||
def get_periods(self, form):
|
def get_periods(self, form):
|
||||||
period_ids = ",".join([str(x) for x in form['periods'][0][2] if x])
|
period_ids = ",".join([str(x) for x in form['periods'][0][2] if x])
|
||||||
self.cr.execute("select name from account_period where id in (%s)" % (period_ids))
|
self.cr.execute("select name from account_period where id in (%s)" % (period_ids))
|
||||||
res=self.cr.fetchall()
|
res=self.cr.fetchall()
|
||||||
result=''
|
result=''
|
||||||
for r in res:
|
for r in res:
|
||||||
result+=r[0]+","
|
result+=r[0]+","
|
||||||
return str(result and result[:-1]) or ''
|
return str(result and result[:-1]) or ''
|
||||||
|
|
||||||
def lines(self, form, ids={}, done=None, level=1):
|
def lines(self, form, ids={}, done=None, level=1):
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = self.ids
|
ids = self.ids
|
||||||
if not ids:
|
if not ids:
|
||||||
return []
|
return []
|
||||||
if not done:
|
if not done:
|
||||||
done={}
|
done={}
|
||||||
result = []
|
result = []
|
||||||
ctx = self.context.copy()
|
ctx = self.context.copy()
|
||||||
ctx['fiscalyear'] = form['fiscalyear']
|
ctx['fiscalyear'] = form['fiscalyear']
|
||||||
ctx['periods'] = form['periods'][0][2]
|
ctx['periods'] = form['periods'][0][2]
|
||||||
ctx['target_move'] = form['target_move']
|
ctx['target_move'] = form['target_move']
|
||||||
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
|
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
|
||||||
def cmp_code(x, y):
|
def cmp_code(x, y):
|
||||||
return cmp(x.code, y.code)
|
return cmp(x.code, y.code)
|
||||||
accounts.sort(cmp_code)
|
accounts.sort(cmp_code)
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
if account.id in done:
|
if account.id in done:
|
||||||
continue
|
continue
|
||||||
done[account.id] = 1
|
done[account.id] = 1
|
||||||
res = {
|
res = {
|
||||||
'code': account.code,
|
'code': account.code,
|
||||||
'name': account.name,
|
'name': account.name,
|
||||||
'level': level,
|
'level': level,
|
||||||
'debit': account.debit,
|
'debit': account.debit,
|
||||||
'credit': account.credit,
|
'credit': account.credit,
|
||||||
'balance': account.balance,
|
'balance': account.balance,
|
||||||
'leef': not bool(account.child_id)
|
'leef': not bool(account.child_id)
|
||||||
}
|
}
|
||||||
self.sum_debit += account.debit
|
self.sum_debit += account.debit
|
||||||
self.sum_credit += account.credit
|
self.sum_credit += account.credit
|
||||||
if not (res['credit'] or res['debit']) and not account.child_id:
|
if not (res['credit'] or res['debit']) and not account.child_id:
|
||||||
continue
|
continue
|
||||||
if account.child_id:
|
if account.child_id:
|
||||||
def _check_rec(account):
|
def _check_rec(account):
|
||||||
if not account.child_id:
|
if not account.child_id:
|
||||||
return bool(account.credit or account.debit)
|
return bool(account.credit or account.debit)
|
||||||
for c in account.child_id:
|
for c in account.child_id:
|
||||||
if _check_rec(c):
|
if _check_rec(c):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
if not _check_rec(account):
|
if not _check_rec(account):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
result.append(res)
|
result.append(res)
|
||||||
if account.child_id:
|
if account.child_id:
|
||||||
ids2 = [(x.code,x.id) for x in account.child_id]
|
ids2 = [(x.code,x.id) for x in account.child_id]
|
||||||
ids2.sort()
|
ids2.sort()
|
||||||
result += self.lines(form, [x[1] for x in ids2], done, level+1)
|
result += self.lines(form, [x[1] for x in ids2], done, level+1)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _sum_credit(self):
|
def _sum_credit(self):
|
||||||
return self.sum_credit
|
return self.sum_credit
|
||||||
|
|
||||||
def _sum_debit(self):
|
def _sum_debit(self):
|
||||||
return self.sum_debit
|
return self.sum_debit
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=2)
|
report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=2)
|
||||||
|
|
||||||
|
|
|
@ -35,28 +35,28 @@ from report import report_sxw
|
||||||
# Use period and Journal for selection or resources
|
# Use period and Journal for selection or resources
|
||||||
#
|
#
|
||||||
class journal_print(report_sxw.rml_parse):
|
class journal_print(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(journal_print, self).__init__(cr, uid, name, context)
|
super(journal_print, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit
|
'sum_credit': self._sum_credit
|
||||||
})
|
})
|
||||||
|
|
||||||
def lines(self, period_id, journal_id, *args):
|
def lines(self, period_id, journal_id, *args):
|
||||||
self.cr.execute('update account_journal_period set state=%s where journal_id=%d and period_id=%d and state=%s', ('printed',journal_id,period_id,'draft'))
|
self.cr.execute('update account_journal_period set state=%s where journal_id=%d and period_id=%d and state=%s', ('printed',journal_id,period_id,'draft'))
|
||||||
self.cr.commit()
|
self.cr.commit()
|
||||||
self.cr.execute('select id from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\' order by date,id', (period_id, journal_id))
|
self.cr.execute('select id from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\' order by date,id', (period_id, journal_id))
|
||||||
ids = map(lambda x: x[0], self.cr.fetchall())
|
ids = map(lambda x: x[0], self.cr.fetchall())
|
||||||
return self.pool.get('account.move.line').browse(self.cr, self.uid, ids)
|
return self.pool.get('account.move.line').browse(self.cr, self.uid, ids)
|
||||||
|
|
||||||
def _sum_debit(self, period_id, journal_id):
|
def _sum_debit(self, period_id, journal_id):
|
||||||
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, period_id, journal_id):
|
def _sum_credit(self, period_id, journal_id):
|
||||||
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print)
|
report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print)
|
||||||
|
|
||||||
|
|
|
@ -32,160 +32,160 @@ import pooler
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class aged_trial_report(report_sxw.rml_parse):
|
class aged_trial_report(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(aged_trial_report, self).__init__(cr, uid, name, context)
|
super(aged_trial_report, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
'get_lines': self._get_lines,
|
'get_lines': self._get_lines,
|
||||||
'get_total': self._get_total,
|
'get_total': self._get_total,
|
||||||
'get_before': self._get_before,
|
'get_before': self._get_before,
|
||||||
'get_for_period': self._get_for_period,
|
'get_for_period': self._get_for_period,
|
||||||
'get_company': self._get_company,
|
'get_company': self._get_company,
|
||||||
'get_currency': self._get_currency,
|
'get_currency': self._get_currency,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _add_header(self, node):
|
def _add_header(self, node):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_lines(self, form):
|
def _get_lines(self, form):
|
||||||
self.form=form
|
self.form=form
|
||||||
res = []
|
res = []
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||||
context={'fiscalyear': form['fiscalyear']})
|
context={'fiscalyear': form['fiscalyear']})
|
||||||
self.cr.execute("SELECT DISTINCT res_partner.id AS id, " \
|
self.cr.execute("SELECT DISTINCT res_partner.id AS id, " \
|
||||||
"res_partner.name AS name, res_partner.ref AS code " \
|
"res_partner.name AS name, res_partner.ref AS code " \
|
||||||
"FROM res_partner, account_move_line AS line, account_account " \
|
"FROM res_partner, account_move_line AS line, account_account " \
|
||||||
"WHERE (line.account_id=account_account.id) " \
|
"WHERE (line.account_id=account_account.id) " \
|
||||||
"AND (line.reconcile_id IS NULL) " \
|
"AND (line.reconcile_id IS NULL) " \
|
||||||
"AND (line.partner_id=res_partner.id) " \
|
"AND (line.partner_id=res_partner.id) " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND (account_account.company_id = %d) " \
|
"AND (account_account.company_id = %d) " \
|
||||||
"AND account_account.active " \
|
"AND account_account.active " \
|
||||||
"ORDER BY res_partner.name", (form['company_id'],))
|
"ORDER BY res_partner.name", (form['company_id'],))
|
||||||
partners = self.cr.dictfetchall()
|
partners = self.cr.dictfetchall()
|
||||||
for partner in partners:
|
for partner in partners:
|
||||||
values = {}
|
values = {}
|
||||||
self.cr.execute("SELECT SUM(debit-credit) " \
|
self.cr.execute("SELECT SUM(debit-credit) " \
|
||||||
"FROM account_move_line AS line, account_account " \
|
"FROM account_move_line AS line, account_account " \
|
||||||
"WHERE (line.account_id=account_account.id) " \
|
"WHERE (line.account_id=account_account.id) " \
|
||||||
"AND (account_account.type IN (" + form['computation'] +")) " \
|
"AND (account_account.type IN (" + form['computation'] +")) " \
|
||||||
"AND (date < %s) AND (partner_id=%d) " \
|
"AND (date < %s) AND (partner_id=%d) " \
|
||||||
"AND (reconcile_id IS NULL) " \
|
"AND (reconcile_id IS NULL) " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND (account_account.company_id = %d) " \
|
"AND (account_account.company_id = %d) " \
|
||||||
"AND account_account.active",
|
"AND account_account.active",
|
||||||
(form['0']['start'], partner['id'], form['company_id']))
|
(form['0']['start'], partner['id'], form['company_id']))
|
||||||
before = self.cr.fetchone()
|
before = self.cr.fetchone()
|
||||||
values['before'] = before and before[0] or ""
|
values['before'] = before and before[0] or ""
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
self.cr.execute("SELECT SUM(debit-credit) " \
|
self.cr.execute("SELECT SUM(debit-credit) " \
|
||||||
"FROM account_move_line AS line, account_account " \
|
"FROM account_move_line AS line, account_account " \
|
||||||
"WHERE (line.account_id=account_account.id) " \
|
"WHERE (line.account_id=account_account.id) " \
|
||||||
"AND (account_account.type IN (" + form['computation'] + ")) " \
|
"AND (account_account.type IN (" + form['computation'] + ")) " \
|
||||||
"AND (date >= %s) AND (date <= %s) " \
|
"AND (date >= %s) AND (date <= %s) " \
|
||||||
"AND (partner_id = %d) " \
|
"AND (partner_id = %d) " \
|
||||||
"AND (reconcile_id IS NULL) " \
|
"AND (reconcile_id IS NULL) " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND (account_account.company_id = %d) " \
|
"AND (account_account.company_id = %d) " \
|
||||||
"AND account_account.active",
|
"AND account_account.active",
|
||||||
(form[str(i)]['start'], form[str(i)]['stop'],
|
(form[str(i)]['start'], form[str(i)]['stop'],
|
||||||
partner['id'], form['company_id']))
|
partner['id'], form['company_id']))
|
||||||
during = self.cr.fetchone()
|
during = self.cr.fetchone()
|
||||||
values[str(i)] = during and during[0] or ""
|
values[str(i)] = during and during[0] or ""
|
||||||
|
|
||||||
self.cr.execute("SELECT SUM(debit-credit) " \
|
self.cr.execute("SELECT SUM(debit-credit) " \
|
||||||
"FROM account_move_line AS line, account_account " \
|
"FROM account_move_line AS line, account_account " \
|
||||||
"WHERE (line.account_id = account_account.id) " \
|
"WHERE (line.account_id = account_account.id) " \
|
||||||
"AND (account_account.type IN (" + form['computation'] + ")) " \
|
"AND (account_account.type IN (" + form['computation'] + ")) " \
|
||||||
"AND (partner_id = %d) " \
|
"AND (partner_id = %d) " \
|
||||||
"AND (reconcile_id IS NULL) " \
|
"AND (reconcile_id IS NULL) " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND (account_account.company_id = %d) " \
|
"AND (account_account.company_id = %d) " \
|
||||||
"AND account_account.active",
|
"AND account_account.active",
|
||||||
(partner['id'], form['company_id']))
|
(partner['id'], form['company_id']))
|
||||||
total = self.cr.fetchone()
|
total = self.cr.fetchone()
|
||||||
values['total'] = total and total[0] or 0.0
|
values['total'] = total and total[0] or 0.0
|
||||||
values['name'] = partner['name']
|
values['name'] = partner['name']
|
||||||
values['ref'] = partner['code']
|
values['ref'] = partner['code']
|
||||||
t = 0.0
|
t = 0.0
|
||||||
for i in range(5)+['before']:
|
for i in range(5)+['before']:
|
||||||
t+= float(values.get(str(i), 0.0) or 0.0)
|
t+= float(values.get(str(i), 0.0) or 0.0)
|
||||||
if values['total']:
|
if values['total']:
|
||||||
res.append(values)
|
res.append(values)
|
||||||
total = 0.0
|
total = 0.0
|
||||||
totals = {}
|
totals = {}
|
||||||
for r in res:
|
for r in res:
|
||||||
total += float(r['total'] or 0.0)
|
total += float(r['total'] or 0.0)
|
||||||
for i in range(5)+['before']:
|
for i in range(5)+['before']:
|
||||||
totals.setdefault(str(i), 0.0)
|
totals.setdefault(str(i), 0.0)
|
||||||
totals[str(i)] += float(r[str(i)] or 0.0)
|
totals[str(i)] += float(r[str(i)] or 0.0)
|
||||||
if form['sorting_on']=='amount':
|
if form['sorting_on']=='amount':
|
||||||
res.sort(lambda x,y:cmp(y['total'],x['total']))
|
res.sort(lambda x,y:cmp(y['total'],x['total']))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_total(self, fiscalyear, company_id):
|
def _get_total(self, fiscalyear, company_id):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||||
context={'fiscalyear': fiscalyear})
|
context={'fiscalyear': fiscalyear})
|
||||||
self.cr.execute("SELECT SUM(debit - credit) " \
|
self.cr.execute("SELECT SUM(debit - credit) " \
|
||||||
"FROM account_move_line AS line, account_account " \
|
"FROM account_move_line AS line, account_account " \
|
||||||
"WHERE (line.account_id = account_account.id) " \
|
"WHERE (line.account_id = account_account.id) " \
|
||||||
"AND (account_account.type IN (" + self.form['computation'] + ")) "\
|
"AND (account_account.type IN (" + self.form['computation'] + ")) "\
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND partner_id is NOT NULL " \
|
"AND partner_id is NOT NULL " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND (account_account.company_id = %d) " \
|
"AND (account_account.company_id = %d) " \
|
||||||
"AND account_account.active",
|
"AND account_account.active",
|
||||||
(company_id,))
|
(company_id,))
|
||||||
total = self.cr.fetchone()
|
total = self.cr.fetchone()
|
||||||
return total and total[0] or 0.0
|
return total and total[0] or 0.0
|
||||||
|
|
||||||
def _get_before(self, date, fiscalyear, company_id):
|
def _get_before(self, date, fiscalyear, company_id):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||||
context={'fiscalyear': fiscalyear})
|
context={'fiscalyear': fiscalyear})
|
||||||
self.cr.execute("SELECT SUM(debit - credit) " \
|
self.cr.execute("SELECT SUM(debit - credit) " \
|
||||||
"FROM account_move_line AS line, account_account " \
|
"FROM account_move_line AS line, account_account " \
|
||||||
"WHERE (line.account_id = account_account.id) " \
|
"WHERE (line.account_id = account_account.id) " \
|
||||||
"AND (account_account.type IN (" + self.form['computation'] + ")) " \
|
"AND (account_account.type IN (" + self.form['computation'] + ")) " \
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND (date < %s) " \
|
"AND (date < %s) " \
|
||||||
"AND partner_id IS NOT NULL " \
|
"AND partner_id IS NOT NULL " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND (account_account.company_id = %d) " \
|
"AND (account_account.company_id = %d) " \
|
||||||
"AND account_account.active",
|
"AND account_account.active",
|
||||||
(date, company_id))
|
(date, company_id))
|
||||||
before = self.cr.fetchone()
|
before = self.cr.fetchone()
|
||||||
return before and before[0] or 0.0
|
return before and before[0] or 0.0
|
||||||
|
|
||||||
def _get_for_period(self, period, fiscalyear, company_id):
|
def _get_for_period(self, period, fiscalyear, company_id):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||||
context={'fiscalyear': fiscalyear})
|
context={'fiscalyear': fiscalyear})
|
||||||
self.cr.execute("SELECT SUM(debit - credit) " \
|
self.cr.execute("SELECT SUM(debit - credit) " \
|
||||||
"FROM account_move_line AS line, account_account " \
|
"FROM account_move_line AS line, account_account " \
|
||||||
"WHERE (line.account_id = account_account.id) " \
|
"WHERE (line.account_id = account_account.id) " \
|
||||||
"AND (account_account.type IN (" + self.form['computation'] + ")) " \
|
"AND (account_account.type IN (" + self.form['computation'] + ")) " \
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND (date >= %s) " \
|
"AND (date >= %s) " \
|
||||||
"AND (date <= %s) " \
|
"AND (date <= %s) " \
|
||||||
"AND partner_id IS NOT NULL " \
|
"AND partner_id IS NOT NULL " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND (account_account.company_id = %d) " \
|
"AND (account_account.company_id = %d) " \
|
||||||
"AND account_account.active",
|
"AND account_account.active",
|
||||||
(period['start'], period['stop'], company_id))
|
(period['start'], period['stop'], company_id))
|
||||||
period = self.cr.fetchone()
|
period = self.cr.fetchone()
|
||||||
return period and period[0] or 0.0
|
return period and period[0] or 0.0
|
||||||
|
|
||||||
def _get_company(self, form):
|
def _get_company(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
||||||
|
|
||||||
def _get_currency(self, form):
|
def _get_currency(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
||||||
|
|
||||||
report_sxw.report_sxw(
|
report_sxw.report_sxw(
|
||||||
'report.account.aged.trial.balance',
|
'report.account.aged.trial.balance',
|
||||||
'res.partner',
|
'res.partner',
|
||||||
'addons/account/report/aged_trial_balance.rml',
|
'addons/account/report/aged_trial_balance.rml',
|
||||||
parser=aged_trial_report, header=False)
|
parser=aged_trial_report, header=False)
|
||||||
|
|
|
@ -33,42 +33,42 @@ import datetime
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
class budget_report(report_sxw.rml_parse):
|
class budget_report(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(budget_report, self).__init__(cr, uid, name, context)
|
super(budget_report, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'budget_total': self.budget_total,
|
'budget_total': self.budget_total,
|
||||||
'post_total': self.post_total,
|
'post_total': self.post_total,
|
||||||
'time': time,
|
'time': time,
|
||||||
})
|
})
|
||||||
|
|
||||||
def post_total(self, post_obj, date1, date2):
|
def post_total(self, post_obj, date1, date2):
|
||||||
def str2date(date_str):
|
def str2date(date_str):
|
||||||
return datetime.date.fromtimestamp(time.mktime(time.strptime(date_str, '%Y-%m-%d')))
|
return datetime.date.fromtimestamp(time.mktime(time.strptime(date_str, '%Y-%m-%d')))
|
||||||
def interval(d1str, d2str):
|
def interval(d1str, d2str):
|
||||||
return (str2date(d2str) - str2date(d1str) + datetime.timedelta(days=1)).days
|
return (str2date(d2str) - str2date(d1str) + datetime.timedelta(days=1)).days
|
||||||
prev = reduce(lambda x,d: x + d.amount, post_obj.dotation_ids, 0.0)
|
prev = reduce(lambda x,d: x + d.amount, post_obj.dotation_ids, 0.0)
|
||||||
period_days = interval(date1, date2)
|
period_days = interval(date1, date2)
|
||||||
for d in post_obj.dotation_ids:
|
for d in post_obj.dotation_ids:
|
||||||
i = interval(d.period_id.date_start, d.period_id.date_stop)
|
i = interval(d.period_id.date_start, d.period_id.date_stop)
|
||||||
total_days = reduce(lambda x,d: x+interval(d.period_id.date_start, d.period_id.date_stop), post_obj.dotation_ids, 0)
|
total_days = reduce(lambda x,d: x+interval(d.period_id.date_start, d.period_id.date_stop), post_obj.dotation_ids, 0)
|
||||||
achievements = reduce(lambda x,l: x+l['achievements'], self.lines(post_obj, date1, date2), 0.0)
|
achievements = reduce(lambda x,l: x+l['achievements'], self.lines(post_obj, date1, date2), 0.0)
|
||||||
return [{'prev': prev, 'prev_period': prev * period_days / total_days, 'achievements': achievements}]
|
return [{'prev': prev, 'prev_period': prev * period_days / total_days, 'achievements': achievements}]
|
||||||
|
|
||||||
def budget_total(self, post_objs, date1, date2):
|
def budget_total(self, post_objs, date1, date2):
|
||||||
res = {'prev': 0.0, 'prev_period': 0.0, 'achievements': 0.0}
|
res = {'prev': 0.0, 'prev_period': 0.0, 'achievements': 0.0}
|
||||||
for post_obj in post_objs:
|
for post_obj in post_objs:
|
||||||
r = self.post_total(post_obj, date1, date2)[0]
|
r = self.post_total(post_obj, date1, date2)[0]
|
||||||
for k in r:
|
for k in r:
|
||||||
res[k] += r[k]
|
res[k] += r[k]
|
||||||
return [res]
|
return [res]
|
||||||
|
|
||||||
def lines(self, post_obj, date1, date2):
|
def lines(self, post_obj, date1, date2):
|
||||||
res = []
|
res = []
|
||||||
for a in post_obj.account_ids:
|
for a in post_obj.account_ids:
|
||||||
self.cr.execute("SELECT COALESCE(SUM(debit-credit), 0) FROM account_move_line WHERE account_id=%d AND date>=%s AND date<=%s and state<>'draft'", (a.id, date1, date2))
|
self.cr.execute("SELECT COALESCE(SUM(debit-credit), 0) FROM account_move_line WHERE account_id=%d AND date>=%s AND date<=%s and state<>'draft'", (a.id, date1, date2))
|
||||||
achievements = float(self.cr.fetchone()[0]) * (post_obj.sens=='produit' and -1 or 1)
|
achievements = float(self.cr.fetchone()[0]) * (post_obj.sens=='produit' and -1 or 1)
|
||||||
res.append({'name': a.name, 'code': a.code, 'achievements': achievements})
|
res.append({'name': a.name, 'code': a.code, 'achievements': achievements})
|
||||||
return res
|
return res
|
||||||
report_sxw.report_sxw('report.account.budget', 'account.budget.post', 'addons/account/report/budget_report.rml',parser=budget_report)
|
report_sxw.report_sxw('report.account.budget', 'account.budget.post', 'addons/account/report/budget_report.rml',parser=budget_report)
|
||||||
|
|
||||||
|
|
|
@ -34,25 +34,25 @@ from report import report_sxw
|
||||||
# Use period and Journal for selection or resources
|
# Use period and Journal for selection or resources
|
||||||
#
|
#
|
||||||
class journal_print(report_sxw.rml_parse):
|
class journal_print(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(journal_print, self).__init__(cr, uid, name, context)
|
super(journal_print, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit
|
'sum_credit': self._sum_credit
|
||||||
})
|
})
|
||||||
|
|
||||||
def lines(self, period_id, journal_id, *args):
|
def lines(self, period_id, journal_id, *args):
|
||||||
self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%d and l.journal_id=%d and l.state<>\'draft\' group by a.id, a.code, a.name', (period_id, journal_id))
|
self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%d and l.journal_id=%d and l.state<>\'draft\' group by a.id, a.code, a.name', (period_id, journal_id))
|
||||||
return self.cr.dictfetchall()
|
return self.cr.dictfetchall()
|
||||||
|
|
||||||
def _sum_debit(self, period_id, journal_id):
|
def _sum_debit(self, period_id, journal_id):
|
||||||
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, period_id, journal_id):
|
def _sum_credit(self, period_id, journal_id):
|
||||||
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id=%d and state<>\'draft\'', (period_id, journal_id))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print)
|
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print)
|
||||||
|
|
||||||
|
|
|
@ -35,65 +35,65 @@ from report import report_sxw
|
||||||
# Use period and Journal for selection or resources
|
# Use period and Journal for selection or resources
|
||||||
#
|
#
|
||||||
class journal_print(report_sxw.rml_parse):
|
class journal_print(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(journal_print, self).__init__(cr, uid, name, context)
|
super(journal_print, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'periods': self.periods,
|
'periods': self.periods,
|
||||||
'sum_debit_period': self._sum_debit_period,
|
'sum_debit_period': self._sum_debit_period,
|
||||||
'sum_credit_period': self._sum_credit_period,
|
'sum_credit_period': self._sum_credit_period,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit
|
'sum_credit': self._sum_credit
|
||||||
})
|
})
|
||||||
|
|
||||||
def preprocess(self, objects, datas, ids):
|
def preprocess(self, objects, datas, ids):
|
||||||
super(journal_print, self).preprocess(objects, datas, ids)
|
super(journal_print, self).preprocess(objects, datas, ids)
|
||||||
self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')')
|
self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')')
|
||||||
res = self.cr.fetchall()
|
res = self.cr.fetchall()
|
||||||
self.period_ids = ','.join([str(x[0]) for x in res])
|
self.period_ids = ','.join([str(x[0]) for x in res])
|
||||||
self.journal_ids = ','.join([str(x[1]) for x in res])
|
self.journal_ids = ','.join([str(x[1]) for x in res])
|
||||||
|
|
||||||
# returns a list of period objs
|
# returns a list of period objs
|
||||||
def periods(self, journal_period_objs):
|
def periods(self, journal_period_objs):
|
||||||
dic = {}
|
dic = {}
|
||||||
def filter_unique(o):
|
def filter_unique(o):
|
||||||
key = o.period_id.id
|
key = o.period_id.id
|
||||||
res = key in dic
|
res = key in dic
|
||||||
if not res:
|
if not res:
|
||||||
dic[key] = True
|
dic[key] = True
|
||||||
return not res
|
return not res
|
||||||
filtered_objs = filter(filter_unique, journal_period_objs)
|
filtered_objs = filter(filter_unique, journal_period_objs)
|
||||||
return map(lambda x: x.period_id, filtered_objs)
|
return map(lambda x: x.period_id, filtered_objs)
|
||||||
|
|
||||||
def lines(self, period_id):
|
def lines(self, period_id):
|
||||||
if not self.journal_ids:
|
if not self.journal_ids:
|
||||||
return []
|
return []
|
||||||
self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%d and journal_id in (' + self.journal_ids + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,))
|
self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%d and journal_id in (' + self.journal_ids + ') and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,))
|
||||||
return self.cr.dictfetchall()
|
return self.cr.dictfetchall()
|
||||||
|
|
||||||
def _sum_debit_period(self, period_id):
|
def _sum_debit_period(self, period_id):
|
||||||
if not self.journal_ids:
|
if not self.journal_ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,))
|
self.cr.execute('select sum(debit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit_period(self, period_id):
|
def _sum_credit_period(self, period_id):
|
||||||
if not self.journal_ids:
|
if not self.journal_ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,))
|
self.cr.execute('select sum(credit) from account_move_line where period_id=%d and journal_id in (' + self.journal_ids + ') and state<>\'draft\'', (period_id,))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_debit(self):
|
def _sum_debit(self):
|
||||||
if not self.journal_ids or not self.period_ids:
|
if not self.journal_ids or not self.period_ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute('select sum(debit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
|
self.cr.execute('select sum(debit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self):
|
def _sum_credit(self):
|
||||||
if not self.journal_ids or not self.period_ids:
|
if not self.journal_ids or not self.period_ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute('select sum(credit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
|
self.cr.execute('select sum(credit) from account_move_line where period_id in (' + self.period_ids + ') and journal_id in (' + self.journal_ids + ') and state<>\'draft\'')
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print)
|
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print)
|
||||||
|
|
||||||
|
|
|
@ -32,139 +32,139 @@ from report import report_sxw
|
||||||
import pooler
|
import pooler
|
||||||
|
|
||||||
class general_ledger(report_sxw.rml_parse):
|
class general_ledger(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(general_ledger, self).__init__(cr, uid, name, context)
|
super(general_ledger, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'sum_debit_account': self._sum_debit_account,
|
'sum_debit_account': self._sum_debit_account,
|
||||||
'sum_credit_account': self._sum_credit_account,
|
'sum_credit_account': self._sum_credit_account,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit,
|
'sum_credit': self._sum_credit,
|
||||||
|
|
||||||
})
|
})
|
||||||
self.context = context
|
self.context = context
|
||||||
self.tmp_list2=[]
|
self.tmp_list2=[]
|
||||||
self.final_list=[]
|
self.final_list=[]
|
||||||
|
|
||||||
|
|
||||||
def recur(self,list1):
|
def recur(self,list1):
|
||||||
tmp_list3 =list1
|
tmp_list3 =list1
|
||||||
self.tmp_list2 =list1
|
self.tmp_list2 =list1
|
||||||
# print "self list",self.tmp_list2
|
# print "self list",self.tmp_list2
|
||||||
for i in range(0,len(list1)):
|
for i in range(0,len(list1)):
|
||||||
if list1[i] in self.final_list:
|
if list1[i] in self.final_list:
|
||||||
continue
|
continue
|
||||||
self.final_list.append(list1[i])
|
self.final_list.append(list1[i])
|
||||||
# print "finallly",self.final_list
|
# print "finallly",self.final_list
|
||||||
if list1[i].child_id:
|
if list1[i].child_id:
|
||||||
|
|
||||||
tmp_list4=(hasattr(list1[i],'child_id') and list(list1[i].child_id) or [])
|
tmp_list4=(hasattr(list1[i],'child_id') and list(list1[i].child_id) or [])
|
||||||
|
|
||||||
self.tmp_list2 +=tmp_list4
|
self.tmp_list2 +=tmp_list4
|
||||||
|
|
||||||
self.tmp_list2+=self.recur(tmp_list4)
|
self.tmp_list2+=self.recur(tmp_list4)
|
||||||
|
|
||||||
return self.final_list
|
return self.final_list
|
||||||
|
|
||||||
def repeatIn(self, lst, name,nodes_parent=False):
|
def repeatIn(self, lst, name,nodes_parent=False):
|
||||||
|
|
||||||
if name=='o':
|
if name=='o':
|
||||||
list_final=[]
|
list_final=[]
|
||||||
if not lst:
|
if not lst:
|
||||||
return super(general_ledger,self).repeatIn(lst, name,nodes_parent)
|
return super(general_ledger,self).repeatIn(lst, name,nodes_parent)
|
||||||
try:
|
try:
|
||||||
tmp_list = list(lst)
|
tmp_list = list(lst)
|
||||||
if tmp_list:
|
if tmp_list:
|
||||||
tmp_list = self.recur(tmp_list)
|
tmp_list = self.recur(tmp_list)
|
||||||
else:
|
else:
|
||||||
return super(general_ledger,self).repeatIn(lst, name,nodes_parent)
|
return super(general_ledger,self).repeatIn(lst, name,nodes_parent)
|
||||||
|
|
||||||
lst = list(set([x for x in tmp_list]))
|
lst = list(set([x for x in tmp_list]))
|
||||||
|
|
||||||
final={}
|
final={}
|
||||||
# for x in lst:
|
# for x in lst:
|
||||||
# final[x]=x.id
|
# final[x]=x.id
|
||||||
# final1=sorted(final.items(), lambda x, y: cmp(x[1], y[1]))
|
# final1=sorted(final.items(), lambda x, y: cmp(x[1], y[1]))
|
||||||
#
|
#
|
||||||
# for a in final1:
|
# for a in final1:
|
||||||
# list_final.append(a[0])
|
# list_final.append(a[0])
|
||||||
list_final=tmp_list
|
list_final=tmp_list
|
||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
||||||
list_final=lst
|
list_final=lst
|
||||||
ret_data = super(general_ledger,self).repeatIn(list_final, name,nodes_parent)
|
ret_data = super(general_ledger,self).repeatIn(list_final, name,nodes_parent)
|
||||||
|
|
||||||
return ret_data
|
return ret_data
|
||||||
|
|
||||||
|
|
||||||
def lines(self, account, form):
|
def lines(self, account, form):
|
||||||
|
|
||||||
ctx = self.context.copy()
|
ctx = self.context.copy()
|
||||||
ctx['fiscalyear'] = form['fiscalyear']
|
ctx['fiscalyear'] = form['fiscalyear']
|
||||||
ctx['periods'] = form['periods'][0][2]
|
ctx['periods'] = form['periods'][0][2]
|
||||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||||
self.cr.execute("SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit "\
|
self.cr.execute("SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit "\
|
||||||
"FROM account_move_line l, account_journal j "\
|
"FROM account_move_line l, account_journal j "\
|
||||||
"WHERE l.journal_id = j.id "\
|
"WHERE l.journal_id = j.id "\
|
||||||
"AND account_id = %d AND "+query+" "\
|
"AND account_id = %d AND "+query+" "\
|
||||||
"ORDER by l.id", (account.id,))
|
"ORDER by l.id", (account.id,))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
sum = 0.0
|
sum = 0.0
|
||||||
|
|
||||||
for l in res:
|
for l in res:
|
||||||
sum += l['debit'] - l ['credit']
|
sum += l['debit'] - l ['credit']
|
||||||
l['progress'] = sum
|
l['progress'] = sum
|
||||||
self.ids +=[account.id]
|
self.ids +=[account.id]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _sum_debit_account(self, account, form):
|
def _sum_debit_account(self, account, form):
|
||||||
ctx = self.context.copy()
|
ctx = self.context.copy()
|
||||||
ctx['fiscalyear'] = form['fiscalyear']
|
ctx['fiscalyear'] = form['fiscalyear']
|
||||||
ctx['periods'] = form['periods'][0][2]
|
ctx['periods'] = form['periods'][0][2]
|
||||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||||
self.cr.execute("SELECT sum(debit) "\
|
self.cr.execute("SELECT sum(debit) "\
|
||||||
"FROM account_move_line l "\
|
"FROM account_move_line l "\
|
||||||
"WHERE l.account_id = %d AND "+query, (account.id,))
|
"WHERE l.account_id = %d AND "+query, (account.id,))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit_account(self, account, form):
|
def _sum_credit_account(self, account, form):
|
||||||
ctx = self.context.copy()
|
ctx = self.context.copy()
|
||||||
ctx['fiscalyear'] = form['fiscalyear']
|
ctx['fiscalyear'] = form['fiscalyear']
|
||||||
ctx['periods'] = form['periods'][0][2]
|
ctx['periods'] = form['periods'][0][2]
|
||||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||||
self.cr.execute("SELECT sum(credit) "\
|
self.cr.execute("SELECT sum(credit) "\
|
||||||
"FROM account_move_line l "\
|
"FROM account_move_line l "\
|
||||||
"WHERE l.account_id = %d AND "+query, (account.id,))
|
"WHERE l.account_id = %d AND "+query, (account.id,))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_debit(self, form):
|
def _sum_debit(self, form):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
ctx = self.context.copy()
|
ctx = self.context.copy()
|
||||||
ctx['fiscalyear'] = form['fiscalyear']
|
ctx['fiscalyear'] = form['fiscalyear']
|
||||||
ctx['periods'] = form['periods'][0][2]
|
ctx['periods'] = form['periods'][0][2]
|
||||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||||
self.cr.execute("SELECT sum(debit) "\
|
self.cr.execute("SELECT sum(debit) "\
|
||||||
"FROM account_move_line l "\
|
"FROM account_move_line l "\
|
||||||
"WHERE l.account_id in ("+','.join(map(str, self.ids))+") AND "+query)
|
"WHERE l.account_id in ("+','.join(map(str, self.ids))+") AND "+query)
|
||||||
|
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, form):
|
def _sum_credit(self, form):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
ctx = self.context.copy()
|
ctx = self.context.copy()
|
||||||
ctx['fiscalyear'] = form['fiscalyear']
|
ctx['fiscalyear'] = form['fiscalyear']
|
||||||
ctx['periods'] = form['periods'][0][2]
|
ctx['periods'] = form['periods'][0][2]
|
||||||
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
|
||||||
self.cr.execute("SELECT sum(credit) "\
|
self.cr.execute("SELECT sum(credit) "\
|
||||||
"FROM account_move_line l "\
|
"FROM account_move_line l "\
|
||||||
"WHERE l.account_id in ("+','.join(map(str, self.ids))+") AND "+query)
|
"WHERE l.account_id in ("+','.join(map(str, self.ids))+") AND "+query)
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False)
|
report_sxw.report_sxw('report.account.general.ledger', 'account.account', 'addons/account/report/general_ledger.rml', parser=general_ledger, header=False)
|
||||||
|
|
||||||
|
|
|
@ -31,15 +31,15 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class account_invoice(report_sxw.rml_parse):
|
class account_invoice(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(account_invoice, self).__init__(cr, uid, name, context)
|
super(account_invoice, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
})
|
})
|
||||||
report_sxw.report_sxw(
|
report_sxw.report_sxw(
|
||||||
'report.account.invoice',
|
'report.account.invoice',
|
||||||
'account.invoice',
|
'account.invoice',
|
||||||
'addons/account/report/invoice.rml',
|
'addons/account/report/invoice.rml',
|
||||||
parser=account_invoice,
|
parser=account_invoice,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -35,30 +35,30 @@ from report import report_sxw
|
||||||
import pooler
|
import pooler
|
||||||
|
|
||||||
class Overdue(report_sxw.rml_parse):
|
class Overdue(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(Overdue, self).__init__(cr, uid, name, context)
|
super(Overdue, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time' : time,
|
'time' : time,
|
||||||
'adr_get' : self._adr_get,
|
'adr_get' : self._adr_get,
|
||||||
'getLines' : self._lines_get,
|
'getLines' : self._lines_get,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _adr_get(self, partner, type):
|
def _adr_get(self, partner, type):
|
||||||
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
|
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
|
||||||
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
|
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
|
||||||
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type])
|
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type])
|
||||||
adr_id = addresses and addresses[type] or False
|
adr_id = addresses and addresses[type] or False
|
||||||
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
|
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
|
||||||
|
|
||||||
def _lines_get(self, partner):
|
def _lines_get(self, partner):
|
||||||
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
movelines = moveline_obj.search(self.cr, self.uid,
|
movelines = moveline_obj.search(self.cr, self.uid,
|
||||||
[('partner_id', '=', partner.id),
|
[('partner_id', '=', partner.id),
|
||||||
('account_id.type', 'in', ['receivable', 'payable']),
|
('account_id.type', 'in', ['receivable', 'payable']),
|
||||||
('state', '<>', 'draft'), ('reconcile_id', '=', False)])
|
('state', '<>', 'draft'), ('reconcile_id', '=', False)])
|
||||||
movelines = moveline_obj.browse(self.cr, self.uid, movelines)
|
movelines = moveline_obj.browse(self.cr, self.uid, movelines)
|
||||||
return movelines
|
return movelines
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.overdue', 'res.partner',
|
report_sxw.report_sxw('report.account.overdue', 'res.partner',
|
||||||
'addons/account/report/overdue.rml', parser=Overdue)
|
'addons/account/report/overdue.rml', parser=Overdue)
|
||||||
|
|
||||||
|
|
|
@ -32,201 +32,201 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class partner_balance(report_sxw.rml_parse):
|
class partner_balance(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(partner_balance, self).__init__(cr, uid, name, context)
|
super(partner_balance, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit,
|
'sum_credit': self._sum_credit,
|
||||||
'sum_litige': self._sum_litige,
|
'sum_litige': self._sum_litige,
|
||||||
'sum_sdebit': self._sum_sdebit,
|
'sum_sdebit': self._sum_sdebit,
|
||||||
'sum_scredit': self._sum_scredit,
|
'sum_scredit': self._sum_scredit,
|
||||||
'solde_debit': self._solde_balance_debit,
|
'solde_debit': self._solde_balance_debit,
|
||||||
'solde_credit': self._solde_balance_credit,
|
'solde_credit': self._solde_balance_credit,
|
||||||
'get_company': self._get_company,
|
'get_company': self._get_company,
|
||||||
'get_currency': self._get_currency,
|
'get_currency': self._get_currency,
|
||||||
})
|
})
|
||||||
|
|
||||||
def preprocess(self, objects, data, ids):
|
def preprocess(self, objects, data, ids):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||||
context={'fiscalyear': data['form']['fiscalyear']})
|
context={'fiscalyear': data['form']['fiscalyear']})
|
||||||
self.cr.execute('SELECT DISTINCT line.partner_id ' \
|
self.cr.execute('SELECT DISTINCT line.partner_id ' \
|
||||||
'FROM account_move_line AS line, account_account AS account ' \
|
'FROM account_move_line AS line, account_account AS account ' \
|
||||||
'WHERE line.partner_id IS NOT NULL ' \
|
'WHERE line.partner_id IS NOT NULL ' \
|
||||||
'AND line.date >= %s ' \
|
'AND line.date >= %s ' \
|
||||||
'AND line.date <= %s ' \
|
'AND line.date <= %s ' \
|
||||||
'AND ' + line_query + ' ' \
|
'AND ' + line_query + ' ' \
|
||||||
'AND line.account_id = account.id ' \
|
'AND line.account_id = account.id ' \
|
||||||
'AND account.company_id = %d ' \
|
'AND account.company_id = %d ' \
|
||||||
'AND account.active',
|
'AND account.active',
|
||||||
(data['form']['date1'], data['form']['date2'],
|
(data['form']['date1'], data['form']['date2'],
|
||||||
data['form']['company_id']))
|
data['form']['company_id']))
|
||||||
new_ids = [id for (id,) in self.cr.fetchall()]
|
new_ids = [id for (id,) in self.cr.fetchall()]
|
||||||
self.cr.execute('SELECT a.id ' \
|
self.cr.execute('SELECT a.id ' \
|
||||||
'FROM account_account a ' \
|
'FROM account_account a ' \
|
||||||
'LEFT JOIN account_account_type t ' \
|
'LEFT JOIN account_account_type t ' \
|
||||||
'ON (a.type = t.code) ' \
|
'ON (a.type = t.code) ' \
|
||||||
'WHERE t.partner_account = TRUE ' \
|
'WHERE t.partner_account = TRUE ' \
|
||||||
'AND a.company_id = %d ' \
|
'AND a.company_id = %d ' \
|
||||||
'AND a.active', (data['form']['company_id'],))
|
'AND a.active', (data['form']['company_id'],))
|
||||||
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
|
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
|
||||||
self.partner_ids = ','.join(map(str, new_ids))
|
self.partner_ids = ','.join(map(str, new_ids))
|
||||||
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
|
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
|
||||||
super(partner_balance, self).preprocess(objects, data, new_ids)
|
super(partner_balance, self).preprocess(objects, data, new_ids)
|
||||||
|
|
||||||
def lines(self):
|
def lines(self):
|
||||||
if not self.partner_ids:
|
if not self.partner_ids:
|
||||||
return []
|
return []
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT p.ref, p.name, sum(debit) as debit, sum(credit) as credit, " \
|
"SELECT p.ref, p.name, sum(debit) as debit, sum(credit) as credit, " \
|
||||||
"CASE WHEN sum(debit) > sum(credit) " \
|
"CASE WHEN sum(debit) > sum(credit) " \
|
||||||
"THEN sum(debit) - sum(credit) " \
|
"THEN sum(debit) - sum(credit) " \
|
||||||
"ELSE 0 " \
|
"ELSE 0 " \
|
||||||
"END AS sdebit, " \
|
"END AS sdebit, " \
|
||||||
"CASE WHEN sum(debit) < sum(credit) " \
|
"CASE WHEN sum(debit) < sum(credit) " \
|
||||||
"THEN sum(credit) - sum(debit) " \
|
"THEN sum(credit) - sum(debit) " \
|
||||||
"ELSE 0 " \
|
"ELSE 0 " \
|
||||||
"END AS scredit, " \
|
"END AS scredit, " \
|
||||||
"(SELECT sum(debit-credit) " \
|
"(SELECT sum(debit-credit) " \
|
||||||
"FROM account_move_line l " \
|
"FROM account_move_line l " \
|
||||||
"WHERE partner_id = p.id " \
|
"WHERE partner_id = p.id " \
|
||||||
"AND date >= %s " \
|
"AND date >= %s " \
|
||||||
"AND date <= %s " \
|
"AND date <= %s " \
|
||||||
"AND blocked = TRUE " \
|
"AND blocked = TRUE " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
") AS enlitige " \
|
") AS enlitige " \
|
||||||
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
|
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
|
||||||
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
||||||
"AND account_id IN (" + self.account_ids + ") " \
|
"AND account_id IN (" + self.account_ids + ") " \
|
||||||
"AND l.date >= %s " \
|
"AND l.date >= %s " \
|
||||||
"AND l.date <= %s " \
|
"AND l.date <= %s " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"GROUP BY p.id, p.ref, p.name " \
|
"GROUP BY p.id, p.ref, p.name " \
|
||||||
"ORDER BY p.ref, p.name",
|
"ORDER BY p.ref, p.name",
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2'],
|
(self.datas['form']['date1'], self.datas['form']['date2'],
|
||||||
self.datas['form']['date1'], self.datas['form']['date2']))
|
self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _sum_debit(self):
|
def _sum_debit(self):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
'SELECT sum(debit) ' \
|
'SELECT sum(debit) ' \
|
||||||
'FROM account_move_line ' \
|
'FROM account_move_line ' \
|
||||||
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
||||||
'AND account_id IN (' + self.account_ids + ') ' \
|
'AND account_id IN (' + self.account_ids + ') ' \
|
||||||
'AND date >=%s ' \
|
'AND date >=%s ' \
|
||||||
'AND date <= %s ' \
|
'AND date <= %s ' \
|
||||||
'AND ' + line_query,
|
'AND ' + line_query,
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2']))
|
(self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self):
|
def _sum_credit(self):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
'SELECT sum(credit) ' \
|
'SELECT sum(credit) ' \
|
||||||
'FROM account_move_line ' \
|
'FROM account_move_line ' \
|
||||||
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
||||||
'AND account_id IN (' + self.account_ids + ') ' \
|
'AND account_id IN (' + self.account_ids + ') ' \
|
||||||
'AND date >= %s ' \
|
'AND date >= %s ' \
|
||||||
'AND date <= %s ' \
|
'AND date <= %s ' \
|
||||||
'AND ' + line_query,
|
'AND ' + line_query,
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2']))
|
(self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_litige(self):
|
def _sum_litige(self):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
'SELECT sum(debit-credit) ' \
|
'SELECT sum(debit-credit) ' \
|
||||||
'FROM account_move_line ' \
|
'FROM account_move_line ' \
|
||||||
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
||||||
'AND account_id IN (' + self.account_ids + ') ' \
|
'AND account_id IN (' + self.account_ids + ') ' \
|
||||||
'AND date >= %s ' \
|
'AND date >= %s ' \
|
||||||
'AND date <= %s ' \
|
'AND date <= %s ' \
|
||||||
'AND blocked=TRUE ' \
|
'AND blocked=TRUE ' \
|
||||||
'AND ' + line_query,
|
'AND ' + line_query,
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2']))
|
(self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_sdebit(self):
|
def _sum_sdebit(self):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
'SELECT CASE WHEN sum(debit) > sum(credit) ' \
|
'SELECT CASE WHEN sum(debit) > sum(credit) ' \
|
||||||
'THEN sum(debit - credit) ' \
|
'THEN sum(debit - credit) ' \
|
||||||
'ELSE 0 ' \
|
'ELSE 0 ' \
|
||||||
'END ' \
|
'END ' \
|
||||||
'FROM account_move_line ' \
|
'FROM account_move_line ' \
|
||||||
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
||||||
'AND account_id IN (' + self.account_ids + ') ' \
|
'AND account_id IN (' + self.account_ids + ') ' \
|
||||||
'AND date >= %s ' \
|
'AND date >= %s ' \
|
||||||
'AND date <= %s ' \
|
'AND date <= %s ' \
|
||||||
'AND ' + line_query + ' ' \
|
'AND ' + line_query + ' ' \
|
||||||
'GROUP BY partner_id',
|
'GROUP BY partner_id',
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2']))
|
(self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_scredit(self):
|
def _sum_scredit(self):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
'SELECT CASE WHEN sum(debit) < sum(credit) ' \
|
'SELECT CASE WHEN sum(debit) < sum(credit) ' \
|
||||||
'THEN sum(credit - debit) ' \
|
'THEN sum(credit - debit) ' \
|
||||||
'ELSE 0 ' \
|
'ELSE 0 ' \
|
||||||
'END ' \
|
'END ' \
|
||||||
'FROM account_move_line ' \
|
'FROM account_move_line ' \
|
||||||
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
'WHERE partner_id IN (' + self.partner_ids + ') ' \
|
||||||
'AND account_id IN (' + self.account_ids + ') ' \
|
'AND account_id IN (' + self.account_ids + ') ' \
|
||||||
'AND date >= %s ' \
|
'AND date >= %s ' \
|
||||||
'AND date <= %s ' \
|
'AND date <= %s ' \
|
||||||
'AND ' + line_query + ' ' \
|
'AND ' + line_query + ' ' \
|
||||||
'GROUP BY partner_id',
|
'GROUP BY partner_id',
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2']))
|
(self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _solde_balance_debit(self):
|
def _solde_balance_debit(self):
|
||||||
debit, credit = self._sum_debit(), self._sum_credit()
|
debit, credit = self._sum_debit(), self._sum_credit()
|
||||||
return debit > credit and debit - credit
|
return debit > credit and debit - credit
|
||||||
|
|
||||||
def _solde_balance_credit(self):
|
def _solde_balance_credit(self):
|
||||||
debit, credit = self._sum_debit(), self._sum_credit()
|
debit, credit = self._sum_debit(), self._sum_credit()
|
||||||
return credit > debit and credit - debit
|
return credit > debit and credit - debit
|
||||||
|
|
||||||
def _get_company(self, form):
|
def _get_company(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
||||||
|
|
||||||
def _get_currency(self, form):
|
def _get_currency(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.partner.balance', 'res.partner',
|
report_sxw.report_sxw('report.account.partner.balance', 'res.partner',
|
||||||
'addons/account/report/partner_balance.rml',parser=partner_balance,
|
'addons/account/report/partner_balance.rml',parser=partner_balance,
|
||||||
header=False)
|
header=False)
|
||||||
|
|
||||||
|
|
|
@ -33,85 +33,85 @@ from report import report_sxw
|
||||||
|
|
||||||
class tax_report(report_sxw.rml_parse):
|
class tax_report(report_sxw.rml_parse):
|
||||||
|
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(tax_report, self).__init__(cr, uid, name, context)
|
super(tax_report, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
'get_period': self._get_period,
|
'get_period': self._get_period,
|
||||||
'get_codes': self._get_codes,
|
'get_codes': self._get_codes,
|
||||||
'get_general': self._get_general,
|
'get_general': self._get_general,
|
||||||
'get_company': self._get_company,
|
'get_company': self._get_company,
|
||||||
'get_currency': self._get_currency,
|
'get_currency': self._get_currency,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _add_header(self, node):
|
def _add_header(self, node):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_period(self, period_id):
|
def _get_period(self, period_id):
|
||||||
return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
|
return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
|
||||||
|
|
||||||
def _get_general(self, tax_code_id, period_id, company_id, based_on):
|
def _get_general(self, tax_code_id, period_id, company_id, based_on):
|
||||||
res=[]
|
res=[]
|
||||||
if based_on == 'payments':
|
if based_on == 'payments':
|
||||||
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
||||||
SUM(line.debit) AS debit, \
|
SUM(line.debit) AS debit, \
|
||||||
SUM(line.credit) AS credit, \
|
SUM(line.credit) AS credit, \
|
||||||
COUNT(*) AS count, \
|
COUNT(*) AS count, \
|
||||||
account.id AS account_id \
|
account.id AS account_id \
|
||||||
FROM account_move_line AS line, \
|
FROM account_move_line AS line, \
|
||||||
account_account AS account, \
|
account_account AS account, \
|
||||||
account_move AS move \
|
account_move AS move \
|
||||||
LEFT JOIN account_invoice invoice ON \
|
LEFT JOIN account_invoice invoice ON \
|
||||||
(invoice.move_id = move.id) \
|
(invoice.move_id = move.id) \
|
||||||
WHERE line.state<>%s \
|
WHERE line.state<>%s \
|
||||||
AND line.period_id = %d \
|
AND line.period_id = %d \
|
||||||
AND line.tax_code_id = %d \
|
AND line.tax_code_id = %d \
|
||||||
AND line.account_id = account.id \
|
AND line.account_id = account.id \
|
||||||
AND account.company_id = %d \
|
AND account.company_id = %d \
|
||||||
AND move.id = line.move_id \
|
AND move.id = line.move_id \
|
||||||
AND ((invoice.state = %s) \
|
AND ((invoice.state = %s) \
|
||||||
OR (invoice.id IS NULL)) \
|
OR (invoice.id IS NULL)) \
|
||||||
GROUP BY account.id', ('draft', period_id, tax_code_id,
|
GROUP BY account.id', ('draft', period_id, tax_code_id,
|
||||||
company_id, 'paid'))
|
company_id, 'paid'))
|
||||||
else :
|
else :
|
||||||
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
||||||
SUM(line.debit) AS debit, \
|
SUM(line.debit) AS debit, \
|
||||||
SUM(line.credit) AS credit, \
|
SUM(line.credit) AS credit, \
|
||||||
COUNT(*) AS count, \
|
COUNT(*) AS count, \
|
||||||
account.id AS account_id \
|
account.id AS account_id \
|
||||||
FROM account_move_line AS line, \
|
FROM account_move_line AS line, \
|
||||||
account_account AS account \
|
account_account AS account \
|
||||||
WHERE line.state <> %s \
|
WHERE line.state <> %s \
|
||||||
AND line.period_id = %d \
|
AND line.period_id = %d \
|
||||||
AND line.tax_code_id = %d \
|
AND line.tax_code_id = %d \
|
||||||
AND line.account_id = account.id \
|
AND line.account_id = account.id \
|
||||||
AND account.company_id = %d \
|
AND account.company_id = %d \
|
||||||
AND account.active \
|
AND account.active \
|
||||||
GROUP BY account.id', ('draft', period_id, tax_code_id,
|
GROUP BY account.id', ('draft', period_id, tax_code_id,
|
||||||
company_id))
|
company_id))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
i = 0
|
i = 0
|
||||||
while i<len(res):
|
while i<len(res):
|
||||||
res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
|
res[i]['account'] = self.pool.get('account.account').browse(self.cr, self.uid, res[i]['account_id'])
|
||||||
i+=1
|
i+=1
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_codes(self, period_id, based_on, parent=False, level=0):
|
def _get_codes(self, period_id, based_on, parent=False, level=0):
|
||||||
tc = self.pool.get('account.tax.code')
|
tc = self.pool.get('account.tax.code')
|
||||||
ids = tc.search(self.cr, self.uid, [('parent_id','=',parent)])
|
ids = tc.search(self.cr, self.uid, [('parent_id','=',parent)])
|
||||||
res = []
|
res = []
|
||||||
for code in tc.browse(self.cr, self.uid, ids, {'period_id': period_id,
|
for code in tc.browse(self.cr, self.uid, ids, {'period_id': period_id,
|
||||||
'based_on': based_on}):
|
'based_on': based_on}):
|
||||||
res.append((' - '*level*2, code))
|
res.append((' - '*level*2, code))
|
||||||
res += self._get_codes(period_id, based_on, code.id, level+1)
|
res += self._get_codes(period_id, based_on, code.id, level+1)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_company(self, form):
|
def _get_company(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
||||||
|
|
||||||
def _get_currency(self, form):
|
def _get_currency(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
|
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
|
||||||
'addons/account/report/tax_report.rml', parser=tax_report, header=False)
|
'addons/account/report/tax_report.rml', parser=tax_report, header=False)
|
||||||
|
|
||||||
|
|
|
@ -32,147 +32,147 @@ import time
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class third_party_ledger(report_sxw.rml_parse):
|
class third_party_ledger(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(third_party_ledger, self).__init__(cr, uid, name, context)
|
super(third_party_ledger, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
'lines': self.lines,
|
'lines': self.lines,
|
||||||
'sum_debit_partner': self._sum_debit_partner,
|
'sum_debit_partner': self._sum_debit_partner,
|
||||||
'sum_credit_partner': self._sum_credit_partner,
|
'sum_credit_partner': self._sum_credit_partner,
|
||||||
'sum_debit': self._sum_debit,
|
'sum_debit': self._sum_debit,
|
||||||
'sum_credit': self._sum_credit,
|
'sum_credit': self._sum_credit,
|
||||||
'get_company': self._get_company,
|
'get_company': self._get_company,
|
||||||
'get_currency': self._get_currency,
|
'get_currency': self._get_currency,
|
||||||
})
|
})
|
||||||
|
|
||||||
def preprocess(self, objects, data, ids):
|
def preprocess(self, objects, data, ids):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
|
||||||
context={'fiscalyear': data['form']['fiscalyear']})
|
context={'fiscalyear': data['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT DISTINCT line.partner_id " \
|
"SELECT DISTINCT line.partner_id " \
|
||||||
"FROM account_move_line AS line, account_account AS account " \
|
"FROM account_move_line AS line, account_account AS account " \
|
||||||
"WHERE line.partner_id IS NOT NULL " \
|
"WHERE line.partner_id IS NOT NULL " \
|
||||||
"AND line.date >= %s " \
|
"AND line.date >= %s " \
|
||||||
"AND line.date <= %s " \
|
"AND line.date <= %s " \
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"AND line.account_id = account.id " \
|
"AND line.account_id = account.id " \
|
||||||
"AND account.company_id = %d " \
|
"AND account.company_id = %d " \
|
||||||
"AND account.active",
|
"AND account.active",
|
||||||
(data['form']['date1'], data['form']['date2'],
|
(data['form']['date1'], data['form']['date2'],
|
||||||
data['form']['company_id']))
|
data['form']['company_id']))
|
||||||
new_ids = [id for (id,) in self.cr.fetchall()]
|
new_ids = [id for (id,) in self.cr.fetchall()]
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT a.id " \
|
"SELECT a.id " \
|
||||||
"FROM account_account a " \
|
"FROM account_account a " \
|
||||||
"LEFT JOIN account_account_type t " \
|
"LEFT JOIN account_account_type t " \
|
||||||
"ON (a.type=t.code) " \
|
"ON (a.type=t.code) " \
|
||||||
"WHERE t.partner_account=TRUE " \
|
"WHERE t.partner_account=TRUE " \
|
||||||
"AND a.company_id = %d " \
|
"AND a.company_id = %d " \
|
||||||
"AND a.active", (data['form']['company_id'],))
|
"AND a.active", (data['form']['company_id'],))
|
||||||
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
|
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
|
||||||
self.partner_ids = ','.join(map(str, new_ids))
|
self.partner_ids = ','.join(map(str, new_ids))
|
||||||
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
|
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
|
||||||
super(third_party_ledger, self).preprocess(objects, data, new_ids)
|
super(third_party_ledger, self).preprocess(objects, data, new_ids)
|
||||||
|
|
||||||
def lines(self, partner):
|
def lines(self, partner):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
|
line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit " \
|
"SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit " \
|
||||||
"FROM account_move_line l " \
|
"FROM account_move_line l " \
|
||||||
"LEFT JOIN account_journal j " \
|
"LEFT JOIN account_journal j " \
|
||||||
"ON (l.journal_id = j.id) " \
|
"ON (l.journal_id = j.id) " \
|
||||||
"WHERE l.partner_id = %d " \
|
"WHERE l.partner_id = %d " \
|
||||||
"AND l.account_id IN (" + self.account_ids + ") " \
|
"AND l.account_id IN (" + self.account_ids + ") " \
|
||||||
"AND l.date >= %s " \
|
"AND l.date >= %s " \
|
||||||
"AND l.date <= %s "
|
"AND l.date <= %s "
|
||||||
"AND " + line_query + " " \
|
"AND " + line_query + " " \
|
||||||
"ORDER BY l.id",
|
"ORDER BY l.id",
|
||||||
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
|
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
sum = 0.0
|
sum = 0.0
|
||||||
for r in res:
|
for r in res:
|
||||||
sum += r['debit'] - r['credit']
|
sum += r['debit'] - r['credit']
|
||||||
r['progress'] = sum
|
r['progress'] = sum
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _sum_debit_partner(self, partner):
|
def _sum_debit_partner(self, partner):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT sum(debit) " \
|
"SELECT sum(debit) " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE partner_id = %d " \
|
"WHERE partner_id = %d " \
|
||||||
"AND account_id IN (" + self.account_ids + ") " \
|
"AND account_id IN (" + self.account_ids + ") " \
|
||||||
"AND date >= %s " \
|
"AND date >= %s " \
|
||||||
"AND date <= %s " \
|
"AND date <= %s " \
|
||||||
"AND " + line_query,
|
"AND " + line_query,
|
||||||
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
|
(partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit_partner(self, partner):
|
def _sum_credit_partner(self, partner):
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT sum(credit) " \
|
"SELECT sum(credit) " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE partner_id=%d " \
|
"WHERE partner_id=%d " \
|
||||||
"AND account_id IN (" + self.account_ids + ") " \
|
"AND account_id IN (" + self.account_ids + ") " \
|
||||||
"AND date >= %s " \
|
"AND date >= %s " \
|
||||||
"AND date <= %s " \
|
"AND date <= %s " \
|
||||||
"AND " + line_query,
|
"AND " + line_query,
|
||||||
(partner.id, self.datas["form"]["date1"], self.datas["form"]["date2"]))
|
(partner.id, self.datas["form"]["date1"], self.datas["form"]["date2"]))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_debit(self):
|
def _sum_debit(self):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT sum(debit) " \
|
"SELECT sum(debit) " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
||||||
"AND account_id IN (" + self.account_ids + ") " \
|
"AND account_id IN (" + self.account_ids + ") " \
|
||||||
"AND date >= %s " \
|
"AND date >= %s " \
|
||||||
"AND date <= %s " \
|
"AND date <= %s " \
|
||||||
"AND " + line_query,
|
"AND " + line_query,
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2']))
|
(self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self):
|
def _sum_credit(self):
|
||||||
if not self.ids:
|
if not self.ids:
|
||||||
return 0.0
|
return 0.0
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
line_query = account_move_line_obj._query_get(self.cr, self.uid,
|
||||||
obj='account_move_line',
|
obj='account_move_line',
|
||||||
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
context={'fiscalyear': self.datas['form']['fiscalyear']})
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT sum(credit) " \
|
"SELECT sum(credit) " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
"WHERE partner_id IN (" + self.partner_ids + ") " \
|
||||||
"AND account_id IN (" + self.account_ids + ") " \
|
"AND account_id IN (" + self.account_ids + ") " \
|
||||||
"AND date >= %s " \
|
"AND date >= %s " \
|
||||||
"AND date <= %s " \
|
"AND date <= %s " \
|
||||||
"AND " + line_query,
|
"AND " + line_query,
|
||||||
(self.datas['form']['date1'], self.datas['form']['date2']))
|
(self.datas['form']['date1'], self.datas['form']['date2']))
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _get_company(self, form):
|
def _get_company(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
|
||||||
|
|
||||||
def _get_currency(self, form):
|
def _get_currency(self, form):
|
||||||
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner',
|
report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner',
|
||||||
'addons/account/report/third_party_ledger.rml',parser=third_party_ledger,
|
'addons/account/report/third_party_ledger.rml',parser=third_party_ledger,
|
||||||
header=False)
|
header=False)
|
||||||
|
|
||||||
|
|
|
@ -32,35 +32,35 @@ import pooler
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="fiscalyear" colspan="4"/>
|
<field name="fiscalyear" colspan="4"/>
|
||||||
<field name="periods" colspan="4"/>
|
<field name="periods" colspan="4"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
'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'},
|
||||||
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
|
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
def _get_defaults(self, cr, uid, data, context):
|
def _get_defaults(self, cr, uid, data, context):
|
||||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||||
data['form']['target_move'] = False
|
data['form']['target_move'] = False
|
||||||
if context.has_key('target_move'):
|
if context.has_key('target_move'):
|
||||||
data['form']['target_move'] = context['target_move']
|
data['form']['target_move'] = context['target_move']
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_defaults],
|
'actions': [_get_defaults],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.account.balance', 'state':'end'}
|
'result': {'type':'print', 'report':'account.account.balance', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.account.balance.report')
|
wizard_report('account.account.balance.report')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,52 +31,52 @@ import wizard
|
||||||
import pooler
|
import pooler
|
||||||
|
|
||||||
class wizard_account_chart(wizard.interface):
|
class wizard_account_chart(wizard.interface):
|
||||||
_account_chart_arch = '''<?xml version="1.0"?>
|
_account_chart_arch = '''<?xml version="1.0"?>
|
||||||
<form string="Account charts">
|
<form string="Account charts">
|
||||||
<field name="fiscalyear"/>
|
<field name="fiscalyear"/>
|
||||||
<field name="target_move"/>
|
<field name="target_move"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_account_chart_fields = {
|
_account_chart_fields = {
|
||||||
'fiscalyear': {
|
'fiscalyear': {
|
||||||
'string': 'Fiscal year',
|
'string': 'Fiscal year',
|
||||||
'type': 'many2one',
|
'type': 'many2one',
|
||||||
'relation': 'account.fiscalyear',
|
'relation': 'account.fiscalyear',
|
||||||
'help': 'Keep empty for all open fiscal year',
|
'help': 'Keep empty for all open fiscal year',
|
||||||
},
|
},
|
||||||
'target_move': {
|
'target_move': {
|
||||||
'string': 'Target Moves',
|
'string': 'Target Moves',
|
||||||
'type': 'selection',
|
'type': 'selection',
|
||||||
'selection': [('all','All Entries'),('posted_only','All Posted Entries')],
|
'selection': [('all','All Entries'),('posted_only','All Posted Entries')],
|
||||||
'required': True,
|
'required': True,
|
||||||
'default': lambda *a:"all",
|
'default': lambda *a:"all",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_defaults(self, cr, uid, data, context):
|
def _get_defaults(self, cr, uid, data, context):
|
||||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
|
|
||||||
def _account_chart_open_window(self, cr, uid, data, context):
|
def _account_chart_open_window(self, cr, uid, data, context):
|
||||||
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
||||||
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
||||||
|
|
||||||
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
|
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
|
||||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||||
result = act_obj.read(cr, uid, [id])[0]
|
result = act_obj.read(cr, uid, [id])[0]
|
||||||
result['context'] = str({'fiscalyear': data['form']['fiscalyear'],'target_move':data['form']['target_move']})
|
result['context'] = str({'fiscalyear': data['form']['fiscalyear'],'target_move':data['form']['target_move']})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_defaults],
|
'actions': [_get_defaults],
|
||||||
'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel'), ('open', 'Open Charts')]}
|
'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel'), ('open', 'Open Charts')]}
|
||||||
},
|
},
|
||||||
'open': {
|
'open': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action':_account_chart_open_window, 'state':'end'}
|
'result': {'type': 'action', 'action':_account_chart_open_window, 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_account_chart('account.chart')
|
wizard_account_chart('account.chart')
|
||||||
|
|
|
@ -32,27 +32,27 @@ import pooler
|
||||||
|
|
||||||
duplicate_form = '''<?xml version="1.0"?>
|
duplicate_form = '''<?xml version="1.0"?>
|
||||||
<form string="Duplicate account charts">
|
<form string="Duplicate account charts">
|
||||||
<field name="company_id"/>
|
<field name="company_id"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
duplicate_fields = {
|
duplicate_fields = {
|
||||||
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _do_duplicate(self, cr, uid, data, context):
|
def _do_duplicate(self, cr, uid, data, context):
|
||||||
account_obj = pooler.get_pool(cr.dbname).get('account.account')
|
account_obj = pooler.get_pool(cr.dbname).get('account.account')
|
||||||
account_obj.copy(cr, uid, data['id'], data['form'], context=context)
|
account_obj.copy(cr, uid, data['id'], data['form'], context=context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wizard_account_duplicate(wizard.interface):
|
class wizard_account_duplicate(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': duplicate_form, 'fields': duplicate_fields, 'state': (('end', 'Cancel'), ('duplicate', 'Duplicate'))},
|
'result': {'type': 'form', 'arch': duplicate_form, 'fields': duplicate_fields, 'state': (('end', 'Cancel'), ('duplicate', 'Duplicate'))},
|
||||||
},
|
},
|
||||||
'duplicate': {
|
'duplicate': {
|
||||||
'actions': [_do_duplicate],
|
'actions': [_do_duplicate],
|
||||||
'result': {'type': 'state', 'state': 'end'},
|
'result': {'type': 'state', 'state': 'end'},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
wizard_account_duplicate('account.wizard.account.duplicate')
|
wizard_account_duplicate('account.wizard.account.duplicate')
|
||||||
|
|
|
@ -37,67 +37,67 @@ from tools.translate import _
|
||||||
|
|
||||||
_aged_trial_form = """<?xml version="1.0"?>
|
_aged_trial_form = """<?xml version="1.0"?>
|
||||||
<form string="Aged Trial Balance">
|
<form string="Aged Trial Balance">
|
||||||
<field name="company_id"/>
|
<field name="company_id"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="fiscalyear"/>
|
<field name="fiscalyear"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="period_length"/>
|
<field name="period_length"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="sorting_on"/>
|
<field name="sorting_on"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="computation"/>
|
<field name="computation"/>
|
||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
_aged_trial_fields = {
|
_aged_trial_fields = {
|
||||||
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
||||||
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
'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'},
|
||||||
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
|
'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
|
||||||
'sorting_on':{'string': 'Sorting On', 'type': 'selection', 'selection': [('partner','By Partner Name (asc)'), ('amount','By Amount (desc)')],'required': True, 'default': lambda *a:'partner'},
|
'sorting_on':{'string': 'Sorting On', 'type': 'selection', 'selection': [('partner','By Partner Name (asc)'), ('amount','By Amount (desc)')],'required': True, 'default': lambda *a:'partner'},
|
||||||
'computation':{'string': 'Computational Method', 'type': 'selection', 'selection': [("\'receivable\'",'On Receivables Only'), ("\'payable\'",'On Payables Only'), ("\'receivable\',\'payable\'",'On Receivables & Payables')], 'required': True, 'default': lambda *a:"\'receivable\'"}
|
'computation':{'string': 'Computational Method', 'type': 'selection', 'selection': [("\'receivable\'",'On Receivables Only'), ("\'payable\'",'On Payables Only'), ("\'receivable\',\'payable\'",'On Receivables & Payables')], 'required': True, 'default': lambda *a:"\'receivable\'"}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _calc_dates(self, cr, uid, data, context):
|
def _calc_dates(self, cr, uid, data, context):
|
||||||
res = {}
|
res = {}
|
||||||
period_length = data['form']['period_length']
|
period_length = data['form']['period_length']
|
||||||
if period_length<=0:
|
if period_length<=0:
|
||||||
raise wizard.except_wizard(_('UserError'), _('You must enter a period length that cannot be 0 or below !'))
|
raise wizard.except_wizard(_('UserError'), _('You must enter a period length that cannot be 0 or below !'))
|
||||||
start = now()
|
start = now()
|
||||||
for i in range(5)[::-1]:
|
for i in range(5)[::-1]:
|
||||||
stop = start-RelativeDateTime(days=period_length)
|
stop = start-RelativeDateTime(days=period_length)
|
||||||
res[str(i)] = {
|
res[str(i)] = {
|
||||||
'name' : str((5-i)*period_length)+' days',
|
'name' : str((5-i)*period_length)+' days',
|
||||||
'stop': start.strftime('%Y-%m-%d'),
|
'stop': start.strftime('%Y-%m-%d'),
|
||||||
'start' : stop.strftime('%Y-%m-%d'),
|
'start' : stop.strftime('%Y-%m-%d'),
|
||||||
}
|
}
|
||||||
start = stop - RelativeDateTime(days=1)
|
start = stop - RelativeDateTime(days=1)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
def _get_defaults(self, cr, uid, data, context):
|
def _get_defaults(self, cr, uid, data, context):
|
||||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||||
|
|
||||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
||||||
if user.company_id:
|
if user.company_id:
|
||||||
company_id = user.company_id.id
|
company_id = user.company_id.id
|
||||||
else:
|
else:
|
||||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||||
data['form']['company_id'] = company_id
|
data['form']['company_id'] = company_id
|
||||||
|
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_defaults],
|
'actions': [_get_defaults],
|
||||||
'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Partner Balance')]},
|
'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Partner Balance')]},
|
||||||
},
|
},
|
||||||
'print': {
|
'print': {
|
||||||
'actions': [_calc_dates],
|
'actions': [_calc_dates],
|
||||||
'result': {'type':'print', 'report':'account.aged.trial.balance', 'state':'end'},
|
'result': {'type':'print', 'report':'account.aged.trial.balance', 'state':'end'},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard_report('account.aged.trial.balance')
|
wizard_report('account.aged.trial.balance')
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,11 @@ import time
|
||||||
# - journal
|
# - journal
|
||||||
# - compte d'ajustement
|
# - compte d'ajustement
|
||||||
# - montant max (0,03)
|
# - montant max (0,03)
|
||||||
# <field name="max_amount"/>
|
# <field name="max_amount"/>
|
||||||
# - libelle write-off
|
# - libelle write-off
|
||||||
# - devise principale ou secondaire
|
# - devise principale ou secondaire
|
||||||
# devise secondaire = amount_currency
|
# devise secondaire = amount_currency
|
||||||
# si devise: pas prendre ceux avec montant_devise = 0
|
# si devise: pas prendre ceux avec montant_devise = 0
|
||||||
|
|
||||||
# a demander à fabien:
|
# a demander à fabien:
|
||||||
# - checkbox (comme ds sage) "lettrage rapide des comptes soldés"?
|
# - checkbox (comme ds sage) "lettrage rapide des comptes soldés"?
|
||||||
|
@ -54,273 +54,273 @@ import time
|
||||||
|
|
||||||
_reconcile_form = '''<?xml version="1.0"?>
|
_reconcile_form = '''<?xml version="1.0"?>
|
||||||
<form string="Reconciliation">
|
<form string="Reconciliation">
|
||||||
<separator string="Options" colspan="4"/>
|
<separator string="Options" colspan="4"/>
|
||||||
<field name="account_ids" colspan="4" domain="[('reconcile','=',1)]" views="account.view_account_list">
|
<field name="account_ids" colspan="4" domain="[('reconcile','=',1)]" views="account.view_account_list">
|
||||||
</field>
|
</field>
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
<field name="power"/>
|
<field name="power"/>
|
||||||
<separator string="Write-Off Move" colspan="4"/>
|
<separator string="Write-Off Move" colspan="4"/>
|
||||||
<field name="max_amount"/>
|
<field name="max_amount"/>
|
||||||
<field name="writeoff_acc_id"/>
|
<field name="writeoff_acc_id"/>
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
<field name="period_id"/>
|
<field name="period_id"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_reconcile_fields = {
|
_reconcile_fields = {
|
||||||
'account_ids': {
|
'account_ids': {
|
||||||
'string': 'Account to reconcile',
|
'string': 'Account to reconcile',
|
||||||
'type': 'many2many',
|
'type': 'many2many',
|
||||||
'relation': 'account.account',
|
'relation': 'account.account',
|
||||||
'domain': [('reconcile','=',1)],
|
'domain': [('reconcile','=',1)],
|
||||||
'required': True
|
'required': True
|
||||||
},
|
},
|
||||||
'writeoff_acc_id': {
|
'writeoff_acc_id': {
|
||||||
'string': 'Account',
|
'string': 'Account',
|
||||||
'type': 'many2one',
|
'type': 'many2one',
|
||||||
'relation': 'account.account',
|
'relation': 'account.account',
|
||||||
'required': True
|
'required': True
|
||||||
},
|
},
|
||||||
'journal_id': {
|
'journal_id': {
|
||||||
'string': 'Journal',
|
'string': 'Journal',
|
||||||
'type': 'many2one',
|
'type': 'many2one',
|
||||||
'relation': 'account.journal',
|
'relation': 'account.journal',
|
||||||
'required': True
|
'required': True
|
||||||
},
|
},
|
||||||
'period_id': {
|
'period_id': {
|
||||||
'string': 'Period',
|
'string': 'Period',
|
||||||
'type': 'many2one',
|
'type': 'many2one',
|
||||||
'relation': 'account.period',
|
'relation': 'account.period',
|
||||||
'required': True
|
'required': True
|
||||||
},
|
},
|
||||||
'max_amount': {
|
'max_amount': {
|
||||||
'string': 'Maximum write-off amount',
|
'string': 'Maximum write-off amount',
|
||||||
'type': 'float',
|
'type': 'float',
|
||||||
},
|
},
|
||||||
#'currency': {
|
#'currency': {
|
||||||
# 'string': 'Reconcile in',
|
# 'string': 'Reconcile in',
|
||||||
# 'type': 'selection',
|
# 'type': 'selection',
|
||||||
# 'selection': [('current','current currency'), ('secondary','secondary currency')],
|
# 'selection': [('current','current currency'), ('secondary','secondary currency')],
|
||||||
# 'required': True
|
# 'required': True
|
||||||
#},
|
#},
|
||||||
'power': {
|
'power': {
|
||||||
'string': 'Power',
|
'string': 'Power',
|
||||||
'type': 'selection',
|
'type': 'selection',
|
||||||
'selection': [(p,str(p)) for p in range(2, 10)],
|
'selection': [(p,str(p)) for p in range(2, 10)],
|
||||||
'required': True
|
'required': True
|
||||||
},
|
},
|
||||||
'date1': {
|
'date1': {
|
||||||
'string': 'Start of period',
|
'string': 'Start of period',
|
||||||
'type': 'date',
|
'type': 'date',
|
||||||
'required': True,
|
'required': True,
|
||||||
'default': lambda *a: time.strftime('%Y-01-01')
|
'default': lambda *a: time.strftime('%Y-01-01')
|
||||||
},
|
},
|
||||||
'date2': {
|
'date2': {
|
||||||
'string': 'End of period',
|
'string': 'End of period',
|
||||||
'type': 'date',
|
'type': 'date',
|
||||||
'required': True,
|
'required': True,
|
||||||
'default': lambda *a: time.strftime('%Y-%m-%d')
|
'default': lambda *a: time.strftime('%Y-%m-%d')
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_result_form = '''<?xml version="1.0"?>
|
_result_form = '''<?xml version="1.0"?>
|
||||||
<form string="Reconciliation result">
|
<form string="Reconciliation result">
|
||||||
<field name="reconciled"/>
|
<field name="reconciled"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="unreconciled"/>
|
<field name="unreconciled"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_result_fields = {
|
_result_fields = {
|
||||||
'reconciled': {
|
'reconciled': {
|
||||||
'string': 'Reconciled transactions',
|
'string': 'Reconciled transactions',
|
||||||
'type': 'integer',
|
'type': 'integer',
|
||||||
'readonly': True
|
'readonly': True
|
||||||
},
|
},
|
||||||
'unreconciled': {
|
'unreconciled': {
|
||||||
'string': 'Not reconciled transactions',
|
'string': 'Not reconciled transactions',
|
||||||
'type': 'integer',
|
'type': 'integer',
|
||||||
'readonly': True
|
'readonly': True
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#TODO: cleanup and comment this code... For now, it is awfulllll
|
#TODO: cleanup and comment this code... For now, it is awfulllll
|
||||||
# (way too complex, and really slow)...
|
# (way too complex, and really slow)...
|
||||||
def do_reconcile(cr, uid, credits, debits, max_amount, power, writeoff_acc_id, period_id, journal_id, context={}):
|
def do_reconcile(cr, uid, credits, debits, max_amount, power, writeoff_acc_id, period_id, journal_id, context={}):
|
||||||
# for one value of a credit, check all debits, and combination of them
|
# for one value of a credit, check all debits, and combination of them
|
||||||
# depending on the power. It starts with a power of one and goes up
|
# depending on the power. It starts with a power of one and goes up
|
||||||
# to the max power allowed
|
# to the max power allowed
|
||||||
def check2(value, move_list, power):
|
def check2(value, move_list, power):
|
||||||
def check(value, move_list, power):
|
def check(value, move_list, power):
|
||||||
for i in range(len(move_list)):
|
for i in range(len(move_list)):
|
||||||
move = move_list[i]
|
move = move_list[i]
|
||||||
if power == 1:
|
if power == 1:
|
||||||
if abs(value - move[1]) <= max_amount + 0.00001:
|
if abs(value - move[1]) <= max_amount + 0.00001:
|
||||||
return [move[0]]
|
return [move[0]]
|
||||||
else:
|
else:
|
||||||
del move_list[i]
|
del move_list[i]
|
||||||
res = check(value - move[1], move_list, power-1)
|
res = check(value - move[1], move_list, power-1)
|
||||||
move_list[i:i] = [move]
|
move_list[i:i] = [move]
|
||||||
if res:
|
if res:
|
||||||
res.append(move[0])
|
res.append(move[0])
|
||||||
return res
|
return res
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for p in range(1, power+1):
|
for p in range(1, power+1):
|
||||||
res = check(value, move_list, p)
|
res = check(value, move_list, p)
|
||||||
if res:
|
if res:
|
||||||
return res
|
return res
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# for a list of credit and debit and a given power, check if there
|
# for a list of credit and debit and a given power, check if there
|
||||||
# are matching tuples of credit and debits, check all debits, and combination of them
|
# are matching tuples of credit and debits, check all debits, and combination of them
|
||||||
# depending on the power. It starts with a power of one and goes up
|
# depending on the power. It starts with a power of one and goes up
|
||||||
# to the max power allowed
|
# to the max power allowed
|
||||||
def check4(list1, list2, power):
|
def check4(list1, list2, power):
|
||||||
def check3(value, list1, list2, list1power, power):
|
def check3(value, list1, list2, list1power, power):
|
||||||
for i in range(len(list1)):
|
for i in range(len(list1)):
|
||||||
move = list1[i]
|
move = list1[i]
|
||||||
if list1power == 1:
|
if list1power == 1:
|
||||||
res = check2(value + move[1], list2, power - 1)
|
res = check2(value + move[1], list2, power - 1)
|
||||||
if res:
|
if res:
|
||||||
return ([move[0]], res)
|
return ([move[0]], res)
|
||||||
else:
|
else:
|
||||||
del list1[i]
|
del list1[i]
|
||||||
res = check3(value + move[1], list1, list2, list1power-1, power-1)
|
res = check3(value + move[1], list1, list2, list1power-1, power-1)
|
||||||
list1[i:i] = [move]
|
list1[i:i] = [move]
|
||||||
if res:
|
if res:
|
||||||
x, y = res
|
x, y = res
|
||||||
x.append(move[0])
|
x.append(move[0])
|
||||||
return (x, y)
|
return (x, y)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for p in range(1, power):
|
for p in range(1, power):
|
||||||
res = check3(0, list1, list2, p, power)
|
res = check3(0, list1, list2, p, power)
|
||||||
if res:
|
if res:
|
||||||
return res
|
return res
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check5(list1, list2, max_power):
|
def check5(list1, list2, max_power):
|
||||||
for p in range(2, max_power+1):
|
for p in range(2, max_power+1):
|
||||||
res = check4(list1, list2, p)
|
res = check4(list1, list2, p)
|
||||||
if res:
|
if res:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
ok = True
|
ok = True
|
||||||
reconciled = 0
|
reconciled = 0
|
||||||
move_line_obj = pooler.get_pool(cr.dbname).get('account.move.line')
|
move_line_obj = pooler.get_pool(cr.dbname).get('account.move.line')
|
||||||
while credits and debits and ok:
|
while credits and debits and ok:
|
||||||
res = check5(credits, debits, power)
|
res = check5(credits, debits, power)
|
||||||
if res:
|
if res:
|
||||||
move_line_obj.reconcile(cr, uid, res[0] + res[1], 'auto', writeoff_acc_id, period_id, journal_id, context)
|
move_line_obj.reconcile(cr, uid, res[0] + res[1], 'auto', writeoff_acc_id, period_id, journal_id, context)
|
||||||
reconciled += len(res[0]) + len(res[1])
|
reconciled += len(res[0]) + len(res[1])
|
||||||
credits = [(id, credit) for (id, credit) in credits if id not in res[0]]
|
credits = [(id, credit) for (id, credit) in credits if id not in res[0]]
|
||||||
debits = [(id, debit) for (id, debit) in debits if id not in res[1]]
|
debits = [(id, debit) for (id, debit) in debits if id not in res[1]]
|
||||||
else:
|
else:
|
||||||
ok = False
|
ok = False
|
||||||
return (reconciled, len(credits)+len(debits))
|
return (reconciled, len(credits)+len(debits))
|
||||||
|
|
||||||
def _reconcile(self, cr, uid, data, context):
|
def _reconcile(self, cr, uid, data, context):
|
||||||
service = netsvc.LocalService("object_proxy")
|
service = netsvc.LocalService("object_proxy")
|
||||||
move_line_obj = pooler.get_pool(cr.dbname).get('account.move.line')
|
move_line_obj = pooler.get_pool(cr.dbname).get('account.move.line')
|
||||||
form = data['form']
|
form = data['form']
|
||||||
max_amount = form.get('max_amount', 0.0)
|
max_amount = form.get('max_amount', 0.0)
|
||||||
power = form['power']
|
power = form['power']
|
||||||
reconciled = unreconciled = 0
|
reconciled = unreconciled = 0
|
||||||
if not form['account_ids']:
|
if not form['account_ids']:
|
||||||
return {'reconciled':0, 'unreconciled':[0]}
|
return {'reconciled':0, 'unreconciled':[0]}
|
||||||
for account_id in form['account_ids'][0][2]:
|
for account_id in form['account_ids'][0][2]:
|
||||||
|
|
||||||
# reconcile automatically all transactions from partners whose balance is 0
|
# reconcile automatically all transactions from partners whose balance is 0
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT partner_id " \
|
"SELECT partner_id " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE account_id=%d " \
|
"WHERE account_id=%d " \
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND state <> 'draft' " \
|
"AND state <> 'draft' " \
|
||||||
"GROUP BY partner_id " \
|
"GROUP BY partner_id " \
|
||||||
"HAVING ABS(SUM(debit-credit)) < %f AND count(*)>0",
|
"HAVING ABS(SUM(debit-credit)) < %f AND count(*)>0",
|
||||||
(account_id, max_amount))
|
(account_id, max_amount))
|
||||||
partner_ids = [id for (id,) in cr.fetchall()]
|
partner_ids = [id for (id,) in cr.fetchall()]
|
||||||
|
|
||||||
for partner_id in partner_ids:
|
for partner_id in partner_ids:
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT id " \
|
"SELECT id " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE account_id=%d " \
|
"WHERE account_id=%d " \
|
||||||
"AND partner_id=%d " \
|
"AND partner_id=%d " \
|
||||||
"AND state <> 'draft' " \
|
"AND state <> 'draft' " \
|
||||||
"AND reconcile_id IS NULL",
|
"AND reconcile_id IS NULL",
|
||||||
(account_id, partner_id))
|
(account_id, partner_id))
|
||||||
line_ids = [id for (id,) in cr.fetchall()]
|
line_ids = [id for (id,) in cr.fetchall()]
|
||||||
|
|
||||||
if len(line_ids):
|
if len(line_ids):
|
||||||
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
|
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
|
||||||
reconciled += len(line_ids)
|
reconciled += len(line_ids)
|
||||||
|
|
||||||
# get the list of partners who have more than one unreconciled transaction
|
# get the list of partners who have more than one unreconciled transaction
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT partner_id " \
|
"SELECT partner_id " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE account_id=%d " \
|
"WHERE account_id=%d " \
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND state <> 'draft' " \
|
"AND state <> 'draft' " \
|
||||||
"GROUP BY partner_id " \
|
"GROUP BY partner_id " \
|
||||||
"HAVING count(*)>1",
|
"HAVING count(*)>1",
|
||||||
(account_id,))
|
(account_id,))
|
||||||
partner_ids = [id for (id,) in cr.fetchall()]
|
partner_ids = [id for (id,) in cr.fetchall()]
|
||||||
#filter?
|
#filter?
|
||||||
for partner_id in partner_ids:
|
for partner_id in partner_ids:
|
||||||
# get the list of unreconciled 'debit transactions' for this partner
|
# get the list of unreconciled 'debit transactions' for this partner
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT id, debit " \
|
"SELECT id, debit " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE account_id=%d " \
|
"WHERE account_id=%d " \
|
||||||
"AND partner_id=%d " \
|
"AND partner_id=%d " \
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND state <> 'draft' " \
|
"AND state <> 'draft' " \
|
||||||
"AND debit > 0",
|
"AND debit > 0",
|
||||||
(account_id, partner_id))
|
(account_id, partner_id))
|
||||||
debits = cr.fetchall()
|
debits = cr.fetchall()
|
||||||
|
|
||||||
# get the list of unreconciled 'credit transactions' for this partner
|
# get the list of unreconciled 'credit transactions' for this partner
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT id, credit " \
|
"SELECT id, credit " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE account_id=%d " \
|
"WHERE account_id=%d " \
|
||||||
"AND partner_id=%d " \
|
"AND partner_id=%d " \
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND state <> 'draft' " \
|
"AND state <> 'draft' " \
|
||||||
"AND credit > 0",
|
"AND credit > 0",
|
||||||
(account_id, partner_id))
|
(account_id, partner_id))
|
||||||
credits = cr.fetchall()
|
credits = cr.fetchall()
|
||||||
|
|
||||||
(rec, unrec) = do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
|
(rec, unrec) = do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
|
||||||
reconciled += rec
|
reconciled += rec
|
||||||
unreconciled += unrec
|
unreconciled += unrec
|
||||||
|
|
||||||
# add the number of transactions for partners who have only one
|
# add the number of transactions for partners who have only one
|
||||||
# unreconciled transactions to the unreconciled count
|
# unreconciled transactions to the unreconciled count
|
||||||
partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or ''
|
partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or ''
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT count(*) " \
|
"SELECT count(*) " \
|
||||||
"FROM account_move_line " \
|
"FROM account_move_line " \
|
||||||
"WHERE account_id=%d " \
|
"WHERE account_id=%d " \
|
||||||
"AND reconcile_id IS NULL " \
|
"AND reconcile_id IS NULL " \
|
||||||
"AND state <> 'draft' " + partner_filter,
|
"AND state <> 'draft' " + partner_filter,
|
||||||
(account_id,))
|
(account_id,))
|
||||||
additional_unrec = cr.fetchone()[0]
|
additional_unrec = cr.fetchone()[0]
|
||||||
return {'reconciled':reconciled, 'unreconciled':unreconciled+additional_unrec}
|
return {'reconciled':reconciled, 'unreconciled':unreconciled+additional_unrec}
|
||||||
|
|
||||||
class wiz_reconcile(wizard.interface):
|
class wiz_reconcile(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':_reconcile_form, 'fields':_reconcile_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
|
'result': {'type':'form', 'arch':_reconcile_form, 'fields':_reconcile_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
|
||||||
},
|
},
|
||||||
'reconcile': {
|
'reconcile': {
|
||||||
'actions': [_reconcile],
|
'actions': [_reconcile],
|
||||||
'result': {'type':'form', 'arch':_result_form, 'fields':_result_fields, 'state':[('end','OK')]}
|
'result': {'type':'form', 'arch':_result_form, 'fields':_result_fields, 'state':[('end','OK')]}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_reconcile('account.automatic.reconcile')
|
wiz_reconcile('account.automatic.reconcile')
|
||||||
|
|
||||||
|
|
|
@ -32,40 +32,40 @@ from tools.translate import _
|
||||||
|
|
||||||
_journal_form = '''<?xml version="1.0"?>
|
_journal_form = '''<?xml version="1.0"?>
|
||||||
<form string="%s">
|
<form string="%s">
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
</form>''' % ('Bank reconciliation',)
|
</form>''' % ('Bank reconciliation',)
|
||||||
|
|
||||||
_journal_fields = {
|
_journal_fields = {
|
||||||
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _action_open_window(self, cr, uid, data, context):
|
def _action_open_window(self, cr, uid, data, context):
|
||||||
form = data['form']
|
form = data['form']
|
||||||
cr.execute('select default_credit_account_id from account_journal where id=%d', (form['journal_id'],))
|
cr.execute('select default_credit_account_id from account_journal where id=%d', (form['journal_id'],))
|
||||||
account_id = cr.fetchone()[0]
|
account_id = cr.fetchone()[0]
|
||||||
if not account_id:
|
if not account_id:
|
||||||
raise Exception, _('You have to define the bank account\nin the journal definition for reconciliation.')
|
raise Exception, _('You have to define the bank account\nin the journal definition for reconciliation.')
|
||||||
return {
|
return {
|
||||||
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id),
|
'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id),
|
||||||
'name': 'Saisie Standard',
|
'name': 'Saisie Standard',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'res_model': 'account.move.line',
|
'res_model': 'account.move.line',
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'context': "{'journal_id':%d}" % (form['journal_id'],),
|
'context': "{'journal_id':%d}" % (form['journal_id'],),
|
||||||
'type': 'ir.actions.act_window'
|
'type': 'ir.actions.act_window'
|
||||||
}
|
}
|
||||||
|
|
||||||
class wiz_journal(wizard.interface):
|
class wiz_journal(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for bank reconciliation')]}
|
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for bank reconciliation')]}
|
||||||
},
|
},
|
||||||
'open': {
|
'open': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_journal('account.move.bank.reconcile')
|
wiz_journal('account.move.bank.reconcile')
|
||||||
|
|
||||||
|
|
|
@ -32,26 +32,26 @@ import wizard
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.budget', 'state':'end'}
|
'result': {'type':'print', 'report':'account.budget', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.budget.report')
|
wizard_report('account.budget.report')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,31 +32,31 @@ import netsvc
|
||||||
|
|
||||||
_spread_form = '''<?xml version="1.0"?>
|
_spread_form = '''<?xml version="1.0"?>
|
||||||
<form string="Spread">
|
<form string="Spread">
|
||||||
<field name="fiscalyear"/>
|
<field name="fiscalyear"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_spread_fields = {
|
_spread_fields = {
|
||||||
'fiscalyear': {'string':'Fiscal Year', 'type':'many2one', 'relation':'account.fiscalyear', 'required':True},
|
'fiscalyear': {'string':'Fiscal Year', 'type':'many2one', 'relation':'account.fiscalyear', 'required':True},
|
||||||
'amount': {'string':'Amount', 'type':'float', 'digits':(16,2)},
|
'amount': {'string':'Amount', 'type':'float', 'digits':(16,2)},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_budget_spread(wizard.interface):
|
class wizard_budget_spread(wizard.interface):
|
||||||
def _spread(self, cr, uid, data, context):
|
def _spread(self, cr, uid, data, context):
|
||||||
service = netsvc.LocalService("object_proxy")
|
service = netsvc.LocalService("object_proxy")
|
||||||
form = data['form']
|
form = data['form']
|
||||||
res = service.execute(cr.dbname, uid, 'account.budget.post', 'spread', data['ids'], form['fiscalyear'], form['amount'])
|
res = service.execute(cr.dbname, uid, 'account.budget.post', 'spread', data['ids'], form['fiscalyear'], form['amount'])
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':_spread_form, 'fields':_spread_fields, 'state':[('end','Cancel'),('spread','Spread')]}
|
'result': {'type':'form', 'arch':_spread_form, 'fields':_spread_fields, 'state':[('end','Cancel'),('spread','Spread')]}
|
||||||
},
|
},
|
||||||
'spread': {
|
'spread': {
|
||||||
'actions': [_spread],
|
'actions': [_spread],
|
||||||
'result': {'type':'state', 'state':'end'}
|
'result': {'type':'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_budget_spread('account.budget.spread')
|
wizard_budget_spread('account.budget.spread')
|
||||||
|
|
||||||
|
|
|
@ -34,142 +34,142 @@ from tools.translate import _
|
||||||
|
|
||||||
_transaction_form = '''<?xml version="1.0"?>
|
_transaction_form = '''<?xml version="1.0"?>
|
||||||
<form string="Close Fiscal Year">
|
<form string="Close Fiscal Year">
|
||||||
<field name="fy_id"/>
|
<field name="fy_id"/>
|
||||||
<field name="fy2_id"/>
|
<field name="fy2_id"/>
|
||||||
<field name="report_new"/>
|
<field name="report_new"/>
|
||||||
<field name="report_name" colspan="3"/>
|
<field name="report_name" colspan="3"/>
|
||||||
|
|
||||||
<separator string="Are you sure ?" colspan="4"/>
|
<separator string="Are you sure ?" colspan="4"/>
|
||||||
<field name="sure"/>
|
<field name="sure"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_transaction_fields = {
|
_transaction_fields = {
|
||||||
'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
|
'fy_id': {'string':'Fiscal Year to close', 'type':'many2one', 'relation': 'account.fiscalyear','required':True, 'domain':[('state','=','draft')]},
|
||||||
'fy2_id': {'string':'New Fiscal Year', 'type':'many2one', 'relation': 'account.fiscalyear', 'domain':[('state','=','draft')], 'required':True},
|
'fy2_id': {'string':'New Fiscal Year', 'type':'many2one', 'relation': 'account.fiscalyear', 'domain':[('state','=','draft')], 'required':True},
|
||||||
'report_new': {'string':'Create new entries', 'type':'boolean', 'required':True, 'default': lambda *a:True},
|
'report_new': {'string':'Create new entries', 'type':'boolean', 'required':True, 'default': lambda *a:True},
|
||||||
'report_name': {'string':'Name of new entries', 'type':'char', 'size': 64, 'required':True},
|
'report_name': {'string':'Name of new entries', 'type':'char', 'size': 64, 'required':True},
|
||||||
'sure': {'string':'Check this box', 'type':'boolean'},
|
'sure': {'string':'Check this box', 'type':'boolean'},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _data_load(self, cr, uid, data, context):
|
def _data_load(self, cr, uid, data, context):
|
||||||
data['form']['report_new'] = True
|
data['form']['report_new'] = True
|
||||||
data['form']['report_name'] = 'End of Fiscal Year Entry'
|
data['form']['report_name'] = 'End of Fiscal Year Entry'
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
def _data_save(self, cr, uid, data, context):
|
def _data_save(self, cr, uid, data, context):
|
||||||
if not data['form']['sure']:
|
if not data['form']['sure']:
|
||||||
raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year canceled, please check the box !'))
|
raise wizard.except_wizard(_('UserError'), _('Closing of fiscal year canceled, please check the box !'))
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
|
|
||||||
fy_id = data['form']['fy_id']
|
fy_id = data['form']['fy_id']
|
||||||
if data['form']['report_new']:
|
if data['form']['report_new']:
|
||||||
period = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids[0]
|
period = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']).period_ids[0]
|
||||||
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'])
|
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'])
|
||||||
start_jp = new_fyear.start_journal_period_id
|
start_jp = new_fyear.start_journal_period_id
|
||||||
if not start_jp:
|
if not start_jp:
|
||||||
raise wizard.except_wizard(_('UserError'),
|
raise wizard.except_wizard(_('UserError'),
|
||||||
_('The new fiscal year should have a journal for new entries define on it'))
|
_('The new fiscal year should have a journal for new entries define on it'))
|
||||||
|
|
||||||
new_journal = start_jp.journal_id
|
new_journal = start_jp.journal_id
|
||||||
|
|
||||||
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
|
if not new_journal.default_credit_account_id or not new_journal.default_debit_account_id:
|
||||||
raise wizard.except_wizard(_('UserError'),
|
raise wizard.except_wizard(_('UserError'),
|
||||||
_('The journal must have default credit and debit account'))
|
_('The journal must have default credit and debit account'))
|
||||||
if not new_journal.centralisation:
|
if not new_journal.centralisation:
|
||||||
raise wizard.except_wizard(_('UserError'),
|
raise wizard.except_wizard(_('UserError'),
|
||||||
_('The journal must have centralised counterpart'))
|
_('The journal must have centralised counterpart'))
|
||||||
|
|
||||||
query_line = pool.get('account.move.line')._query_get(cr, uid,
|
query_line = pool.get('account.move.line')._query_get(cr, uid,
|
||||||
obj='account_move_line', context={'fiscalyear': fy_id})
|
obj='account_move_line', context={'fiscalyear': fy_id})
|
||||||
cr.execute('select id from account_account WHERE active')
|
cr.execute('select id from account_account WHERE active')
|
||||||
ids = map(lambda x: x[0], cr.fetchall())
|
ids = map(lambda x: x[0], cr.fetchall())
|
||||||
for account in pool.get('account.account').browse(cr, uid, ids,
|
for account in pool.get('account.account').browse(cr, uid, ids,
|
||||||
context={'fiscalyear': fy_id}):
|
context={'fiscalyear': fy_id}):
|
||||||
if account.close_method=='none' or account.type == 'view':
|
if account.close_method=='none' or account.type == 'view':
|
||||||
continue
|
continue
|
||||||
if account.close_method=='balance':
|
if account.close_method=='balance':
|
||||||
if abs(account.balance)>0.0001:
|
if abs(account.balance)>0.0001:
|
||||||
pool.get('account.move.line').create(cr, uid, {
|
pool.get('account.move.line').create(cr, uid, {
|
||||||
'debit': account.balance>0 and account.balance,
|
'debit': account.balance>0 and account.balance,
|
||||||
'credit': account.balance<0 and -account.balance,
|
'credit': account.balance<0 and -account.balance,
|
||||||
'name': data['form']['report_name'],
|
'name': data['form']['report_name'],
|
||||||
'date': period.date_start,
|
'date': period.date_start,
|
||||||
'journal_id': new_journal.id,
|
'journal_id': new_journal.id,
|
||||||
'period_id': period.id,
|
'period_id': period.id,
|
||||||
'account_id': account.id
|
'account_id': account.id
|
||||||
}, {'journal_id': new_journal.id, 'period_id':period.id})
|
}, {'journal_id': new_journal.id, 'period_id':period.id})
|
||||||
if account.close_method=='unreconciled':
|
if account.close_method=='unreconciled':
|
||||||
offset = 0
|
offset = 0
|
||||||
limit = 100
|
limit = 100
|
||||||
while True:
|
while True:
|
||||||
cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
|
cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
|
||||||
'amount_currency, currency_id, blocked, partner_id, ' \
|
'amount_currency, currency_id, blocked, partner_id, ' \
|
||||||
'date_maturity, date_created ' \
|
'date_maturity, date_created ' \
|
||||||
'FROM account_move_line ' \
|
'FROM account_move_line ' \
|
||||||
'WHERE account_id = %d ' \
|
'WHERE account_id = %d ' \
|
||||||
'AND ' + query_line + ' ' \
|
'AND ' + query_line + ' ' \
|
||||||
'AND reconcile_id is NULL ' \
|
'AND reconcile_id is NULL ' \
|
||||||
'ORDER BY id ' \
|
'ORDER BY id ' \
|
||||||
'LIMIT %d OFFSET %d', (account.id, limit, offset))
|
'LIMIT %d OFFSET %d', (account.id, limit, offset))
|
||||||
result = cr.dictfetchall()
|
result = cr.dictfetchall()
|
||||||
if not result:
|
if not result:
|
||||||
break
|
break
|
||||||
for move in result:
|
for move in result:
|
||||||
move.update({
|
move.update({
|
||||||
'date': period.date_start,
|
'date': period.date_start,
|
||||||
'journal_id': new_journal.id,
|
'journal_id': new_journal.id,
|
||||||
'period_id': period.id,
|
'period_id': period.id,
|
||||||
})
|
})
|
||||||
pool.get('account.move.line').create(cr, uid, move, {
|
pool.get('account.move.line').create(cr, uid, move, {
|
||||||
'journal_id': new_journal.id,
|
'journal_id': new_journal.id,
|
||||||
'period_id': period.id,
|
'period_id': period.id,
|
||||||
})
|
})
|
||||||
offset += limit
|
offset += limit
|
||||||
if account.close_method=='detail':
|
if account.close_method=='detail':
|
||||||
offset = 0
|
offset = 0
|
||||||
limit = 100
|
limit = 100
|
||||||
while True:
|
while True:
|
||||||
cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
|
cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
|
||||||
'amount_currency, currency_id, blocked, partner_id, ' \
|
'amount_currency, currency_id, blocked, partner_id, ' \
|
||||||
'date_maturity, date_created ' \
|
'date_maturity, date_created ' \
|
||||||
'FROM account_move_line ' \
|
'FROM account_move_line ' \
|
||||||
'WHERE account_id = %d ' \
|
'WHERE account_id = %d ' \
|
||||||
'AND ' + query_line + ' ' \
|
'AND ' + query_line + ' ' \
|
||||||
'ORDER BY id ' \
|
'ORDER BY id ' \
|
||||||
'LIMIT %d OFFSET %d', (account.id,fy_id, limit, offset))
|
'LIMIT %d OFFSET %d', (account.id,fy_id, limit, offset))
|
||||||
result = cr.dictfetchall()
|
result = cr.dictfetchall()
|
||||||
if not result:
|
if not result:
|
||||||
break
|
break
|
||||||
for move in result:
|
for move in result:
|
||||||
move.update({
|
move.update({
|
||||||
'date': period.date_start,
|
'date': period.date_start,
|
||||||
'journal_id': new_journal.id,
|
'journal_id': new_journal.id,
|
||||||
'period_id': period.id,
|
'period_id': period.id,
|
||||||
})
|
})
|
||||||
pool.get('account.move.line').create(cr, uid, move)
|
pool.get('account.move.line').create(cr, uid, move)
|
||||||
offset += limit
|
offset += limit
|
||||||
|
|
||||||
cr.execute('UPDATE account_journal_period ' \
|
cr.execute('UPDATE account_journal_period ' \
|
||||||
'SET state = %s ' \
|
'SET state = %s ' \
|
||||||
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %d)',
|
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %d)',
|
||||||
('done',fy_id))
|
('done',fy_id))
|
||||||
cr.execute('UPDATE account_period SET state = %s ' \
|
cr.execute('UPDATE account_period SET state = %s ' \
|
||||||
'WHERE fiscalyear_id = %d', ('done',fy_id))
|
'WHERE fiscalyear_id = %d', ('done',fy_id))
|
||||||
cr.execute('UPDATE account_fiscalyear ' \
|
cr.execute('UPDATE account_fiscalyear ' \
|
||||||
'SET state = %s, end_journal_period_id = %d' \
|
'SET state = %s, end_journal_period_id = %d' \
|
||||||
'WHERE id = %d', ('done',start_jp,fy_id))
|
'WHERE id = %d', ('done',start_jp,fy_id))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wiz_journal_close(wizard.interface):
|
class wiz_journal_close(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_data_load],
|
'actions': [_data_load],
|
||||||
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Fiscal Year')]}
|
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Fiscal Year')]}
|
||||||
},
|
},
|
||||||
'close': {
|
'close': {
|
||||||
'actions': [_data_save],
|
'actions': [_data_save],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_journal_close('account.fiscalyear.close')
|
wiz_journal_close('account.fiscalyear.close')
|
||||||
|
|
||||||
|
|
|
@ -32,31 +32,31 @@ import pooler
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="fiscalyear" colspan="4"/>
|
<field name="fiscalyear" colspan="4"/>
|
||||||
<field name="periods" colspan="4"/>
|
<field name="periods" colspan="4"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
'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'},
|
||||||
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
|
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
def _get_defaults(self, cr, uid, data, context):
|
def _get_defaults(self, cr, uid, data, context):
|
||||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_defaults],
|
'actions': [_get_defaults],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.general.ledger', 'state':'end'}
|
'result': {'type':'print', 'report':'account.general.ledger', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.general.ledger.report')
|
wizard_report('account.general.ledger.report')
|
||||||
|
|
||||||
|
|
|
@ -31,34 +31,34 @@ import wizard
|
||||||
import netsvc
|
import netsvc
|
||||||
|
|
||||||
def _invoice_confirm(self, cr, uid, data, context):
|
def _invoice_confirm(self, cr, uid, data, context):
|
||||||
wf_service = netsvc.LocalService('workflow')
|
wf_service = netsvc.LocalService('workflow')
|
||||||
for id in data['ids']:
|
for id in data['ids']:
|
||||||
wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_open', cr)
|
wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_open', cr)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wizard_invoice_confirm(wizard.interface):
|
class wizard_invoice_confirm(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_invoice_confirm],
|
'actions': [_invoice_confirm],
|
||||||
'result': {'type':'state', 'state':'end'}
|
'result': {'type':'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_invoice_confirm('account.invoice.state.confirm')
|
wizard_invoice_confirm('account.invoice.state.confirm')
|
||||||
|
|
||||||
|
|
||||||
def _invoice_cancel(self, cr, uid, data, context):
|
def _invoice_cancel(self, cr, uid, data, context):
|
||||||
wf_service = netsvc.LocalService('workflow')
|
wf_service = netsvc.LocalService('workflow')
|
||||||
for id in data['ids']:
|
for id in data['ids']:
|
||||||
wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)
|
wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wizard_invoice_cancel(wizard.interface):
|
class wizard_invoice_cancel(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_invoice_cancel],
|
'actions': [_invoice_cancel],
|
||||||
'result': {'type':'state', 'state':'end'}
|
'result': {'type':'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_invoice_cancel('account.invoice.state.cancel')
|
wizard_invoice_cancel('account.invoice.state.cancel')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,65 +34,65 @@ from tools.translate import _
|
||||||
|
|
||||||
_journal_form = '''<?xml version="1.0"?>
|
_journal_form = '''<?xml version="1.0"?>
|
||||||
<form string="Standard entries">
|
<form string="Standard entries">
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="period_id"/>
|
<field name="period_id"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
def _period_get(self, cr, uid, datas, ctx={}):
|
def _period_get(self, cr, uid, datas, ctx={}):
|
||||||
try:
|
try:
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
ids = pool.get('account.period').find(cr, uid, context=ctx)
|
ids = pool.get('account.period').find(cr, uid, context=ctx)
|
||||||
return {'period_id': ids[0]}
|
return {'period_id': ids[0]}
|
||||||
except:
|
except:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
_journal_fields = {
|
_journal_fields = {
|
||||||
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
||||||
'period_id': {
|
'period_id': {
|
||||||
'string':'Period',
|
'string':'Period',
|
||||||
'type':'many2one',
|
'type':'many2one',
|
||||||
'relation':'account.period',
|
'relation':'account.period',
|
||||||
'required':True,
|
'required':True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _action_open_window(self, cr, uid, data, context):
|
def _action_open_window(self, cr, uid, data, context):
|
||||||
form = data['form']
|
form = data['form']
|
||||||
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
|
cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
|
||||||
view_res = cr.fetchone()
|
view_res = cr.fetchone()
|
||||||
jp = pooler.get_pool(cr.dbname).get('account.journal.period')
|
jp = pooler.get_pool(cr.dbname).get('account.journal.period')
|
||||||
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
|
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
name = pooler.get_pool(cr.dbname).get('account.journal').read(cr, uid, [form['journal_id']])[0]['name']
|
name = pooler.get_pool(cr.dbname).get('account.journal').read(cr, uid, [form['journal_id']])[0]['name']
|
||||||
state = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['state']
|
state = pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [form['period_id']])[0]['state']
|
||||||
if state == 'done':
|
if state == 'done':
|
||||||
raise wizard.except_wizard(_('UserError'), _('This period is already closed !'))
|
raise wizard.except_wizard(_('UserError'), _('This period is already closed !'))
|
||||||
jp.create(cr, uid, {'name':name, 'period_id': form['period_id'], 'journal_id':form['journal_id']})
|
jp.create(cr, uid, {'name':name, 'period_id': form['period_id'], 'journal_id':form['journal_id']})
|
||||||
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
|
ids = jp.search(cr, uid, [('journal_id','=',form['journal_id']), ('period_id','=',form['period_id'])])
|
||||||
jp = jp.browse(cr, uid, ids, context=context)[0]
|
jp = jp.browse(cr, uid, ids, context=context)[0]
|
||||||
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
|
name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
|
||||||
return {
|
return {
|
||||||
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (form['journal_id'],form['period_id']),
|
'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (form['journal_id'],form['period_id']),
|
||||||
'name': name,
|
'name': name,
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'res_model': 'account.move.line',
|
'res_model': 'account.move.line',
|
||||||
'view_id': view_res,
|
'view_id': view_res,
|
||||||
'context': "{'journal_id':%d, 'period_id':%d}" % (form['journal_id'],form['period_id']),
|
'context': "{'journal_id':%d, 'period_id':%d}" % (form['journal_id'],form['period_id']),
|
||||||
'type': 'ir.actions.act_window'
|
'type': 'ir.actions.act_window'
|
||||||
}
|
}
|
||||||
|
|
||||||
class wiz_journal(wizard.interface):
|
class wiz_journal(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_period_get],
|
'actions': [_period_get],
|
||||||
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open Journal')]}
|
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open Journal')]}
|
||||||
},
|
},
|
||||||
'open': {
|
'open': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_journal('account.move.journal')
|
wiz_journal('account.move.journal')
|
||||||
|
|
||||||
|
|
|
@ -31,26 +31,26 @@ import wizard
|
||||||
import pooler
|
import pooler
|
||||||
|
|
||||||
def _action_open_window(self, cr, uid, data, context):
|
def _action_open_window(self, cr, uid, data, context):
|
||||||
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
||||||
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
||||||
|
|
||||||
result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_select')
|
result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_select')
|
||||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||||
result = act_obj.read(cr, uid, [id])[0]
|
result = act_obj.read(cr, uid, [id])[0]
|
||||||
|
|
||||||
cr.execute('select journal_id,period_id from account_journal_period where id=%d', (data['id'],))
|
cr.execute('select journal_id,period_id from account_journal_period where id=%d', (data['id'],))
|
||||||
journal_id,period_id = cr.fetchone()
|
journal_id,period_id = cr.fetchone()
|
||||||
|
|
||||||
result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)])
|
result['domain'] = str([('journal_id', '=', journal_id), ('period_id', '=', period_id)])
|
||||||
result['context'] = str({'journal_id': journal_id, 'period_id': period_id})
|
result['context'] = str({'journal_id': journal_id, 'period_id': period_id})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
class wiz_journal(wizard.interface):
|
class wiz_journal(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_journal('account.move.journal.select')
|
wiz_journal('account.move.journal.select')
|
||||||
|
|
||||||
|
|
|
@ -31,35 +31,35 @@ import wizard
|
||||||
import pooler
|
import pooler
|
||||||
|
|
||||||
class wizard_move_line_select(wizard.interface):
|
class wizard_move_line_select(wizard.interface):
|
||||||
def _open_window(self, cr, uid, data, context):
|
def _open_window(self, cr, uid, data, context):
|
||||||
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
||||||
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
||||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||||
|
|
||||||
if not context.get('fiscalyear', False):
|
if not context.get('fiscalyear', False):
|
||||||
fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')])
|
fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')])
|
||||||
else:
|
else:
|
||||||
fiscalyear_ids = [context['fiscalyear']]
|
fiscalyear_ids = [context['fiscalyear']]
|
||||||
|
|
||||||
fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids)
|
fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids)
|
||||||
period_ids = []
|
period_ids = []
|
||||||
for fiscalyear in fiscalyears:
|
for fiscalyear in fiscalyears:
|
||||||
for period in fiscalyear.period_ids:
|
for period in fiscalyear.period_ids:
|
||||||
period_ids.append(period.id)
|
period_ids.append(period.id)
|
||||||
domain = str(('period_id', 'in', period_ids))
|
domain = str(('period_id', 'in', period_ids))
|
||||||
|
|
||||||
result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_tree1')
|
result = mod_obj._get_id(cr, uid, 'account', 'action_move_line_tree1')
|
||||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||||
result = act_obj.read(cr, uid, [id])[0]
|
result = act_obj.read(cr, uid, [id])[0]
|
||||||
result['context'] = str({'fiscalyear': context.get('fiscalyear', False)})
|
result['context'] = str({'fiscalyear': context.get('fiscalyear', False)})
|
||||||
result['domain']=result['domain'][0:-1]+','+domain+result['domain'][-1]
|
result['domain']=result['domain'][0:-1]+','+domain+result['domain'][-1]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action': _open_window, 'state': 'end'}
|
'result': {'type': 'action', 'action': _open_window, 'state': 'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_move_line_select('account.move.line.select')
|
wizard_move_line_select('account.move.line.select')
|
||||||
|
|
||||||
|
|
|
@ -33,53 +33,53 @@ from tools.translate import _
|
||||||
|
|
||||||
form = """<?xml version="1.0"?>
|
form = """<?xml version="1.0"?>
|
||||||
<form string="Choose Fiscal Year">
|
<form string="Choose Fiscal Year">
|
||||||
<field name="fyear_id" domain="[('state','=','done')]"/>
|
<field name="fyear_id" domain="[('state','=','done')]"/>
|
||||||
</form>
|
</form>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
'fyear_id': {'string': 'Fiscal Year to Open', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
|
'fyear_id': {'string': 'Fiscal Year to Open', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _remove_entries(self, cr, uid, data, context):
|
def _remove_entries(self, cr, uid, data, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
data_fyear = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear_id'])
|
data_fyear = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear_id'])
|
||||||
if not data_fyear.end_journal_period_id:
|
if not data_fyear.end_journal_period_id:
|
||||||
raise wizard.except_wizard(_('Error'), _('No journal for ending writings have been defined for the fiscal year'))
|
raise wizard.except_wizard(_('Error'), _('No journal for ending writings have been defined for the fiscal year'))
|
||||||
period_journal = data_fyear.end_journal_period_id
|
period_journal = data_fyear.end_journal_period_id
|
||||||
if not period_journal.journal_id.centralisation:
|
if not period_journal.journal_id.centralisation:
|
||||||
raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart'))
|
raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart'))
|
||||||
ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
|
ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
|
||||||
pool.get('account.move').unlink(cr,uid,ids_move)
|
pool.get('account.move').unlink(cr,uid,ids_move)
|
||||||
cr.execute('UPDATE account_journal_period ' \
|
cr.execute('UPDATE account_journal_period ' \
|
||||||
'SET state = %s ' \
|
'SET state = %s ' \
|
||||||
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %d)',
|
'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %d)',
|
||||||
('draft',data_fyear))
|
('draft',data_fyear))
|
||||||
cr.execute('UPDATE account_period SET state = %s ' \
|
cr.execute('UPDATE account_period SET state = %s ' \
|
||||||
'WHERE fiscalyear_id = %d', ('draft',data_fyear))
|
'WHERE fiscalyear_id = %d', ('draft',data_fyear))
|
||||||
cr.execute('UPDATE account_fiscalyear ' \
|
cr.execute('UPDATE account_fiscalyear ' \
|
||||||
'SET state = %s, end_journal_period_id = null '\
|
'SET state = %s, end_journal_period_id = null '\
|
||||||
'WHERE id = %d', ('draft',data_fyear))
|
'WHERE id = %d', ('draft',data_fyear))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class open_closed_fiscal(wizard.interface):
|
class open_closed_fiscal(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init' : {
|
'init' : {
|
||||||
'actions' : [],
|
'actions' : [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': form,
|
'arch': form,
|
||||||
'fields': fields,
|
'fields': fields,
|
||||||
'state':[('end','Cancel'),('open','Open')]
|
'state':[('end','Cancel'),('open','Open')]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'open': {
|
'open': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type':'action',
|
'type':'action',
|
||||||
'action':_remove_entries,
|
'action':_remove_entries,
|
||||||
'state':'end'
|
'state':'end'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
open_closed_fiscal("account.open_closed_fiscalyear")
|
open_closed_fiscal("account.open_closed_fiscalyear")
|
||||||
|
|
|
@ -33,45 +33,45 @@ import pooler
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="company_id" colspan="4"/>
|
<field name="company_id" colspan="4"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="fiscalyear" colspan="4"/>
|
<field name="fiscalyear" colspan="4"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
||||||
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
'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'},
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
def _get_defaults(self, cr, uid, data, context):
|
def _get_defaults(self, cr, uid, data, context):
|
||||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||||
|
|
||||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
||||||
if user.company_id:
|
if user.company_id:
|
||||||
company_id = user.company_id.id
|
company_id = user.company_id.id
|
||||||
else:
|
else:
|
||||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||||
data['form']['company_id'] = company_id
|
data['form']['company_id'] = company_id
|
||||||
|
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_defaults],
|
'actions': [_get_defaults],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.partner.balance', 'state':'end'}
|
'result': {'type':'print', 'report':'account.partner.balance', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.partner.balance.report')
|
wizard_report('account.partner.balance.report')
|
||||||
|
|
||||||
|
|
|
@ -35,105 +35,105 @@ from tools.translate import _
|
||||||
|
|
||||||
pay_form = '''<?xml version="1.0"?>
|
pay_form = '''<?xml version="1.0"?>
|
||||||
<form string="Pay invoice">
|
<form string="Pay invoice">
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
<field name="period_id"/>
|
<field name="period_id"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
pay_fields = {
|
pay_fields = {
|
||||||
'amount': {'string': 'Amount paid', 'type':'float', 'required':True},
|
'amount': {'string': 'Amount paid', 'type':'float', 'required':True},
|
||||||
'name': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
|
'name': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
|
||||||
'date': {'string': 'Payment date', 'type':'date', 'required':True, 'default':lambda *args: time.strftime('%Y-%m-%d')},
|
'date': {'string': 'Payment date', 'type':'date', 'required':True, 'default':lambda *args: time.strftime('%Y-%m-%d')},
|
||||||
'journal_id': {'string': 'Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True, 'domain':[('type','=','cash')]},
|
'journal_id': {'string': 'Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True, 'domain':[('type','=','cash')]},
|
||||||
'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
|
'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _pay_and_reconcile(self, cr, uid, data, context):
|
def _pay_and_reconcile(self, cr, uid, data, context):
|
||||||
form = data['form']
|
form = data['form']
|
||||||
period_id = form.get('period_id', False)
|
period_id = form.get('period_id', False)
|
||||||
journal_id = form.get('journal_id', False)
|
journal_id = form.get('journal_id', False)
|
||||||
writeoff_account_id = form.get('writeoff_acc_id', False)
|
writeoff_account_id = form.get('writeoff_acc_id', False)
|
||||||
writeoff_journal_id = form.get('writeoff_journal_id', False)
|
writeoff_journal_id = form.get('writeoff_journal_id', False)
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
cur_obj = pool.get('res.currency')
|
cur_obj = pool.get('res.currency')
|
||||||
amount = form['amount']
|
amount = form['amount']
|
||||||
|
|
||||||
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
||||||
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
|
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
|
||||||
if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
|
if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
|
||||||
ctx = {'date':data['form']['date']}
|
ctx = {'date':data['form']['date']}
|
||||||
amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
|
amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
|
||||||
|
|
||||||
acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
|
acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
|
||||||
if not acc_id:
|
if not acc_id:
|
||||||
raise wizard.except_wizard(_('Error !'), _('Your journal must have a default credit and debit account.'))
|
raise wizard.except_wizard(_('Error !'), _('Your journal must have a default credit and debit account.'))
|
||||||
pool.get('account.invoice').pay_and_reconcile(cr, uid, [data['id']],
|
pool.get('account.invoice').pay_and_reconcile(cr, uid, [data['id']],
|
||||||
amount, acc_id, period_id, journal_id, writeoff_account_id,
|
amount, acc_id, period_id, journal_id, writeoff_account_id,
|
||||||
period_id, writeoff_journal_id, context, data['form']['name'])
|
period_id, writeoff_journal_id, context, data['form']['name'])
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _wo_check(self, cr, uid, data, context):
|
def _wo_check(self, cr, uid, data, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
||||||
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_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:
|
||||||
return 'addendum'
|
return 'addendum'
|
||||||
if pool.get('res.currency').is_zero(cr, uid, invoice.currency_id,
|
if pool.get('res.currency').is_zero(cr, uid, invoice.currency_id,
|
||||||
(data['form']['amount'] - invoice.amount_total)):
|
(data['form']['amount'] - invoice.amount_total)):
|
||||||
return 'reconcile'
|
return 'reconcile'
|
||||||
return 'addendum'
|
return 'addendum'
|
||||||
|
|
||||||
_transaction_add_form = '''<?xml version="1.0"?>
|
_transaction_add_form = '''<?xml version="1.0"?>
|
||||||
<form string="Information addendum">
|
<form string="Information addendum">
|
||||||
<separator string="Write-Off Move" colspan="4"/>
|
<separator string="Write-Off Move" colspan="4"/>
|
||||||
<field name="writeoff_acc_id"/>
|
<field name="writeoff_acc_id"/>
|
||||||
<field name="writeoff_journal_id"/>
|
<field name="writeoff_journal_id"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_transaction_add_fields = {
|
_transaction_add_fields = {
|
||||||
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
'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},
|
'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_value_addendum(self, cr, uid, data, context={}):
|
def _get_value_addendum(self, cr, uid, data, context={}):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _get_period(self, cr, uid, data, context={}):
|
def _get_period(self, cr, uid, data, context={}):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
ids = pool.get('account.period').find(cr, uid, context=context)
|
ids = pool.get('account.period').find(cr, uid, context=context)
|
||||||
period_id = False
|
period_id = False
|
||||||
if len(ids):
|
if len(ids):
|
||||||
period_id = ids[0]
|
period_id = ids[0]
|
||||||
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
|
||||||
if invoice.state == 'draft':
|
if invoice.state == 'draft':
|
||||||
raise wizard.except_wizard(_('Error !'), _('Can not pay draft invoice.'))
|
raise wizard.except_wizard(_('Error !'), _('Can not pay draft invoice.'))
|
||||||
return {
|
return {
|
||||||
'period_id': period_id,
|
'period_id': period_id,
|
||||||
'amount': invoice.amount_total,
|
'amount': invoice.amount_total,
|
||||||
'date': time.strftime('%Y-%m-%d')
|
'date': time.strftime('%Y-%m-%d')
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_pay_invoice(wizard.interface):
|
class wizard_pay_invoice(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_period],
|
'actions': [_get_period],
|
||||||
'result': {'type':'form', 'arch':pay_form, 'fields':pay_fields, 'state':[('end','Cancel'),('reconcile','Partial Payment'),('writeoff_check','Full Payment')]}
|
'result': {'type':'form', 'arch':pay_form, 'fields':pay_fields, 'state':[('end','Cancel'),('reconcile','Partial Payment'),('writeoff_check','Full Payment')]}
|
||||||
},
|
},
|
||||||
'writeoff_check': {
|
'writeoff_check': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result' : {'type': 'choice', 'next_state': _wo_check }
|
'result' : {'type': 'choice', 'next_state': _wo_check }
|
||||||
},
|
},
|
||||||
'addendum': {
|
'addendum': {
|
||||||
'actions': [_get_value_addendum],
|
'actions': [_get_value_addendum],
|
||||||
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Pay and reconcile')]}
|
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Pay and reconcile')]}
|
||||||
},
|
},
|
||||||
'reconcile': {
|
'reconcile': {
|
||||||
'actions': [_pay_and_reconcile],
|
'actions': [_pay_and_reconcile],
|
||||||
'result': {'type':'state', 'state':'end'}
|
'result': {'type':'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_pay_invoice('account.invoice.pay')
|
wizard_pay_invoice('account.invoice.pay')
|
||||||
|
|
||||||
|
|
|
@ -31,32 +31,32 @@ import wizard
|
||||||
|
|
||||||
_transaction_form = '''<?xml version="1.0"?>
|
_transaction_form = '''<?xml version="1.0"?>
|
||||||
<form string="Close Period">
|
<form string="Close Period">
|
||||||
<separator string="Are you sure ?" colspan="4"/>
|
<separator string="Are you sure ?" colspan="4"/>
|
||||||
<field name="sure"/>
|
<field name="sure"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_transaction_fields = {
|
_transaction_fields = {
|
||||||
'sure': {'string':'Check this box', 'type':'boolean'},
|
'sure': {'string':'Check this box', 'type':'boolean'},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _data_save(self, cr, uid, data, context):
|
def _data_save(self, cr, uid, data, context):
|
||||||
mode = 'done'
|
mode = 'done'
|
||||||
if data['form']['sure']:
|
if data['form']['sure']:
|
||||||
for id in data['ids']:
|
for id in data['ids']:
|
||||||
cr.execute('update account_journal_period set state=%s where period_id=%d', (mode, id))
|
cr.execute('update account_journal_period set state=%s where period_id=%d', (mode, id))
|
||||||
cr.execute('update account_period set state=%s where id=%d', (mode, id))
|
cr.execute('update account_period set state=%s where id=%d', (mode, id))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wiz_journal_close(wizard.interface):
|
class wiz_journal_close(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Period')]}
|
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('close','Close Period')]}
|
||||||
},
|
},
|
||||||
'close': {
|
'close': {
|
||||||
'actions': [_data_save],
|
'actions': [_data_save],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_journal_close('account.period.close')
|
wiz_journal_close('account.period.close')
|
||||||
|
|
||||||
|
|
|
@ -35,108 +35,108 @@ import pooler
|
||||||
|
|
||||||
_transaction_form = '''<?xml version="1.0"?>
|
_transaction_form = '''<?xml version="1.0"?>
|
||||||
<form string="Reconciliation">
|
<form string="Reconciliation">
|
||||||
<separator string="Reconciliation transactions" colspan="4"/>
|
<separator string="Reconciliation transactions" colspan="4"/>
|
||||||
<field name="trans_nbr"/>
|
<field name="trans_nbr"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="credit"/>
|
<field name="credit"/>
|
||||||
<field name="debit"/>
|
<field name="debit"/>
|
||||||
<separator string="Write-Off" colspan="4"/>
|
<separator string="Write-Off" colspan="4"/>
|
||||||
<field name="writeoff"/>
|
<field name="writeoff"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_transaction_fields = {
|
_transaction_fields = {
|
||||||
'trans_nbr': {'string':'# of Transaction', 'type':'integer', 'readonly':True},
|
'trans_nbr': {'string':'# of Transaction', 'type':'integer', 'readonly':True},
|
||||||
'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
|
'credit': {'string':'Credit amount', 'type':'float', 'readonly':True},
|
||||||
'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
|
'debit': {'string':'Debit amount', 'type':'float', 'readonly':True},
|
||||||
'writeoff': {'string':'Write-Off amount', 'type':'float', 'readonly':True},
|
'writeoff': {'string':'Write-Off amount', 'type':'float', 'readonly':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _trans_rec_get(self, cr, uid, data, context=None):
|
def _trans_rec_get(self, cr, uid, data, context=None):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
account_move_line_obj = pool.get('account.move.line')
|
account_move_line_obj = pool.get('account.move.line')
|
||||||
credit = debit = 0
|
credit = debit = 0
|
||||||
account_id = False
|
account_id = False
|
||||||
count = 0
|
count = 0
|
||||||
for line in account_move_line_obj.browse(cr, uid, data['ids'], context=context):
|
for line in account_move_line_obj.browse(cr, uid, data['ids'], context=context):
|
||||||
if not line.reconcile_id and not line.reconcile_id.id:
|
if not line.reconcile_id and not line.reconcile_id.id:
|
||||||
count += 1
|
count += 1
|
||||||
credit += line.credit
|
credit += line.credit
|
||||||
debit += line.debit
|
debit += line.debit
|
||||||
account_id = line.account_id.id
|
account_id = line.account_id.id
|
||||||
return {'trans_nbr': count, 'account_id': account_id, 'credit': credit, 'debit': debit, 'writeoff': debit - credit}
|
return {'trans_nbr': count, 'account_id': account_id, 'credit': credit, 'debit': debit, 'writeoff': debit - credit}
|
||||||
|
|
||||||
def _trans_rec_reconcile_partial(self, cr, uid, data, context=None):
|
def _trans_rec_reconcile_partial(self, cr, uid, data, context=None):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
account_move_line_obj = pool.get('account.move.line')
|
account_move_line_obj = pool.get('account.move.line')
|
||||||
account_move_line_obj.reconcile_partial(cr, uid, data['ids'], 'manual', context=context)
|
account_move_line_obj.reconcile_partial(cr, uid, data['ids'], 'manual', context=context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _trans_rec_reconcile(self, cr, uid, data, context=None):
|
def _trans_rec_reconcile(self, cr, uid, data, context=None):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
account_move_line_obj = pool.get('account.move.line')
|
account_move_line_obj = pool.get('account.move.line')
|
||||||
|
|
||||||
form = data['form']
|
form = data['form']
|
||||||
account_id = form.get('writeoff_acc_id', False)
|
account_id = form.get('writeoff_acc_id', False)
|
||||||
period_id = form.get('period_id', False)
|
period_id = form.get('period_id', False)
|
||||||
journal_id = form.get('journal_id', False)
|
journal_id = form.get('journal_id', False)
|
||||||
account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
|
account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
|
||||||
period_id, journal_id, context=context)
|
period_id, journal_id, context=context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _partial_check(self, cr, uid, data, context):
|
def _partial_check(self, cr, uid, data, context):
|
||||||
if _trans_rec_get(self,cr,uid, data, context)['writeoff'] == 0:
|
if _trans_rec_get(self,cr,uid, data, context)['writeoff'] == 0:
|
||||||
return 'init_full'
|
return 'init_full'
|
||||||
return 'init_partial'
|
return 'init_partial'
|
||||||
|
|
||||||
_transaction_add_form = '''<?xml version="1.0"?>
|
_transaction_add_form = '''<?xml version="1.0"?>
|
||||||
<form string="Information addendum">
|
<form string="Information addendum">
|
||||||
<separator string="Write-Off Move" colspan="4"/>
|
<separator string="Write-Off Move" colspan="4"/>
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
<field name="period_id"/>
|
<field name="period_id"/>
|
||||||
<field name="writeoff_acc_id" domain="[('type', '<>', 'view')]"/>
|
<field name="writeoff_acc_id" domain="[('type', '<>', 'view')]"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_transaction_add_fields = {
|
_transaction_add_fields = {
|
||||||
'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
|
'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
|
||||||
'period_id': {'string': 'Write-Off Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
|
'period_id': {'string': 'Write-Off Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
|
||||||
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _trans_rec_addendum(self, cr, uid, data, context={}):
|
def _trans_rec_addendum(self, cr, uid, data, context={}):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
ids = pool.get('account.period').find(cr, uid, context=context)
|
ids = pool.get('account.period').find(cr, uid, context=context)
|
||||||
period_id = False
|
period_id = False
|
||||||
if len(ids):
|
if len(ids):
|
||||||
period_id = ids[0]
|
period_id = ids[0]
|
||||||
return {'period_id':period_id}
|
return {'period_id':period_id}
|
||||||
|
|
||||||
|
|
||||||
class wiz_reconcile(wizard.interface):
|
class wiz_reconcile(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'choice', 'next_state': _partial_check}
|
'result': {'type': 'choice', 'next_state': _partial_check}
|
||||||
},
|
},
|
||||||
'init_full': {
|
'init_full': {
|
||||||
'actions': [_trans_rec_get],
|
'actions': [_trans_rec_get],
|
||||||
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
|
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
|
||||||
},
|
},
|
||||||
'init_partial': {
|
'init_partial': {
|
||||||
'actions': [_trans_rec_get],
|
'actions': [_trans_rec_get],
|
||||||
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('addendum','Reconcile With Write-Off'),('partial','Partial Reconcile')]}
|
'result': {'type': 'form', 'arch':_transaction_form, 'fields':_transaction_fields, 'state':[('end','Cancel'),('addendum','Reconcile With Write-Off'),('partial','Partial Reconcile')]}
|
||||||
},
|
},
|
||||||
'addendum': {
|
'addendum': {
|
||||||
'actions': [_trans_rec_addendum],
|
'actions': [_trans_rec_addendum],
|
||||||
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
|
'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]}
|
||||||
},
|
},
|
||||||
'reconcile': {
|
'reconcile': {
|
||||||
'actions': [_trans_rec_reconcile],
|
'actions': [_trans_rec_reconcile],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
},
|
},
|
||||||
'partial': {
|
'partial': {
|
||||||
'actions': [_trans_rec_reconcile_partial],
|
'actions': [_trans_rec_reconcile_partial],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_reconcile('account.move.line.reconcile')
|
wiz_reconcile('account.move.line.reconcile')
|
||||||
|
|
||||||
|
|
|
@ -31,34 +31,34 @@ import wizard
|
||||||
|
|
||||||
_journal_form = '''<?xml version="1.0"?>
|
_journal_form = '''<?xml version="1.0"?>
|
||||||
<form string="%s">
|
<form string="%s">
|
||||||
<field name="account_id"/>
|
<field name="account_id"/>
|
||||||
</form>''' % ('Reconciliation',)
|
</form>''' % ('Reconciliation',)
|
||||||
|
|
||||||
_journal_fields = {
|
_journal_fields = {
|
||||||
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account','domain': [('reconcile','=',1)], 'required':True},
|
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account','domain': [('reconcile','=',1)], 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _action_open_window(self, cr, uid, data, context):
|
def _action_open_window(self, cr, uid, data, context):
|
||||||
return {
|
return {
|
||||||
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['form']['account_id'],
|
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['form']['account_id'],
|
||||||
'name': 'Reconciliation',
|
'name': 'Reconciliation',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'res_model': 'account.move.line',
|
'res_model': 'account.move.line',
|
||||||
'type': 'ir.actions.act_window'
|
'type': 'ir.actions.act_window'
|
||||||
}
|
}
|
||||||
|
|
||||||
class wiz_rec_select(wizard.interface):
|
class wiz_rec_select(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for reconciliation')]}
|
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for reconciliation')]}
|
||||||
},
|
},
|
||||||
'open': {
|
'open': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_rec_select('account.move.line.reconcile.select')
|
wiz_rec_select('account.move.line.reconcile.select')
|
||||||
|
|
||||||
|
|
|
@ -32,35 +32,35 @@ import pooler
|
||||||
|
|
||||||
sur_form = '''<?xml version="1.0"?>
|
sur_form = '''<?xml version="1.0"?>
|
||||||
<form string="Refund Invoice">
|
<form string="Refund Invoice">
|
||||||
<label string="Are you sure you want to refund this invoice ?"/>
|
<label string="Are you sure you want to refund this invoice ?"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
sur_fields = {
|
sur_fields = {
|
||||||
}
|
}
|
||||||
|
|
||||||
class wiz_refund(wizard.interface):
|
class wiz_refund(wizard.interface):
|
||||||
def _invoice_refund(self, cr, uid, data, context):
|
def _invoice_refund(self, cr, uid, data, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
ids = pool.get('account.invoice').refund(cr, uid, data['ids'])
|
ids = pool.get('account.invoice').refund(cr, uid, data['ids'])
|
||||||
return {
|
return {
|
||||||
'domain': "[('id','in', ["+','.join(map(str,ids))+"])]",
|
'domain': "[('id','in', ["+','.join(map(str,ids))+"])]",
|
||||||
'name': 'Invoices',
|
'name': 'Invoices',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'res_model': 'account.invoice',
|
'res_model': 'account.invoice',
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'context': "{'type':'out_refund'}",
|
'context': "{'type':'out_refund'}",
|
||||||
'type': 'ir.actions.act_window'
|
'type': 'ir.actions.act_window'
|
||||||
}
|
}
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':sur_form, 'fields':sur_fields, 'state':[('end','Cancel'),('refund','Refund Invoice')]}
|
'result': {'type':'form', 'arch':sur_form, 'fields':sur_fields, 'state':[('end','Cancel'),('refund','Refund Invoice')]}
|
||||||
},
|
},
|
||||||
'refund': {
|
'refund': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'action', 'action':_invoice_refund, 'state':'end'}
|
'result': {'type':'action', 'action':_invoice_refund, 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_refund('account.invoice.refund')
|
wiz_refund('account.invoice.refund')
|
||||||
|
|
||||||
|
|
|
@ -37,30 +37,30 @@ import pooler
|
||||||
|
|
||||||
_subscription_form = '''<?xml version="1.0"?>
|
_subscription_form = '''<?xml version="1.0"?>
|
||||||
<form string="%s">
|
<form string="%s">
|
||||||
<seperator string="Generate entries before:" colspan="4"/>
|
<seperator string="Generate entries before:" colspan="4"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
</form>''' % ('Subscription Compute',)
|
</form>''' % ('Subscription Compute',)
|
||||||
|
|
||||||
_subscription_fields = {
|
_subscription_fields = {
|
||||||
'date': {'string':'Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
|
'date': {'string':'Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wiz_subscription(wizard.interface):
|
class wiz_subscription(wizard.interface):
|
||||||
def _action_generate(self, cr, uid, data, context):
|
def _action_generate(self, cr, uid, data, context):
|
||||||
cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['form']['date'],))
|
cr.execute('select id from account_subscription_line where date<%s and move_id is null', (data['form']['date'],))
|
||||||
ids = map(lambda x: x[0], cr.fetchall())
|
ids = map(lambda x: x[0], cr.fetchall())
|
||||||
pooler.get_pool(cr.dbname).get('account.subscription.line').move_create(cr, uid, ids)
|
pooler.get_pool(cr.dbname).get('account.subscription.line').move_create(cr, uid, ids)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch':_subscription_form, 'fields':_subscription_fields, 'state':[('end','Cancel'),('generate','Compute Entry Dates')]}
|
'result': {'type': 'form', 'arch':_subscription_form, 'fields':_subscription_fields, 'state':[('end','Cancel'),('generate','Compute Entry Dates')]}
|
||||||
},
|
},
|
||||||
'generate': {
|
'generate': {
|
||||||
'actions': [_action_generate],
|
'actions': [_action_generate],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_subscription('account.subscription.generate')
|
wiz_subscription('account.subscription.generate')
|
||||||
|
|
||||||
|
|
|
@ -33,45 +33,45 @@ import pooler
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="company_id" colspan="4"/>
|
<field name="company_id" colspan="4"/>
|
||||||
<field name="fiscalyear" colspan="4"/>
|
<field name="fiscalyear" colspan="4"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="date1"/>
|
<field name="date1"/>
|
||||||
<field name="date2"/>
|
<field name="date2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
|
||||||
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
'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'},
|
||||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||||
}
|
}
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
def _get_defaults(self, cr, uid, data, context):
|
def _get_defaults(self, cr, uid, data, context):
|
||||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||||
|
|
||||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
||||||
if user.company_id:
|
if user.company_id:
|
||||||
company_id = user.company_id.id
|
company_id = user.company_id.id
|
||||||
else:
|
else:
|
||||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||||
data['form']['company_id'] = company_id
|
data['form']['company_id'] = company_id
|
||||||
|
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_defaults],
|
'actions': [_get_defaults],
|
||||||
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
|
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
|
'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_report('account.third_party_ledger.report')
|
wizard_report('account.third_party_ledger.report')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,49 +32,49 @@ import pooler
|
||||||
|
|
||||||
_info_form = '''<?xml version="1.0"?>
|
_info_form = '''<?xml version="1.0"?>
|
||||||
<form string="Unreconciliation">
|
<form string="Unreconciliation">
|
||||||
<separator string="Unreconciliation transactions" colspan="4"/>
|
<separator string="Unreconciliation transactions" colspan="4"/>
|
||||||
<image name="gtk-dialog-info" colspan="2"/>
|
<image name="gtk-dialog-info" colspan="2"/>
|
||||||
<label string="If you unreconciliate transactions, you must also verify all the actions that are linked to those transactions because they will not be disable" colspan="2"/>
|
<label string="If you unreconciliate transactions, you must also verify all the actions that are linked to those transactions because they will not be disable" colspan="2"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
def _trans_unrec(self, cr, uid, data, context):
|
def _trans_unrec(self, cr, uid, data, context):
|
||||||
recs = pooler.get_pool(cr.dbname).get('account.move.line').read(cr, uid, data['ids'], ['reconcile_id',])
|
recs = pooler.get_pool(cr.dbname).get('account.move.line').read(cr, uid, data['ids'], ['reconcile_id',])
|
||||||
recs = filter(lambda x: x['reconcile_id'], recs)
|
recs = filter(lambda x: x['reconcile_id'], recs)
|
||||||
rec_ids = [rec['reconcile_id'][0] for rec in recs]
|
rec_ids = [rec['reconcile_id'][0] for rec in recs]
|
||||||
if len(rec_ids):
|
if len(rec_ids):
|
||||||
pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, rec_ids)
|
pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, rec_ids)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wiz_unreconcile(wizard.interface):
|
class wiz_unreconcile(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': _info_form, 'fields': {}, 'state':[('end', 'Cancel'), ('unrec', 'Unreconcile')]}
|
'result': {'type': 'form', 'arch': _info_form, 'fields': {}, 'state':[('end', 'Cancel'), ('unrec', 'Unreconcile')]}
|
||||||
},
|
},
|
||||||
'unrec': {
|
'unrec': {
|
||||||
'actions': [_trans_unrec],
|
'actions': [_trans_unrec],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_unreconcile('account.move.line.unreconcile')
|
wiz_unreconcile('account.move.line.unreconcile')
|
||||||
|
|
||||||
|
|
||||||
def _trans_unrec_reconcile(self, cr, uid, data, context):
|
def _trans_unrec_reconcile(self, cr, uid, data, context):
|
||||||
rec_ids = data['ids']
|
rec_ids = data['ids']
|
||||||
if len(rec_ids):
|
if len(rec_ids):
|
||||||
pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, rec_ids)
|
pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, rec_ids)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wiz_unreconcile_reconcile(wizard.interface):
|
class wiz_unreconcile_reconcile(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': _info_form, 'fields': {}, 'state':[('end', 'Cancel'), ('unrec', 'Unreconcile')]}
|
'result': {'type': 'form', 'arch': _info_form, 'fields': {}, 'state':[('end', 'Cancel'), ('unrec', 'Unreconcile')]}
|
||||||
},
|
},
|
||||||
'unrec': {
|
'unrec': {
|
||||||
'actions': [_trans_unrec_reconcile],
|
'actions': [_trans_unrec_reconcile],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_unreconcile_reconcile('account.reconcile.unreconcile')
|
wiz_unreconcile_reconcile('account.reconcile.unreconcile')
|
||||||
|
|
||||||
|
|
|
@ -31,34 +31,34 @@ import wizard
|
||||||
|
|
||||||
_journal_form = '''<?xml version="1.0"?>
|
_journal_form = '''<?xml version="1.0"?>
|
||||||
<form string="%s">
|
<form string="%s">
|
||||||
<field name="account_id"/>
|
<field name="account_id"/>
|
||||||
</form>''' % ('Unreconciliation',)
|
</form>''' % ('Unreconciliation',)
|
||||||
|
|
||||||
_journal_fields = {
|
_journal_fields = {
|
||||||
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
'account_id': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _action_open_window(self, cr, uid, data, context):
|
def _action_open_window(self, cr, uid, data, context):
|
||||||
return {
|
return {
|
||||||
'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['form']['account_id'],
|
'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['form']['account_id'],
|
||||||
'name': 'Unreconciliation',
|
'name': 'Unreconciliation',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'res_model': 'account.move.line',
|
'res_model': 'account.move.line',
|
||||||
'type': 'ir.actions.act_window'
|
'type': 'ir.actions.act_window'
|
||||||
}
|
}
|
||||||
|
|
||||||
class wiz_unrec_select(wizard.interface):
|
class wiz_unrec_select(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for unreconciliation')]}
|
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for unreconciliation')]}
|
||||||
},
|
},
|
||||||
'open': {
|
'open': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wiz_unrec_select('account.move.line.unreconcile.select')
|
wiz_unrec_select('account.move.line.unreconcile.select')
|
||||||
|
|
||||||
|
|
|
@ -34,58 +34,58 @@ from tools.translate import _
|
||||||
|
|
||||||
_journal_form = '''<?xml version="1.0"?>
|
_journal_form = '''<?xml version="1.0"?>
|
||||||
<form string="Standard entries">
|
<form string="Standard entries">
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="period_id"/>
|
<field name="period_id"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
_journal_fields = {
|
_journal_fields = {
|
||||||
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
'journal_id': {'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required':True},
|
||||||
'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True, 'domain':"[('state','<>','done')]"},
|
'period_id': {'string':'Period', 'type':'many2one', 'relation':'account.period', 'required':True, 'domain':"[('state','<>','done')]"},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _validate_move(self, cr, uid, data, context={}):
|
def _validate_move(self, cr, uid, data, context={}):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
move_obj = pool.get('account.move')
|
move_obj = pool.get('account.move')
|
||||||
ids_move = move_obj.search(cr,uid,[('state','=','draft'),('journal_id','=',data['form']['journal_id']),('period_id','=',data['form']['period_id'])])
|
ids_move = move_obj.search(cr,uid,[('state','=','draft'),('journal_id','=',data['form']['journal_id']),('period_id','=',data['form']['period_id'])])
|
||||||
if not ids_move:
|
if not ids_move:
|
||||||
raise wizard.except_wizard(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period'))
|
raise wizard.except_wizard(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period'))
|
||||||
res = move_obj.button_validate(cr, uid, ids_move, context)
|
res = move_obj.button_validate(cr, uid, ids_move, context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class validate_account_move(wizard.interface):
|
class validate_account_move(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('validate','Validate')]}
|
'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('validate','Validate')]}
|
||||||
},
|
},
|
||||||
'validate': {
|
'validate': {
|
||||||
'actions': [_validate_move],
|
'actions': [_validate_move],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
validate_account_move('account.move.validate')
|
validate_account_move('account.move.validate')
|
||||||
|
|
||||||
def _validate_move_lines(self, cr, uid, data, context={}):
|
def _validate_move_lines(self, cr, uid, data, context={}):
|
||||||
move_ids = []
|
move_ids = []
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
move_line_obj = pool.get('account.move.line')
|
move_line_obj = pool.get('account.move.line')
|
||||||
move_obj = pool.get('account.move')
|
move_obj = pool.get('account.move')
|
||||||
data_line = move_line_obj.browse(cr,uid,data['ids'],context)
|
data_line = move_line_obj.browse(cr,uid,data['ids'],context)
|
||||||
for line in data_line:
|
for line in data_line:
|
||||||
if line.move_id.state=='draft':
|
if line.move_id.state=='draft':
|
||||||
move_ids.append(line.move_id.id)
|
move_ids.append(line.move_id.id)
|
||||||
move_ids = list(set(move_ids))
|
move_ids = list(set(move_ids))
|
||||||
if not move_ids:
|
if not move_ids:
|
||||||
raise wizard.except_wizard(_('Warning'), _('Selected Move lines does not have any account move enties in draft state'))
|
raise wizard.except_wizard(_('Warning'), _('Selected Move lines does not have any account move enties in draft state'))
|
||||||
res = move_obj.button_validate(cr, uid, move_ids, context)
|
res = move_obj.button_validate(cr, uid, move_ids, context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class validate_account_move_lines(wizard.interface):
|
class validate_account_move_lines(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_validate_move_lines],
|
'actions': [_validate_move_lines],
|
||||||
'result': {'type': 'state', 'state':'end'}
|
'result': {'type': 'state', 'state':'end'}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
validate_account_move_lines('account.move_line.validate')
|
validate_account_move_lines('account.move_line.validate')
|
||||||
|
|
|
@ -33,64 +33,64 @@ import pooler
|
||||||
|
|
||||||
dates_form = '''<?xml version="1.0"?>
|
dates_form = '''<?xml version="1.0"?>
|
||||||
<form string="Select period">
|
<form string="Select period">
|
||||||
<field name="company_id"/>
|
<field name="company_id"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="period_id"/>
|
<field name="period_id"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="based_on"/>
|
<field name="based_on"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
dates_fields = {
|
dates_fields = {
|
||||||
'company_id': {'string': 'Company', 'type': 'many2one',
|
'company_id': {'string': 'Company', 'type': 'many2one',
|
||||||
'relation': 'res.company', 'required': True},
|
'relation': 'res.company', 'required': True},
|
||||||
'period_id': {'string':'Period', 'type':'many2one',
|
'period_id': {'string':'Period', 'type':'many2one',
|
||||||
'relation': 'account.period', 'required':True},
|
'relation': 'account.period', 'required':True},
|
||||||
'based_on':{'string':'Base on', 'type':'selection', 'selection':[
|
'based_on':{'string':'Base on', 'type':'selection', 'selection':[
|
||||||
('invoices','Invoices'),
|
('invoices','Invoices'),
|
||||||
('payments','Payments'),
|
('payments','Payments'),
|
||||||
], 'required':True, 'default': lambda *a: 'invoices'},
|
], 'required':True, 'default': lambda *a: 'invoices'},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class wizard_report(wizard.interface):
|
class wizard_report(wizard.interface):
|
||||||
|
|
||||||
def _get_defaults(self, cr, uid, data, context):
|
def _get_defaults(self, cr, uid, data, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
period_obj = pool.get('account.period')
|
period_obj = pool.get('account.period')
|
||||||
data['form']['period_id'] = period_obj.find(cr, uid)[0]
|
data['form']['period_id'] = period_obj.find(cr, uid)[0]
|
||||||
|
|
||||||
user = pool.get('res.users').browse(cr, uid, uid, context=context)
|
user = pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||||
if user.company_id:
|
if user.company_id:
|
||||||
company_id = user.company_id.id
|
company_id = user.company_id.id
|
||||||
else:
|
else:
|
||||||
company_id = pool.get('res.company').search(cr, uid,
|
company_id = pool.get('res.company').search(cr, uid,
|
||||||
[('parent_id', '=', False)])[0]
|
[('parent_id', '=', False)])[0]
|
||||||
data['form']['company_id'] = company_id
|
data['form']['company_id'] = company_id
|
||||||
|
|
||||||
return data['form']
|
return data['form']
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_defaults],
|
'actions': [_get_defaults],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': dates_form,
|
'arch': dates_form,
|
||||||
'fields': dates_fields,
|
'fields': dates_fields,
|
||||||
'state': [
|
'state': [
|
||||||
('end', 'Cancel'),
|
('end', 'Cancel'),
|
||||||
('report', 'Print VAT Decl.')
|
('report', 'Print VAT Decl.')
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'report': {
|
'report': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'print',
|
'type': 'print',
|
||||||
'report': 'account.vat.declaration',
|
'report': 'account.vat.declaration',
|
||||||
'state':'end'
|
'state':'end'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard_report('account.vat.declaration')
|
wizard_report('account.vat.declaration')
|
||||||
|
|
||||||
|
|
|
@ -26,22 +26,22 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "report_account_analytic",
|
"name" : "report_account_analytic",
|
||||||
"description": """Modifiy the account analytic view to show
|
"description": """Modifiy the account analytic view to show
|
||||||
important data for project manager of services companies.
|
important data for project manager of services companies.
|
||||||
Add menu to show relevant information for each manager.""",
|
Add menu to show relevant information for each manager.""",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"author" : "Camptocamp",
|
"author" : "Camptocamp",
|
||||||
"category" : "Generic Modules/Accounting",
|
"category" : "Generic Modules/Accounting",
|
||||||
"module": "",
|
"module": "",
|
||||||
"website": "http://www.camptocamp.com/",
|
"website": "http://www.camptocamp.com/",
|
||||||
"depends" : ["account","hr_timesheet","hr_timesheet_invoice"],
|
"depends" : ["account","hr_timesheet","hr_timesheet_invoice"],
|
||||||
"init_xml" : [],
|
"init_xml" : [],
|
||||||
"update_xml" : [
|
"update_xml" : [
|
||||||
"account_analytic_analysis_view.xml",
|
"account_analytic_analysis_view.xml",
|
||||||
"account_analytic_analysis_menu.xml",
|
"account_analytic_analysis_menu.xml",
|
||||||
],
|
],
|
||||||
"demo_xml" : [],
|
"demo_xml" : [],
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,20 +26,20 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Charts of Accounts",
|
"name" : "Charts of Accounts",
|
||||||
"version" : "1.1",
|
"version" : "1.1",
|
||||||
"depends" : ["account"],
|
"depends" : ["account"],
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"description": """Remove minimal account chart""",
|
"description": """Remove minimal account chart""",
|
||||||
"website" : "http://tinyerp.com/module_account.html",
|
"website" : "http://tinyerp.com/module_account.html",
|
||||||
"category" : "Generic Modules/Accounting",
|
"category" : "Generic Modules/Accounting",
|
||||||
"init_xml" : [
|
"init_xml" : [
|
||||||
],
|
],
|
||||||
"demo_xml" : [
|
"demo_xml" : [
|
||||||
],
|
],
|
||||||
"update_xml" : [
|
"update_xml" : [
|
||||||
# Must be loaded by each modules
|
# Must be loaded by each modules
|
||||||
# "account_chart.xml",
|
# "account_chart.xml",
|
||||||
],
|
],
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,32 +26,32 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Accounting follow-ups management",
|
"name" : "Accounting follow-ups management",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"depends" : ["account"],
|
"depends" : ["account"],
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"description": """
|
"description": """
|
||||||
Modules to automate letters for unpaid invoices, with multi-level recalls.
|
Modules to automate letters for unpaid invoices, with multi-level recalls.
|
||||||
|
|
||||||
You can define your multiple levels of recall through the menu:
|
You can define your multiple levels of recall through the menu:
|
||||||
Financial Management/Configuration/Payment Terms/Follow-Ups
|
Financial Management/Configuration/Payment Terms/Follow-Ups
|
||||||
|
|
||||||
Once it's defined, you can automatically prints recall every days
|
Once it's defined, you can automatically prints recall every days
|
||||||
through simply clicking on the menu:
|
through simply clicking on the menu:
|
||||||
Financial_Management/Periodical_Processing/Print_Follow-Ups
|
Financial_Management/Periodical_Processing/Print_Follow-Ups
|
||||||
|
|
||||||
It will generate a PDF with all the letters according the the
|
It will generate a PDF with all the letters according the the
|
||||||
different levels of recall defined. You can define different policies
|
different levels of recall defined. You can define different policies
|
||||||
for different companies.""",
|
for different companies.""",
|
||||||
"website" : "http://tinyerp.com/module_account.html",
|
"website" : "http://tinyerp.com/module_account.html",
|
||||||
"category" : "Generic Modules/Accounting",
|
"category" : "Generic Modules/Accounting",
|
||||||
"init_xml" : [],
|
"init_xml" : [],
|
||||||
"demo_xml" : ["followup_demo.xml"],
|
"demo_xml" : ["followup_demo.xml"],
|
||||||
"update_xml" : [
|
"update_xml" : [
|
||||||
"followup_view.xml",
|
"followup_view.xml",
|
||||||
"followup_report_view.xml"
|
"followup_report_view.xml"
|
||||||
],
|
],
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,36 +31,36 @@
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
|
||||||
class followup(osv.osv):
|
class followup(osv.osv):
|
||||||
_name = 'account_followup.followup'
|
_name = 'account_followup.followup'
|
||||||
_description = 'Follow-Ups'
|
_description = 'Follow-Ups'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Name', size=64, required=True),
|
'name': fields.char('Name', size=64, required=True),
|
||||||
'description': fields.text('Description'),
|
'description': fields.text('Description'),
|
||||||
'followup_line': fields.one2many('account_followup.followup.line', 'followup_id', 'Follow-Up'),
|
'followup_line': fields.one2many('account_followup.followup.line', 'followup_id', 'Follow-Up'),
|
||||||
'company_id': fields.many2one('res.company', 'Company'),
|
'company_id': fields.many2one('res.company', 'Company'),
|
||||||
}
|
}
|
||||||
followup()
|
followup()
|
||||||
|
|
||||||
class followup_line(osv.osv):
|
class followup_line(osv.osv):
|
||||||
_name = 'account_followup.followup.line'
|
_name = 'account_followup.followup.line'
|
||||||
_description = 'Follow-Ups Criteria'
|
_description = 'Follow-Ups Criteria'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Name', size=64, required=True),
|
'name': fields.char('Name', size=64, required=True),
|
||||||
'sequence': fields.integer('Sequence'),
|
'sequence': fields.integer('Sequence'),
|
||||||
'delay': fields.integer('Days of delay'),
|
'delay': fields.integer('Days of delay'),
|
||||||
'start': fields.selection([('days','Net Days'),('end_of_month','End of Month')], 'Type of Term', size=64, required=True),
|
'start': fields.selection([('days','Net Days'),('end_of_month','End of Month')], 'Type of Term', size=64, required=True),
|
||||||
'followup_id': fields.many2one('account_followup.followup', 'Follow Ups', required=True, ondelete="cascade"),
|
'followup_id': fields.many2one('account_followup.followup', 'Follow Ups', required=True, ondelete="cascade"),
|
||||||
'description': fields.text('Printed Message'),
|
'description': fields.text('Printed Message'),
|
||||||
#'prints': fields.one2many('account_followup.followup.print', 'line_id'),
|
#'prints': fields.one2many('account_followup.followup.print', 'line_id'),
|
||||||
}
|
}
|
||||||
followup_line()
|
followup_line()
|
||||||
|
|
||||||
class account_move_line(osv.osv):
|
class account_move_line(osv.osv):
|
||||||
_name = 'account.move.line'
|
_name = 'account.move.line'
|
||||||
_inherit = 'account.move.line'
|
_inherit = 'account.move.line'
|
||||||
_columns = {
|
_columns = {
|
||||||
'followup_line_id': fields.many2one('account_followup.followup.line', 'Follow-up Level'),
|
'followup_line_id': fields.many2one('account_followup.followup.line', 'Follow-up Level'),
|
||||||
'followup_date': fields.date('Latest Follow-up'),
|
'followup_date': fields.date('Latest Follow-up'),
|
||||||
}
|
}
|
||||||
account_move_line()
|
account_move_line()
|
||||||
|
|
||||||
|
|
|
@ -31,55 +31,55 @@
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
|
||||||
def _code_get(self, cr, uid, context={}):
|
def _code_get(self, cr, uid, context={}):
|
||||||
acc_type_obj = self.pool.get('account.account.type')
|
acc_type_obj = self.pool.get('account.account.type')
|
||||||
ids = acc_type_obj.search(cr, uid, [])
|
ids = acc_type_obj.search(cr, uid, [])
|
||||||
res = acc_type_obj.read(cr, uid, ids, ['code', 'name'], context)
|
res = acc_type_obj.read(cr, uid, ids, ['code', 'name'], context)
|
||||||
return [(r['code'], r['name']) for r in res]
|
return [(r['code'], r['name']) for r in res]
|
||||||
|
|
||||||
|
|
||||||
class account_followup_stat(osv.osv):
|
class account_followup_stat(osv.osv):
|
||||||
_name = "account_followup.stat"
|
_name = "account_followup.stat"
|
||||||
_description = "Followup statistics"
|
_description = "Followup statistics"
|
||||||
_auto = False
|
_auto = False
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.many2one('res.partner', 'Partner', readonly=True),
|
'name': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||||
'account_type': fields.selection(_code_get, 'Account Type', readonly=True),
|
'account_type': fields.selection(_code_get, 'Account Type', readonly=True),
|
||||||
'date_move':fields.date('First move', readonly=True),
|
'date_move':fields.date('First move', readonly=True),
|
||||||
'date_move_last':fields.date('Last move', readonly=True),
|
'date_move_last':fields.date('Last move', readonly=True),
|
||||||
'date_followup':fields.date('Latest followup', readonly=True),
|
'date_followup':fields.date('Latest followup', readonly=True),
|
||||||
'followup_id': fields.many2one('account_followup.followup.line',
|
'followup_id': fields.many2one('account_followup.followup.line',
|
||||||
'Follow Ups', readonly=True, ondelete="cascade"),
|
'Follow Ups', readonly=True, ondelete="cascade"),
|
||||||
'balance':fields.float('Balance', readonly=True),
|
'balance':fields.float('Balance', readonly=True),
|
||||||
'debit':fields.float('Debit', readonly=True),
|
'debit':fields.float('Debit', readonly=True),
|
||||||
'credit':fields.float('Credit', readonly=True),
|
'credit':fields.float('Credit', readonly=True),
|
||||||
}
|
}
|
||||||
_order = 'date_move'
|
_order = 'date_move'
|
||||||
def init(self, cr):
|
def init(self, cr):
|
||||||
cr.execute("""
|
cr.execute("""
|
||||||
create or replace view account_followup_stat as (
|
create or replace view account_followup_stat as (
|
||||||
select
|
select
|
||||||
min(l.id) as id,
|
min(l.id) as id,
|
||||||
l.partner_id as name,
|
l.partner_id as name,
|
||||||
min(l.date) as date_move,
|
min(l.date) as date_move,
|
||||||
max(l.date) as date_move_last,
|
max(l.date) as date_move_last,
|
||||||
max(l.followup_date) as date_followup,
|
max(l.followup_date) as date_followup,
|
||||||
max(l.followup_line_id) as followup_id,
|
max(l.followup_line_id) as followup_id,
|
||||||
sum(l.debit) as debit,
|
sum(l.debit) as debit,
|
||||||
sum(l.credit) as credit,
|
sum(l.credit) as credit,
|
||||||
sum(l.debit - l.credit) as balance,
|
sum(l.debit - l.credit) as balance,
|
||||||
a.type as account_type
|
a.type as account_type
|
||||||
from
|
from
|
||||||
account_move_line l
|
account_move_line l
|
||||||
left join
|
left join
|
||||||
account_account a on (l.account_id=a.id)
|
account_account a on (l.account_id=a.id)
|
||||||
where
|
where
|
||||||
l.reconcile_id is NULL and
|
l.reconcile_id is NULL and
|
||||||
a.type in ('receivable', 'payable')
|
a.type in ('receivable', 'payable')
|
||||||
and a.active and
|
and a.active and
|
||||||
l.partner_id is not null
|
l.partner_id is not null
|
||||||
group by
|
group by
|
||||||
l.partner_id, a.type
|
l.partner_id, a.type
|
||||||
)""")
|
)""")
|
||||||
account_followup_stat()
|
account_followup_stat()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,39 +34,39 @@ from osv import osv
|
||||||
from report import report_sxw
|
from report import report_sxw
|
||||||
|
|
||||||
class report_rappel(report_sxw.rml_parse):
|
class report_rappel(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(report_rappel, self).__init__(cr, uid, name, context)
|
super(report_rappel, self).__init__(cr, uid, name, context)
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time' : time,
|
'time' : time,
|
||||||
'ids_to_objects': self._ids_to_objects,
|
'ids_to_objects': self._ids_to_objects,
|
||||||
'adr_get' : self._adr_get,
|
'adr_get' : self._adr_get,
|
||||||
'getLines' : self._lines_get,
|
'getLines' : self._lines_get,
|
||||||
})
|
})
|
||||||
|
|
||||||
def _ids_to_objects(self, partners_ids):
|
def _ids_to_objects(self, partners_ids):
|
||||||
pool = pooler.get_pool(self.cr.dbname)
|
pool = pooler.get_pool(self.cr.dbname)
|
||||||
all_partners = []
|
all_partners = []
|
||||||
for partner in partners_ids:
|
for partner in partners_ids:
|
||||||
partners = pool.get('account_followup.stat').browse(self.cr, self.uid, partner[2])
|
partners = pool.get('account_followup.stat').browse(self.cr, self.uid, partner[2])
|
||||||
for par in partners:
|
for par in partners:
|
||||||
all_partners.append(par.name)
|
all_partners.append(par.name)
|
||||||
return all_partners
|
return all_partners
|
||||||
|
|
||||||
def _adr_get(self, partner, type):
|
def _adr_get(self, partner, type):
|
||||||
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
|
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
|
||||||
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
|
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
|
||||||
adr = res_partner.address_get(self.cr, self.uid, [partner.id], [type])[type]
|
adr = res_partner.address_get(self.cr, self.uid, [partner.id], [type])[type]
|
||||||
return res_partner_address.read(self.cr, self.uid, [adr])
|
return res_partner_address.read(self.cr, self.uid, [adr])
|
||||||
|
|
||||||
def _lines_get(self, partner):
|
def _lines_get(self, partner):
|
||||||
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
movelines = moveline_obj.search(self.cr, self.uid,
|
movelines = moveline_obj.search(self.cr, self.uid,
|
||||||
[('partner_id', '=', partner.id),
|
[('partner_id', '=', partner.id),
|
||||||
('account_id.type', '=', 'receivable'),
|
('account_id.type', '=', 'receivable'),
|
||||||
('reconcile_id', '=', False), ('state', '<>', 'draft')])
|
('reconcile_id', '=', False), ('state', '<>', 'draft')])
|
||||||
movelines = moveline_obj.read(self.cr, self.uid, movelines)
|
movelines = moveline_obj.read(self.cr, self.uid, movelines)
|
||||||
return movelines
|
return movelines
|
||||||
|
|
||||||
report_sxw.report_sxw('report.account_followup.followup.print',
|
report_sxw.report_sxw('report.account_followup.followup.print',
|
||||||
'res.partner', 'addons/account_followup/report/rappel.rml',
|
'res.partner', 'addons/account_followup/report/rappel.rml',
|
||||||
parser=report_rappel)
|
parser=report_rappel)
|
||||||
|
|
|
@ -38,73 +38,73 @@ from tools.translate import _
|
||||||
|
|
||||||
_followup_wizard_date_form = """<?xml version="1.0"?>
|
_followup_wizard_date_form = """<?xml version="1.0"?>
|
||||||
<form string="Select a date">
|
<form string="Select a date">
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
_followup_wizard_date_fields = {
|
_followup_wizard_date_fields = {
|
||||||
'date': {'string': 'Date', 'type': 'date', 'required': True},
|
'date': {'string': 'Date', 'type': 'date', 'required': True},
|
||||||
}
|
}
|
||||||
|
|
||||||
form = """<?xml version="1.0"?>
|
form = """<?xml version="1.0"?>
|
||||||
<form string="Mail">
|
<form string="Mail">
|
||||||
<field name="mail_sent" colspan="4"/>
|
<field name="mail_sent" colspan="4"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<separator string="Mail not sent to following Partners , Email not available !" colspan="4"/>
|
<separator string="Mail not sent to following Partners , Email not available !" colspan="4"/>
|
||||||
<field name="mail_notsent" colspan="4" nolabel="1"/>
|
<field name="mail_notsent" colspan="4" nolabel="1"/>
|
||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
'mail_sent': {'string':'Number of Mail sent', 'type':'char', 'readonly':True },
|
'mail_sent': {'string':'Number of Mail sent', 'type':'char', 'readonly':True },
|
||||||
'mail_notsent': {'string':'Error Messages', 'type':'text', 'readonly':True , 'nolabel':'1'},
|
'mail_notsent': {'string':'Error Messages', 'type':'text', 'readonly':True , 'nolabel':'1'},
|
||||||
}
|
}
|
||||||
|
|
||||||
_followup_wizard_all_form = """<?xml version="1.0"?>
|
_followup_wizard_all_form = """<?xml version="1.0"?>
|
||||||
<form string="Select partners" colspan="4">
|
<form string="Select partners" colspan="4">
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="FollowUp selection">
|
<page string="FollowUp selection">
|
||||||
<separator string="Select partners to remind" colspan="4"/>
|
<separator string="Select partners to remind" colspan="4"/>
|
||||||
<field name="partner_ids" colspan="4" nolabel="1"/>
|
<field name="partner_ids" colspan="4" nolabel="1"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Email confirmation">
|
<page string="Email confirmation">
|
||||||
<field name="email_conf" colspan="4"/>
|
<field name="email_conf" colspan="4"/>
|
||||||
<field name="email_subject" colspan="4"/>
|
<field name="email_subject" colspan="4"/>
|
||||||
<separator string="Email body" colspan="4"/>
|
<separator string="Email body" colspan="4"/>
|
||||||
<field name="email_body" colspan="4" nolabel="1"/>
|
<field name="email_body" colspan="4" nolabel="1"/>
|
||||||
<separator string="Legend" colspan="4"/>
|
<separator string="Legend" colspan="4"/>
|
||||||
|
|
||||||
<label string="%(partner_name)s: Partner name" colspan="2"/>
|
<label string="%(partner_name)s: Partner name" colspan="2"/>
|
||||||
<label string="%(followup_amount)s: Total Amount Due" colspan="2"/>
|
<label string="%(followup_amount)s: Total Amount Due" colspan="2"/>
|
||||||
<label string="%(user_signature)s: User name" colspan="2"/>
|
<label string="%(user_signature)s: User name" colspan="2"/>
|
||||||
<label string="%(company_name)s: User's Company name" colspan="2"/>
|
<label string="%(company_name)s: User's Company name" colspan="2"/>
|
||||||
<label string="%(line)s: Account Move lines" colspan="2"/>
|
<label string="%(line)s: Account Move lines" colspan="2"/>
|
||||||
<label string="%(heading)s: Move line header" colspan="2"/>
|
<label string="%(heading)s: Move line header" colspan="2"/>
|
||||||
<label string="%(date)s: Current Date" colspan="2"/>
|
<label string="%(date)s: Current Date" colspan="2"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
_followup_wizard_all_fields = {
|
_followup_wizard_all_fields = {
|
||||||
'partner_ids': {
|
'partner_ids': {
|
||||||
'string': "Partners",
|
'string': "Partners",
|
||||||
'type': 'many2many',
|
'type': 'many2many',
|
||||||
'relation': 'account_followup.stat',
|
'relation': 'account_followup.stat',
|
||||||
'domain':"[('account_type','=','receivable')]"
|
'domain':"[('account_type','=','receivable')]"
|
||||||
},
|
},
|
||||||
'email_conf': {
|
'email_conf': {
|
||||||
'string': "Send email confirmation",
|
'string': "Send email confirmation",
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
},
|
},
|
||||||
'email_subject' : {
|
'email_subject' : {
|
||||||
'string' : "Email Subject",
|
'string' : "Email Subject",
|
||||||
'type' : "char",
|
'type' : "char",
|
||||||
'size': 64,
|
'size': 64,
|
||||||
'default': 'Account Follow-up'
|
'default': 'Account Follow-up'
|
||||||
},
|
},
|
||||||
'email_body': {
|
'email_body': {
|
||||||
'string': "Email body",
|
'string': "Email body",
|
||||||
'type': 'text',
|
'type': 'text',
|
||||||
'default': '''
|
'default': '''
|
||||||
Date : %(date)s
|
Date : %(date)s
|
||||||
|
|
||||||
Dear %(partner_name)s,
|
Dear %(partner_name)s,
|
||||||
|
@ -126,183 +126,183 @@ Thanks,
|
||||||
--
|
--
|
||||||
%(user_signature)s
|
%(user_signature)s
|
||||||
%(company_name)s
|
%(company_name)s
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class followup_all_print(wizard.interface):
|
class followup_all_print(wizard.interface):
|
||||||
def _update_partners(self, cr, uid, data, context):
|
def _update_partners(self, cr, uid, data, context):
|
||||||
to_update = data['form']['to_update']
|
to_update = data['form']['to_update']
|
||||||
for id in to_update.keys():
|
for id in to_update.keys():
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"UPDATE account_move_line "\
|
"UPDATE account_move_line "\
|
||||||
"SET followup_line_id=%d, followup_date=%s "\
|
"SET followup_line_id=%d, followup_date=%s "\
|
||||||
"WHERE id=%d",
|
"WHERE id=%d",
|
||||||
(to_update[id],
|
(to_update[id],
|
||||||
data['form']['date'], int(id),))
|
data['form']['date'], int(id),))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _sendmail(self ,cr, uid, data, context):
|
def _sendmail(self ,cr, uid, data, context):
|
||||||
self._update_partners(cr, uid, data, context)
|
self._update_partners(cr, uid, data, context)
|
||||||
mail_notsent = ''
|
mail_notsent = ''
|
||||||
count = 0
|
count = 0
|
||||||
if data['form']['email_conf']:
|
if data['form']['email_conf']:
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
data_user = pool.get('res.users').browse(cr,uid,uid)
|
data_user = pool.get('res.users').browse(cr,uid,uid)
|
||||||
line_obj = pool.get('account_followup.stat')
|
line_obj = pool.get('account_followup.stat')
|
||||||
move_lines = line_obj.browse(cr,uid,data['form']['partner_ids'][0][2])
|
move_lines = line_obj.browse(cr,uid,data['form']['partner_ids'][0][2])
|
||||||
partners = []
|
partners = []
|
||||||
dict_lines = {}
|
dict_lines = {}
|
||||||
for line in move_lines:
|
for line in move_lines:
|
||||||
partners.append(line.name)
|
partners.append(line.name)
|
||||||
dict_lines[line.name.id] =line
|
dict_lines[line.name.id] =line
|
||||||
for partner in partners:
|
for partner in partners:
|
||||||
ids_lines = pool.get('account.move.line').search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable','payable'])])
|
ids_lines = pool.get('account.move.line').search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable','payable'])])
|
||||||
data_lines = pool.get('account.move.line').browse(cr,uid,ids_lines)
|
data_lines = pool.get('account.move.line').browse(cr,uid,ids_lines)
|
||||||
followup_data = dict_lines[partner.id]
|
followup_data = dict_lines[partner.id]
|
||||||
dest = False
|
dest = False
|
||||||
if partner.address:
|
if partner.address:
|
||||||
for adr in partner.address:
|
for adr in partner.address:
|
||||||
if adr.type=='contact':
|
if adr.type=='contact':
|
||||||
if adr.email:
|
if adr.email:
|
||||||
dest = [adr.email]
|
dest = [adr.email]
|
||||||
if (not dest) and adr.type=='default':
|
if (not dest) and adr.type=='default':
|
||||||
if adr.email:
|
if adr.email:
|
||||||
dest = [adr.email]
|
dest = [adr.email]
|
||||||
src = tools.config.options['smtp_user']
|
src = tools.config.options['smtp_user']
|
||||||
body=data['form']['email_body']
|
body=data['form']['email_body']
|
||||||
total_amt = followup_data.debit - followup_data.credit
|
total_amt = followup_data.debit - followup_data.credit
|
||||||
move_line = ''
|
move_line = ''
|
||||||
subtotal_due = 0.0
|
subtotal_due = 0.0
|
||||||
subtotal_paid = 0.0
|
subtotal_paid = 0.0
|
||||||
subtotal_maturity = 0.0
|
subtotal_maturity = 0.0
|
||||||
balance = 0.0
|
balance = 0.0
|
||||||
l = '--------------------------------------------------------------------------------------------------------------------------'
|
l = '--------------------------------------------------------------------------------------------------------------------------'
|
||||||
head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Maturity date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
|
head = l+ '\n' + 'Date'.rjust(10) + '\t' + 'Description'.rjust(10) + '\t' + 'Ref'.rjust(10) + '\t' + 'Maturity date'.rjust(10) + '\t' + 'Due'.rjust(10) + '\t' + 'Paid'.rjust(10) + '\t' + 'Maturity'.rjust(10) + '\t' + 'Litigation'.rjust(10) + '\n' + l
|
||||||
for i in data_lines:
|
for i in data_lines:
|
||||||
maturity = ''
|
maturity = ''
|
||||||
if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
|
if i.date_maturity < time.strftime('%Y-%m-%d') and (i.debit - i.credit):
|
||||||
maturity = i.debit - i.credit
|
maturity = i.debit - i.credit
|
||||||
subtotal_due = subtotal_due + i.debit
|
subtotal_due = subtotal_due + i.debit
|
||||||
subtotal_paid = subtotal_paid + i.credit
|
subtotal_paid = subtotal_paid + i.credit
|
||||||
subtotal_maturity = subtotal_maturity + int(maturity)
|
subtotal_maturity = subtotal_maturity + int(maturity)
|
||||||
balance = balance + (i.debit - i.credit)
|
balance = balance + (i.debit - i.credit)
|
||||||
move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
|
move_line = move_line + (i.date).rjust(10) + '\t'+ (i.name).rjust(10) + '\t'+ (i.ref or '').rjust(10) + '\t' + (i.date_maturity or '').rjust(10) + '\t' + str(i.debit).rjust(10) + '\t' + str(i.credit).rjust(10) + '\t' + str(maturity).rjust(10) + '\t' + str(i.blocked).rjust(10) + '\n'
|
||||||
move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
|
move_line = move_line + l + '\n'+ '\t\t\t' + 'Sub total'.rjust(35) + '\t' + (str(subtotal_due) or '').rjust(10) + '\t' + (str(subtotal_paid) or '').rjust(10) + '\t' + (str(subtotal_maturity) or '').rjust(10)+ '\n'
|
||||||
move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
|
move_line = move_line + '\t\t\t' + 'Balance'.rjust(33) + '\t' + str(balance).rjust(10) + '\n' + l
|
||||||
val = {
|
val = {
|
||||||
'partner_name':partner.name,
|
'partner_name':partner.name,
|
||||||
'followup_amount':total_amt,
|
'followup_amount':total_amt,
|
||||||
'user_signature':data_user.name,
|
'user_signature':data_user.name,
|
||||||
'company_name':data_user.company_id.name,
|
'company_name':data_user.company_id.name,
|
||||||
'line':move_line,
|
'line':move_line,
|
||||||
'heading': head,
|
'heading': head,
|
||||||
'date':time.strftime('%Y-%m-%d')
|
'date':time.strftime('%Y-%m-%d')
|
||||||
}
|
}
|
||||||
body = body%val
|
body = body%val
|
||||||
sub = str(data['form']['email_subject'])
|
sub = str(data['form']['email_subject'])
|
||||||
if dest:
|
if dest:
|
||||||
tools.email_send(src,dest,sub,body)
|
tools.email_send(src,dest,sub,body)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
else:
|
else:
|
||||||
mail_notsent = mail_notsent + partner.name + ','
|
mail_notsent = mail_notsent + partner.name + ','
|
||||||
return {'mail_notsent' : str(mail_notsent) , 'mail_sent' : str(count)}
|
return {'mail_notsent' : str(mail_notsent) , 'mail_sent' : str(count)}
|
||||||
|
|
||||||
def _get_partners(self, cr, uid, data, context):
|
def _get_partners(self, cr, uid, data, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT l.partner_id, l.followup_line_id, l.date, l.id "\
|
"SELECT l.partner_id, l.followup_line_id, l.date, l.id "\
|
||||||
"FROM account_move_line AS l "\
|
"FROM account_move_line AS l "\
|
||||||
"LEFT JOIN account_account AS a "\
|
"LEFT JOIN account_account AS a "\
|
||||||
"ON (l.account_id=a.id) "\
|
"ON (l.account_id=a.id) "\
|
||||||
"WHERE (l.reconcile_id IS NULL) "\
|
"WHERE (l.reconcile_id IS NULL) "\
|
||||||
"AND (a.type='receivable') "\
|
"AND (a.type='receivable') "\
|
||||||
"AND (l.state<>'draft') "\
|
"AND (l.state<>'draft') "\
|
||||||
"AND (l.reconcile_id is NULL) "\
|
"AND (l.reconcile_id is NULL) "\
|
||||||
"AND partner_id is NOT NULL "\
|
"AND partner_id is NOT NULL "\
|
||||||
"AND a.active "\
|
"AND a.active "\
|
||||||
"ORDER BY l.date")
|
"ORDER BY l.date")
|
||||||
move_lines = cr.fetchall()
|
move_lines = cr.fetchall()
|
||||||
|
|
||||||
old = None
|
old = None
|
||||||
fups = {}
|
fups = {}
|
||||||
fup_ids = pool.get('account_followup.followup').search(cr, uid, [])
|
fup_ids = pool.get('account_followup.followup').search(cr, uid, [])
|
||||||
if not fup_ids:
|
if not fup_ids:
|
||||||
raise wizard.except_wizard(_('No Follow up Defined'),
|
raise wizard.except_wizard(_('No Follow up Defined'),
|
||||||
_('You must define at least one follow up for your company !'))
|
_('You must define at least one follow up for your company !'))
|
||||||
fup_id = fup_ids[0]
|
fup_id = fup_ids[0]
|
||||||
|
|
||||||
current_date = datetime.date(*time.strptime(data['form']['date'],
|
current_date = datetime.date(*time.strptime(data['form']['date'],
|
||||||
'%Y-%m-%d')[:3])
|
'%Y-%m-%d')[:3])
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT * "\
|
"SELECT * "\
|
||||||
"FROM account_followup_followup_line "\
|
"FROM account_followup_followup_line "\
|
||||||
"WHERE followup_id=%d "\
|
"WHERE followup_id=%d "\
|
||||||
"ORDER BY sequence", (fup_id,))
|
"ORDER BY sequence", (fup_id,))
|
||||||
for result in cr.dictfetchall():
|
for result in cr.dictfetchall():
|
||||||
delay = datetime.timedelta(days=result['delay'])
|
delay = datetime.timedelta(days=result['delay'])
|
||||||
fups[old] = (current_date - delay, result['id'])
|
fups[old] = (current_date - delay, result['id'])
|
||||||
if result['start'] == 'end_of_month':
|
if result['start'] == 'end_of_month':
|
||||||
fups[old][0].replace(day=1)
|
fups[old][0].replace(day=1)
|
||||||
old = result['id']
|
old = result['id']
|
||||||
|
|
||||||
fups[old] = (datetime.date(datetime.MAXYEAR, 12, 31), old)
|
fups[old] = (datetime.date(datetime.MAXYEAR, 12, 31), old)
|
||||||
|
|
||||||
partner_list = []
|
partner_list = []
|
||||||
to_update = {}
|
to_update = {}
|
||||||
for partner_id, followup_line_id, date, id in move_lines:
|
for partner_id, followup_line_id, date, id in move_lines:
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
continue
|
continue
|
||||||
if partner_id in partner_list:
|
if partner_id in partner_list:
|
||||||
to_update[str(id)] = fups[followup_line_id][1]
|
to_update[str(id)] = fups[followup_line_id][1]
|
||||||
if followup_line_id not in fups:
|
if followup_line_id not in fups:
|
||||||
continue
|
continue
|
||||||
if date <= fups[followup_line_id][0].strftime('%Y-%m-%d'):
|
if date <= fups[followup_line_id][0].strftime('%Y-%m-%d'):
|
||||||
partner_list.append(partner_id)
|
partner_list.append(partner_id)
|
||||||
to_update[str(id)] = fups[followup_line_id][1]
|
to_update[str(id)] = fups[followup_line_id][1]
|
||||||
return {'partner_ids': partner_list, 'to_update': to_update}
|
return {'partner_ids': partner_list, 'to_update': to_update}
|
||||||
|
|
||||||
def _get_date(self, cursor, user, data, context):
|
def _get_date(self, cursor, user, data, context):
|
||||||
return {'date': time.strftime('%Y-%m-%d')}
|
return {'date': time.strftime('%Y-%m-%d')}
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_get_date],
|
'actions': [_get_date],
|
||||||
'result': {'type': 'form',
|
'result': {'type': 'form',
|
||||||
'arch': _followup_wizard_date_form,
|
'arch': _followup_wizard_date_form,
|
||||||
'fields': _followup_wizard_date_fields,
|
'fields': _followup_wizard_date_fields,
|
||||||
'state': [
|
'state': [
|
||||||
('end', 'Cancel'),
|
('end', 'Cancel'),
|
||||||
('next', 'Continue'),
|
('next', 'Continue'),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'next': {
|
'next': {
|
||||||
'actions': [_get_partners],
|
'actions': [_get_partners],
|
||||||
'result': {'type': 'form',
|
'result': {'type': 'form',
|
||||||
'arch': _followup_wizard_all_form,
|
'arch': _followup_wizard_all_form,
|
||||||
'fields': _followup_wizard_all_fields,
|
'fields': _followup_wizard_all_fields,
|
||||||
'state': [
|
'state': [
|
||||||
('end','Cancel'),
|
('end','Cancel'),
|
||||||
('print','Print Follow Ups'),
|
('print','Print Follow Ups'),
|
||||||
('sendmail','Send Mail')
|
('sendmail','Send Mail')
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'print': {
|
'print': {
|
||||||
'actions': [_update_partners],
|
'actions': [_update_partners],
|
||||||
'result': {'type': 'print',
|
'result': {'type': 'print',
|
||||||
'report':'account_followup.followup.print',
|
'report':'account_followup.followup.print',
|
||||||
'state':'end'},
|
'state':'end'},
|
||||||
},
|
},
|
||||||
'sendmail': {
|
'sendmail': {
|
||||||
'actions': [_sendmail],
|
'actions': [_sendmail],
|
||||||
'result': {'type': 'form',
|
'result': {'type': 'form',
|
||||||
'arch': form,
|
'arch': form,
|
||||||
'fields': fields,
|
'fields': fields,
|
||||||
'state':[('end','Ok')]},
|
'state':[('end','Ok')]},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
followup_all_print('account_followup.followup.print.all')
|
followup_all_print('account_followup.followup.print.all')
|
||||||
|
|
||||||
|
|
|
@ -26,22 +26,22 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name": "Payment Management",
|
"name": "Payment Management",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"author": "Tiny",
|
"author": "Tiny",
|
||||||
"category": "Generic Modules/Payment",
|
"category": "Generic Modules/Payment",
|
||||||
"depends": ["account"],
|
"depends": ["account"],
|
||||||
"init_xml": [],
|
"init_xml": [],
|
||||||
"description": """
|
"description": """
|
||||||
This module provide :
|
This module provide :
|
||||||
* a more efficient way to manage invoice payment.
|
* a more efficient way to manage invoice payment.
|
||||||
* a basic mechanism to easily plug various automated payment.
|
* a basic mechanism to easily plug various automated payment.
|
||||||
""",
|
""",
|
||||||
"demo_xml": [],
|
"demo_xml": [],
|
||||||
"update_xml": ["payment_wizard.xml", "payment_view.xml",
|
"update_xml": ["payment_wizard.xml", "payment_view.xml",
|
||||||
"payment_workflow.xml", "payment_sequence.xml",
|
"payment_workflow.xml", "payment_sequence.xml",
|
||||||
"account_invoice_view.xml", "payment_report.xml"],
|
"account_invoice_view.xml", "payment_report.xml"],
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,28 +31,28 @@ from osv import fields, osv
|
||||||
from mx import DateTime
|
from mx import DateTime
|
||||||
|
|
||||||
class Invoice(osv.osv):
|
class Invoice(osv.osv):
|
||||||
_inherit = 'account.invoice'
|
_inherit = 'account.invoice'
|
||||||
|
|
||||||
def _amount_to_pay(self, cursor, user, ids, name, args, context=None):
|
def _amount_to_pay(self, cursor, user, ids, name, args, context=None):
|
||||||
'''Return the amount still to pay regarding all the payment orders'''
|
'''Return the amount still to pay regarding all the payment orders'''
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
res = {}
|
res = {}
|
||||||
for invoice in self.browse(cursor, user, ids, context=context):
|
for invoice in self.browse(cursor, user, ids, context=context):
|
||||||
res[invoice.id] = 0.0
|
res[invoice.id] = 0.0
|
||||||
if invoice.move_id:
|
if invoice.move_id:
|
||||||
for line in invoice.move_id.line_id:
|
for line in invoice.move_id.line_id:
|
||||||
if not line.date_maturity or \
|
if not line.date_maturity or \
|
||||||
DateTime.strptime(line.date_maturity, '%Y-%m-%d') \
|
DateTime.strptime(line.date_maturity, '%Y-%m-%d') \
|
||||||
< DateTime.now():
|
< DateTime.now():
|
||||||
res[invoice.id] += line.amount_to_pay
|
res[invoice.id] += line.amount_to_pay
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'amount_to_pay': fields.function(_amount_to_pay, method=True,
|
'amount_to_pay': fields.function(_amount_to_pay, method=True,
|
||||||
type='float', string='Amount to be paid',
|
type='float', string='Amount to be paid',
|
||||||
help='The amount which should be paid at the current date\n' \
|
help='The amount which should be paid at the current date\n' \
|
||||||
'minus the amount which is already in payment order'),
|
'minus the amount which is already in payment order'),
|
||||||
}
|
}
|
||||||
|
|
||||||
Invoice()
|
Invoice()
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -31,88 +31,88 @@ from osv import fields, osv
|
||||||
|
|
||||||
|
|
||||||
class account_move_line(osv.osv):
|
class account_move_line(osv.osv):
|
||||||
_inherit = "account.move.line"
|
_inherit = "account.move.line"
|
||||||
|
|
||||||
def amount_to_pay(self, cr, uid, ids, name, arg={}, context={}):
|
def amount_to_pay(self, cr, uid, ids, name, arg={}, context={}):
|
||||||
""" Return the amount still to pay regarding all the payemnt orders
|
""" Return the amount still to pay regarding all the payemnt orders
|
||||||
(excepting cancelled orders)"""
|
(excepting cancelled orders)"""
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
cr.execute("""SELECT ml.id,
|
cr.execute("""SELECT ml.id,
|
||||||
CASE WHEN ml.amount_currency < 0
|
CASE WHEN ml.amount_currency < 0
|
||||||
THEN - ml.amount_currency
|
THEN - ml.amount_currency
|
||||||
ELSE ml.credit
|
ELSE ml.credit
|
||||||
END -
|
END -
|
||||||
(SELECT coalesce(sum(amount_currency),0)
|
(SELECT coalesce(sum(amount_currency),0)
|
||||||
FROM payment_line pl
|
FROM payment_line pl
|
||||||
INNER JOIN payment_order po
|
INNER JOIN payment_order po
|
||||||
ON (pl.order_id = po.id)
|
ON (pl.order_id = po.id)
|
||||||
WHERE move_line_id = ml.id
|
WHERE move_line_id = ml.id
|
||||||
AND po.state != 'cancel') as amount
|
AND po.state != 'cancel') as amount
|
||||||
FROM account_move_line ml
|
FROM account_move_line ml
|
||||||
WHERE id in (%s)""" % (",".join(map(str, ids))))
|
WHERE id in (%s)""" % (",".join(map(str, ids))))
|
||||||
r=dict(cr.fetchall())
|
r=dict(cr.fetchall())
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def _to_pay_search(self, cr, uid, obj, name, args):
|
def _to_pay_search(self, cr, uid, obj, name, args):
|
||||||
if not len(args):
|
if not len(args):
|
||||||
return []
|
return []
|
||||||
line_obj = self.pool.get('account.move.line')
|
line_obj = self.pool.get('account.move.line')
|
||||||
query = line_obj._query_get(cr, uid, context={})
|
query = line_obj._query_get(cr, uid, context={})
|
||||||
where = ' and '.join(map(lambda x: '''(SELECT
|
where = ' and '.join(map(lambda x: '''(SELECT
|
||||||
CASE WHEN l.amount_currency < 0
|
CASE WHEN l.amount_currency < 0
|
||||||
THEN - l.amount_currency
|
THEN - l.amount_currency
|
||||||
ELSE l.credit
|
ELSE l.credit
|
||||||
END - coalesce(sum(pl.amount_currency), 0)
|
END - coalesce(sum(pl.amount_currency), 0)
|
||||||
FROM payment_line pl
|
FROM payment_line pl
|
||||||
INNER JOIN payment_order po ON (pl.order_id = po.id)
|
INNER JOIN payment_order po ON (pl.order_id = po.id)
|
||||||
WHERE move_line_id = l.id AND po.state != 'cancel')''' \
|
WHERE move_line_id = l.id AND po.state != 'cancel')''' \
|
||||||
+ x[1] + str(x[2])+' ',args))
|
+ x[1] + str(x[2])+' ',args))
|
||||||
|
|
||||||
cr.execute(('''select id
|
cr.execute(('''select id
|
||||||
from account_move_line l
|
from account_move_line l
|
||||||
where account_id in (select id
|
where account_id in (select id
|
||||||
from account_account
|
from account_account
|
||||||
where type=%s and active)
|
where type=%s and active)
|
||||||
and reconcile_id is null
|
and reconcile_id is null
|
||||||
and credit > 0
|
and credit > 0
|
||||||
and ''' + where + ' and ' + query), ('payable',) )
|
and ''' + where + ' and ' + query), ('payable',) )
|
||||||
|
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
if not len(res):
|
if not len(res):
|
||||||
return [('id','=','0')]
|
return [('id','=','0')]
|
||||||
return [('id','in',map(lambda x:x[0], res))]
|
return [('id','in',map(lambda x:x[0], res))]
|
||||||
|
|
||||||
def line2bank(self, cr, uid, ids, payment_type='manual', context=None):
|
def line2bank(self, cr, uid, ids, payment_type='manual', context=None):
|
||||||
"""
|
"""
|
||||||
Try to return for each account move line a corresponding bank
|
Try to return for each account move line a corresponding bank
|
||||||
account according to the payment type. This work using one of
|
account according to the payment type. This work using one of
|
||||||
the bank of the partner defined on the invoice eventually
|
the bank of the partner defined on the invoice eventually
|
||||||
associated to the line.
|
associated to the line.
|
||||||
Return the first suitable bank for the corresponding partner.
|
Return the first suitable bank for the corresponding partner.
|
||||||
"""
|
"""
|
||||||
payment_mode_obj = self.pool.get('payment.mode')
|
payment_mode_obj = self.pool.get('payment.mode')
|
||||||
line2bank = {}
|
line2bank = {}
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type,
|
bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type,
|
||||||
context=context)
|
context=context)
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
line2bank[line.id] = False
|
line2bank[line.id] = False
|
||||||
if line.invoice and line.invoice.partner_bank:
|
if line.invoice and line.invoice.partner_bank:
|
||||||
line2bank[line.id] = line.invoice.partner_bank.id
|
line2bank[line.id] = line.invoice.partner_bank.id
|
||||||
elif line.partner_id:
|
elif line.partner_id:
|
||||||
for bank in line.partner_id.bank_ids:
|
for bank in line.partner_id.bank_ids:
|
||||||
if bank.state in bank_type:
|
if bank.state in bank_type:
|
||||||
line2bank[line.id] = bank.id
|
line2bank[line.id] = bank.id
|
||||||
break
|
break
|
||||||
if line.id not in line2bank and line.partner_id.bank_ids:
|
if line.id not in line2bank and line.partner_id.bank_ids:
|
||||||
line2bank[line.id] = line.partner_id.bank_ids[0].id
|
line2bank[line.id] = line.partner_id.bank_ids[0].id
|
||||||
return line2bank
|
return line2bank
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'amount_to_pay' : fields.function(amount_to_pay, method=True,
|
'amount_to_pay' : fields.function(amount_to_pay, method=True,
|
||||||
type='float', string='Amount to pay', fnct_search=_to_pay_search),
|
type='float', string='Amount to pay', fnct_search=_to_pay_search),
|
||||||
}
|
}
|
||||||
|
|
||||||
account_move_line()
|
account_move_line()
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -35,471 +35,471 @@ import pooler
|
||||||
|
|
||||||
|
|
||||||
class payment_type(osv.osv):
|
class payment_type(osv.osv):
|
||||||
_name= 'payment.type'
|
_name= 'payment.type'
|
||||||
_description= 'Payment type'
|
_description= 'Payment type'
|
||||||
_columns= {
|
_columns= {
|
||||||
'name': fields.char('Name', size=64, required=True),
|
'name': fields.char('Name', size=64, required=True),
|
||||||
'code': fields.char('Code', size=64, required=True),
|
'code': fields.char('Code', size=64, required=True),
|
||||||
'suitable_bank_types': fields.many2many('res.partner.bank.type',
|
'suitable_bank_types': fields.many2many('res.partner.bank.type',
|
||||||
'bank_type_payment_type_rel',
|
'bank_type_payment_type_rel',
|
||||||
'pay_type_id','bank_type_id',
|
'pay_type_id','bank_type_id',
|
||||||
'Suitable bank types')
|
'Suitable bank types')
|
||||||
}
|
}
|
||||||
|
|
||||||
payment_type()
|
payment_type()
|
||||||
|
|
||||||
|
|
||||||
class payment_mode(osv.osv):
|
class payment_mode(osv.osv):
|
||||||
_name= 'payment.mode'
|
_name= 'payment.mode'
|
||||||
_description= 'Payment mode'
|
_description= 'Payment mode'
|
||||||
_columns= {
|
_columns= {
|
||||||
'name': fields.char('Name', size=64, required=True),
|
'name': fields.char('Name', size=64, required=True),
|
||||||
'bank_id': fields.many2one('res.partner.bank', "Bank account",
|
'bank_id': fields.many2one('res.partner.bank', "Bank account",
|
||||||
required=True),
|
required=True),
|
||||||
'journal': fields.many2one('account.journal', 'Journal', required=True,
|
'journal': fields.many2one('account.journal', 'Journal', required=True,
|
||||||
domain=[('type', '=', 'cash')]),
|
domain=[('type', '=', 'cash')]),
|
||||||
'type': fields.many2one('payment.type','Payment type',required=True),
|
'type': fields.many2one('payment.type','Payment type',required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
def suitable_bank_types(self,cr,uid,payment_code= 'manual',context={}):
|
def suitable_bank_types(self,cr,uid,payment_code= 'manual',context={}):
|
||||||
"""Return the codes of the bank type that are suitable
|
"""Return the codes of the bank type that are suitable
|
||||||
for the given payment type code"""
|
for the given payment type code"""
|
||||||
cr.execute(""" select t.code
|
cr.execute(""" select t.code
|
||||||
from res_partner_bank_type t
|
from res_partner_bank_type t
|
||||||
join bank_type_payment_type_rel r on (r.bank_type_id = t.id)
|
join bank_type_payment_type_rel r on (r.bank_type_id = t.id)
|
||||||
join payment_type pt on (r.pay_type_id = pt.id)
|
join payment_type pt on (r.pay_type_id = pt.id)
|
||||||
where pt.code = %s """, [payment_code])
|
where pt.code = %s """, [payment_code])
|
||||||
return [x[0] for x in cr.fetchall()]
|
return [x[0] for x in cr.fetchall()]
|
||||||
|
|
||||||
payment_mode()
|
payment_mode()
|
||||||
|
|
||||||
|
|
||||||
class payment_order(osv.osv):
|
class payment_order(osv.osv):
|
||||||
_name = 'payment.order'
|
_name = 'payment.order'
|
||||||
_description = 'Payment Order'
|
_description = 'Payment Order'
|
||||||
_rec_name = 'date'
|
_rec_name = 'date'
|
||||||
|
|
||||||
def get_wizard(self,type):
|
def get_wizard(self,type):
|
||||||
logger = netsvc.Logger()
|
logger = netsvc.Logger()
|
||||||
logger.notifyChannel("warning", netsvc.LOG_WARNING,
|
logger.notifyChannel("warning", netsvc.LOG_WARNING,
|
||||||
"No wizard found for the payment type '%s'." % type)
|
"No wizard found for the payment type '%s'." % type)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _total(self, cursor, user, ids, name, args, context=None):
|
def _total(self, cursor, user, ids, name, args, context=None):
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
res = {}
|
res = {}
|
||||||
for order in self.browse(cursor, user, ids, context=context):
|
for order in self.browse(cursor, user, ids, context=context):
|
||||||
if order.line_ids:
|
if order.line_ids:
|
||||||
res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0)
|
res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0)
|
||||||
else:
|
else:
|
||||||
res[order.id] = 0.0
|
res[order.id] = 0.0
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'date_planned': fields.date('Scheduled date if fixed'),
|
'date_planned': fields.date('Scheduled date if fixed'),
|
||||||
'reference': fields.char('Reference',size=128,required=1),
|
'reference': fields.char('Reference',size=128,required=1),
|
||||||
'mode': fields.many2one('payment.mode','Payment mode', select=True, required=1),
|
'mode': fields.many2one('payment.mode','Payment mode', select=True, required=1),
|
||||||
'state': fields.selection([
|
'state': fields.selection([
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
('open','Confirmed'),
|
('open','Confirmed'),
|
||||||
('cancel','Cancelled'),
|
('cancel','Cancelled'),
|
||||||
('done','Done')], 'State', select=True),
|
('done','Done')], 'State', select=True),
|
||||||
'line_ids': fields.one2many('payment.line','order_id','Payment lines',states={'done':[('readonly',True)]}),
|
'line_ids': fields.one2many('payment.line','order_id','Payment lines',states={'done':[('readonly',True)]}),
|
||||||
'total': fields.function(_total, string="Total", method=True,
|
'total': fields.function(_total, string="Total", method=True,
|
||||||
type='float'),
|
type='float'),
|
||||||
'user_id': fields.many2one('res.users','User',required=True),
|
'user_id': fields.many2one('res.users','User',required=True),
|
||||||
'date_prefered': fields.selection([
|
'date_prefered': fields.selection([
|
||||||
('now', 'Directly'),
|
('now', 'Directly'),
|
||||||
('due', 'Due date'),
|
('due', 'Due date'),
|
||||||
('fixed', 'Fixed date')
|
('fixed', 'Fixed date')
|
||||||
], "Prefered date", change_default=True, required=True),
|
], "Prefered date", change_default=True, required=True),
|
||||||
'date_created': fields.date('Creation date', readonly=True),
|
'date_created': fields.date('Creation date', readonly=True),
|
||||||
'date_done': fields.date('Execution date', readonly=True),
|
'date_done': fields.date('Execution date', readonly=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'user_id': lambda self,cr,uid,context: uid,
|
'user_id': lambda self,cr,uid,context: uid,
|
||||||
'state': lambda *a: 'draft',
|
'state': lambda *a: 'draft',
|
||||||
'date_prefered': lambda *a: 'due',
|
'date_prefered': lambda *a: 'due',
|
||||||
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
|
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
|
||||||
'reference': lambda self,cr,uid,context: self.pool.get('ir.sequence').get(cr, uid, 'payment.order'),
|
'reference': lambda self,cr,uid,context: self.pool.get('ir.sequence').get(cr, uid, 'payment.order'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_to_draft(self, cr, uid, ids, *args):
|
def set_to_draft(self, cr, uid, ids, *args):
|
||||||
self.write(cr, uid, ids, {'state':'draft'})
|
self.write(cr, uid, ids, {'state':'draft'})
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
for id in ids:
|
for id in ids:
|
||||||
wf_service.trg_create(uid, 'payment.order', id, cr)
|
wf_service.trg_create(uid, 'payment.order', id, cr)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_open(self, cr, uid, ids, *args):
|
def action_open(self, cr, uid, ids, *args):
|
||||||
for order in self.read(cr,uid,ids,['reference']):
|
for order in self.read(cr,uid,ids,['reference']):
|
||||||
if not order['reference']:
|
if not order['reference']:
|
||||||
reference = self.pool.get('ir.sequence').get(cr, uid, 'payment.order')
|
reference = self.pool.get('ir.sequence').get(cr, uid, 'payment.order')
|
||||||
self.write(cr,uid,order['id'],{'reference':reference})
|
self.write(cr,uid,order['id'],{'reference':reference})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def set_done(self, cr, uid, id, *args):
|
def set_done(self, cr, uid, id, *args):
|
||||||
self.write(cr,uid,id,{'date_done': time.strftime('%Y-%m-%d'),
|
self.write(cr,uid,id,{'date_done': time.strftime('%Y-%m-%d'),
|
||||||
'state': 'done',})
|
'state': 'done',})
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
wf_service.trg_validate(uid, 'payment.order', id, 'done', cr)
|
wf_service.trg_validate(uid, 'payment.order', id, 'done', cr)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
payment_order()
|
payment_order()
|
||||||
|
|
||||||
|
|
||||||
class payment_line(osv.osv):
|
class payment_line(osv.osv):
|
||||||
_name = 'payment.line'
|
_name = 'payment.line'
|
||||||
_description = 'Payment Line'
|
_description = 'Payment Line'
|
||||||
|
|
||||||
def partner_payable(self, cr, uid, ids, name, args, context={}):
|
def partner_payable(self, cr, uid, ids, name, args, context={}):
|
||||||
if not ids: return {}
|
if not ids: return {}
|
||||||
partners= self.read(cr, uid, ids, ['partner_id'], context)
|
partners= self.read(cr, uid, ids, ['partner_id'], context)
|
||||||
partners= dict(map(lambda x: (x['id'], x['partner_id'][0]), partners))
|
partners= dict(map(lambda x: (x['id'], x['partner_id'][0]), partners))
|
||||||
debit = self.pool.get('res.partner')._debit_get(cr, uid,
|
debit = self.pool.get('res.partner')._debit_get(cr, uid,
|
||||||
partners.values(), name, args, context)
|
partners.values(), name, args, context)
|
||||||
for i in partners:
|
for i in partners:
|
||||||
partners[i] = debit[partners[i]]
|
partners[i] = debit[partners[i]]
|
||||||
return partners
|
return partners
|
||||||
|
|
||||||
def translate(self, orig):
|
def translate(self, orig):
|
||||||
return {
|
return {
|
||||||
# "to_pay": "credit",
|
# "to_pay": "credit",
|
||||||
"due_date": "date_maturity",
|
"due_date": "date_maturity",
|
||||||
"reference": "ref"}.get(orig, orig)
|
"reference": "ref"}.get(orig, orig)
|
||||||
|
|
||||||
def info_owner(self, cr, uid, ids, name=None, args=None, context=None):
|
def info_owner(self, cr, uid, ids, name=None, args=None, context=None):
|
||||||
if not ids: return {}
|
if not ids: return {}
|
||||||
result = {}
|
result = {}
|
||||||
info=''
|
info=''
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
owner=line.order_id.mode.bank_id.partner_id
|
owner=line.order_id.mode.bank_id.partner_id
|
||||||
result[line.id]=False
|
result[line.id]=False
|
||||||
if owner.address:
|
if owner.address:
|
||||||
for ads in owner.address:
|
for ads in owner.address:
|
||||||
if ads.type=='default':
|
if ads.type=='default':
|
||||||
st=ads.street and ads.street or ''
|
st=ads.street and ads.street or ''
|
||||||
st1=ads.street2 and ads.street2 or ''
|
st1=ads.street2 and ads.street2 or ''
|
||||||
if 'zip_id' in ads:
|
if 'zip_id' in ads:
|
||||||
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
|
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
|
||||||
else:
|
else:
|
||||||
zip=ads.zip and ads.zip or ''
|
zip=ads.zip and ads.zip or ''
|
||||||
city= ads.city and ads.city or ''
|
city= ads.city and ads.city or ''
|
||||||
zip_city= zip + ' ' + city
|
zip_city= zip + ' ' + city
|
||||||
cntry= ads.country_id and ads.country_id.name or ''
|
cntry= ads.country_id and ads.country_id.name or ''
|
||||||
info=owner.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
info=owner.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||||
result[line.id]=info
|
result[line.id]=info
|
||||||
break
|
break
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def info_partner(self, cr, uid, ids, name=None, args=None, context=None):
|
def info_partner(self, cr, uid, ids, name=None, args=None, context=None):
|
||||||
if not ids: return {}
|
if not ids: return {}
|
||||||
result = {}
|
result = {}
|
||||||
info=''
|
info=''
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
result[line.id]=False
|
result[line.id]=False
|
||||||
if not line.partner_id:
|
if not line.partner_id:
|
||||||
break
|
break
|
||||||
partner = line.partner_id.name or ''
|
partner = line.partner_id.name or ''
|
||||||
if line.partner_id.address:
|
if line.partner_id.address:
|
||||||
for ads in line.partner_id.address:
|
for ads in line.partner_id.address:
|
||||||
if ads.type=='default':
|
if ads.type=='default':
|
||||||
st=ads.street and ads.street or ''
|
st=ads.street and ads.street or ''
|
||||||
st1=ads.street2 and ads.street2 or ''
|
st1=ads.street2 and ads.street2 or ''
|
||||||
if 'zip_id' in ads:
|
if 'zip_id' in ads:
|
||||||
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
|
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
|
||||||
else:
|
else:
|
||||||
zip=ads.zip and ads.zip or ''
|
zip=ads.zip and ads.zip or ''
|
||||||
city= ads.city and ads.city or ''
|
city= ads.city and ads.city or ''
|
||||||
zip_city= zip + ' ' + city
|
zip_city= zip + ' ' + city
|
||||||
cntry= ads.country_id and ads.country_id.name or ''
|
cntry= ads.country_id and ads.country_id.name or ''
|
||||||
info=partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
info=partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||||
result[line.id]=info
|
result[line.id]=info
|
||||||
break
|
break
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def select_by_name(self, cr, uid, ids, name, args, context=None):
|
def select_by_name(self, cr, uid, ids, name, args, context=None):
|
||||||
if not ids: return {}
|
if not ids: return {}
|
||||||
|
|
||||||
partner_obj = self.pool.get('res.partner')
|
partner_obj = self.pool.get('res.partner')
|
||||||
cr.execute("""SELECT pl.id, ml.%s
|
cr.execute("""SELECT pl.id, ml.%s
|
||||||
from account_move_line ml
|
from account_move_line ml
|
||||||
inner join payment_line pl
|
inner join payment_line pl
|
||||||
on (ml.id = pl.move_line_id)
|
on (ml.id = pl.move_line_id)
|
||||||
where pl.id in (%s)"""%
|
where pl.id in (%s)"""%
|
||||||
(self.translate(name), ','.join(map(str,ids))) )
|
(self.translate(name), ','.join(map(str,ids))) )
|
||||||
res = dict(cr.fetchall())
|
res = dict(cr.fetchall())
|
||||||
print "res: ", res
|
print "res: ", res
|
||||||
print "name ", name
|
print "name ", name
|
||||||
|
|
||||||
if name == 'partner_id':
|
if name == 'partner_id':
|
||||||
partner_name = {}
|
partner_name = {}
|
||||||
for p_id, p_name in partner_obj.name_get(cr,uid,
|
for p_id, p_name in partner_obj.name_get(cr,uid,
|
||||||
filter(lambda x:x and x != 0,res.values()),context=context):
|
filter(lambda x:x and x != 0,res.values()),context=context):
|
||||||
partner_name[p_id] = p_name
|
partner_name[p_id] = p_name
|
||||||
|
|
||||||
for id in ids:
|
for id in ids:
|
||||||
if id in res and partner_name:
|
if id in res and partner_name:
|
||||||
res[id] = (res[id],partner_name[res[id]])
|
res[id] = (res[id],partner_name[res[id]])
|
||||||
else:
|
else:
|
||||||
res[id] = (False,False)
|
res[id] = (False,False)
|
||||||
else:
|
else:
|
||||||
for id in ids:
|
for id in ids:
|
||||||
res.setdefault(id, (False, ""))
|
res.setdefault(id, (False, ""))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# def _currency(self, cursor, user, ids, name, args, context=None):
|
# def _currency(self, cursor, user, ids, name, args, context=None):
|
||||||
# if not ids:
|
# if not ids:
|
||||||
# return {}
|
# return {}
|
||||||
# res = {}
|
# res = {}
|
||||||
#
|
#
|
||||||
# currency_obj = self.pool.get('res.currency')
|
# currency_obj = self.pool.get('res.currency')
|
||||||
# account_obj = self.pool.get('account.account')
|
# account_obj = self.pool.get('account.account')
|
||||||
# cursor.execute('''SELECT pl.id, ml.currency_id, ml.account_id
|
# cursor.execute('''SELECT pl.id, ml.currency_id, ml.account_id
|
||||||
# FROM account_move_line ml
|
# FROM account_move_line ml
|
||||||
# INNER JOIN payment_line pl
|
# INNER JOIN payment_line pl
|
||||||
# ON (ml.id = pl.move_line_id)
|
# ON (ml.id = pl.move_line_id)
|
||||||
# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')')
|
# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')')
|
||||||
#
|
#
|
||||||
# res2 = {}
|
# res2 = {}
|
||||||
# account_ids = []
|
# account_ids = []
|
||||||
# for payment_line_id, currency_id, account_id in cursor.fetchall():
|
# for payment_line_id, currency_id, account_id in cursor.fetchall():
|
||||||
# res2[payment_line_id] = [currency_id, account_id]
|
# res2[payment_line_id] = [currency_id, account_id]
|
||||||
# account_ids.append(account_id)
|
# account_ids.append(account_id)
|
||||||
#
|
#
|
||||||
# account2currency_id = {}
|
# account2currency_id = {}
|
||||||
# for account in account_obj.browse(cursor, user, account_ids,
|
# for account in account_obj.browse(cursor, user, account_ids,
|
||||||
# context=context):
|
# context=context):
|
||||||
# account2currency_id[account.id] = account.company_currency_id.id
|
# account2currency_id[account.id] = account.company_currency_id.id
|
||||||
#
|
#
|
||||||
# for payment_line_id in ids:
|
# for payment_line_id in ids:
|
||||||
# if res2[payment_line_id][0]:
|
# if res2[payment_line_id][0]:
|
||||||
# res[payment_line_id] = res2[payment_line_id][0]
|
# res[payment_line_id] = res2[payment_line_id][0]
|
||||||
# else:
|
# else:
|
||||||
# res[payment_line_id] = \
|
# res[payment_line_id] = \
|
||||||
# account2currency_id[res2[payment_line_id][1]]
|
# account2currency_id[res2[payment_line_id][1]]
|
||||||
#
|
#
|
||||||
# currency_names = {}
|
# currency_names = {}
|
||||||
# for currency_id, name in currency_obj.name_get(cursor, user, res.values(),
|
# for currency_id, name in currency_obj.name_get(cursor, user, res.values(),
|
||||||
# context=context):
|
# context=context):
|
||||||
# currency_names[currency_id] = name
|
# currency_names[currency_id] = name
|
||||||
# for payment_line_id in ids:
|
# for payment_line_id in ids:
|
||||||
# res[payment_line_id] = (res[payment_line_id],
|
# res[payment_line_id] = (res[payment_line_id],
|
||||||
# currency_names[res[payment_line_id]])
|
# currency_names[res[payment_line_id]])
|
||||||
# return res
|
# return res
|
||||||
#
|
#
|
||||||
# def _to_pay_currency(self, cursor, user, ids, name , args, context=None):
|
# def _to_pay_currency(self, cursor, user, ids, name , args, context=None):
|
||||||
# if not ids:
|
# if not ids:
|
||||||
# return {}
|
# return {}
|
||||||
#
|
#
|
||||||
# cursor.execute('''SELECT pl.id,
|
# cursor.execute('''SELECT pl.id,
|
||||||
# CASE WHEN ml.amount_currency < 0
|
# CASE WHEN ml.amount_currency < 0
|
||||||
# THEN - ml.amount_currency
|
# THEN - ml.amount_currency
|
||||||
# ELSE ml.credit
|
# ELSE ml.credit
|
||||||
# END
|
# END
|
||||||
# FROM account_move_line ml
|
# FROM account_move_line ml
|
||||||
# INNER JOIN payment_line pl
|
# INNER JOIN payment_line pl
|
||||||
# ON (ml.id = pl.move_line_id)
|
# ON (ml.id = pl.move_line_id)
|
||||||
# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')')
|
# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')')
|
||||||
# return dict(cursor.fetchall())
|
# return dict(cursor.fetchall())
|
||||||
|
|
||||||
def _amount(self, cursor, user, ids, name, args, context=None):
|
def _amount(self, cursor, user, ids, name, args, context=None):
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
currency_obj = self.pool.get('res.currency')
|
currency_obj = self.pool.get('res.currency')
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
res = {}
|
res = {}
|
||||||
for line in self.browse(cursor, user, ids, context=context):
|
for line in self.browse(cursor, user, ids, context=context):
|
||||||
ctx = context.copy()
|
ctx = context.copy()
|
||||||
ctx['date'] = line.order_id.date_done or time.strftime('%Y-%m-%d')
|
ctx['date'] = line.order_id.date_done or time.strftime('%Y-%m-%d')
|
||||||
res[line.id] = currency_obj.compute(cursor, user, line.currency.id,
|
res[line.id] = currency_obj.compute(cursor, user, line.currency.id,
|
||||||
line.company_currency.id,
|
line.company_currency.id,
|
||||||
line.amount_currency, context=ctx)
|
line.amount_currency, context=ctx)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _value_date(self, cursor, user, ids, name, args, context=None):
|
def _value_date(self, cursor, user, ids, name, args, context=None):
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
res = {}
|
res = {}
|
||||||
for line in self.browse(cursor, user, ids, context=context):
|
for line in self.browse(cursor, user, ids, context=context):
|
||||||
if line.order_id.date_prefered == 'fixed':
|
if line.order_id.date_prefered == 'fixed':
|
||||||
res[line.id] = line.order_id.date_planned
|
res[line.id] = line.order_id.date_planned
|
||||||
elif line.order_id.date_prefered == 'due':
|
elif line.order_id.date_prefered == 'due':
|
||||||
res[line.id] = line.due_date or time.strftime('%Y-%m-%d')
|
res[line.id] = line.due_date or time.strftime('%Y-%m-%d')
|
||||||
else:
|
else:
|
||||||
res[line.id] = time.strftime('%Y-%m-%d')
|
res[line.id] = time.strftime('%Y-%m-%d')
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_currency(self, cr, uid, context):
|
def _get_currency(self, cr, uid, context):
|
||||||
user = self.pool.get('res.users').browse(cr, uid, uid)
|
user = self.pool.get('res.users').browse(cr, uid, uid)
|
||||||
if user.company_id:
|
if user.company_id:
|
||||||
return user.company_id.currency_id.id
|
return user.company_id.currency_id.id
|
||||||
else:
|
else:
|
||||||
return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
|
return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
|
||||||
|
|
||||||
# def select_move_lines(*a):
|
# def select_move_lines(*a):
|
||||||
# print a
|
# print a
|
||||||
# return []
|
# return []
|
||||||
|
|
||||||
# def create(self, cr, uid, vals, context):
|
# def create(self, cr, uid, vals, context):
|
||||||
# print "created!!!"
|
# print "created!!!"
|
||||||
# vals['company_currency'] = self._get_currency(cr, uid, context)
|
# vals['company_currency'] = self._get_currency(cr, uid, context)
|
||||||
# return super(payment_line, self).create(cr, uid, vals, context)
|
# return super(payment_line, self).create(cr, uid, vals, context)
|
||||||
|
|
||||||
def _get_ml_inv_ref(self, cr, uid, ids, *a):
|
def _get_ml_inv_ref(self, cr, uid, ids, *a):
|
||||||
res={}
|
res={}
|
||||||
for id in self.browse(cr, uid, ids):
|
for id in self.browse(cr, uid, ids):
|
||||||
res[id.id] = ""
|
res[id.id] = ""
|
||||||
print "test"
|
print "test"
|
||||||
if id.move_line_id:
|
if id.move_line_id:
|
||||||
print "blablabl"
|
print "blablabl"
|
||||||
res[id.id] = "pas de invoice"
|
res[id.id] = "pas de invoice"
|
||||||
if id.move_line_id.invoice:
|
if id.move_line_id.invoice:
|
||||||
res[id.id] = str(id.move_line_id.invoice.number)
|
res[id.id] = str(id.move_line_id.invoice.number)
|
||||||
if id.move_line_id.invoice.name:
|
if id.move_line_id.invoice.name:
|
||||||
res[id.id] += " " + id.move_line_id.invoice.name
|
res[id.id] += " " + id.move_line_id.invoice.name
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_ml_maturity_date(self, cr, uid, ids, *a):
|
def _get_ml_maturity_date(self, cr, uid, ids, *a):
|
||||||
res={}
|
res={}
|
||||||
for id in self.browse(cr, uid, ids):
|
for id in self.browse(cr, uid, ids):
|
||||||
if id.move_line_id:
|
if id.move_line_id:
|
||||||
res[id.id] = id.move_line_id.date_maturity
|
res[id.id] = id.move_line_id.date_maturity
|
||||||
else:
|
else:
|
||||||
res[id.id] = ""
|
res[id.id] = ""
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_ml_created_date(self, cr, uid, ids, *a):
|
def _get_ml_created_date(self, cr, uid, ids, *a):
|
||||||
res={}
|
res={}
|
||||||
for id in self.browse(cr, uid, ids):
|
for id in self.browse(cr, uid, ids):
|
||||||
if id.move_line_id:
|
if id.move_line_id:
|
||||||
res[id.id] = id.move_line_id.date_created
|
res[id.id] = id.move_line_id.date_created
|
||||||
else:
|
else:
|
||||||
res[id.id] = ""
|
res[id.id] = ""
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Your Reference', size=64, required=True),
|
'name': fields.char('Your Reference', size=64, required=True),
|
||||||
'communication': fields.char('Communication', size=64, required=True),
|
'communication': fields.char('Communication', size=64, required=True),
|
||||||
'communication2': fields.char('Communication 2', size=64),
|
'communication2': fields.char('Communication 2', size=64),
|
||||||
'move_line_id': fields.many2one('account.move.line','Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')]),
|
'move_line_id': fields.many2one('account.move.line','Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')]),
|
||||||
'amount_currency': fields.float('Amount', digits=(16,2),
|
'amount_currency': fields.float('Amount', digits=(16,2),
|
||||||
required=True, help='Payment amount in the partner currency'),
|
required=True, help='Payment amount in the partner currency'),
|
||||||
# 'to_pay_currency': fields.function(_to_pay_currency, string='To Pay',
|
# 'to_pay_currency': fields.function(_to_pay_currency, string='To Pay',
|
||||||
# method=True, type='float',
|
# method=True, type='float',
|
||||||
# help='Amount to pay in the partner currency'),
|
# help='Amount to pay in the partner currency'),
|
||||||
# 'currency': fields.function(_currency, string='Currency',
|
# 'currency': fields.function(_currency, string='Currency',
|
||||||
# method=True, type='many2one', obj='res.currency'),
|
# method=True, type='many2one', obj='res.currency'),
|
||||||
'currency': fields.many2one('res.currency','Currency',required=True),
|
'currency': fields.many2one('res.currency','Currency',required=True),
|
||||||
'company_currency': fields.many2one('res.currency','Currency',readonly=True),
|
'company_currency': fields.many2one('res.currency','Currency',readonly=True),
|
||||||
'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
|
'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
|
||||||
'order_id': fields.many2one('payment.order', 'Order', required=True,
|
'order_id': fields.many2one('payment.order', 'Order', required=True,
|
||||||
ondelete='cascade', select=True),
|
ondelete='cascade', select=True),
|
||||||
'partner_id': fields.many2one('res.partner', string="Partner",required=True),
|
'partner_id': fields.many2one('res.partner', string="Partner",required=True),
|
||||||
'amount': fields.function(_amount, string='Amount',
|
'amount': fields.function(_amount, string='Amount',
|
||||||
method=True, type='float',
|
method=True, type='float',
|
||||||
help='Payment amount in the company currency'),
|
help='Payment amount in the company currency'),
|
||||||
# 'to_pay': fields.function(select_by_name, string="To Pay", method=True,
|
# 'to_pay': fields.function(select_by_name, string="To Pay", method=True,
|
||||||
# type='float', help='Amount to pay in the company currency'),
|
# type='float', help='Amount to pay in the company currency'),
|
||||||
# 'due_date': fields.function(select_by_name, string="Due date",
|
# 'due_date': fields.function(select_by_name, string="Due date",
|
||||||
# method=True, type='date'),
|
# method=True, type='date'),
|
||||||
'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date",
|
'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date",
|
||||||
method=True, type='date',help="Invoice Effective Date"),
|
method=True, type='date',help="Invoice Effective Date"),
|
||||||
# 'reference': fields.function(select_by_name, string="Ref", method=True,
|
# 'reference': fields.function(select_by_name, string="Ref", method=True,
|
||||||
# type='char'),
|
# type='char'),
|
||||||
'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='char', string='Maturity Date'),
|
'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='char', string='Maturity Date'),
|
||||||
'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='char', string='Invoice Ref'),
|
'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='char', string='Invoice Ref'),
|
||||||
'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text"),
|
'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text"),
|
||||||
'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text"),
|
'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text"),
|
||||||
'partner_payable': fields.function(partner_payable,
|
'partner_payable': fields.function(partner_payable,
|
||||||
string="Partner payable", method=True, type='float'),
|
string="Partner payable", method=True, type='float'),
|
||||||
# 'value_date': fields.function(_value_date, string='Value Date',
|
# 'value_date': fields.function(_value_date, string='Value Date',
|
||||||
# method=True, type='date'),
|
# method=True, type='date'),
|
||||||
'date': fields.date('Payment Date'),
|
'date': fields.date('Payment Date'),
|
||||||
'create_date': fields.datetime('Created' ,readonly=True),
|
'create_date': fields.datetime('Created' ,readonly=True),
|
||||||
'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True)
|
'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True)
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence'
|
'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence'
|
||||||
).get(cursor, user, 'payment.line'),
|
).get(cursor, user, 'payment.line'),
|
||||||
'state': lambda *args: 'normal',
|
'state': lambda *args: 'normal',
|
||||||
'currency': _get_currency,
|
'currency': _get_currency,
|
||||||
'company_currency': _get_currency,
|
'company_currency': _get_currency,
|
||||||
}
|
}
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),
|
('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,context=None):
|
def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,context=None):
|
||||||
data={}
|
data={}
|
||||||
data['amount_currency']=data['currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=False
|
data['amount_currency']=data['currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=False
|
||||||
if move_line_id:
|
if move_line_id:
|
||||||
line=self.pool.get('account.move.line').browse(cr,uid,move_line_id)
|
line=self.pool.get('account.move.line').browse(cr,uid,move_line_id)
|
||||||
data['amount_currency']=line.amount_to_pay
|
data['amount_currency']=line.amount_to_pay
|
||||||
data['partner_id']=line.partner_id.id
|
data['partner_id']=line.partner_id.id
|
||||||
data['currency']=line.currency_id and line.currency_id.id or False
|
data['currency']=line.currency_id and line.currency_id.id or False
|
||||||
if not data['currency']:
|
if not data['currency']:
|
||||||
data['currency']=line.invoice and line.invoice.currency_id.id or False
|
data['currency']=line.invoice and line.invoice.currency_id.id or False
|
||||||
# calling onchange of partner and updating data dictionary
|
# calling onchange of partner and updating data dictionary
|
||||||
temp_dict=self.onchange_partner(cr,uid,ids,line.partner_id.id)
|
temp_dict=self.onchange_partner(cr,uid,ids,line.partner_id.id)
|
||||||
data.update(temp_dict['value'])
|
data.update(temp_dict['value'])
|
||||||
|
|
||||||
data['reference']=line.ref
|
data['reference']=line.ref
|
||||||
data['date_created']=line.date_created
|
data['date_created']=line.date_created
|
||||||
data['communication']=line.ref
|
data['communication']=line.ref
|
||||||
|
|
||||||
if payment_type:
|
if payment_type:
|
||||||
payment_mode = self.pool.get('payment.mode').browse(cr,uid,payment_type).type.code
|
payment_mode = self.pool.get('payment.mode').browse(cr,uid,payment_type).type.code
|
||||||
else:
|
else:
|
||||||
payment_mode=False
|
payment_mode=False
|
||||||
|
|
||||||
# data['bank_id']=self.pool.get('account.move.line').line2bank(cr, uid,
|
# data['bank_id']=self.pool.get('account.move.line').line2bank(cr, uid,
|
||||||
# [move_line_id],
|
# [move_line_id],
|
||||||
# payment_mode or 'manual', context)[move_line_id]
|
# payment_mode or 'manual', context)[move_line_id]
|
||||||
|
|
||||||
return {'value': data}
|
return {'value': data}
|
||||||
|
|
||||||
def onchange_partner(self,cr,uid,ids,partner_id,context=None):
|
def onchange_partner(self,cr,uid,ids,partner_id,context=None):
|
||||||
data={}
|
data={}
|
||||||
data['info_partner']=data['bank_id']=False
|
data['info_partner']=data['bank_id']=False
|
||||||
|
|
||||||
if partner_id:
|
if partner_id:
|
||||||
part_obj=self.pool.get('res.partner').browse(cr,uid,partner_id)
|
part_obj=self.pool.get('res.partner').browse(cr,uid,partner_id)
|
||||||
partner=part_obj.name or ''
|
partner=part_obj.name or ''
|
||||||
|
|
||||||
if part_obj.address:
|
if part_obj.address:
|
||||||
for ads in part_obj.address:
|
for ads in part_obj.address:
|
||||||
if ads.type=='default':
|
if ads.type=='default':
|
||||||
st=ads.street and ads.street or ''
|
st=ads.street and ads.street or ''
|
||||||
st1=ads.street2 and ads.street2 or ''
|
st1=ads.street2 and ads.street2 or ''
|
||||||
|
|
||||||
if 'zip_id' in ads:
|
if 'zip_id' in ads:
|
||||||
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
|
zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or ''
|
||||||
else:
|
else:
|
||||||
zip=ads.zip and ads.zip or ''
|
zip=ads.zip and ads.zip or ''
|
||||||
city= ads.city and ads.city or ''
|
city= ads.city and ads.city or ''
|
||||||
zip_city= zip + ' ' + city
|
zip_city= zip + ' ' + city
|
||||||
|
|
||||||
cntry= ads.country_id and ads.country_id.name or ''
|
cntry= ads.country_id and ads.country_id.name or ''
|
||||||
info=partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
info=partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
|
||||||
|
|
||||||
data['info_partner']=info
|
data['info_partner']=info
|
||||||
|
|
||||||
if part_obj.bank_ids and len(part_obj.bank_ids)==1:
|
if part_obj.bank_ids and len(part_obj.bank_ids)==1:
|
||||||
data['bank_id']=self.pool.get('res.partner.bank').name_get(cr,uid,[part_obj.bank_ids[0].id])[0][0]
|
data['bank_id']=self.pool.get('res.partner.bank').name_get(cr,uid,[part_obj.bank_ids[0].id])[0][0]
|
||||||
|
|
||||||
return {'value': data}
|
return {'value': data}
|
||||||
|
|
||||||
def fields_get(self, cr, uid, fields=None, context=None):
|
def fields_get(self, cr, uid, fields=None, context=None):
|
||||||
res = super(payment_line, self).fields_get(cr, uid, fields, context)
|
res = super(payment_line, self).fields_get(cr, uid, fields, context)
|
||||||
if 'communication2' in res:
|
if 'communication2' in res:
|
||||||
res['communication2'].setdefault('states', {})
|
res['communication2'].setdefault('states', {})
|
||||||
res['communication2']['states']['structured'] = [('readonly', True)]
|
res['communication2']['states']['structured'] = [('readonly', True)]
|
||||||
res['communication2']['states']['normal'] = [('readonly', False)]
|
res['communication2']['states']['normal'] = [('readonly', False)]
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
payment_line()
|
payment_line()
|
||||||
|
|
|
@ -35,39 +35,39 @@ import time
|
||||||
|
|
||||||
|
|
||||||
def _launch_wizard(self, cr, uid, data, context):
|
def _launch_wizard(self, cr, uid, data, context):
|
||||||
"""
|
"""
|
||||||
Search for a wizard to launch according to the type.
|
Search for a wizard to launch according to the type.
|
||||||
If type is manual. just confirm the order.
|
If type is manual. just confirm the order.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
order_ref= pooler.get_pool(cr.dbname).get('payment.order')
|
order_ref= pooler.get_pool(cr.dbname).get('payment.order')
|
||||||
order= order_ref.browse(cr,uid,data['id'],context)
|
order= order_ref.browse(cr,uid,data['id'],context)
|
||||||
t= order.mode and order.mode.type.code or 'manual'
|
t= order.mode and order.mode.type.code or 'manual'
|
||||||
if t == 'manual' :
|
if t == 'manual' :
|
||||||
order_ref.set_done(cr,uid,data['id'],context)
|
order_ref.set_done(cr,uid,data['id'],context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
gw= order_ref.get_wizard(t)
|
gw= order_ref.get_wizard(t)
|
||||||
if not gw:
|
if not gw:
|
||||||
order_ref.set_done(cr,uid,data['id'],context)
|
order_ref.set_done(cr,uid,data['id'],context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
||||||
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.wizard')
|
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.wizard')
|
||||||
module, wizard= gw
|
module, wizard= gw
|
||||||
result = mod_obj._get_id(cr, uid, module, wizard)
|
result = mod_obj._get_id(cr, uid, module, wizard)
|
||||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||||
result = act_obj.read(cr, uid, [id])[0]
|
result = act_obj.read(cr, uid, [id])[0]
|
||||||
#result['context'] = str({'fiscalyear': data['form']['fiscalyear']})
|
#result['context'] = str({'fiscalyear': data['form']['fiscalyear']})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class wizard_pay(wizard.interface):
|
class wizard_pay(wizard.interface):
|
||||||
|
|
||||||
states= {'init' : {'actions': [],
|
states= {'init' : {'actions': [],
|
||||||
'result':{'type':'action',
|
'result':{'type':'action',
|
||||||
'action':_launch_wizard,
|
'action':_launch_wizard,
|
||||||
'state':'end'}
|
'state':'end'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_pay('pay_payment')
|
wizard_pay('pay_payment')
|
||||||
|
|
|
@ -35,12 +35,12 @@ import time
|
||||||
FORM = UpdateableStr()
|
FORM = UpdateableStr()
|
||||||
|
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
'entries': {'string':'Entries', 'type':'many2many',
|
'entries': {'string':'Entries', 'type':'many2many',
|
||||||
'relation': 'account.move.line',},
|
'relation': 'account.move.line',},
|
||||||
}
|
}
|
||||||
field_duedate={
|
field_duedate={
|
||||||
'duedate': {'string':'Due Date', 'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d'),},
|
'duedate': {'string':'Due Date', 'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d'),},
|
||||||
}
|
}
|
||||||
arch_duedate='''<?xml version="1.0"?>
|
arch_duedate='''<?xml version="1.0"?>
|
||||||
<form string="Search Payment lines">
|
<form string="Search Payment lines">
|
||||||
<field name="duedate" />
|
<field name="duedate" />
|
||||||
|
@ -48,103 +48,103 @@ arch_duedate='''<?xml version="1.0"?>
|
||||||
|
|
||||||
|
|
||||||
def search_entries(self, cr, uid, data, context):
|
def search_entries(self, cr, uid, data, context):
|
||||||
search_due_date=data['form']['duedate']
|
search_due_date=data['form']['duedate']
|
||||||
|
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
order_obj = pool.get('payment.order')
|
order_obj = pool.get('payment.order')
|
||||||
line_obj = pool.get('account.move.line')
|
line_obj = pool.get('account.move.line')
|
||||||
|
|
||||||
payment = order_obj.browse(cr, uid, data['id'],
|
payment = order_obj.browse(cr, uid, data['id'],
|
||||||
context=context)
|
context=context)
|
||||||
ctx = ''
|
ctx = ''
|
||||||
if payment.mode:
|
if payment.mode:
|
||||||
ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id
|
ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id
|
||||||
|
|
||||||
# Search for move line to pay:
|
# Search for move line to pay:
|
||||||
line_ids = line_obj.search(cr, uid, [
|
line_ids = line_obj.search(cr, uid, [
|
||||||
('reconcile_id', '=', False),
|
('reconcile_id', '=', False),
|
||||||
('amount_to_pay', '>', 0),('date_maturity','<=',search_due_date)], context=context)
|
('amount_to_pay', '>', 0),('date_maturity','<=',search_due_date)], context=context)
|
||||||
|
|
||||||
|
|
||||||
FORM.string = '''<?xml version="1.0"?>
|
FORM.string = '''<?xml version="1.0"?>
|
||||||
<form string="Populate Payment:">
|
<form string="Populate Payment:">
|
||||||
<field name="entries" colspan="4" height="300" width="800" nolabel="1"
|
<field name="entries" colspan="4" height="300" width="800" nolabel="1"
|
||||||
domain="[('id', 'in', [%s])]" %s/>
|
domain="[('id', 'in', [%s])]" %s/>
|
||||||
</form>''' % (','.join([str(x) for x in line_ids]), ctx)
|
</form>''' % (','.join([str(x) for x in line_ids]), ctx)
|
||||||
return {'entries': line_ids}
|
return {'entries': line_ids}
|
||||||
|
|
||||||
def create_payment(self, cr, uid, data, context):
|
def create_payment(self, cr, uid, data, context):
|
||||||
line_ids= data['form']['entries'][0][2]
|
line_ids= data['form']['entries'][0][2]
|
||||||
if not line_ids: return {}
|
if not line_ids: return {}
|
||||||
|
|
||||||
pool= pooler.get_pool(cr.dbname)
|
pool= pooler.get_pool(cr.dbname)
|
||||||
order_obj = pool.get('payment.order')
|
order_obj = pool.get('payment.order')
|
||||||
line_obj = pool.get('account.move.line')
|
line_obj = pool.get('account.move.line')
|
||||||
|
|
||||||
payment = order_obj.browse(cr, uid, data['id'],
|
payment = order_obj.browse(cr, uid, data['id'],
|
||||||
context=context)
|
context=context)
|
||||||
t = payment.mode and payment.mode.type.code or 'manual'
|
t = payment.mode and payment.mode.type.code or 'manual'
|
||||||
line2bank= pool.get('account.move.line').line2bank(cr, uid,
|
line2bank= pool.get('account.move.line').line2bank(cr, uid,
|
||||||
line_ids, t, context)
|
line_ids, t, context)
|
||||||
|
|
||||||
## Finally populate the current payment with new lines:
|
## Finally populate the current payment with new lines:
|
||||||
for line in line_obj.browse(cr, uid, line_ids, context=context):
|
for line in line_obj.browse(cr, uid, line_ids, context=context):
|
||||||
pool.get('payment.line').create(cr,uid,{
|
pool.get('payment.line').create(cr,uid,{
|
||||||
'move_line_id': line.id,
|
'move_line_id': line.id,
|
||||||
'amount_currency': line.amount_to_pay,
|
'amount_currency': line.amount_to_pay,
|
||||||
'bank_id': line2bank.get(line.id),
|
'bank_id': line2bank.get(line.id),
|
||||||
'order_id': payment.id,
|
'order_id': payment.id,
|
||||||
'partner_id': line.partner_id and line.partner_id.id or False,
|
'partner_id': line.partner_id and line.partner_id.id or False,
|
||||||
'communication': line.ref or '/'
|
'communication': line.ref or '/'
|
||||||
}, context=context)
|
}, context=context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class wizard_payment_order(wizard.interface):
|
class wizard_payment_order(wizard.interface):
|
||||||
"""
|
"""
|
||||||
Create a payment object with lines corresponding to the account move line
|
Create a payment object with lines corresponding to the account move line
|
||||||
to pay according to the date and the mode provided by the user.
|
to pay according to the date and the mode provided by the user.
|
||||||
Hypothesis:
|
Hypothesis:
|
||||||
- Small number of non-reconcilied move line , payment mode and bank account type,
|
- Small number of non-reconcilied move line , payment mode and bank account type,
|
||||||
- Big number of partner and bank account.
|
- Big number of partner and bank account.
|
||||||
|
|
||||||
If a type is given, unsuitable account move lines are ignored.
|
If a type is given, unsuitable account move lines are ignored.
|
||||||
"""
|
"""
|
||||||
states = {
|
states = {
|
||||||
|
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': arch_duedate,
|
'arch': arch_duedate,
|
||||||
'fields':field_duedate,
|
'fields':field_duedate,
|
||||||
'state': [
|
'state': [
|
||||||
('end','_Cancel'),
|
('end','_Cancel'),
|
||||||
('search','_Search', '', True)
|
('search','_Search', '', True)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'search': {
|
'search': {
|
||||||
'actions': [search_entries],
|
'actions': [search_entries],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': FORM,
|
'arch': FORM,
|
||||||
'fields': FIELDS,
|
'fields': FIELDS,
|
||||||
'state': [
|
'state': [
|
||||||
('end','_Cancel'),
|
('end','_Cancel'),
|
||||||
('create','_Add to payment order', '', True)
|
('create','_Add to payment order', '', True)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'create': {
|
'create': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'action',
|
'type': 'action',
|
||||||
'action': create_payment,
|
'action': create_payment,
|
||||||
'state': 'end'}
|
'state': 'end'}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard_payment_order('populate_payment')
|
wizard_payment_order('populate_payment')
|
||||||
|
|
||||||
|
|
|
@ -33,91 +33,91 @@ from tools.misc import UpdateableStr
|
||||||
FORM = UpdateableStr()
|
FORM = UpdateableStr()
|
||||||
|
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
'lines': {'string': 'Payment Lines', 'type': 'many2many',
|
'lines': {'string': 'Payment Lines', 'type': 'many2many',
|
||||||
'relation': 'payment.line'},
|
'relation': 'payment.line'},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _search_entries(obj, cursor, user, data, context):
|
def _search_entries(obj, cursor, user, data, context):
|
||||||
pool = pooler.get_pool(cursor.dbname)
|
pool = pooler.get_pool(cursor.dbname)
|
||||||
line_obj = pool.get('payment.line')
|
line_obj = pool.get('payment.line')
|
||||||
statement_obj = pool.get('account.bank.statement')
|
statement_obj = pool.get('account.bank.statement')
|
||||||
|
|
||||||
statement = statement_obj.browse(cursor, user, data['id'], context=context)
|
statement = statement_obj.browse(cursor, user, data['id'], context=context)
|
||||||
|
|
||||||
line_ids = line_obj.search(cursor, user, [
|
line_ids = line_obj.search(cursor, user, [
|
||||||
('move_line_id.reconcile_id', '=', False),
|
('move_line_id.reconcile_id', '=', False),
|
||||||
('order_id.mode.journal.id', '=', statement.journal_id.id)])
|
('order_id.mode.journal.id', '=', statement.journal_id.id)])
|
||||||
line_ids.extend(line_obj.search(cursor, user, [
|
line_ids.extend(line_obj.search(cursor, user, [
|
||||||
('move_line_id.reconcile_id', '=', False),
|
('move_line_id.reconcile_id', '=', False),
|
||||||
('order_id.mode', '=', False)]))
|
('order_id.mode', '=', False)]))
|
||||||
|
|
||||||
FORM.string = '''<?xml version="1.0"?>
|
FORM.string = '''<?xml version="1.0"?>
|
||||||
<form string="Populate Statement:">
|
<form string="Populate Statement:">
|
||||||
<field name="lines" colspan="4" height="300" width="800" nolabel="1"
|
<field name="lines" colspan="4" height="300" width="800" nolabel="1"
|
||||||
domain="[('id', 'in', [%s])]"/>
|
domain="[('id', 'in', [%s])]"/>
|
||||||
</form>''' % (','.join([str(x) for x in line_ids]))
|
</form>''' % (','.join([str(x) for x in line_ids]))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _populate_statement(obj, cursor, user, data, context):
|
def _populate_statement(obj, cursor, user, data, context):
|
||||||
line_ids = data['form']['lines'][0][2]
|
line_ids = data['form']['lines'][0][2]
|
||||||
if not line_ids:
|
if not line_ids:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
pool = pooler.get_pool(cursor.dbname)
|
pool = pooler.get_pool(cursor.dbname)
|
||||||
line_obj = pool.get('payment.line')
|
line_obj = pool.get('payment.line')
|
||||||
statement_obj = pool.get('account.bank.statement')
|
statement_obj = pool.get('account.bank.statement')
|
||||||
statement_line_obj = pool.get('account.bank.statement.line')
|
statement_line_obj = pool.get('account.bank.statement.line')
|
||||||
currency_obj = pool.get('res.currency')
|
currency_obj = pool.get('res.currency')
|
||||||
statement_reconcile_obj = pool.get('account.bank.statement.reconcile')
|
statement_reconcile_obj = pool.get('account.bank.statement.reconcile')
|
||||||
|
|
||||||
statement = statement_obj.browse(cursor, user, data['id'], context=context)
|
statement = statement_obj.browse(cursor, user, data['id'], context=context)
|
||||||
|
|
||||||
for line in line_obj.browse(cursor, user, line_ids, context=context):
|
for line in line_obj.browse(cursor, user, line_ids, context=context):
|
||||||
ctx = context.copy()
|
ctx = context.copy()
|
||||||
ctx['date'] = line.value_date
|
ctx['date'] = line.value_date
|
||||||
amount = currency_obj.compute(cursor, user, line.currency.id,
|
amount = currency_obj.compute(cursor, user, line.currency.id,
|
||||||
statement.currency.id, line.amount_currency, context=ctx)
|
statement.currency.id, line.amount_currency, context=ctx)
|
||||||
reconcile_id = statement_reconcile_obj.create(cursor, user, {
|
reconcile_id = statement_reconcile_obj.create(cursor, user, {
|
||||||
'line_ids': [(6, 0, [line.move_line_id.id])]
|
'line_ids': [(6, 0, [line.move_line_id.id])]
|
||||||
}, context=context)
|
}, context=context)
|
||||||
statement_line_obj.create(cursor, user, {
|
statement_line_obj.create(cursor, user, {
|
||||||
'name': line.order_id.reference or '?',
|
'name': line.order_id.reference or '?',
|
||||||
'amount': - amount,
|
'amount': - amount,
|
||||||
'type': 'supplier',
|
'type': 'supplier',
|
||||||
'partner_id': line.partner_id.id,
|
'partner_id': line.partner_id.id,
|
||||||
'account_id': line.move_line_id.account_id.id,
|
'account_id': line.move_line_id.account_id.id,
|
||||||
'statement_id': statement.id,
|
'statement_id': statement.id,
|
||||||
'ref': line.reference,
|
'ref': line.reference,
|
||||||
'reconcile_id': reconcile_id,
|
'reconcile_id': reconcile_id,
|
||||||
}, context=context)
|
}, context=context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class PopulateStatement(wizard.interface):
|
class PopulateStatement(wizard.interface):
|
||||||
"""
|
"""
|
||||||
Populate the current statement with selected payement lines
|
Populate the current statement with selected payement lines
|
||||||
"""
|
"""
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [_search_entries],
|
'actions': [_search_entries],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': FORM,
|
'arch': FORM,
|
||||||
'fields': FIELDS,
|
'fields': FIELDS,
|
||||||
'state': [
|
'state': [
|
||||||
('end', '_Cancel'),
|
('end', '_Cancel'),
|
||||||
('add', '_Add', '', True)
|
('add', '_Add', '', True)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'add': {
|
'add': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'action',
|
'type': 'action',
|
||||||
'action': _populate_statement,
|
'action': _populate_statement,
|
||||||
'state': 'end'
|
'state': 'end'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
PopulateStatement('populate_statement')
|
PopulateStatement('populate_statement')
|
||||||
|
|
|
@ -26,19 +26,19 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Reporting for accounting",
|
"name" : "Reporting for accounting",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"depends" : ["account"],
|
"depends" : ["account"],
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"description": """Financial and accounting reporting""",
|
"description": """Financial and accounting reporting""",
|
||||||
"website" : "http://tinyerp.com/module_account.html",
|
"website" : "http://tinyerp.com/module_account.html",
|
||||||
"category" : "Generic Modules/Accounting",
|
"category" : "Generic Modules/Accounting",
|
||||||
"init_xml" : [ ],
|
"init_xml" : [ ],
|
||||||
"demo_xml" : [ ],
|
"demo_xml" : [ ],
|
||||||
"update_xml" : [ "account_view.xml","account_report.xml" ],
|
"update_xml" : [ "account_view.xml","account_report.xml" ],
|
||||||
# "translations" : {
|
# "translations" : {
|
||||||
# "fr": "i18n/french_fr.csv"
|
# "fr": "i18n/french_fr.csv"
|
||||||
# },
|
# },
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,141 +38,141 @@ from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||||
|
|
||||||
|
|
||||||
class account_report(osv.osv):
|
class account_report(osv.osv):
|
||||||
_name = "account.report.report"
|
_name = "account.report.report"
|
||||||
_description = "Account reporting"
|
_description = "Account reporting"
|
||||||
_color = [
|
_color = [
|
||||||
('', ''),
|
('', ''),
|
||||||
('green','Green'),
|
('green','Green'),
|
||||||
('red','Red'),
|
('red','Red'),
|
||||||
('pink','Pink'),
|
('pink','Pink'),
|
||||||
('blue','Blue'),
|
('blue','Blue'),
|
||||||
('yellow','Yellow'),
|
('yellow','Yellow'),
|
||||||
('cyan','Cyan'),
|
('cyan','Cyan'),
|
||||||
('lightblue','Light Blue'),
|
('lightblue','Light Blue'),
|
||||||
('orange','Orange'),
|
('orange','Orange'),
|
||||||
]
|
]
|
||||||
_style = [
|
_style = [
|
||||||
('1','Header 1'),
|
('1','Header 1'),
|
||||||
('2','Header 2'),
|
('2','Header 2'),
|
||||||
('3','Header 3'),
|
('3','Header 3'),
|
||||||
('4','Header 4'),
|
('4','Header 4'),
|
||||||
('5','Normal'),
|
('5','Normal'),
|
||||||
('6', 'Small'),
|
('6', 'Small'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def _amount_get(self, cr, uid, ids, field_name, arg, context={}):
|
def _amount_get(self, cr, uid, ids, field_name, arg, context={}):
|
||||||
def _calc_credit(*code):
|
def _calc_credit(*code):
|
||||||
acc = self.pool.get('account.account')
|
acc = self.pool.get('account.account')
|
||||||
acc_id = acc.search(cr, uid, [('code','in',code)])
|
acc_id = acc.search(cr, uid, [('code','in',code)])
|
||||||
return reduce(lambda y,x=0: x.credit+y, acc.browse(cr, uid, acc_id, context),0)
|
return reduce(lambda y,x=0: x.credit+y, acc.browse(cr, uid, acc_id, context),0)
|
||||||
def _calc_debit(*code):
|
def _calc_debit(*code):
|
||||||
acc = self.pool.get('account.account')
|
acc = self.pool.get('account.account')
|
||||||
acc_id = acc.search(cr, uid, [('code','in',code)])
|
acc_id = acc.search(cr, uid, [('code','in',code)])
|
||||||
return reduce(lambda y,x=0: x.debit+y, acc.browse(cr, uid, acc_id, context),0)
|
return reduce(lambda y,x=0: x.debit+y, acc.browse(cr, uid, acc_id, context),0)
|
||||||
def _calc_balance(*code):
|
def _calc_balance(*code):
|
||||||
acc = self.pool.get('account.account')
|
acc = self.pool.get('account.account')
|
||||||
acc_id = acc.search(cr, uid, [('code','in',code)])
|
acc_id = acc.search(cr, uid, [('code','in',code)])
|
||||||
return reduce(lambda y,x=0: x.balance+y, acc.browse(cr, uid, acc_id, context),0)
|
return reduce(lambda y,x=0: x.balance+y, acc.browse(cr, uid, acc_id, context),0)
|
||||||
def _calc_report(*code):
|
def _calc_report(*code):
|
||||||
acc = self.pool.get('account.report.report')
|
acc = self.pool.get('account.report.report')
|
||||||
acc_id = acc.search(cr, uid, [('code','in',code)])
|
acc_id = acc.search(cr, uid, [('code','in',code)])
|
||||||
return reduce(lambda y,x=0: x.amount+y, acc.browse(cr, uid, acc_id, context),0)
|
return reduce(lambda y,x=0: x.amount+y, acc.browse(cr, uid, acc_id, context),0)
|
||||||
result = {}
|
result = {}
|
||||||
for rep in self.browse(cr, uid, ids, context):
|
for rep in self.browse(cr, uid, ids, context):
|
||||||
objdict = {
|
objdict = {
|
||||||
'debit': _calc_debit,
|
'debit': _calc_debit,
|
||||||
'credit': _calc_credit,
|
'credit': _calc_credit,
|
||||||
'balance': _calc_balance,
|
'balance': _calc_balance,
|
||||||
'report': _calc_report,
|
'report': _calc_report,
|
||||||
}
|
}
|
||||||
if field_name=='status':
|
if field_name=='status':
|
||||||
fld_name = 'expression_status'
|
fld_name = 'expression_status'
|
||||||
else:
|
else:
|
||||||
fld_name = 'expression'
|
fld_name = 'expression'
|
||||||
try:
|
try:
|
||||||
val = eval(getattr(rep, fld_name), objdict)
|
val = eval(getattr(rep, fld_name), objdict)
|
||||||
except:
|
except:
|
||||||
val = 0.0
|
val = 0.0
|
||||||
if field_name=='status':
|
if field_name=='status':
|
||||||
if val<-1:
|
if val<-1:
|
||||||
result[rep.id] = 'very bad'
|
result[rep.id] = 'very bad'
|
||||||
elif val<0:
|
elif val<0:
|
||||||
result[rep.id] = 'bad'
|
result[rep.id] = 'bad'
|
||||||
elif val==0:
|
elif val==0:
|
||||||
result[rep.id] = 'normal'
|
result[rep.id] = 'normal'
|
||||||
elif val<1:
|
elif val<1:
|
||||||
result[rep.id] = 'good'
|
result[rep.id] = 'good'
|
||||||
else:
|
else:
|
||||||
result[rep.id] = 'excellent'
|
result[rep.id] = 'excellent'
|
||||||
else:
|
else:
|
||||||
result[rep.id] = val
|
result[rep.id] = val
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def onchange_parent_id(self, cr, uid, ids, parent_id):
|
def onchange_parent_id(self, cr, uid, ids, parent_id):
|
||||||
v={}
|
v={}
|
||||||
if parent_id:
|
if parent_id:
|
||||||
acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
|
acc=self.pool.get('account.report.report').browse(cr,uid,parent_id)
|
||||||
v['type']=acc.type
|
v['type']=acc.type
|
||||||
if int(acc.style) < 6:
|
if int(acc.style) < 6:
|
||||||
v['style'] = str(int(acc.style)+1)
|
v['style'] = str(int(acc.style)+1)
|
||||||
return {'value': v}
|
return {'value': v}
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Name', size=64, required=True),
|
'name': fields.char('Name', size=64, required=True),
|
||||||
'active': fields.boolean('Active'),
|
'active': fields.boolean('Active'),
|
||||||
'sequence': fields.integer('Sequence'),
|
'sequence': fields.integer('Sequence'),
|
||||||
'code': fields.char('Code', size=64, required=True),
|
'code': fields.char('Code', size=64, required=True),
|
||||||
'type': fields.selection([
|
'type': fields.selection([
|
||||||
('fiscal', 'Fiscal statement'),
|
('fiscal', 'Fiscal statement'),
|
||||||
('indicator','Indicator'),
|
('indicator','Indicator'),
|
||||||
('other','Others')],
|
('other','Others')],
|
||||||
'Type', required=True),
|
'Type', required=True),
|
||||||
'expression': fields.char('Expression', size=240, required=True),
|
'expression': fields.char('Expression', size=240, required=True),
|
||||||
'expression_status': fields.char('Status expression', size=240, required=True),
|
'expression_status': fields.char('Status expression', size=240, required=True),
|
||||||
'parent_id': fields.many2one('account.report.report', 'Parent'),
|
'parent_id': fields.many2one('account.report.report', 'Parent'),
|
||||||
'child_ids': fields.one2many('account.report.report', 'parent_id', 'Childs'),
|
'child_ids': fields.one2many('account.report.report', 'parent_id', 'Childs'),
|
||||||
'note': fields.text('Note'),
|
'note': fields.text('Note'),
|
||||||
'amount': fields.function(_amount_get, method=True, string='Value'),
|
'amount': fields.function(_amount_get, method=True, string='Value'),
|
||||||
'status': fields.function(_amount_get,
|
'status': fields.function(_amount_get,
|
||||||
method=True,
|
method=True,
|
||||||
type="selection",
|
type="selection",
|
||||||
selection=[
|
selection=[
|
||||||
('very bad', 'Very Bad'),
|
('very bad', 'Very Bad'),
|
||||||
('bad', 'Bad'),
|
('bad', 'Bad'),
|
||||||
('normal', ''),
|
('normal', ''),
|
||||||
('good', 'Good'),
|
('good', 'Good'),
|
||||||
('excellent', 'Excellent')
|
('excellent', 'Excellent')
|
||||||
],
|
],
|
||||||
string='Status'),
|
string='Status'),
|
||||||
'style': fields.selection(_style, 'Style', required=True),
|
'style': fields.selection(_style, 'Style', required=True),
|
||||||
'color_font' : fields.selection(_color, 'Font Color', help="Font Color for the report"),
|
'color_font' : fields.selection(_color, 'Font Color', help="Font Color for the report"),
|
||||||
'color_back' : fields.selection(_color, 'Back Color')
|
'color_back' : fields.selection(_color, 'Back Color')
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'style': lambda *args: '5',
|
'style': lambda *args: '5',
|
||||||
'active': lambda *args: True,
|
'active': lambda *args: True,
|
||||||
'type': lambda *args: 'indicator',
|
'type': lambda *args: 'indicator',
|
||||||
}
|
}
|
||||||
|
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||||
if not args:
|
if not args:
|
||||||
args=[]
|
args=[]
|
||||||
if not context:
|
if not context:
|
||||||
context={}
|
context={}
|
||||||
ids = []
|
ids = []
|
||||||
if name:
|
if name:
|
||||||
ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
|
ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
|
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
|
||||||
else:
|
else:
|
||||||
ids = self.search(cr, user, args, limit=limit, context=context)
|
ids = self.search(cr, user, args, limit=limit, context=context)
|
||||||
return self.name_get(cr, user, ids, context=context)
|
return self.name_get(cr, user, ids, context=context)
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
#TODO Put an expression to valid expression and expression_status
|
#TODO Put an expression to valid expression and expression_status
|
||||||
]
|
]
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('code_uniq', 'unique (code)', 'The code of the report entry must be unique !')
|
('code_uniq', 'unique (code)', 'The code of the report entry must be unique !')
|
||||||
]
|
]
|
||||||
|
|
||||||
account_report()
|
account_report()
|
||||||
|
|
|
@ -34,33 +34,33 @@ from report import report_sxw
|
||||||
|
|
||||||
class accounting_report(report_sxw.rml_parse):
|
class accounting_report(report_sxw.rml_parse):
|
||||||
|
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(accounting_report, self).__init__(cr, uid, name, context)
|
super(accounting_report, self).__init__(cr, uid, name, context)
|
||||||
self.ret_list = []
|
self.ret_list = []
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
'childs':self.process
|
'childs':self.process
|
||||||
})
|
})
|
||||||
|
|
||||||
def process(self,id,level=0):
|
def process(self,id,level=0):
|
||||||
res = pooler.get_pool(self.cr.dbname).get('account.report.report').read(self.cr,self.uid,[id])
|
res = pooler.get_pool(self.cr.dbname).get('account.report.report').read(self.cr,self.uid,[id])
|
||||||
ret_dict={
|
ret_dict={
|
||||||
'name':res[0]['name'],
|
'name':res[0]['name'],
|
||||||
'code':res[0]['code'],
|
'code':res[0]['code'],
|
||||||
'amount':res[0]['amount'],
|
'amount':res[0]['amount'],
|
||||||
'note':res[0]['note'],
|
'note':res[0]['note'],
|
||||||
'level': level,
|
'level': level,
|
||||||
'color_font':res[0]['color_font'],
|
'color_font':res[0]['color_font'],
|
||||||
'color_back':res[0]['color_back'],
|
'color_back':res[0]['color_back'],
|
||||||
}
|
}
|
||||||
|
|
||||||
self.ret_list.append(ret_dict)
|
self.ret_list.append(ret_dict)
|
||||||
for child_id in res[0]['child_ids']:
|
for child_id in res[0]['child_ids']:
|
||||||
self.process(child_id,level+1)
|
self.process(child_id,level+1)
|
||||||
return self.ret_list
|
return self.ret_list
|
||||||
|
|
||||||
|
|
||||||
report_sxw.report_sxw('report.accounting.report', 'account.report.report',
|
report_sxw.report_sxw('report.accounting.report', 'account.report.report',
|
||||||
'addons/account_report/report/accounting_report.rml',
|
'addons/account_report/report/accounting_report.rml',
|
||||||
parser=accounting_report, header=False)
|
parser=accounting_report, header=False)
|
||||||
|
|
||||||
|
|
|
@ -26,20 +26,20 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Invoices and prices with taxes included",
|
"name" : "Invoices and prices with taxes included",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"depends" : ["account"],
|
"depends" : ["account"],
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"description": """Allow the user to work tax included prices.
|
"description": """Allow the user to work tax included prices.
|
||||||
Especially useful for b2c businesses.
|
Especially useful for b2c businesses.
|
||||||
|
|
||||||
This module implement the modification on the invoice form.
|
This module implement the modification on the invoice form.
|
||||||
""",
|
""",
|
||||||
"website" : "http://tinyerp.com/module_account.html",
|
"website" : "http://tinyerp.com/module_account.html",
|
||||||
"category" : "Generic Modules/Accounting",
|
"category" : "Generic Modules/Accounting",
|
||||||
"init_xml" : [ ],
|
"init_xml" : [ ],
|
||||||
"demo_xml" : [ ],
|
"demo_xml" : [ ],
|
||||||
"update_xml" : [ 'invoice_tax_incl.xml' ],
|
"update_xml" : [ 'invoice_tax_incl.xml' ],
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,183 +34,183 @@ from osv import fields, osv
|
||||||
import ir
|
import ir
|
||||||
|
|
||||||
class account_invoice(osv.osv):
|
class account_invoice(osv.osv):
|
||||||
def _amount_untaxed(self, cr, uid, ids, name, args, context={}):
|
def _amount_untaxed(self, cr, uid, ids, name, args, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
for invoice in self.browse(cr,uid,ids):
|
for invoice in self.browse(cr,uid,ids):
|
||||||
if invoice.price_type == 'tax_included':
|
if invoice.price_type == 'tax_included':
|
||||||
res[invoice.id] = reduce( lambda x, y: x+y.price_subtotal, invoice.invoice_line,0)
|
res[invoice.id] = reduce( lambda x, y: x+y.price_subtotal, invoice.invoice_line,0)
|
||||||
else:
|
else:
|
||||||
res[invoice.id] = super(account_invoice, self)._amount_untaxed(cr, uid, [invoice.id], name, args, context)[invoice.id]
|
res[invoice.id] = super(account_invoice, self)._amount_untaxed(cr, uid, [invoice.id], name, args, context)[invoice.id]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _amount_tax(self, cr, uid, ids, name, args, context={}):
|
def _amount_tax(self, cr, uid, ids, name, args, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
for invoice in self.browse(cr,uid,ids):
|
for invoice in self.browse(cr,uid,ids):
|
||||||
if invoice.price_type == 'tax_included':
|
if invoice.price_type == 'tax_included':
|
||||||
res[invoice.id] = reduce( lambda x, y: x+y.amount, invoice.tax_line,0)
|
res[invoice.id] = reduce( lambda x, y: x+y.amount, invoice.tax_line,0)
|
||||||
else:
|
else:
|
||||||
res[invoice.id] = super(account_invoice, self)._amount_tax(cr, uid, [invoice.id], name, args, context)[invoice.id]
|
res[invoice.id] = super(account_invoice, self)._amount_tax(cr, uid, [invoice.id], name, args, context)[invoice.id]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _amount_total(self, cr, uid, ids, name, args, context={}):
|
def _amount_total(self, cr, uid, ids, name, args, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
for invoice in self.browse(cr,uid,ids):
|
for invoice in self.browse(cr,uid,ids):
|
||||||
if invoice.price_type == 'tax_included':
|
if invoice.price_type == 'tax_included':
|
||||||
res[invoice.id]= invoice.amount_untaxed + invoice.amount_tax
|
res[invoice.id]= invoice.amount_untaxed + invoice.amount_tax
|
||||||
else:
|
else:
|
||||||
res[invoice.id] = super(account_invoice, self)._amount_total(cr, uid, [invoice.id], name, args, context)[invoice.id]
|
res[invoice.id] = super(account_invoice, self)._amount_total(cr, uid, [invoice.id], name, args, context)[invoice.id]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_inherit = "account.invoice"
|
_inherit = "account.invoice"
|
||||||
_columns = {
|
_columns = {
|
||||||
'price_type': fields.selection([('tax_included','Tax included'),
|
'price_type': fields.selection([('tax_included','Tax included'),
|
||||||
('tax_excluded','Tax excluded')],
|
('tax_excluded','Tax excluded')],
|
||||||
'Price method', required=True, readonly=True,
|
'Price method', required=True, readonly=True,
|
||||||
states={'draft':[('readonly',False)]}),
|
states={'draft':[('readonly',False)]}),
|
||||||
'amount_untaxed': fields.function(_amount_untaxed, digits=(16,2), method=True,string='Untaxed Amount'),
|
'amount_untaxed': fields.function(_amount_untaxed, digits=(16,2), method=True,string='Untaxed Amount'),
|
||||||
'amount_tax': fields.function(_amount_tax, method=True, string='Tax', store=True),
|
'amount_tax': fields.function(_amount_tax, method=True, string='Tax', store=True),
|
||||||
'amount_total': fields.function(_amount_total, method=True, string='Total', store=True),
|
'amount_total': fields.function(_amount_total, method=True, string='Total', store=True),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'price_type': lambda *a: 'tax_excluded',
|
'price_type': lambda *a: 'tax_excluded',
|
||||||
}
|
}
|
||||||
account_invoice()
|
account_invoice()
|
||||||
|
|
||||||
class account_invoice_line(osv.osv):
|
class account_invoice_line(osv.osv):
|
||||||
_inherit = "account.invoice.line"
|
_inherit = "account.invoice.line"
|
||||||
def _amount_line(self, cr, uid, ids, name, args, context={}):
|
def _amount_line(self, cr, uid, ids, name, args, context={}):
|
||||||
"""
|
"""
|
||||||
Return the subtotal excluding taxes with respect to price_type.
|
Return the subtotal excluding taxes with respect to price_type.
|
||||||
"""
|
"""
|
||||||
res = {}
|
res = {}
|
||||||
tax_obj = self.pool.get('account.tax')
|
tax_obj = self.pool.get('account.tax')
|
||||||
res = super(account_invoice_line, self)._amount_line(cr, uid, ids, name, args, context)
|
res = super(account_invoice_line, self)._amount_line(cr, uid, ids, name, args, context)
|
||||||
res2 = res.copy()
|
res2 = res.copy()
|
||||||
for line in self.browse(cr, uid, ids):
|
for line in self.browse(cr, uid, ids):
|
||||||
if not line.quantity:
|
if not line.quantity:
|
||||||
res[line.id] = 0.0
|
res[line.id] = 0.0
|
||||||
continue
|
continue
|
||||||
if line.invoice_id and line.invoice_id.price_type == 'tax_included':
|
if line.invoice_id and line.invoice_id.price_type == 'tax_included':
|
||||||
product_taxes = None
|
product_taxes = None
|
||||||
if line.product_id:
|
if line.product_id:
|
||||||
if line.invoice_id.type in ('out_invoice', 'out_refund'):
|
if line.invoice_id.type in ('out_invoice', 'out_refund'):
|
||||||
product_taxes = line.product_id.taxes_id
|
product_taxes = line.product_id.taxes_id
|
||||||
else:
|
else:
|
||||||
product_taxes = line.product_id.supplier_taxes_id
|
product_taxes = line.product_id.supplier_taxes_id
|
||||||
if product_taxes:
|
if product_taxes:
|
||||||
for tax in tax_obj.compute_inv(cr, uid, product_taxes, res[line.id]/line.quantity, line.quantity):
|
for tax in tax_obj.compute_inv(cr, uid, product_taxes, res[line.id]/line.quantity, line.quantity):
|
||||||
res[line.id] = res[line.id] - round(tax['amount'], 2)
|
res[line.id] = res[line.id] - round(tax['amount'], 2)
|
||||||
else:
|
else:
|
||||||
for tax in tax_obj.compute_inv(cr, uid,line.invoice_line_tax_id, res[line.id]/line.quantity, line.quantity):
|
for tax in tax_obj.compute_inv(cr, uid,line.invoice_line_tax_id, res[line.id]/line.quantity, line.quantity):
|
||||||
res[line.id] = res[line.id] - round(tax['amount'], 2)
|
res[line.id] = res[line.id] - round(tax['amount'], 2)
|
||||||
if name == 'price_subtotal_incl' and line.invoice_id and line.invoice_id.price_type == 'tax_included':
|
if name == 'price_subtotal_incl' and line.invoice_id and line.invoice_id.price_type == 'tax_included':
|
||||||
prod_taxe_ids = None
|
prod_taxe_ids = None
|
||||||
line_taxe_ids = None
|
line_taxe_ids = None
|
||||||
if product_taxes:
|
if product_taxes:
|
||||||
prod_taxe_ids = [ t.id for t in product_taxes ]
|
prod_taxe_ids = [ t.id for t in product_taxes ]
|
||||||
prod_taxe_ids.sort()
|
prod_taxe_ids.sort()
|
||||||
line_taxe_ids = [ t.id for t in line.invoice_line_tax_id ]
|
line_taxe_ids = [ t.id for t in line.invoice_line_tax_id ]
|
||||||
line_taxe_ids.sort()
|
line_taxe_ids.sort()
|
||||||
if product_taxes and prod_taxe_ids == line_taxe_ids:
|
if product_taxes and prod_taxe_ids == line_taxe_ids:
|
||||||
res[line.id] = res2[line.id]
|
res[line.id] = res2[line.id]
|
||||||
elif not line.product_id:
|
elif not line.product_id:
|
||||||
res[line.id] = res2[line.id]
|
res[line.id] = res2[line.id]
|
||||||
else:
|
else:
|
||||||
for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, res[line.id]/line.quantity, line.quantity):
|
for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, res[line.id]/line.quantity, line.quantity):
|
||||||
res[line.id] = res[line.id] + tax['amount']
|
res[line.id] = res[line.id] + tax['amount']
|
||||||
res[line.id]= round(res[line.id], 2)
|
res[line.id]= round(res[line.id], 2)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _price_unit_default(self, cr, uid, context={}):
|
def _price_unit_default(self, cr, uid, context={}):
|
||||||
if 'check_total' in context:
|
if 'check_total' in context:
|
||||||
t = context['check_total']
|
t = context['check_total']
|
||||||
if context.get('price_type', False) == 'tax_included':
|
if context.get('price_type', False) == 'tax_included':
|
||||||
for l in context.get('invoice_line', {}):
|
for l in context.get('invoice_line', {}):
|
||||||
if len(l) >= 3 and l[2]:
|
if len(l) >= 3 and l[2]:
|
||||||
p = l[2].get('price_unit', 0) * (1-l[2].get('discount', 0)/100.0)
|
p = l[2].get('price_unit', 0) * (1-l[2].get('discount', 0)/100.0)
|
||||||
t = t - (p * l[2].get('quantity'))
|
t = t - (p * l[2].get('quantity'))
|
||||||
return t
|
return t
|
||||||
return super(account_invoice_line, self)._price_unit_default(cr, uid, context)
|
return super(account_invoice_line, self)._price_unit_default(cr, uid, context)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal w/o tax', store=True),
|
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal w/o tax', store=True),
|
||||||
'price_subtotal_incl': fields.function(_amount_line, method=True, string='Subtotal'),
|
'price_subtotal_incl': fields.function(_amount_line, method=True, string='Subtotal'),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'price_unit': _price_unit_default,
|
'price_unit': _price_unit_default,
|
||||||
}
|
}
|
||||||
|
|
||||||
def move_line_get_item(self, cr, uid, line, context={}):
|
def move_line_get_item(self, cr, uid, line, context={}):
|
||||||
return {
|
return {
|
||||||
'type':'src',
|
'type':'src',
|
||||||
'name':line.name,
|
'name':line.name,
|
||||||
'price_unit':line.price_subtotal / line.quantity,
|
'price_unit':line.price_subtotal / line.quantity,
|
||||||
'quantity':line.quantity,
|
'quantity':line.quantity,
|
||||||
'price':line.price_subtotal,
|
'price':line.price_subtotal,
|
||||||
'account_id':line.account_id.id,
|
'account_id':line.account_id.id,
|
||||||
'product_id': line.product_id.id,
|
'product_id': line.product_id.id,
|
||||||
'uos_id':line.uos_id.id,
|
'uos_id':line.uos_id.id,
|
||||||
'account_analytic_id':line.account_analytic_id.id,
|
'account_analytic_id':line.account_analytic_id.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
def product_id_change_unit_price_inv(self, cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context={}):
|
def product_id_change_unit_price_inv(self, cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context={}):
|
||||||
if context.get('price_type', False) == 'tax_included':
|
if context.get('price_type', False) == 'tax_included':
|
||||||
return {'price_unit': price_unit,'invoice_line_tax_id': tax_id}
|
return {'price_unit': price_unit,'invoice_line_tax_id': tax_id}
|
||||||
else:
|
else:
|
||||||
return super(account_invoice_line, self).product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
|
return super(account_invoice_line, self).product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
|
||||||
|
|
||||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, price_unit=False, address_invoice_id=False, price_type='tax_excluded', context={}):
|
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, price_unit=False, address_invoice_id=False, price_type='tax_excluded', context={}):
|
||||||
context.update({'price_type': price_type})
|
context.update({'price_type': price_type})
|
||||||
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, price_unit, address_invoice_id, context=context)
|
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, price_unit, address_invoice_id, context=context)
|
||||||
account_invoice_line()
|
account_invoice_line()
|
||||||
|
|
||||||
class account_invoice_tax(osv.osv):
|
class account_invoice_tax(osv.osv):
|
||||||
_inherit = "account.invoice.tax"
|
_inherit = "account.invoice.tax"
|
||||||
|
|
||||||
def compute(self, cr, uid, invoice_id):
|
def compute(self, cr, uid, invoice_id):
|
||||||
tax_grouped = {}
|
tax_grouped = {}
|
||||||
tax_obj = self.pool.get('account.tax')
|
tax_obj = self.pool.get('account.tax')
|
||||||
cur_obj = self.pool.get('res.currency')
|
cur_obj = self.pool.get('res.currency')
|
||||||
inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
|
inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
|
||||||
cur = inv.currency_id
|
cur = inv.currency_id
|
||||||
|
|
||||||
if inv.price_type=='tax_excluded':
|
if inv.price_type=='tax_excluded':
|
||||||
return super(account_invoice_tax,self).compute(cr, uid, invoice_id)
|
return super(account_invoice_tax,self).compute(cr, uid, invoice_id)
|
||||||
|
|
||||||
for line in inv.invoice_line:
|
for line in inv.invoice_line:
|
||||||
for tax in tax_obj.compute_inv(cr, uid, line.invoice_line_tax_id, (line.price_unit * (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id):
|
for tax in tax_obj.compute_inv(cr, uid, line.invoice_line_tax_id, (line.price_unit * (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id):
|
||||||
val={}
|
val={}
|
||||||
val['invoice_id'] = inv.id
|
val['invoice_id'] = inv.id
|
||||||
val['name'] = tax['name']
|
val['name'] = tax['name']
|
||||||
val['amount'] = cur_obj.round(cr, uid, cur, tax['amount'])
|
val['amount'] = cur_obj.round(cr, uid, cur, tax['amount'])
|
||||||
val['manual'] = False
|
val['manual'] = False
|
||||||
val['sequence'] = tax['sequence']
|
val['sequence'] = tax['sequence']
|
||||||
val['base'] = tax['price_unit'] * line['quantity']
|
val['base'] = tax['price_unit'] * line['quantity']
|
||||||
|
|
||||||
if inv.type in ('out_invoice','in_invoice'):
|
if inv.type in ('out_invoice','in_invoice'):
|
||||||
val['base_code_id'] = tax['base_code_id']
|
val['base_code_id'] = tax['base_code_id']
|
||||||
val['tax_code_id'] = tax['tax_code_id']
|
val['tax_code_id'] = tax['tax_code_id']
|
||||||
val['base_amount'] = val['base'] * tax['base_sign']
|
val['base_amount'] = val['base'] * tax['base_sign']
|
||||||
val['tax_amount'] = val['amount'] * tax['tax_sign']
|
val['tax_amount'] = val['amount'] * tax['tax_sign']
|
||||||
val['account_id'] = tax['account_collected_id'] or line.account_id.id
|
val['account_id'] = tax['account_collected_id'] or line.account_id.id
|
||||||
else:
|
else:
|
||||||
val['base_code_id'] = tax['ref_base_code_id']
|
val['base_code_id'] = tax['ref_base_code_id']
|
||||||
val['tax_code_id'] = tax['ref_tax_code_id']
|
val['tax_code_id'] = tax['ref_tax_code_id']
|
||||||
val['base_amount'] = val['base'] * tax['ref_base_sign']
|
val['base_amount'] = val['base'] * tax['ref_base_sign']
|
||||||
val['tax_amount'] = val['amount'] * tax['ref_tax_sign']
|
val['tax_amount'] = val['amount'] * tax['ref_tax_sign']
|
||||||
val['account_id'] = tax['account_paid_id'] or line.account_id.id
|
val['account_id'] = tax['account_paid_id'] or line.account_id.id
|
||||||
|
|
||||||
key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
|
key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
|
||||||
if not key in tax_grouped:
|
if not key in tax_grouped:
|
||||||
tax_grouped[key] = val
|
tax_grouped[key] = val
|
||||||
else:
|
else:
|
||||||
tax_grouped[key]['amount'] += val['amount']
|
tax_grouped[key]['amount'] += val['amount']
|
||||||
tax_grouped[key]['base'] += val['base']
|
tax_grouped[key]['base'] += val['base']
|
||||||
tax_grouped[key]['base_amount'] += val['base_amount']
|
tax_grouped[key]['base_amount'] += val['base_amount']
|
||||||
tax_grouped[key]['tax_amount'] += val['tax_amount']
|
tax_grouped[key]['tax_amount'] += val['tax_amount']
|
||||||
|
|
||||||
return tax_grouped
|
return tax_grouped
|
||||||
account_invoice_tax()
|
account_invoice_tax()
|
||||||
|
|
||||||
|
|
|
@ -26,17 +26,17 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "IBAN",
|
"name" : "IBAN",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"category" : "Generic Modules/Base",
|
"category" : "Generic Modules/Base",
|
||||||
"depends" : ["base"],
|
"depends" : ["base"],
|
||||||
"description": """
|
"description": """
|
||||||
This module install the base for IBAN bank accounts.
|
This module install the base for IBAN bank accounts.
|
||||||
|
|
||||||
""",
|
""",
|
||||||
"update_xml" : ["base_iban_view.xml"],
|
"update_xml" : ["base_iban_view.xml"],
|
||||||
"init_xml" : ["base_iban_data.xml"],
|
"init_xml" : ["base_iban_data.xml"],
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,21 +31,21 @@ import netsvc
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
|
||||||
class res_partner_bank(osv.osv):
|
class res_partner_bank(osv.osv):
|
||||||
_inherit = "res.partner.bank"
|
_inherit = "res.partner.bank"
|
||||||
_columns = {
|
_columns = {
|
||||||
'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"),
|
'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def name_get(self, cr, uid, ids, context=None):
|
def name_get(self, cr, uid, ids, context=None):
|
||||||
res = []
|
res = []
|
||||||
to_check_ids = []
|
to_check_ids = []
|
||||||
for id in self.browse(cr, uid, ids):
|
for id in self.browse(cr, uid, ids):
|
||||||
if id.state=='iban':
|
if id.state=='iban':
|
||||||
res.append((id.id,id.iban))
|
res.append((id.id,id.iban))
|
||||||
else:
|
else:
|
||||||
to_check_ids.append(id.id)
|
to_check_ids.append(id.id)
|
||||||
res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context)
|
res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
res_partner_bank()
|
res_partner_bank()
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Module publisher",
|
"name" : "Module publisher",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"website" : "http://tinyerp.com",
|
"website" : "http://tinyerp.com",
|
||||||
"category" : "Generic Modules/Base",
|
"category" : "Generic Modules/Base",
|
||||||
"description": """
|
"description": """
|
||||||
This module can be used by developpers to automatically publish their modules
|
This module can be used by developpers to automatically publish their modules
|
||||||
in a few click to the following websites:
|
in a few click to the following websites:
|
||||||
* http://TinyERP.com, section module
|
* http://TinyERP.com, section module
|
||||||
|
@ -41,10 +41,10 @@ in a few click to the following websites:
|
||||||
|
|
||||||
It adds a button "Publish module" on each module, so that you simply have
|
It adds a button "Publish module" on each module, so that you simply have
|
||||||
to call this button when you want to release a new version of your module.
|
to call this button when you want to release a new version of your module.
|
||||||
""",
|
""",
|
||||||
"depends" : ["base"],
|
"depends" : ["base"],
|
||||||
"init_xml" : [ ],
|
"init_xml" : [ ],
|
||||||
"demo_xml" : [ ],
|
"demo_xml" : [ ],
|
||||||
"update_xml" : [ "base_module_publish_wizard.xml" ],
|
"update_xml" : [ "base_module_publish_wizard.xml" ],
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,13 +39,13 @@ import tools
|
||||||
|
|
||||||
intro_form = '''<?xml version="1.0"?>
|
intro_form = '''<?xml version="1.0"?>
|
||||||
<form string="Module publication">
|
<form string="Module publication">
|
||||||
<separator string="Publication information" colspan="4"/>
|
<separator string="Publication information" colspan="4"/>
|
||||||
<field name="text" colspan="4" nolabel="1" width="300" height="200"/>
|
<field name="text" colspan="4" nolabel="1" width="300" height="200"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
intro_fields = {
|
intro_fields = {
|
||||||
'text': {'string':'Introduction', 'type':'text', 'readonly':True,
|
'text': {'string':'Introduction', 'type':'text', 'readonly':True,
|
||||||
'default': lambda *args: """
|
'default': lambda *args: """
|
||||||
This system will automatically publish the selected module to the
|
This system will automatically publish the selected module to the
|
||||||
Tiny ERP official website. You can use it to quickly publish a new
|
Tiny ERP official website. You can use it to quickly publish a new
|
||||||
module or update an existing one (new version).
|
module or update an existing one (new version).
|
||||||
|
@ -59,298 +59,298 @@ Thank you for contributing!
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_selection(self, cr, uid, datas, *args):
|
def _get_selection(self, cr, uid, datas, *args):
|
||||||
a = urllib.urlopen('http://www.openerp.com/mtree_interface.php')
|
a = urllib.urlopen('http://www.openerp.com/mtree_interface.php')
|
||||||
contents = a.read()
|
contents = a.read()
|
||||||
content = filter(None, contents.split('\n'))
|
content = filter(None, contents.split('\n'))
|
||||||
result = map(lambda x:x.split('='), content)
|
result = map(lambda x:x.split('='), content)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
check_form = '''<?xml version="1.0"?>
|
check_form = '''<?xml version="1.0"?>
|
||||||
<form string="Module publication">
|
<form string="Module publication">
|
||||||
<separator string="Verify your module information" colspan="4"/>
|
<separator string="Verify your module information" colspan="4"/>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="General">
|
<page string="General">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="version"/>
|
<field name="version"/>
|
||||||
<field name="author"/>
|
<field name="author"/>
|
||||||
<field name="website" widget="url"/>
|
<field name="website" widget="url"/>
|
||||||
<field name="shortdesc"/>
|
<field name="shortdesc"/>
|
||||||
<field name="operation"/>
|
<field name="operation"/>
|
||||||
<field name="category" colspan="4"/>
|
<field name="category" colspan="4"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="license"/>
|
<field name="license"/>
|
||||||
<field name="include_src"/>
|
<field name="include_src"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="url_download" colspan="4" widget="url"/>
|
<field name="url_download" colspan="4" widget="url"/>
|
||||||
<field name="docurl" colspan="4" widget="url"/>
|
<field name="docurl" colspan="4" widget="url"/>
|
||||||
<field name="demourl" colspan="4" widget="url"/>
|
<field name="demourl" colspan="4" widget="url"/>
|
||||||
<field name="image"/>
|
<field name="image"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Description">
|
<page string="Description">
|
||||||
<field name="description" colspan="4" nolabel="1"/>
|
<field name="description" colspan="4" nolabel="1"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
check_fields = {
|
check_fields = {
|
||||||
'name': {'string':'Name', 'type':'char', 'size':64, 'readonly':True},
|
'name': {'string':'Name', 'type':'char', 'size':64, 'readonly':True},
|
||||||
'shortdesc': {'string':'Small description', 'type':'char', 'size':200,
|
'shortdesc': {'string':'Small description', 'type':'char', 'size':200,
|
||||||
'readonly':True},
|
'readonly':True},
|
||||||
'author': {'string':'Author', 'type':'char', 'size':128, 'readonly':True},
|
'author': {'string':'Author', 'type':'char', 'size':128, 'readonly':True},
|
||||||
'website': {'string':'Website', 'type':'char', 'size':200, 'readonly':True},
|
'website': {'string':'Website', 'type':'char', 'size':200, 'readonly':True},
|
||||||
'url': {'string':'Download URL', 'type':'char', 'size':200, 'readonly':True},
|
'url': {'string':'Download URL', 'type':'char', 'size':200, 'readonly':True},
|
||||||
'image': {'string':'Image file', 'type':'image', 'help': 'support only .png files'},
|
'image': {'string':'Image file', 'type':'image', 'help': 'support only .png files'},
|
||||||
'description': {'string':'Description', 'type':'text', 'readonly':True},
|
'description': {'string':'Description', 'type':'text', 'readonly':True},
|
||||||
'version': {'string':'Version', 'type':'char', 'readonly':True},
|
'version': {'string':'Version', 'type':'char', 'readonly':True},
|
||||||
'demourl': {'string':'Demo URL', 'type':'char', 'size':128,
|
'demourl': {'string':'Demo URL', 'type':'char', 'size':128,
|
||||||
'help': 'empty to keep existing value'},
|
'help': 'empty to keep existing value'},
|
||||||
'docurl': {'string':'Documentation URL', 'type':'char', 'size':128,
|
'docurl': {'string':'Documentation URL', 'type':'char', 'size':128,
|
||||||
'help': 'Empty to keep existing value'},
|
'help': 'Empty to keep existing value'},
|
||||||
'category': {'string':'Category', 'type':'selection', 'size':64, 'required':True,
|
'category': {'string':'Category', 'type':'selection', 'size':64, 'required':True,
|
||||||
'selection': _get_selection},
|
'selection': _get_selection},
|
||||||
'license': {
|
'license': {
|
||||||
'string':'Licence', 'type':'selection', 'size':64, 'required':True,
|
'string':'Licence', 'type':'selection', 'size':64, 'required':True,
|
||||||
'selection': [('GPL-2', 'GPL-2'), ('Other proprietary','Other proprietary')],
|
'selection': [('GPL-2', 'GPL-2'), ('Other proprietary','Other proprietary')],
|
||||||
'default': lambda *args: 'GPL-2'
|
'default': lambda *args: 'GPL-2'
|
||||||
},
|
},
|
||||||
'include_src': {'string': 'Include source', 'type': 'boolean',
|
'include_src': {'string': 'Include source', 'type': 'boolean',
|
||||||
'default': lambda *a: True},
|
'default': lambda *a: True},
|
||||||
'operation': {
|
'operation': {
|
||||||
'string':'Operation',
|
'string':'Operation',
|
||||||
'type':'selection',
|
'type':'selection',
|
||||||
'readonly':True,
|
'readonly':True,
|
||||||
'selection':[('0','Creation'),('1','Modification')],
|
'selection':[('0','Creation'),('1','Modification')],
|
||||||
},
|
},
|
||||||
'url_download': {'string':'Download URL', 'type':'char', 'size':128,
|
'url_download': {'string':'Download URL', 'type':'char', 'size':128,
|
||||||
'help': 'Keep empty for an auto upload of the module'},
|
'help': 'Keep empty for an auto upload of the module'},
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_info_form = '''<?xml version="1.0"?>
|
upload_info_form = '''<?xml version="1.0"?>
|
||||||
<form string="Module publication">
|
<form string="Module publication">
|
||||||
<separator string="User information" colspan="4"/>
|
<separator string="User information" colspan="4"/>
|
||||||
<label string="Please provide here your login on the Tiny ERP website."
|
<label string="Please provide here your login on the Tiny ERP website."
|
||||||
align="0.0" colspan="4"/>
|
align="0.0" colspan="4"/>
|
||||||
<label string="If you don't have an access, you can create one http://www.openerp.com/"
|
<label string="If you don't have an access, you can create one http://www.openerp.com/"
|
||||||
align="0.0" colspan="4"/>
|
align="0.0" colspan="4"/>
|
||||||
<field name="login"/>
|
<field name="login"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="password"/>
|
<field name="password"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="email"/>
|
<field name="email"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
def _get_edit(self, cr, uid, datas, *args):
|
def _get_edit(self, cr, uid, datas, *args):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
name = pool.get('ir.module.module').read(cr, uid, [datas['id']], ['name'])[0]['name']
|
name = pool.get('ir.module.module').read(cr, uid, [datas['id']], ['name'])[0]['name']
|
||||||
a = urllib.urlopen('http://www.openerp.com/mtree_interface.php?module=%s' % (name,))
|
a = urllib.urlopen('http://www.openerp.com/mtree_interface.php?module=%s' % (name,))
|
||||||
content = a.read()
|
content = a.read()
|
||||||
try:
|
try:
|
||||||
email = self.pool.get('res.users').browse(cr, uid, uid).address.email or ''
|
email = self.pool.get('res.users').browse(cr, uid, uid).address.email or ''
|
||||||
except:
|
except:
|
||||||
email =''
|
email =''
|
||||||
result = {'operation': ((content[0]=='0') and '0') or '1', 'email':email}
|
result = {'operation': ((content[0]=='0') and '0') or '1', 'email':email}
|
||||||
if (content[0]<>'0'):
|
if (content[0]<>'0'):
|
||||||
result['category'] = content.split('\n')[1]
|
result['category'] = content.split('\n')[1]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
upload_info_fields = {
|
upload_info_fields = {
|
||||||
'login': {'string':'Login', 'type':'char', 'size':32, 'required':True},
|
'login': {'string':'Login', 'type':'char', 'size':32, 'required':True},
|
||||||
'email': {'string':'Email', 'type':'char', 'size':100, 'required':True},
|
'email': {'string':'Email', 'type':'char', 'size':100, 'required':True},
|
||||||
'password': {'string':'Password', 'type':'char', 'size':32, 'required':True,
|
'password': {'string':'Password', 'type':'char', 'size':32, 'required':True,
|
||||||
'invisible':True},
|
'invisible':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
end_form = '''<?xml version="1.0"?>
|
end_form = '''<?xml version="1.0"?>
|
||||||
<form string="Module publication">
|
<form string="Module publication">
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Information">
|
<page string="Information">
|
||||||
<field name="text_end" colspan="4" nolabel="1" width="300" height="200"/>
|
<field name="text_end" colspan="4" nolabel="1" width="300" height="200"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Result">
|
<page string="Result">
|
||||||
<field name="result" colspan="4" nolabel="1"/>
|
<field name="result" colspan="4" nolabel="1"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
end_fields = {
|
end_fields = {
|
||||||
'text_end': {'string':'Summary', 'type':'text', 'readonly':True,
|
'text_end': {'string':'Summary', 'type':'text', 'readonly':True,
|
||||||
'default': lambda *args: """
|
'default': lambda *args: """
|
||||||
Thank you for contributing !
|
Thank you for contributing !
|
||||||
|
|
||||||
Your module has been successfully uploaded to the official website.
|
Your module has been successfully uploaded to the official website.
|
||||||
You must wait a few hours/days so that the Tiny ERP core team review
|
You must wait a few hours/days so that the Tiny ERP core team review
|
||||||
your module for approval on the website.
|
your module for approval on the website.
|
||||||
"""},
|
"""},
|
||||||
'result': {'string':'Result page', 'type':'text', 'readonly':True}
|
'result': {'string':'Result page', 'type':'text', 'readonly':True}
|
||||||
}
|
}
|
||||||
|
|
||||||
import httplib, mimetypes
|
import httplib, mimetypes
|
||||||
|
|
||||||
def post_multipart(host, selector, fields, files):
|
def post_multipart(host, selector, fields, files):
|
||||||
def encode_multipart_formdata(fields, files):
|
def encode_multipart_formdata(fields, files):
|
||||||
BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
|
BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
|
||||||
CRLF = '\r\n'
|
CRLF = '\r\n'
|
||||||
L = []
|
L = []
|
||||||
for (key, value) in fields:
|
for (key, value) in fields:
|
||||||
L.append('--' + BOUNDARY)
|
L.append('--' + BOUNDARY)
|
||||||
L.append('Content-Disposition: form-data; name="%s"' % key)
|
L.append('Content-Disposition: form-data; name="%s"' % key)
|
||||||
L.append('')
|
L.append('')
|
||||||
L.append(value)
|
L.append(value)
|
||||||
for (key,fname,value) in files:
|
for (key,fname,value) in files:
|
||||||
L.append('--' + BOUNDARY)
|
L.append('--' + BOUNDARY)
|
||||||
L.append('Content-Disposition: form-data; name="%s"; filename="%s"'
|
L.append('Content-Disposition: form-data; name="%s"; filename="%s"'
|
||||||
% (key, fname))
|
% (key, fname))
|
||||||
L.append('Content-Type: application/octet-stream')
|
L.append('Content-Type: application/octet-stream')
|
||||||
L.append('')
|
L.append('')
|
||||||
L.append(value)
|
L.append(value)
|
||||||
L.append('--' + BOUNDARY + '--')
|
L.append('--' + BOUNDARY + '--')
|
||||||
L.append('')
|
L.append('')
|
||||||
body = CRLF.join(L)
|
body = CRLF.join(L)
|
||||||
content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
|
content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
|
||||||
return content_type, body
|
return content_type, body
|
||||||
content_type, body = encode_multipart_formdata(fields, files)
|
content_type, body = encode_multipart_formdata(fields, files)
|
||||||
import httplib
|
import httplib
|
||||||
|
|
||||||
headers = {"Content-type": content_type, "Accept": "*/*"}
|
headers = {"Content-type": content_type, "Accept": "*/*"}
|
||||||
conn = httplib.HTTPConnection(host)
|
conn = httplib.HTTPConnection(host)
|
||||||
conn.request("POST", selector, body, headers = headers)
|
conn.request("POST", selector, body, headers = headers)
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
val = response.status
|
val = response.status
|
||||||
res = response.read()
|
res = response.read()
|
||||||
conn.close()
|
conn.close()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def _upload(self, cr, uid, datas, context):
|
def _upload(self, cr, uid, datas, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
mod = pool.get('ir.module.module').browse(cr, uid, datas['id'])
|
mod = pool.get('ir.module.module').browse(cr, uid, datas['id'])
|
||||||
download = datas['form']['url_download'] or ''
|
download = datas['form']['url_download'] or ''
|
||||||
if not download:
|
if not download:
|
||||||
res = module_zip.createzip(cr, uid, datas['id'], context,
|
res = module_zip.createzip(cr, uid, datas['id'], context,
|
||||||
b64enc=False, src=datas['form']['include_src'])
|
b64enc=False, src=datas['form']['include_src'])
|
||||||
download = 'http://www.openerp.com/download/modules/'+res['module_filename']
|
download = 'http://www.openerp.com/download/modules/'+res['module_filename']
|
||||||
result = post_multipart('www.openerp.com', '/mtree_upload.php',
|
result = post_multipart('www.openerp.com', '/mtree_upload.php',
|
||||||
[
|
[
|
||||||
('login',datas['form']['login']),
|
('login',datas['form']['login']),
|
||||||
('password',datas['form']['password']),
|
('password',datas['form']['password']),
|
||||||
('module_name',mod.name)
|
('module_name',mod.name)
|
||||||
], [
|
], [
|
||||||
('module', res['module_filename'], res['module_file'])
|
('module', res['module_filename'], res['module_file'])
|
||||||
])
|
])
|
||||||
if result[0] == "1":
|
if result[0] == "1":
|
||||||
raise wizard.except_wizard(_('Error'), _('Login failed!'))
|
raise wizard.except_wizard(_('Error'), _('Login failed!'))
|
||||||
elif result[0] == "2":
|
elif result[0] == "2":
|
||||||
raise wizard.except_wizard(_('Error'),
|
raise wizard.except_wizard(_('Error'),
|
||||||
_('This version of the module is already exist on the server'))
|
_('This version of the module is already exist on the server'))
|
||||||
elif result[0] != "0":
|
elif result[0] != "0":
|
||||||
raise wizard.except_wizard(_('Error'), _('Failed to upload the file'))
|
raise wizard.except_wizard(_('Error'), _('Failed to upload the file'))
|
||||||
|
|
||||||
updata = {
|
updata = {
|
||||||
'link_name': mod.shortdesc or '',
|
'link_name': mod.shortdesc or '',
|
||||||
'new_cat_id': datas['form']['category'],
|
'new_cat_id': datas['form']['category'],
|
||||||
'link_desc': (mod.description or '').replace('\n','<br/>\n'),
|
'link_desc': (mod.description or '').replace('\n','<br/>\n'),
|
||||||
'website': mod.website or '',
|
'website': mod.website or '',
|
||||||
'price': '0.0',
|
'price': '0.0',
|
||||||
'email': datas['form']['email'] or '',
|
'email': datas['form']['email'] or '',
|
||||||
'cust_1': download,
|
'cust_1': download,
|
||||||
'cust_2': datas['form']['demourl'] or '', # Put here the download url
|
'cust_2': datas['form']['demourl'] or '', # Put here the download url
|
||||||
'cust_3': mod.url or '/',
|
'cust_3': mod.url or '/',
|
||||||
'cust_4': datas['form']['docurl'] or '',
|
'cust_4': datas['form']['docurl'] or '',
|
||||||
'cust_5': datas['form']['license'] or '',
|
'cust_5': datas['form']['license'] or '',
|
||||||
'cust_6': mod.installed_version or '0',
|
'cust_6': mod.installed_version or '0',
|
||||||
'cust_7': mod.name,
|
'cust_7': mod.name,
|
||||||
'option': 'com_mtree',
|
'option': 'com_mtree',
|
||||||
'task': 'savelisting',
|
'task': 'savelisting',
|
||||||
'Itemid': '99999999',
|
'Itemid': '99999999',
|
||||||
'cat_id': '0',
|
'cat_id': '0',
|
||||||
'adminForm': '',
|
'adminForm': '',
|
||||||
'auto_login': datas['form']['login'],
|
'auto_login': datas['form']['login'],
|
||||||
'auto_password': datas['form']['password']
|
'auto_password': datas['form']['password']
|
||||||
}
|
}
|
||||||
name = mod.name
|
name = mod.name
|
||||||
a = urllib.urlopen('http://www.openerp.com/mtree_interface.php?module=%s' % (name,))
|
a = urllib.urlopen('http://www.openerp.com/mtree_interface.php?module=%s' % (name,))
|
||||||
aa = a.read()
|
aa = a.read()
|
||||||
if aa[0]<>'0':
|
if aa[0]<>'0':
|
||||||
updata['link_id']=aa.split('\n')[0]
|
updata['link_id']=aa.split('\n')[0]
|
||||||
updata['option'] = 'mtree'
|
updata['option'] = 'mtree'
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
if datas['form']['image']:
|
if datas['form']['image']:
|
||||||
files.append(('link_image', 'link_image.png',
|
files.append(('link_image', 'link_image.png',
|
||||||
base64.decodestring(datas['form']['image'])))
|
base64.decodestring(datas['form']['image'])))
|
||||||
result = post_multipart('www.openerp.com', '/index.php', updata.items(), files)
|
result = post_multipart('www.openerp.com', '/index.php', updata.items(), files)
|
||||||
return {'result': result}
|
return {'result': result}
|
||||||
|
|
||||||
def module_check(self, cr, uid, data, context):
|
def module_check(self, cr, uid, data, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
module = pool.get('ir.module.module').browse(cr, uid, data['id'], context)
|
module = pool.get('ir.module.module').browse(cr, uid, data['id'], context)
|
||||||
if module.state != 'installed':
|
if module.state != 'installed':
|
||||||
raise wizard.except_wizard(_('Error'), _('You could not publish a module that is not installed!'))
|
raise wizard.except_wizard(_('Error'), _('You could not publish a module that is not installed!'))
|
||||||
return {
|
return {
|
||||||
'name': module.name,
|
'name': module.name,
|
||||||
'shortdesc': module.shortdesc,
|
'shortdesc': module.shortdesc,
|
||||||
'author': module.author,
|
'author': module.author,
|
||||||
'website': module.website,
|
'website': module.website,
|
||||||
'url': module.url,
|
'url': module.url,
|
||||||
'description': module.description,
|
'description': module.description,
|
||||||
'version': module.installed_version,
|
'version': module.installed_version,
|
||||||
'license': module.license,
|
'license': module.license,
|
||||||
}
|
}
|
||||||
|
|
||||||
class base_module_publish(wizard.interface):
|
class base_module_publish(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type':'form',
|
'type':'form',
|
||||||
'arch':intro_form,
|
'arch':intro_form,
|
||||||
'fields':intro_fields,
|
'fields':intro_fields,
|
||||||
'state':[
|
'state':[
|
||||||
('end', 'Cancel', 'gtk-cancel'),
|
('end', 'Cancel', 'gtk-cancel'),
|
||||||
('step1', 'Continue', 'gtk-go-forward', True)
|
('step1', 'Continue', 'gtk-go-forward', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'step1': {
|
'step1': {
|
||||||
'actions': [module_check, _get_edit],
|
'actions': [module_check, _get_edit],
|
||||||
'result': {
|
'result': {
|
||||||
'type':'form',
|
'type':'form',
|
||||||
'arch':check_form,
|
'arch':check_form,
|
||||||
'fields':check_fields,
|
'fields':check_fields,
|
||||||
'state':[
|
'state':[
|
||||||
('end','Cancel', 'gtk-cancel'),
|
('end','Cancel', 'gtk-cancel'),
|
||||||
('init', 'Previous', 'gtk-go-back'),
|
('init', 'Previous', 'gtk-go-back'),
|
||||||
('step2','Continue', 'gtk-go-forward', True)
|
('step2','Continue', 'gtk-go-forward', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'step2': {
|
'step2': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type':'form',
|
'type':'form',
|
||||||
'arch':upload_info_form,
|
'arch':upload_info_form,
|
||||||
'fields':upload_info_fields,
|
'fields':upload_info_fields,
|
||||||
'state':[
|
'state':[
|
||||||
('end','Cancel', 'gtk-cancel'),
|
('end','Cancel', 'gtk-cancel'),
|
||||||
('step1', 'Previous', 'gtk-go-back'),
|
('step1', 'Previous', 'gtk-go-back'),
|
||||||
('publish','Publish', 'gtk-ok', True)
|
('publish','Publish', 'gtk-ok', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'publish': {
|
'publish': {
|
||||||
'actions': [_upload], # Action to develop: upload method
|
'actions': [_upload], # Action to develop: upload method
|
||||||
'result': {
|
'result': {
|
||||||
'type':'form',
|
'type':'form',
|
||||||
'arch':end_form,
|
'arch':end_form,
|
||||||
'fields':end_fields,
|
'fields':end_fields,
|
||||||
'state':[
|
'state':[
|
||||||
('end','Close', 'gtk-ok', True)
|
('end','Close', 'gtk-ok', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base_module_publish('base_module_publish.module_publish')
|
base_module_publish('base_module_publish.module_publish')
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,13 @@ from urllib import urlopen
|
||||||
|
|
||||||
intro_form = '''<?xml version="1.0"?>
|
intro_form = '''<?xml version="1.0"?>
|
||||||
<form string="Module publication">
|
<form string="Module publication">
|
||||||
<separator string="Publication information" colspan="4"/>
|
<separator string="Publication information" colspan="4"/>
|
||||||
<field name="text" colspan="4" nolabel="1"/>
|
<field name="text" colspan="4" nolabel="1"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
intro_fields = {
|
intro_fields = {
|
||||||
'text': {'string': 'Introduction', 'type': 'text', 'readonly': True,
|
'text': {'string': 'Introduction', 'type': 'text', 'readonly': True,
|
||||||
'default': lambda *a: """
|
'default': lambda *a: """
|
||||||
This system will automatically publish and upload the selected modules to the
|
This system will automatically publish and upload the selected modules to the
|
||||||
Tiny ERP official website. You can use it to quickly update a set of
|
Tiny ERP official website. You can use it to quickly update a set of
|
||||||
module (new version).
|
module (new version).
|
||||||
|
@ -56,129 +56,129 @@ Thanks you for contributing!
|
||||||
|
|
||||||
login_form = '''<?xml version="1.0"?>
|
login_form = '''<?xml version="1.0"?>
|
||||||
<form string="Module publication">
|
<form string="Module publication">
|
||||||
<separator string="User information" colspan="4"/>
|
<separator string="User information" colspan="4"/>
|
||||||
<label string="Please provide here your login on the Tiny ERP website."
|
<label string="Please provide here your login on the Tiny ERP website."
|
||||||
align="0.0" colspan="4"/>
|
align="0.0" colspan="4"/>
|
||||||
<label string="If you don't have an access, you can create one http://www.openerp.com/"
|
<label string="If you don't have an access, you can create one http://www.openerp.com/"
|
||||||
align="0.0" colspan="4"/>
|
align="0.0" colspan="4"/>
|
||||||
<field name="login"/>
|
<field name="login"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="password"/>
|
<field name="password"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="email"/>
|
<field name="email"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
login_fields = {
|
login_fields = {
|
||||||
'login': {'string':'Login', 'type':'char', 'size':32, 'required':True},
|
'login': {'string':'Login', 'type':'char', 'size':32, 'required':True},
|
||||||
'email': {'string':'Email', 'type':'char', 'size':100, 'required':True},
|
'email': {'string':'Email', 'type':'char', 'size':100, 'required':True},
|
||||||
'password': {'string':'Password', 'type':'char', 'size':32, 'required':True,
|
'password': {'string':'Password', 'type':'char', 'size':32, 'required':True,
|
||||||
'invisible':True},
|
'invisible':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
end_form = '''<?xml version="1.0"?>
|
end_form = '''<?xml version="1.0"?>
|
||||||
<form string="Module publication">
|
<form string="Module publication">
|
||||||
<separator string="Upload information" colspan="4"/>
|
<separator string="Upload information" colspan="4"/>
|
||||||
<field name="update" colspan="4"/>
|
<field name="update" colspan="4"/>
|
||||||
<field name="already" colspan="4"/>
|
<field name="already" colspan="4"/>
|
||||||
<field name="error" colspan="4"/>
|
<field name="error" colspan="4"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
end_fields= {
|
end_fields= {
|
||||||
'update': {'type': 'text', 'string': 'Modules updated', 'readonly': True},
|
'update': {'type': 'text', 'string': 'Modules updated', 'readonly': True},
|
||||||
'already': {'type': 'text', 'string': 'Modules already updated',
|
'already': {'type': 'text', 'string': 'Modules already updated',
|
||||||
'readonly': True},
|
'readonly': True},
|
||||||
'error': {'type': 'text', 'string': 'Modules in error', 'readonly': True},
|
'error': {'type': 'text', 'string': 'Modules in error', 'readonly': True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def _upload(self, cr, uid, datas, context):
|
def _upload(self, cr, uid, datas, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
modules = pool.get('ir.module.module').browse(cr, uid, datas['ids'])
|
modules = pool.get('ir.module.module').browse(cr, uid, datas['ids'])
|
||||||
log = [[], [], []] # [update, already, error]
|
log = [[], [], []] # [update, already, error]
|
||||||
for mod in modules: # whoooouuuuffff update
|
for mod in modules: # whoooouuuuffff update
|
||||||
if mod.state != 'installed':
|
if mod.state != 'installed':
|
||||||
result[2].append(mod.name)
|
result[2].append(mod.name)
|
||||||
continue
|
continue
|
||||||
res = module_zip.createzip(cr, uid, mod.id, context, b64enc=False,
|
res = module_zip.createzip(cr, uid, mod.id, context, b64enc=False,
|
||||||
src=(mod.license in ('GPL-2')))
|
src=(mod.license in ('GPL-2')))
|
||||||
download = 'http://www.openerp.com/download/modules/'+res['module_filename']
|
download = 'http://www.openerp.com/download/modules/'+res['module_filename']
|
||||||
result = post_multipart('www.openerp.com', '/mtree_upload.php',
|
result = post_multipart('www.openerp.com', '/mtree_upload.php',
|
||||||
[('login', datas['form']['login']),
|
[('login', datas['form']['login']),
|
||||||
('password', datas['form']['password']),
|
('password', datas['form']['password']),
|
||||||
('module_name', mod.name)
|
('module_name', mod.name)
|
||||||
], [('module', res['module_filename'],
|
], [('module', res['module_filename'],
|
||||||
res['module_file'])
|
res['module_file'])
|
||||||
])
|
])
|
||||||
if result[0] == "1":
|
if result[0] == "1":
|
||||||
raise wizard.except_wizard('Error', 'Login failed!')
|
raise wizard.except_wizard('Error', 'Login failed!')
|
||||||
elif result[0] == "0":
|
elif result[0] == "0":
|
||||||
log[0].append(mod.name)
|
log[0].append(mod.name)
|
||||||
elif result[0] == "2":
|
elif result[0] == "2":
|
||||||
log[1].append(mod.name)
|
log[1].append(mod.name)
|
||||||
else:
|
else:
|
||||||
log[2].append(mod.name)
|
log[2].append(mod.name)
|
||||||
updata = {
|
updata = {
|
||||||
'link_name': mod.shortdesc or '',
|
'link_name': mod.shortdesc or '',
|
||||||
'link_desc': (mod.description or '').replace('\n','<br/>\n'),
|
'link_desc': (mod.description or '').replace('\n','<br/>\n'),
|
||||||
'website': mod.website or '',
|
'website': mod.website or '',
|
||||||
'email': datas['form']['email'] or '',
|
'email': datas['form']['email'] or '',
|
||||||
'cust_1': download,
|
'cust_1': download,
|
||||||
'cust_3': mod.url or '/',
|
'cust_3': mod.url or '/',
|
||||||
'cust_6': mod.installed_version or '0',
|
'cust_6': mod.installed_version or '0',
|
||||||
'cust_7': mod.name,
|
'cust_7': mod.name,
|
||||||
'option': 'com_mtree',
|
'option': 'com_mtree',
|
||||||
'task': 'savelisting',
|
'task': 'savelisting',
|
||||||
'Itemid': '99999999',
|
'Itemid': '99999999',
|
||||||
'cat_id': '0',
|
'cat_id': '0',
|
||||||
'adminForm': '',
|
'adminForm': '',
|
||||||
'auto_login': datas['form']['login'],
|
'auto_login': datas['form']['login'],
|
||||||
'auto_password': datas['form']['password']
|
'auto_password': datas['form']['password']
|
||||||
}
|
}
|
||||||
a = urlopen('http://www.openerp.com/mtree_interface.php?module=%s' % (mod.name,))
|
a = urlopen('http://www.openerp.com/mtree_interface.php?module=%s' % (mod.name,))
|
||||||
aa = a.read()
|
aa = a.read()
|
||||||
if aa[0]<>'0':
|
if aa[0]<>'0':
|
||||||
updata['link_id']=aa.split('\n')[0]
|
updata['link_id']=aa.split('\n')[0]
|
||||||
updata['cat_id']=aa.split('\n')[1]
|
updata['cat_id']=aa.split('\n')[1]
|
||||||
updata['option'] = 'mtree'
|
updata['option'] = 'mtree'
|
||||||
result = post_multipart('www.openerp.com', '/index.php', updata.items(), [])
|
result = post_multipart('www.openerp.com', '/index.php', updata.items(), [])
|
||||||
return {'update': '\n'.join(log[0]), 'already': '\n'.join(log[1]),
|
return {'update': '\n'.join(log[0]), 'already': '\n'.join(log[1]),
|
||||||
'error': '\n'.join(log[2])}
|
'error': '\n'.join(log[2])}
|
||||||
|
|
||||||
class base_module_publish_all(wizard.interface):
|
class base_module_publish_all(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': intro_form,
|
'arch': intro_form,
|
||||||
'fields': intro_fields,
|
'fields': intro_fields,
|
||||||
'state': [
|
'state': [
|
||||||
('end', 'Cancel'),
|
('end', 'Cancel'),
|
||||||
('login', 'Ok'),
|
('login', 'Ok'),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'login': {
|
'login': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': login_form,
|
'arch': login_form,
|
||||||
'fields': login_fields,
|
'fields': login_fields,
|
||||||
'state': [
|
'state': [
|
||||||
('end', 'Cancel'),
|
('end', 'Cancel'),
|
||||||
('publish', 'Publish')
|
('publish', 'Publish')
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'publish': {
|
'publish': {
|
||||||
'actions': [_upload],
|
'actions': [_upload],
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'form',
|
'type': 'form',
|
||||||
'arch': end_form,
|
'arch': end_form,
|
||||||
'fields': end_fields,
|
'fields': end_fields,
|
||||||
'state': [
|
'state': [
|
||||||
('end', 'Close')
|
('end', 'Close')
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
base_module_publish_all('base_module_publish.module_publish_all')
|
base_module_publish_all('base_module_publish.module_publish_all')
|
||||||
|
|
|
@ -36,46 +36,46 @@ import StringIO
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
def _zippy(archive, fromurl, path, src=True):
|
def _zippy(archive, fromurl, path, src=True):
|
||||||
url = os.path.join(fromurl, path)
|
url = os.path.join(fromurl, path)
|
||||||
if os.path.isdir(url):
|
if os.path.isdir(url):
|
||||||
if path.split('/')[-1].startswith('.'):
|
if path.split('/')[-1].startswith('.'):
|
||||||
return False
|
return False
|
||||||
for fname in os.listdir(url):
|
for fname in os.listdir(url):
|
||||||
_zippy(archive, fromurl, path and os.path.join(path, fname) or fname, src=src)
|
_zippy(archive, fromurl, path and os.path.join(path, fname) or fname, src=src)
|
||||||
else:
|
else:
|
||||||
if src:
|
if src:
|
||||||
exclude = ['pyo', 'pyc']
|
exclude = ['pyo', 'pyc']
|
||||||
else:
|
else:
|
||||||
exclude = ['py','pyo','pyc']
|
exclude = ['py','pyo','pyc']
|
||||||
if (path.split('.')[-1] not in exclude) or (os.path.basename(path)=='__terp__.py'):
|
if (path.split('.')[-1] not in exclude) or (os.path.basename(path)=='__terp__.py'):
|
||||||
archive.write(os.path.join(fromurl, path), path)
|
archive.write(os.path.join(fromurl, path), path)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def createzip(cr, uid, moduleid, context, b64enc=True, src=True):
|
def createzip(cr, uid, moduleid, context, b64enc=True, src=True):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
module_obj = pool.get('ir.module.module')
|
module_obj = pool.get('ir.module.module')
|
||||||
|
|
||||||
module = module_obj.browse(cr, uid, moduleid)
|
module = module_obj.browse(cr, uid, moduleid)
|
||||||
|
|
||||||
if module.state != 'installed':
|
if module.state != 'installed':
|
||||||
raise wizard.except_wizard(_('Error'),
|
raise wizard.except_wizard(_('Error'),
|
||||||
_('Can not export module that is not installed!'))
|
_('Can not export module that is not installed!'))
|
||||||
|
|
||||||
ad = tools.config['addons_path']
|
ad = tools.config['addons_path']
|
||||||
if os.path.isdir(os.path.join(ad, module.name)):
|
if os.path.isdir(os.path.join(ad, module.name)):
|
||||||
archname = StringIO.StringIO('wb')
|
archname = StringIO.StringIO('wb')
|
||||||
archive = PyZipFile(archname, "w", ZIP_DEFLATED)
|
archive = PyZipFile(archname, "w", ZIP_DEFLATED)
|
||||||
archive.writepy(os.path.join(ad, module.name))
|
archive.writepy(os.path.join(ad, module.name))
|
||||||
_zippy(archive, ad, module.name, src=src)
|
_zippy(archive, ad, module.name, src=src)
|
||||||
archive.close()
|
archive.close()
|
||||||
val =archname.getvalue()
|
val =archname.getvalue()
|
||||||
archname.close()
|
archname.close()
|
||||||
elif os.path.isfile(os.path.join(ad, module.name + '.zip')):
|
elif os.path.isfile(os.path.join(ad, module.name + '.zip')):
|
||||||
val = file(os.path.join(ad, module.name + '.zip'), 'rb').read()
|
val = file(os.path.join(ad, module.name + '.zip'), 'rb').read()
|
||||||
else:
|
else:
|
||||||
raise wizard.except_wizard(_('Error'), _('Could not find the module to export!'))
|
raise wizard.except_wizard(_('Error'), _('Could not find the module to export!'))
|
||||||
if b64enc:
|
if b64enc:
|
||||||
val =base64.encodestring(val)
|
val =base64.encodestring(val)
|
||||||
return {'module_file':val, 'module_filename': module.name + '-' + \
|
return {'module_file':val, 'module_filename': module.name + '-' + \
|
||||||
(module.installed_version or '0') + '.zip'}
|
(module.installed_version or '0') + '.zip'}
|
||||||
|
|
||||||
|
|
|
@ -35,42 +35,42 @@ import module_zip
|
||||||
|
|
||||||
init_form = '''<?xml version="1.0"?>
|
init_form = '''<?xml version="1.0"?>
|
||||||
<form string="Export module">
|
<form string="Export module">
|
||||||
<separator string="Export module" colspan="4"/>
|
<separator string="Export module" colspan="4"/>
|
||||||
<field name="include_src"/>
|
<field name="include_src"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
init_fields = {
|
init_fields = {
|
||||||
'include_src': {'string': 'Include sources', 'type': 'boolean',
|
'include_src': {'string': 'Include sources', 'type': 'boolean',
|
||||||
'default': lambda *a: True,},
|
'default': lambda *a: True,},
|
||||||
}
|
}
|
||||||
|
|
||||||
finish_form = '''<?xml version="1.0"?>
|
finish_form = '''<?xml version="1.0"?>
|
||||||
<form string="Finish">
|
<form string="Finish">
|
||||||
<separator string="Module successfully exported !" colspan="4"/>
|
<separator string="Module successfully exported !" colspan="4"/>
|
||||||
<field name="module_file"/>
|
<field name="module_file"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="module_filename"/>
|
<field name="module_filename"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
finish_fields = {
|
finish_fields = {
|
||||||
'module_file': {'string': 'Module .zip file', 'type':'binary', 'readonly':True},
|
'module_file': {'string': 'Module .zip file', 'type':'binary', 'readonly':True},
|
||||||
'module_filename': {'string': 'Filename', 'type':'char', 'size': 64, 'readonly':True},
|
'module_filename': {'string': 'Filename', 'type':'char', 'size': 64, 'readonly':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
class move_module_wizard(wizard.interface):
|
class move_module_wizard(wizard.interface):
|
||||||
def createzip(self, cr, uid, data, context):
|
def createzip(self, cr, uid, data, context):
|
||||||
return module_zip.createzip(cr, uid, data['id'], context, src=data['form']['include_src'])
|
return module_zip.createzip(cr, uid, data['id'], context, src=data['form']['include_src'])
|
||||||
|
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': init_form,
|
'result': {'type': 'form', 'arch': init_form,
|
||||||
'fields': init_fields, 'state': [('end', 'Cancel'), ('zip', 'Ok')]},
|
'fields': init_fields, 'state': [('end', 'Cancel'), ('zip', 'Ok')]},
|
||||||
},
|
},
|
||||||
'zip': {
|
'zip': {
|
||||||
'actions': [createzip],
|
'actions': [createzip],
|
||||||
'result': {'type': 'form', 'arch': finish_form,
|
'result': {'type': 'form', 'arch': finish_form,
|
||||||
'fields': finish_fields, 'state': [('end', 'Close')]},
|
'fields': finish_fields, 'state': [('end', 'Close')]},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
move_module_wizard('base_module_publish.module_export')
|
move_module_wizard('base_module_publish.module_export')
|
||||||
|
|
|
@ -26,34 +26,34 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Base Setup",
|
"name" : "Base Setup",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"website" : "http://tinyerp.com",
|
"website" : "http://tinyerp.com",
|
||||||
"category" : "Generic Modules/Base",
|
"category" : "Generic Modules/Base",
|
||||||
"description": """
|
"description": """
|
||||||
This module implements a configuration system that helps user
|
This module implements a configuration system that helps user
|
||||||
to configure the system at the installation of a new database.
|
to configure the system at the installation of a new database.
|
||||||
|
|
||||||
It allows you to select between a list of profiles to install:
|
It allows you to select between a list of profiles to install:
|
||||||
* Minimal profile
|
* Minimal profile
|
||||||
* Accounting only
|
* Accounting only
|
||||||
* Services companies
|
* Services companies
|
||||||
* Manufacturing companies
|
* Manufacturing companies
|
||||||
|
|
||||||
It also asks screens to help easily configure your company, the header and
|
It also asks screens to help easily configure your company, the header and
|
||||||
footer, the account chart to install and the language.
|
footer, the account chart to install and the language.
|
||||||
""",
|
""",
|
||||||
"depends" : ["base"],
|
"depends" : ["base"],
|
||||||
"init_xml" : [
|
"init_xml" : [
|
||||||
"base_setup_data.xml",
|
"base_setup_data.xml",
|
||||||
],
|
],
|
||||||
"demo_xml" : [
|
"demo_xml" : [
|
||||||
"base_setup_demo.xml",
|
"base_setup_demo.xml",
|
||||||
],
|
],
|
||||||
"update_xml" : [
|
"update_xml" : [
|
||||||
"base_setup_wizard.xml",
|
"base_setup_wizard.xml",
|
||||||
],
|
],
|
||||||
"active": True,
|
"active": True,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
|
||||||
class base_setup(osv.osv):
|
class base_setup(osv.osv):
|
||||||
_name="base_setup.base_setup"
|
_name="base_setup.base_setup"
|
||||||
_columns={
|
_columns={
|
||||||
'name': fields.char("Name", size=128),
|
'name': fields.char("Name", size=128),
|
||||||
}
|
}
|
||||||
base_setup()
|
base_setup()
|
||||||
|
|
|
@ -35,418 +35,418 @@ import os
|
||||||
|
|
||||||
view_form_profit = """<?xml version="1.0"?>
|
view_form_profit = """<?xml version="1.0"?>
|
||||||
<form string="Setup">
|
<form string="Setup">
|
||||||
<image name="gtk-dialog-info"/>
|
<image name="gtk-dialog-info"/>
|
||||||
<group>
|
<group>
|
||||||
<separator string="Select a profile" colspan="2"/>
|
<separator string="Select a profile" colspan="2"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field align="0.0" name="profile"/>
|
<field align="0.0" name="profile"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label string="A profile sets a pre-selection of modules for enterprise needs." colspan="2" align="0.0"/>
|
<label string="A profile sets a pre-selection of modules for enterprise needs." colspan="2" align="0.0"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label string="You'll be able to install others modules later through the Administration menu." colspan="2" align="0.0"/>
|
<label string="You'll be able to install others modules later through the Administration menu." colspan="2" align="0.0"/>
|
||||||
</group>
|
</group>
|
||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
view_form_charts = """<?xml version="1.0"?>
|
view_form_charts = """<?xml version="1.0"?>
|
||||||
<form string="Setup">
|
<form string="Setup">
|
||||||
<image name="gtk-dialog-info" colspan="2"/>
|
<image name="gtk-dialog-info" colspan="2"/>
|
||||||
<group>
|
<group>
|
||||||
<separator string="Select a chart of accounts" colspan="2"/>
|
<separator string="Select a chart of accounts" colspan="2"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="charts" align="0.0"/>
|
<field name="charts" align="0.0"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label string="There are many other chart of accounts available on the OpenERP website." colspan="2" align="0.0"/>
|
<label string="There are many other chart of accounts available on the OpenERP website." colspan="2" align="0.0"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<label string="If you don't select one now, you'll be able to install an other one through the Administration menu." colspan="2" align="0.0"/>
|
<label string="If you don't select one now, you'll be able to install an other one through the Administration menu." colspan="2" align="0.0"/>
|
||||||
</group>
|
</group>
|
||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
view_form_company = """<?xml version="1.0"?>
|
view_form_company = """<?xml version="1.0"?>
|
||||||
<form string="Setup">
|
<form string="Setup">
|
||||||
<image name="gtk-dialog-info" colspan="2"/>
|
<image name="gtk-dialog-info" colspan="2"/>
|
||||||
<group>
|
<group>
|
||||||
<separator string="Define main company" colspan="4"/>
|
<separator string="Define main company" colspan="4"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="name" align="0.0" colspan="4" required="True"/>
|
<field name="name" align="0.0" colspan="4" required="True"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="street" align="0.0"/>
|
<field name="street" align="0.0"/>
|
||||||
<field name="street2" align="0.0"/>
|
<field name="street2" align="0.0"/>
|
||||||
<field name="zip" align="0.0"/>
|
<field name="zip" align="0.0"/>
|
||||||
<field name="city" align="0.0"/>
|
<field name="city" align="0.0"/>
|
||||||
<field name="country_id" align="0.0"/>
|
<field name="country_id" align="0.0"/>
|
||||||
<field name="state_id" align="0.0"/>
|
<field name="state_id" align="0.0"/>
|
||||||
<field name="email" align="0.0"/>
|
<field name="email" align="0.0"/>
|
||||||
<field name="phone" align="0.0"/>
|
<field name="phone" align="0.0"/>
|
||||||
<field name="currency" align="0.0"/>
|
<field name="currency" align="0.0"/>
|
||||||
<separator string="Report header" colspan="4"/>
|
<separator string="Report header" colspan="4"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="rml_header1" align="0.0" colspan="4"/>
|
<field name="rml_header1" align="0.0" colspan="4"/>
|
||||||
<field name="rml_footer1" align="0.0" colspan="4"/>
|
<field name="rml_footer1" align="0.0" colspan="4"/>
|
||||||
<field name="rml_footer2" align="0.0" colspan="4"/>
|
<field name="rml_footer2" align="0.0" colspan="4"/>
|
||||||
</group>
|
</group>
|
||||||
</form>"""
|
</form>"""
|
||||||
|
|
||||||
view_form_update = """<?xml version="1.0"?>
|
view_form_update = """<?xml version="1.0"?>
|
||||||
<form string="Setup">
|
<form string="Setup">
|
||||||
<image name="gtk-dialog-info" colspan="2"/>
|
<image name="gtk-dialog-info" colspan="2"/>
|
||||||
<group>
|
<group>
|
||||||
<separator string="Summary" colspan="2"/>
|
<separator string="Summary" colspan="2"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="profile" align="0.0" readonly="1"/>
|
<field name="profile" align="0.0" readonly="1"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="charts" align="0.0" readonly="1"/>
|
<field name="charts" align="0.0" readonly="1"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="name" align="0.0" readonly="1"/>
|
<field name="name" align="0.0" readonly="1"/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
view_form_finish = """<?xml version="1.0"?>
|
view_form_finish = """<?xml version="1.0"?>
|
||||||
<form string="Setup">
|
<form string="Setup">
|
||||||
<image name="gtk-dialog-info" colspan="2"/>
|
<image name="gtk-dialog-info" colspan="2"/>
|
||||||
<group colspan="2" col="4">
|
<group colspan="2" col="4">
|
||||||
<separator colspan="4" string="Installation Done"/>
|
<separator colspan="4" string="Installation Done"/>
|
||||||
<label align="0.0" colspan="4" string="Your new database is now fully installed."/>
|
<label align="0.0" colspan="4" string="Your new database is now fully installed."/>
|
||||||
<label align="0.0" colspan="4" string="You can start configuring the system or connect directly to the database using the default setup."/>
|
<label align="0.0" colspan="4" string="You can start configuring the system or connect directly to the database using the default setup."/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class wizard_base_setup(wizard.interface):
|
class wizard_base_setup(wizard.interface):
|
||||||
|
|
||||||
def _get_profiles(self, cr, uid, context):
|
def _get_profiles(self, cr, uid, context):
|
||||||
module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
|
module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
|
||||||
ids=module_obj.search(cr, uid, [('category_id', '=', 'Profile'),
|
ids=module_obj.search(cr, uid, [('category_id', '=', 'Profile'),
|
||||||
('state', '<>', 'uninstallable')])
|
('state', '<>', 'uninstallable')])
|
||||||
res=[(m.id, m.shortdesc) for m in module_obj.browse(cr, uid, ids)]
|
res=[(m.id, m.shortdesc) for m in module_obj.browse(cr, uid, ids)]
|
||||||
res.append((-1, 'Minimal Profile'))
|
res.append((-1, 'Minimal Profile'))
|
||||||
res.sort()
|
res.sort()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_charts(self, cr, uid, context):
|
def _get_charts(self, cr, uid, context):
|
||||||
module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
|
module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
|
||||||
ids=module_obj.search(cr, uid, [('category_id', '=', 'Account charts'),
|
ids=module_obj.search(cr, uid, [('category_id', '=', 'Account charts'),
|
||||||
('state', '<>', 'uninstallable')])
|
('state', '<>', 'uninstallable')])
|
||||||
res=[(m.id, m.shortdesc) for m in module_obj.browse(cr, uid, ids)]
|
res=[(m.id, m.shortdesc) for m in module_obj.browse(cr, uid, ids)]
|
||||||
res.append((-1, 'None'))
|
res.append((-1, 'None'))
|
||||||
res.sort(lambda x,y: cmp(x[1],y[1]))
|
res.sort(lambda x,y: cmp(x[1],y[1]))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_company(self, cr, uid, data, context):
|
def _get_company(self, cr, uid, data, context):
|
||||||
pool=pooler.get_pool(cr.dbname)
|
pool=pooler.get_pool(cr.dbname)
|
||||||
company_obj=pool.get('res.company')
|
company_obj=pool.get('res.company')
|
||||||
ids=company_obj.search(cr, uid, [])
|
ids=company_obj.search(cr, uid, [])
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
company=company_obj.browse(cr, uid, ids)[0]
|
company=company_obj.browse(cr, uid, ids)[0]
|
||||||
self.fields['name']['default']=company.name
|
self.fields['name']['default']=company.name
|
||||||
self.fields['currency']['default']=company.currency_id.id
|
self.fields['currency']['default']=company.currency_id.id
|
||||||
return {}
|
return {}
|
||||||
#self.fields['rml_header1']['default']=company.rml_header1
|
#self.fields['rml_header1']['default']=company.rml_header1
|
||||||
#self.fields['rml_footer1']['default']=company.rml_footer1
|
#self.fields['rml_footer1']['default']=company.rml_footer1
|
||||||
#self.fields['rml_footer2']['default']=company.rml_footer2
|
#self.fields['rml_footer2']['default']=company.rml_footer2
|
||||||
#if not company.partner_id.address:
|
#if not company.partner_id.address:
|
||||||
# return {}
|
# return {}
|
||||||
#address=company.partner_id.address[0]
|
#address=company.partner_id.address[0]
|
||||||
#self.fields['street']['default']=address.street
|
#self.fields['street']['default']=address.street
|
||||||
#self.fields['street2']['default']=address.street2
|
#self.fields['street2']['default']=address.street2
|
||||||
#self.fields['zip']['default']=address.zip
|
#self.fields['zip']['default']=address.zip
|
||||||
#self.fields['city']['default']=address.city
|
#self.fields['city']['default']=address.city
|
||||||
#self.fields['email']['default']=address.email
|
#self.fields['email']['default']=address.email
|
||||||
#self.fields['phone']['default']=address.phone
|
#self.fields['phone']['default']=address.phone
|
||||||
#if address.state_id:
|
#if address.state_id:
|
||||||
# self.fields['state_id']['default']=address.state_id.id
|
# self.fields['state_id']['default']=address.state_id.id
|
||||||
#else:
|
#else:
|
||||||
# self.fields['state_id']['default']=-1
|
# self.fields['state_id']['default']=-1
|
||||||
#if address.country_id:
|
#if address.country_id:
|
||||||
# self.fields['country_id']['default']=address.country_id.id
|
# self.fields['country_id']['default']=address.country_id.id
|
||||||
#else:
|
#else:
|
||||||
# self.fields['country_id']['default']=-1
|
# self.fields['country_id']['default']=-1
|
||||||
#return {}
|
#return {}
|
||||||
|
|
||||||
def _get_states(self, cr, uid, context):
|
def _get_states(self, cr, uid, context):
|
||||||
pool=pooler.get_pool(cr.dbname)
|
pool=pooler.get_pool(cr.dbname)
|
||||||
state_obj=pool.get('res.country.state')
|
state_obj=pool.get('res.country.state')
|
||||||
ids=state_obj.search(cr, uid, [])
|
ids=state_obj.search(cr, uid, [])
|
||||||
res=[(state.id, state.name) for state in state_obj.browse(cr, uid, ids)]
|
res=[(state.id, state.name) for state in state_obj.browse(cr, uid, ids)]
|
||||||
res.append((-1, ''))
|
res.append((-1, ''))
|
||||||
res.sort(lambda x,y: cmp(x[1],y[1]))
|
res.sort(lambda x,y: cmp(x[1],y[1]))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_countries(self, cr, uid, context):
|
def _get_countries(self, cr, uid, context):
|
||||||
pool=pooler.get_pool(cr.dbname)
|
pool=pooler.get_pool(cr.dbname)
|
||||||
country_obj=pool.get('res.country')
|
country_obj=pool.get('res.country')
|
||||||
ids=country_obj.search(cr, uid, [])
|
ids=country_obj.search(cr, uid, [])
|
||||||
res=[(country.id, country.name) for country in country_obj.browse(cr, uid, ids)]
|
res=[(country.id, country.name) for country in country_obj.browse(cr, uid, ids)]
|
||||||
res.sort(lambda x,y: cmp(x[1],y[1]))
|
res.sort(lambda x,y: cmp(x[1],y[1]))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _update(self, cr, uid, data, context):
|
def _update(self, cr, uid, data, context):
|
||||||
pool=pooler.get_pool(cr.dbname)
|
pool=pooler.get_pool(cr.dbname)
|
||||||
form=data['form']
|
form=data['form']
|
||||||
if 'profile' in data['form'] and data['form']['profile'] > 0:
|
if 'profile' in data['form'] and data['form']['profile'] > 0:
|
||||||
module_obj=pool.get('ir.module.module')
|
module_obj=pool.get('ir.module.module')
|
||||||
module_obj.state_change(cr, uid, [data['form']['profile']], 'to install', context)
|
module_obj.state_change(cr, uid, [data['form']['profile']], 'to install', context)
|
||||||
if 'charts' in data['form'] and data['form']['charts'] > 0:
|
if 'charts' in data['form'] and data['form']['charts'] > 0:
|
||||||
module_obj=pool.get('ir.module.module')
|
module_obj=pool.get('ir.module.module')
|
||||||
module_obj.state_change(cr, uid, [data['form']['charts']], 'to install', context)
|
module_obj.state_change(cr, uid, [data['form']['charts']], 'to install', context)
|
||||||
|
|
||||||
company_obj=pool.get('res.company')
|
company_obj=pool.get('res.company')
|
||||||
partner_obj=pool.get('res.partner')
|
partner_obj=pool.get('res.partner')
|
||||||
address_obj=pool.get('res.partner.address')
|
address_obj=pool.get('res.partner.address')
|
||||||
ids=company_obj.search(cr, uid, [])
|
ids=company_obj.search(cr, uid, [])
|
||||||
company=company_obj.browse(cr, uid, ids)[0]
|
company=company_obj.browse(cr, uid, ids)[0]
|
||||||
company_obj.write(cr, uid, [company.id], {
|
company_obj.write(cr, uid, [company.id], {
|
||||||
'name': form['name'],
|
'name': form['name'],
|
||||||
'rml_header1': form['rml_header1'],
|
'rml_header1': form['rml_header1'],
|
||||||
'rml_footer1': form['rml_footer1'],
|
'rml_footer1': form['rml_footer1'],
|
||||||
'rml_footer2': form['rml_footer2'],
|
'rml_footer2': form['rml_footer2'],
|
||||||
'currency_id': form['currency'],
|
'currency_id': form['currency'],
|
||||||
})
|
})
|
||||||
partner_obj.write(cr, uid, [company.partner_id.id], {
|
partner_obj.write(cr, uid, [company.partner_id.id], {
|
||||||
'name': form['name'],
|
'name': form['name'],
|
||||||
})
|
})
|
||||||
values={
|
values={
|
||||||
'name': form['name'],
|
'name': form['name'],
|
||||||
'street': form['street'],
|
'street': form['street'],
|
||||||
'street2': form['street2'],
|
'street2': form['street2'],
|
||||||
'zip': form['zip'],
|
'zip': form['zip'],
|
||||||
'city': form['city'],
|
'city': form['city'],
|
||||||
'email': form['email'],
|
'email': form['email'],
|
||||||
'phone': form['phone'],
|
'phone': form['phone'],
|
||||||
'country_id': form['country_id'],
|
'country_id': form['country_id'],
|
||||||
}
|
}
|
||||||
if form['state_id'] > 0:
|
if form['state_id'] > 0:
|
||||||
values['state_id']=form['state_id']
|
values['state_id']=form['state_id']
|
||||||
if company.partner_id.address:
|
if company.partner_id.address:
|
||||||
address=company.partner_id.address[0]
|
address=company.partner_id.address[0]
|
||||||
address_obj.write(cr, uid, [address.id], values)
|
address_obj.write(cr, uid, [address.id], values)
|
||||||
else:
|
else:
|
||||||
values['partner_id']=company.partner_id.id
|
values['partner_id']=company.partner_id.id
|
||||||
add_id=address_obj.create(cr, uid, values)
|
add_id=address_obj.create(cr, uid, values)
|
||||||
|
|
||||||
cr.commit()
|
cr.commit()
|
||||||
(db, pool)=pooler.restart_pool(cr.dbname, update_module=True)
|
(db, pool)=pooler.restart_pool(cr.dbname, update_module=True)
|
||||||
|
|
||||||
lang_obj=pool.get('res.lang')
|
lang_obj=pool.get('res.lang')
|
||||||
lang_ids=lang_obj.search(cr, uid, [])
|
lang_ids=lang_obj.search(cr, uid, [])
|
||||||
langs=lang_obj.browse(cr, uid, lang_ids)
|
langs=lang_obj.browse(cr, uid, lang_ids)
|
||||||
for lang in langs:
|
for lang in langs:
|
||||||
if lang.code and lang.code != 'en_US':
|
if lang.code and lang.code != 'en_US':
|
||||||
filename=os.path.join(tools.config["root_path"], "i18n", lang.code + ".csv")
|
filename=os.path.join(tools.config["root_path"], "i18n", lang.code + ".csv")
|
||||||
tools.trans_load(cr.dbname, filename, lang.code)
|
tools.trans_load(cr.dbname, filename, lang.code)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _menu(self, cr, uid, data, context):
|
def _menu(self, cr, uid, data, context):
|
||||||
users_obj=pooler.get_pool(cr.dbname).get('res.users')
|
users_obj=pooler.get_pool(cr.dbname).get('res.users')
|
||||||
action_obj=pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
action_obj=pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
||||||
|
|
||||||
ids=action_obj.search(cr, uid, [('name', '=', 'Menu')])
|
ids=action_obj.search(cr, uid, [('name', '=', 'Menu')])
|
||||||
menu=action_obj.browse(cr, uid, ids)[0]
|
menu=action_obj.browse(cr, uid, ids)[0]
|
||||||
|
|
||||||
ids=users_obj.search(cr, uid, [('action_id', '=', 'Setup')])
|
ids=users_obj.search(cr, uid, [('action_id', '=', 'Setup')])
|
||||||
users_obj.write(cr, uid, ids, {'action_id': menu.id})
|
users_obj.write(cr, uid, ids, {'action_id': menu.id})
|
||||||
ids=users_obj.search(cr, uid, [('menu_id', '=', 'Setup')])
|
ids=users_obj.search(cr, uid, [('menu_id', '=', 'Setup')])
|
||||||
users_obj.write(cr, uid, ids, {'menu_id': menu.id})
|
users_obj.write(cr, uid, ids, {'menu_id': menu.id})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'name': menu.name,
|
'name': menu.name,
|
||||||
'type': menu.type,
|
'type': menu.type,
|
||||||
'view_id': (menu.view_id and\
|
'view_id': (menu.view_id and\
|
||||||
(menu.view_id.id, menu.view_id.name)) or False,
|
(menu.view_id.id, menu.view_id.name)) or False,
|
||||||
'domain': menu.domain,
|
'domain': menu.domain,
|
||||||
'res_model': menu.res_model,
|
'res_model': menu.res_model,
|
||||||
'src_model': menu.src_model,
|
'src_model': menu.src_model,
|
||||||
'view_type': menu.view_type,
|
'view_type': menu.view_type,
|
||||||
'view_mode': menu.view_mode,
|
'view_mode': menu.view_mode,
|
||||||
'views': menu.views,
|
'views': menu.views,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _next(self, cr, uid, data, context):
|
def _next(self, cr, uid, data, context):
|
||||||
if not data['form']['profile'] or data['form']['profile'] <= 0:
|
if not data['form']['profile'] or data['form']['profile'] <= 0:
|
||||||
return 'company'
|
return 'company'
|
||||||
return 'charts'
|
return 'charts'
|
||||||
|
|
||||||
def _previous(self, cr, uid, data, context):
|
def _previous(self, cr, uid, data, context):
|
||||||
if 'profile' not in data['form'] or data['form']['profile'] <= 0:
|
if 'profile' not in data['form'] or data['form']['profile'] <= 0:
|
||||||
return 'init'
|
return 'init'
|
||||||
return 'charts'
|
return 'charts'
|
||||||
|
|
||||||
def _config(self, cr, uid, data, context=None):
|
def _config(self, cr, uid, data, context=None):
|
||||||
users_obj=pooler.get_pool(cr.dbname).get('res.users')
|
users_obj=pooler.get_pool(cr.dbname).get('res.users')
|
||||||
action_obj=pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
action_obj=pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
||||||
|
|
||||||
ids=action_obj.search(cr, uid, [('name', '=', 'Menu')])
|
ids=action_obj.search(cr, uid, [('name', '=', 'Menu')])
|
||||||
menu=action_obj.browse(cr, uid, ids)[0]
|
menu=action_obj.browse(cr, uid, ids)[0]
|
||||||
|
|
||||||
ids=users_obj.search(cr, uid, [('action_id', '=', 'Setup')])
|
ids=users_obj.search(cr, uid, [('action_id', '=', 'Setup')])
|
||||||
users_obj.write(cr, uid, ids, {'action_id': menu.id})
|
users_obj.write(cr, uid, ids, {'action_id': menu.id})
|
||||||
ids=users_obj.search(cr, uid, [('menu_id', '=', 'Setup')])
|
ids=users_obj.search(cr, uid, [('menu_id', '=', 'Setup')])
|
||||||
users_obj.write(cr, uid, ids, {'menu_id': menu.id})
|
users_obj.write(cr, uid, ids, {'menu_id': menu.id})
|
||||||
return {
|
return {
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
"view_mode": 'form',
|
"view_mode": 'form',
|
||||||
'res_model': 'ir.module.module.configuration.wizard',
|
'res_model': 'ir.module.module.configuration.wizard',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'target':'new',
|
'target':'new',
|
||||||
}
|
}
|
||||||
|
|
||||||
fields={
|
fields={
|
||||||
'profile':{
|
'profile':{
|
||||||
'string':'Profile',
|
'string':'Profile',
|
||||||
'type':'selection',
|
'type':'selection',
|
||||||
'selection':_get_profiles,
|
'selection':_get_profiles,
|
||||||
'default': -1,
|
'default': -1,
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
},
|
||||||
'charts':{
|
'charts':{
|
||||||
'string':'Chart of accounts',
|
'string':'Chart of accounts',
|
||||||
'type':'selection',
|
'type':'selection',
|
||||||
'selection':_get_charts,
|
'selection':_get_charts,
|
||||||
'default': -1,
|
'default': -1,
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
},
|
||||||
'name':{
|
'name':{
|
||||||
'string': 'Company Name',
|
'string': 'Company Name',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 64,
|
'size': 64,
|
||||||
},
|
},
|
||||||
'street':{
|
'street':{
|
||||||
'string': 'Street',
|
'string': 'Street',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 128,
|
'size': 128,
|
||||||
},
|
},
|
||||||
'street2':{
|
'street2':{
|
||||||
'string': 'Street2',
|
'string': 'Street2',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 128,
|
'size': 128,
|
||||||
},
|
},
|
||||||
'zip':{
|
'zip':{
|
||||||
'string': 'Zip code',
|
'string': 'Zip code',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 24,
|
'size': 24,
|
||||||
},
|
},
|
||||||
'city':{
|
'city':{
|
||||||
'string': 'City',
|
'string': 'City',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 128,
|
'size': 128,
|
||||||
},
|
},
|
||||||
'state_id':{
|
'state_id':{
|
||||||
'string': 'State',
|
'string': 'State',
|
||||||
'type': 'selection',
|
'type': 'selection',
|
||||||
'selection':_get_states,
|
'selection':_get_states,
|
||||||
},
|
},
|
||||||
'country_id':{
|
'country_id':{
|
||||||
'string': 'Country',
|
'string': 'Country',
|
||||||
'type': 'selection',
|
'type': 'selection',
|
||||||
'selection':_get_countries,
|
'selection':_get_countries,
|
||||||
},
|
},
|
||||||
'email':{
|
'email':{
|
||||||
'string': 'E-mail',
|
'string': 'E-mail',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 64,
|
'size': 64,
|
||||||
},
|
},
|
||||||
'phone':{
|
'phone':{
|
||||||
'string': 'Phone',
|
'string': 'Phone',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 64,
|
'size': 64,
|
||||||
},
|
},
|
||||||
'currency': {
|
'currency': {
|
||||||
'string': 'Currency',
|
'string': 'Currency',
|
||||||
'type': 'many2one',
|
'type': 'many2one',
|
||||||
'relation': 'res.currency',
|
'relation': 'res.currency',
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
},
|
||||||
'rml_header1':{
|
'rml_header1':{
|
||||||
'string': 'Report Header',
|
'string': 'Report Header',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'help': """This sentence will appear at the top right corner of your reports.
|
'help': """This sentence will appear at the top right corner of your reports.
|
||||||
We suggest you to put a slogan here:
|
We suggest you to put a slogan here:
|
||||||
"Open Source Business Solutions".""",
|
"Open Source Business Solutions".""",
|
||||||
'size': 200,
|
'size': 200,
|
||||||
},
|
},
|
||||||
'rml_footer1':{
|
'rml_footer1':{
|
||||||
'string': 'Report Footer 1',
|
'string': 'Report Footer 1',
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'help': """This sentence will appear at the bottom of your reports.
|
'help': """This sentence will appear at the bottom of your reports.
|
||||||
We suggest you to write legal sentences here:
|
We suggest you to write legal sentences here:
|
||||||
Web: http://openerp.com - Fax: +32.81.73.35.01 - Fortis Bank: 126-2013269-07""",
|
Web: http://openerp.com - Fax: +32.81.73.35.01 - Fortis Bank: 126-2013269-07""",
|
||||||
'size': 200,
|
'size': 200,
|
||||||
},
|
},
|
||||||
'rml_footer2':{
|
'rml_footer2':{
|
||||||
'string': 'Report Footer 2',
|
'string': 'Report Footer 2',
|
||||||
'help': """This sentence will appear at the bottom of your reports.
|
'help': """This sentence will appear at the bottom of your reports.
|
||||||
We suggest you to put bank information here:
|
We suggest you to put bank information here:
|
||||||
IBAN: BE74 1262 0121 6907 - SWIFT: CPDF BE71 - VAT: BE0477.472.701""",
|
IBAN: BE74 1262 0121 6907 - SWIFT: CPDF BE71 - VAT: BE0477.472.701""",
|
||||||
'type': 'char',
|
'type': 'char',
|
||||||
'size': 200,
|
'size': 200,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
states={
|
states={
|
||||||
'init':{
|
'init':{
|
||||||
'actions': [_get_company],
|
'actions': [_get_company],
|
||||||
'result': {'type': 'form', 'arch': view_form_profit, 'fields': fields,
|
'result': {'type': 'form', 'arch': view_form_profit, 'fields': fields,
|
||||||
'state': [
|
'state': [
|
||||||
('menu', 'Cancel', 'gtk-cancel'),
|
('menu', 'Cancel', 'gtk-cancel'),
|
||||||
('next', 'Next', 'gtk-go-forward', True)
|
('next', 'Next', 'gtk-go-forward', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'next': {
|
'next': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'choice', 'next_state': _next}
|
'result': {'type': 'choice', 'next_state': _next}
|
||||||
},
|
},
|
||||||
'charts':{
|
'charts':{
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': view_form_charts, 'fields': fields,
|
'result': {'type': 'form', 'arch': view_form_charts, 'fields': fields,
|
||||||
'state':[
|
'state':[
|
||||||
('init', 'Previous', 'gtk-go-back'),
|
('init', 'Previous', 'gtk-go-back'),
|
||||||
('company', 'Next', 'gtk-go-forward', True)
|
('company', 'Next', 'gtk-go-forward', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'company':{
|
'company':{
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': view_form_company, 'fields': fields,
|
'result': {'type': 'form', 'arch': view_form_company, 'fields': fields,
|
||||||
'state': [
|
'state': [
|
||||||
('previous', 'Previous', 'gtk-go-back'),
|
('previous', 'Previous', 'gtk-go-back'),
|
||||||
('update', 'Next', 'gtk-go-forward', True)
|
('update', 'Next', 'gtk-go-forward', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'previous':{
|
'previous':{
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'choice', 'next_state': _previous}
|
'result': {'type': 'choice', 'next_state': _previous}
|
||||||
},
|
},
|
||||||
'update':{
|
'update':{
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'form', 'arch': view_form_update, 'fields': fields,
|
'result': {'type': 'form', 'arch': view_form_update, 'fields': fields,
|
||||||
'state': [
|
'state': [
|
||||||
('company', 'Previous', 'gtk-go-back'),
|
('company', 'Previous', 'gtk-go-back'),
|
||||||
('finish', 'Install', 'gtk-ok', True)
|
('finish', 'Install', 'gtk-ok', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'finish':{
|
'finish':{
|
||||||
'actions': [_update],
|
'actions': [_update],
|
||||||
'result': {'type': 'form', 'arch': view_form_finish, 'fields': {},
|
'result': {'type': 'form', 'arch': view_form_finish, 'fields': {},
|
||||||
'state': [
|
'state': [
|
||||||
('menu', 'Use Directly'),
|
('menu', 'Use Directly'),
|
||||||
('config', 'Start Configuration', 'gtk-ok', True)
|
('config', 'Start Configuration', 'gtk-ok', True)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'config': {
|
'config': {
|
||||||
'result': {
|
'result': {
|
||||||
'type': 'action',
|
'type': 'action',
|
||||||
'action': _config,
|
'action': _config,
|
||||||
'state': 'end',
|
'state': 'end',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'menu': {
|
'menu': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type': 'action', 'action': _menu, 'state': 'end'}
|
'result': {'type': 'action', 'action': _menu, 'state': 'end'}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard_base_setup('base_setup.base_setup')
|
wizard_base_setup('base_setup.base_setup')
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "VAT",
|
"name" : "VAT",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"category" : "Generic Modules/Base",
|
"category" : "Generic Modules/Base",
|
||||||
"depends" : ["base"],
|
"depends" : ["base"],
|
||||||
"update_xml" : ["base_vat_data.xml"],
|
"update_xml" : ["base_vat_data.xml"],
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,14 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name":"Dashboard main module",
|
"name":"Dashboard main module",
|
||||||
"version":"1.0",
|
"version":"1.0",
|
||||||
"author":"Tiny",
|
"author":"Tiny",
|
||||||
"category":"Board/Base",
|
"category":"Board/Base",
|
||||||
"depends":["base"],
|
"depends":["base"],
|
||||||
"demo_xml":[],
|
"demo_xml":[],
|
||||||
"update_xml":["board_view.xml"],
|
"update_xml":["board_view.xml"],
|
||||||
"description": "Base module for all dashboards.",
|
"description": "Base module for all dashboards.",
|
||||||
"active":False,
|
"active":False,
|
||||||
"installable":True,
|
"installable":True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,94 +31,94 @@ import time
|
||||||
from osv import fields,osv
|
from osv import fields,osv
|
||||||
|
|
||||||
class board_board(osv.osv):
|
class board_board(osv.osv):
|
||||||
_name = 'board.board'
|
_name = 'board.board'
|
||||||
def create(self, cr, user, vals, context=None):
|
def create(self, cr, user, vals, context=None):
|
||||||
if not 'name' in vals:
|
if not 'name' in vals:
|
||||||
return False
|
return False
|
||||||
return super(board_board, self).create(cr, user, vals, context)
|
return super(board_board, self).create(cr, user, vals, context)
|
||||||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
|
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
|
||||||
if context and ('view' in context):
|
if context and ('view' in context):
|
||||||
board = self.pool.get('board.board').browse(cr, user, int(context['view']), context)
|
board = self.pool.get('board.board').browse(cr, user, int(context['view']), context)
|
||||||
left = []
|
left = []
|
||||||
right = []
|
right = []
|
||||||
for line in board.line_ids:
|
for line in board.line_ids:
|
||||||
linestr = '<action string="%s" name="%d" colspan="4"' % (line.name, line.action_id.id)
|
linestr = '<action string="%s" name="%d" colspan="4"' % (line.name, line.action_id.id)
|
||||||
if line.height:
|
if line.height:
|
||||||
linestr+=(' height="%d"' % (line.height,))
|
linestr+=(' height="%d"' % (line.height,))
|
||||||
if line.width:
|
if line.width:
|
||||||
linestr+=(' width="%d"' % (line.width,))
|
linestr+=(' width="%d"' % (line.width,))
|
||||||
linestr += '/>'
|
linestr += '/>'
|
||||||
if line.position=='left':
|
if line.position=='left':
|
||||||
left.append(linestr)
|
left.append(linestr)
|
||||||
else:
|
else:
|
||||||
right.append(linestr)
|
right.append(linestr)
|
||||||
arch = """<form string="My Board">
|
arch = """<form string="My Board">
|
||||||
<hpaned>
|
<hpaned>
|
||||||
<child1>
|
<child1>
|
||||||
%s
|
%s
|
||||||
</child1>
|
</child1>
|
||||||
<child2>
|
<child2>
|
||||||
%s
|
%s
|
||||||
</child2>
|
</child2>
|
||||||
</hpaned>
|
</hpaned>
|
||||||
</form>""" % ('\n'.join(left), '\n'.join(right))
|
</form>""" % ('\n'.join(left), '\n'.join(right))
|
||||||
result = {
|
result = {
|
||||||
'toolbar': {'print':[],'action':[],'relate':[]},
|
'toolbar': {'print':[],'action':[],'relate':[]},
|
||||||
'fields': {},
|
'fields': {},
|
||||||
'arch': arch
|
'arch': arch
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
res = super(board_board, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
|
res = super(board_board, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
|
||||||
res['toolbar'] = {'print':[],'action':[],'relate':[]}
|
res['toolbar'] = {'print':[],'action':[],'relate':[]}
|
||||||
return res
|
return res
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Dashboard', size=64, required=True),
|
'name': fields.char('Dashboard', size=64, required=True),
|
||||||
'line_ids': fields.one2many('board.board.line', 'board_id', 'Action Views')
|
'line_ids': fields.one2many('board.board.line', 'board_id', 'Action Views')
|
||||||
}
|
}
|
||||||
board_board()
|
board_board()
|
||||||
|
|
||||||
class board_line(osv.osv):
|
class board_line(osv.osv):
|
||||||
_name = 'board.board.line'
|
_name = 'board.board.line'
|
||||||
_order = 'position,sequence'
|
_order = 'position,sequence'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Board', size=64, required=True),
|
'name': fields.char('Board', size=64, required=True),
|
||||||
'sequence': fields.integer('Sequence'),
|
'sequence': fields.integer('Sequence'),
|
||||||
'height': fields.integer('Height'),
|
'height': fields.integer('Height'),
|
||||||
'width': fields.integer('Width'),
|
'width': fields.integer('Width'),
|
||||||
'board_id': fields.many2one('board.board', 'Dashboard', required=True, ondelete='cascade'),
|
'board_id': fields.many2one('board.board', 'Dashboard', required=True, ondelete='cascade'),
|
||||||
'action_id': fields.many2one('ir.actions.act_window', 'Action', required=True),
|
'action_id': fields.many2one('ir.actions.act_window', 'Action', required=True),
|
||||||
'position': fields.selection([('left','Left'),('right','Right')], 'Position', required=True)
|
'position': fields.selection([('left','Left'),('right','Right')], 'Position', required=True)
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'position': lambda *args: 'left'
|
'position': lambda *args: 'left'
|
||||||
}
|
}
|
||||||
board_line()
|
board_line()
|
||||||
|
|
||||||
class board_note_type(osv.osv):
|
class board_note_type(osv.osv):
|
||||||
_name = 'board.note.type'
|
_name = 'board.note.type'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Note Type', size=64, required=True),
|
'name': fields.char('Note Type', size=64, required=True),
|
||||||
}
|
}
|
||||||
board_note_type()
|
board_note_type()
|
||||||
|
|
||||||
def _type_get(self, cr, uid, context={}):
|
def _type_get(self, cr, uid, context={}):
|
||||||
obj = self.pool.get('board.note.type')
|
obj = self.pool.get('board.note.type')
|
||||||
ids = obj.search(cr, uid, [])
|
ids = obj.search(cr, uid, [])
|
||||||
res = obj.read(cr, uid, ids, ['name'], context)
|
res = obj.read(cr, uid, ids, ['name'], context)
|
||||||
res = [(r['name'], r['name']) for r in res]
|
res = [(r['name'], r['name']) for r in res]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
class board_note(osv.osv):
|
class board_note(osv.osv):
|
||||||
_name = 'board.note'
|
_name = 'board.note'
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Subject', size=128, required=True),
|
'name': fields.char('Subject', size=128, required=True),
|
||||||
'note': fields.text('Note'),
|
'note': fields.text('Note'),
|
||||||
'user_id': fields.many2one('res.users', 'Author', size=64),
|
'user_id': fields.many2one('res.users', 'Author', size=64),
|
||||||
'date': fields.date('Date', size=64, required=True),
|
'date': fields.date('Date', size=64, required=True),
|
||||||
'type': fields.selection(_type_get, 'Note type', size=64),
|
'type': fields.selection(_type_get, 'Note type', size=64),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'user_id': lambda object,cr,uid,context: uid,
|
'user_id': lambda object,cr,uid,context: uid,
|
||||||
'date': lambda object,cr,uid,context: time.strftime('%Y-%m-%d'),
|
'date': lambda object,cr,uid,context: time.strftime('%Y-%m-%d'),
|
||||||
}
|
}
|
||||||
board_note()
|
board_note()
|
||||||
|
|
|
@ -35,47 +35,47 @@ import pooler
|
||||||
|
|
||||||
section_form = '''<?xml version="1.0"?>
|
section_form = '''<?xml version="1.0"?>
|
||||||
<form string="Create Menu For Dashboard">
|
<form string="Create Menu For Dashboard">
|
||||||
<separator string="Menu Information" colspan="4"/>
|
<separator string="Menu Information" colspan="4"/>
|
||||||
<field name="menu_name"/>
|
<field name="menu_name"/>
|
||||||
<field name="menu_parent_id"/>
|
<field name="menu_parent_id"/>
|
||||||
</form>'''
|
</form>'''
|
||||||
|
|
||||||
section_fields = {
|
section_fields = {
|
||||||
'menu_name': {'string':'Menu Name', 'type':'char', 'required':True, 'size':64},
|
'menu_name': {'string':'Menu Name', 'type':'char', 'required':True, 'size':64},
|
||||||
'menu_parent_id': {'string':'Parent Menu', 'type':'many2one', 'relation':'ir.ui.menu', 'required':True},
|
'menu_parent_id': {'string':'Parent Menu', 'type':'many2one', 'relation':'ir.ui.menu', 'required':True},
|
||||||
}
|
}
|
||||||
|
|
||||||
def board_menu_create(self, cr, uid, data, context):
|
def board_menu_create(self, cr, uid, data, context):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
board = pool.get('board.board').browse(cr, uid, data['id'])
|
board = pool.get('board.board').browse(cr, uid, data['id'])
|
||||||
action_id = pool.get('ir.actions.act_window').create(cr, uid, {
|
action_id = pool.get('ir.actions.act_window').create(cr, uid, {
|
||||||
'name': board.name,
|
'name': board.name,
|
||||||
'view_type':'form',
|
'view_type':'form',
|
||||||
'view_mode':'form',
|
'view_mode':'form',
|
||||||
'context': "{'view':%d}" % (board.id,),
|
'context': "{'view':%d}" % (board.id,),
|
||||||
'res_model': 'board.board'
|
'res_model': 'board.board'
|
||||||
})
|
})
|
||||||
pool.get('ir.ui.menu').create(cr, uid, {
|
pool.get('ir.ui.menu').create(cr, uid, {
|
||||||
'name': data['form']['menu_name'],
|
'name': data['form']['menu_name'],
|
||||||
'parent_id': data['form']['menu_parent_id'],
|
'parent_id': data['form']['menu_parent_id'],
|
||||||
'icon': 'STOCK_SELECT_COLOR',
|
'icon': 'STOCK_SELECT_COLOR',
|
||||||
'action': 'ir.actions.act_window,'+str(action_id)
|
'action': 'ir.actions.act_window,'+str(action_id)
|
||||||
}, context)
|
}, context)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
class wizard_section_menu_create(wizard.interface):
|
class wizard_section_menu_create(wizard.interface):
|
||||||
states = {
|
states = {
|
||||||
'init': {
|
'init': {
|
||||||
'actions': [],
|
'actions': [],
|
||||||
'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]}
|
'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]}
|
||||||
},
|
},
|
||||||
'create_menu': {
|
'create_menu': {
|
||||||
'actions': [board_menu_create],
|
'actions': [board_menu_create],
|
||||||
'result': {
|
'result': {
|
||||||
'type':'state',
|
'type':'state',
|
||||||
'state':'end'
|
'state':'end'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wizard_section_menu_create('board.board.menu.create')
|
wizard_section_menu_create('board.board.menu.create')
|
||||||
|
|
||||||
|
|
|
@ -26,30 +26,30 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name":"Board for accountant",
|
"name":"Board for accountant",
|
||||||
"version":"1.0",
|
"version":"1.0",
|
||||||
"author":"Tiny",
|
"author":"Tiny",
|
||||||
"category":"Board/Accounting",
|
"category":"Board/Accounting",
|
||||||
"depends":[
|
"depends":[
|
||||||
"account",
|
"account",
|
||||||
"hr_timesheet_invoice",
|
"hr_timesheet_invoice",
|
||||||
"board",
|
"board",
|
||||||
"report_account",
|
"report_account",
|
||||||
"report_analytic",
|
"report_analytic",
|
||||||
"report_analytic_line",
|
"report_analytic_line",
|
||||||
"account_report",
|
"account_report",
|
||||||
],
|
],
|
||||||
"demo_xml":["board_account_demo.xml"],
|
"demo_xml":["board_account_demo.xml"],
|
||||||
"update_xml":["board_account_view.xml"],
|
"update_xml":["board_account_view.xml"],
|
||||||
"description": """
|
"description": """
|
||||||
This module creates a dashboards for accountants that includes:
|
This module creates a dashboards for accountants that includes:
|
||||||
* List of analytic accounts to close
|
* List of analytic accounts to close
|
||||||
* List of uninvoiced quotations
|
* List of uninvoiced quotations
|
||||||
* List of invoices to confirm
|
* List of invoices to confirm
|
||||||
* Graph of costs to invoice
|
* Graph of costs to invoice
|
||||||
* Graph of aged receivables
|
* Graph of aged receivables
|
||||||
* Graph of aged incomes
|
* Graph of aged incomes
|
||||||
""",
|
""",
|
||||||
"active":False,
|
"active":False,
|
||||||
"installable":True,
|
"installable":True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,29 +26,29 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name":"Board for project users",
|
"name":"Board for project users",
|
||||||
"version":"1.0",
|
"version":"1.0",
|
||||||
"author":"Tiny",
|
"author":"Tiny",
|
||||||
"category":"Board/Projects & Services",
|
"category":"Board/Projects & Services",
|
||||||
"depends":[
|
"depends":[
|
||||||
"project",
|
"project",
|
||||||
"report_timesheet",
|
"report_timesheet",
|
||||||
"board",
|
"board",
|
||||||
"report_analytic_planning",
|
"report_analytic_planning",
|
||||||
"report_analytic_line",
|
"report_analytic_line",
|
||||||
"report_task",
|
"report_task",
|
||||||
"hr_timesheet_sheet"
|
"hr_timesheet_sheet"
|
||||||
],
|
],
|
||||||
"demo_xml":["board_project_demo.xml"],
|
"demo_xml":["board_project_demo.xml"],
|
||||||
"update_xml":["board_project_view.xml", "board_project_manager_view.xml"],
|
"update_xml":["board_project_view.xml", "board_project_manager_view.xml"],
|
||||||
"description": """
|
"description": """
|
||||||
This module implements a dashboard for project member that includes:
|
This module implements a dashboard for project member that includes:
|
||||||
* List of my open tasks
|
* List of my open tasks
|
||||||
* List of my next deadlines
|
* List of my next deadlines
|
||||||
* List of public notes
|
* List of public notes
|
||||||
* Graph of my timesheet
|
* Graph of my timesheet
|
||||||
* Graph of my work analysis
|
* Graph of my work analysis
|
||||||
""",
|
""",
|
||||||
"active":False,
|
"active":False,
|
||||||
"installable":True,
|
"installable":True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,21 +26,21 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name":"Dashboard for sales",
|
"name":"Dashboard for sales",
|
||||||
"version":"1.0",
|
"version":"1.0",
|
||||||
"author":"Tiny",
|
"author":"Tiny",
|
||||||
"category":"Board/Sales & Purchase",
|
"category":"Board/Sales & Purchase",
|
||||||
"depends":["board","sale", "report_crm", "report_sale"],
|
"depends":["board","sale", "report_crm", "report_sale"],
|
||||||
"demo_xml":["board_sale_demo.xml"],
|
"demo_xml":["board_sale_demo.xml"],
|
||||||
"update_xml":["board_sale_view.xml"],
|
"update_xml":["board_sale_view.xml"],
|
||||||
"description": """
|
"description": """
|
||||||
This module implements a dashboard for salesman that includes:
|
This module implements a dashboard for salesman that includes:
|
||||||
* You open quotations
|
* You open quotations
|
||||||
* Top 10 sales of the month
|
* Top 10 sales of the month
|
||||||
* Cases statistics
|
* Cases statistics
|
||||||
* Graph of sales by product
|
* Graph of sales by product
|
||||||
* Graph of cases of the month
|
* Graph of cases of the month
|
||||||
""",
|
""",
|
||||||
"active":False,
|
"active":False,
|
||||||
"installable":True,
|
"installable":True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
"name" : "Customer & Supplier Relationship Management",
|
"name" : "Customer & Supplier Relationship Management",
|
||||||
"version" : "1.0",
|
"version" : "1.0",
|
||||||
"author" : "Tiny",
|
"author" : "Tiny",
|
||||||
"website" : "http://tinyerp.com/module_crm.html",
|
"website" : "http://tinyerp.com/module_crm.html",
|
||||||
"category" : "Generic Modules/CRM & SRM",
|
"category" : "Generic Modules/CRM & SRM",
|
||||||
"description": """The Tiny ERP case and request tracker enables a group of
|
"description": """The Tiny ERP case and request tracker enables a group of
|
||||||
people to intelligently and efficiently manage tasks, issues, and requests.
|
people to intelligently and efficiently manage tasks, issues, and requests.
|
||||||
It manages key tasks such as communication, identification, prioritization,
|
It manages key tasks such as communication, identification, prioritization,
|
||||||
assignment, resolution and notification.
|
assignment, resolution and notification.
|
||||||
|
@ -48,10 +48,10 @@ place.
|
||||||
|
|
||||||
The CRM module has a email gateway for the synchronisation interface
|
The CRM module has a email gateway for the synchronisation interface
|
||||||
between mails and Tiny ERP.""",
|
between mails and Tiny ERP.""",
|
||||||
"depends" : ["base"],
|
"depends" : ["base"],
|
||||||
"init_xml" : ["crm_data.xml"],
|
"init_xml" : ["crm_data.xml"],
|
||||||
"demo_xml" : ["crm_demo.xml"],
|
"demo_xml" : ["crm_demo.xml"],
|
||||||
"update_xml" : ["crm_view.xml", "crm_report.xml", "crm_wizard.xml", "crm_security.xml"],
|
"update_xml" : ["crm_view.xml", "crm_report.xml", "crm_wizard.xml", "crm_security.xml"],
|
||||||
"active": False,
|
"active": False,
|
||||||
"installable": True
|
"installable": True
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue