mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[MRG] account_statement_ext improvements
docstring for Statement default profile hide type column in bank statement line add a sequence on bank profile and set the first of the company as default hide useless information on bank statement move profile to top simplify xpath in xml views rename profil to profile
This commit is contained in:
@@ -38,7 +38,7 @@ def fixed_write(self, cr, uid, ids, vals, context=None):
|
||||
stat_mod.account_bank_statement.write = fixed_write
|
||||
|
||||
|
||||
class AccountStatementProfil(Model):
|
||||
class AccountStatementProfile(Model):
|
||||
"""
|
||||
A Profile will contain all infos related to the type of
|
||||
bank statement, and related generated entries. It defines the
|
||||
@@ -47,10 +47,12 @@ class AccountStatementProfil(Model):
|
||||
_name = "account.statement.profile"
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
_description = "Statement Profil"
|
||||
_description = "Statement Profile"
|
||||
_order = 'sequence'
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True),
|
||||
'sequence': fields.integer('Sequence', help="Gives a sequence in lists, the first profile will be used as default"),
|
||||
'partner_id': fields.many2one(
|
||||
'res.partner',
|
||||
'Bank/Payment Office partner',
|
||||
@@ -135,12 +137,27 @@ class AccountBankSatement(Model):
|
||||
periods = period_obj.find(cr, uid, dt=context.get('date'), context=context)
|
||||
return periods and periods[0] or False
|
||||
|
||||
def _default_profile(self, cr, uid, context=None):
|
||||
"""
|
||||
Returns the default statement profile
|
||||
Default profile is the one with the lowest sequence of user's company
|
||||
|
||||
:return profile_id or False
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
user_obj = self.pool.get('res.users')
|
||||
profile_obj = self.pool.get('account.statement.profile')
|
||||
user = user_obj.browse(cr, uid, uid, context=context)
|
||||
profile_ids = profile_obj.search(cr, uid, [('company_id', '=', user.company_id.id)], context=context)
|
||||
|
||||
return profile_ids[0] if profile_ids else False
|
||||
|
||||
_columns = {
|
||||
'profile_id': fields.many2one(
|
||||
'account.statement.profile',
|
||||
'Profil',
|
||||
'Bank Account Profile',
|
||||
required=True,
|
||||
readonly=True,
|
||||
states={'draft': [('readonly', False)]}),
|
||||
'credit_partner_id': fields.related(
|
||||
'profile_id',
|
||||
@@ -175,6 +192,7 @@ class AccountBankSatement(Model):
|
||||
|
||||
_defaults = {
|
||||
'period_id': _default_period,
|
||||
'profile_id': _default_profile,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
@@ -283,7 +301,7 @@ class AccountBankSatement(Model):
|
||||
uid,
|
||||
st_line,
|
||||
context=context)
|
||||
# get the right partner according to the chosen profil
|
||||
# get the right partner according to the chosen profile
|
||||
if st_line.statement_id.profile_id.force_partner_on_bank:
|
||||
bank_partner_id = st_line.statement_id.profile_id.partner_id.id
|
||||
return bank_partner_id
|
||||
|
||||
@@ -99,51 +99,49 @@
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<!-- Add before the group : profile and related infos -->
|
||||
<xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">
|
||||
</xpath>
|
||||
<field name="journal_id" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</field>
|
||||
|
||||
<xpath expr="/form/sheet/group" position="after">
|
||||
<label for="name" position="before">
|
||||
<group>
|
||||
<field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
|
||||
<separator string="Profile Details" colspan="4"/>
|
||||
<field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" widget="selection"/>
|
||||
<field name="credit_partner_id"/>
|
||||
<field name="account_id" invisible="1"/>
|
||||
<field name="balance_check" invisible="1"/>
|
||||
<field name="balance_check" invisible="1"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</label>
|
||||
|
||||
# Make balance visible or not depending on profile
|
||||
<xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes">
|
||||
<field name="balance_start" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="attributes">
|
||||
</field>
|
||||
<field name="balance_end_real" position="attributes">
|
||||
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="after">
|
||||
</field>
|
||||
<field name="balance_end_real" position="after">
|
||||
<field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after">
|
||||
<xpath expr="//field[@name='line_ids']/tree/field[@name='sequence']" position="after">
|
||||
<field name="id" readonly="1" />
|
||||
</xpath>
|
||||
|
||||
<xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before">
|
||||
<xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before">
|
||||
<field name="id" readonly="1" />
|
||||
</xpath>
|
||||
# Adapt onchange signature
|
||||
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='partner_id']" position="replace">
|
||||
# Adapt onchange signature
|
||||
<xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']" position="replace">
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='partner_id']" position="replace">
|
||||
<xpath expr="//field[@name='line_ids']/form//field[@name='partner_id']" position="replace">
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='type']" position="replace">
|
||||
<xpath expr="//field[@name='line_ids']/form//field[@name='type']" position="replace">
|
||||
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/sheet/notebook/page/field/tree/field[@name='type']" position="replace">
|
||||
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
|
||||
# also set type hidden as it has no impact on reconciliation
|
||||
<xpath expr="//field[@name='line_ids']/tree/field[@name='type']" position="replace">
|
||||
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)" invisible="1"/>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user