[IMP] account: account.statement.operation.template model

- better many2one ondelete strategies
- added analytic account domain
- added multi-company support
This commit is contained in:
Arthur Maniet
2014-11-28 05:28:53 +01:00
parent b7ba307094
commit 3e0ffcf4e4
4 changed files with 21 additions and 11 deletions
+9 -8
View File
@@ -834,17 +834,18 @@ class account_statement_operation_template(osv.osv):
_description = "Preset for the lines that can be created in a bank statement reconciliation"
_columns = {
'name': fields.char('Button Label', required=True),
'account_id': fields.many2one('account.account', 'Account', ondelete='cascade', domain=[('type','!=','view')]),
'label': fields.char('Label'),
'amount_type': fields.selection([('fixed', 'Fixed'),('percentage_of_total','Percentage of total amount'),('percentage_of_balance', 'Percentage of open balance')],
'Amount type', required=True),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account'), help="The amount will count as a debit if it is negative, as a credit if it is positive (except if amount type is 'Percentage of open balance').", required=True),
'tax_id': fields.many2one('account.tax', 'Tax', ondelete='cascade'),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', ondelete='cascade'),
'account_id': fields.many2one('account.account', 'Account', ondelete='cascade', domain=[('type','not in',('view','closed','consolidation'))]),
'label': fields.char('Journal Item Label'),
'amount_type': fields.selection([('fixed', 'Fixed'),('percentage_of_total','Percentage of total amount'),('percentage_of_balance', 'Percentage of open balance')], 'Amount type', required=True),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account'), required=True, help="The amount will count as a debit if it is negative, as a credit if it is positive (except if amount type is 'Percentage of open balance')."),
'tax_id': fields.many2one('account.tax', 'Tax', ondelete='restrict', domain=[('type_tax_use','in',('purchase','all')), ('parent_id','=',False)]),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', ondelete='set null', domain=[('type','!=','view'), ('state','not in',('close','cancelled'))]),
'company_id': fields.many2one('res.company', 'Company', required=True),
}
_defaults = {
'amount_type': 'percentage_of_balance',
'amount': 100.0
'amount': 100.0,
'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+4 -3
View File
@@ -700,9 +700,9 @@
</div>
<group>
<group>
<field name="account_id" domain="[('type', 'not in', ['view', 'closed', 'consolidation'])]"/>
<field name="account_id" domain="[('company_id', '=', company_id)]"/>
<field name="amount_type"/>
<field name="tax_id" domain="[('type_tax_use', 'in', ['purchase', 'all']), ('parent_id', '=', False)]"/>
<field name="tax_id" domain="[('company_id', '=', company_id)]"/>
</group>
<group>
<field name="label"/>
@@ -711,7 +711,8 @@
<field name="amount" class="oe_inline" />
<label string="%" class="oe_inline" attrs="{'invisible':[('amount_type','not in',('percentage_of_total', 'percentage_of_balance'))]}" />
</div>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', company_id)]"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</group>
</sheet>
@@ -167,5 +167,12 @@
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
<record model="ir.rule" id="account_statement_operation_template_comp_rule">
<field name="name">Account statement operation template company rule</field>
<field name="model_id" ref="model_account_statement_operation_template"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
</data>
</openerp>
@@ -120,6 +120,7 @@ openerp.account = function (instance) {
relation: "account.analytic.account",
string: _t("Analytic Acc."),
type: "many2one",
domain: [['type','!=','view'], ['state','not in',['close','cancelled']]],
},
},
};