Merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-account_statement_ext-improvement-20130628 into lp:banking-addons/bank-statement-reconcile-70

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 97
Proposed branch: lp:~camptocamp/banking-addons/bank-statement-reconcile-70-account_statement_ext-improvement-20130628
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 158 lines (+52/-36)
2 files modified
account_statement_ext/statement.py (+23/-5)
account_statement_ext/statement_view.xml (+29/-31)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-account_statement_ext-improvement-20130628
Reviewer Review Type Date Requested Status
Stéphane Bidoul (Acsone) (community) code review Approve
Raphaël Valyi - http://www.akretion.com Approve
Guewen Baconnier @ Camptocamp code review, no test Approve
Review via email: mp+172068@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

LGTM

review: Approve
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Good thing to have a default profile to restore compatibility with other modules creating bank statements.

Doc string in _default_profile should be "Statement default profile" instead of "Statement default period". Or removed as it does not say anything more than the method name ;)

review: Approve (code review)
100. By Yannick Vaucher @ Camptocamp

[IMP] account_statement_ext - docstring for Statement default profile

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Thanks for the reviews!

I corrected the docstring for _default_profile method to give it some meaning :)

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Is there any core reviewer in the room to merge this one ? (Approved 3 times)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_statement_ext/statement.py'
--- account_statement_ext/statement.py 2013-05-24 09:38:35 +0000
+++ account_statement_ext/statement.py 2013-09-12 09:00:19 +0000
@@ -38,7 +38,7 @@
38stat_mod.account_bank_statement.write = fixed_write38stat_mod.account_bank_statement.write = fixed_write
3939
4040
41class AccountStatementProfil(Model):41class AccountStatementProfile(Model):
42 """42 """
43 A Profile will contain all infos related to the type of43 A Profile will contain all infos related to the type of
44 bank statement, and related generated entries. It defines the44 bank statement, and related generated entries. It defines the
@@ -47,10 +47,12 @@
47 _name = "account.statement.profile"47 _name = "account.statement.profile"
48 _inherit = ['mail.thread']48 _inherit = ['mail.thread']
4949
50 _description = "Statement Profil"50 _description = "Statement Profile"
51 _order = 'sequence'
5152
52 _columns = {53 _columns = {
53 'name': fields.char('Name', required=True),54 'name': fields.char('Name', required=True),
55 'sequence': fields.integer('Sequence', help="Gives a sequence in lists, the first profile will be used as default"),
54 'partner_id': fields.many2one(56 'partner_id': fields.many2one(
55 'res.partner',57 'res.partner',
56 'Bank/Payment Office partner',58 'Bank/Payment Office partner',
@@ -135,12 +137,27 @@
135 periods = period_obj.find(cr, uid, dt=context.get('date'), context=context)137 periods = period_obj.find(cr, uid, dt=context.get('date'), context=context)
136 return periods and periods[0] or False138 return periods and periods[0] or False
137139
140 def _default_profile(self, cr, uid, context=None):
141 """
142 Returns the default statement profile
143 Default profile is the one with the lowest sequence of user's company
144
145 :return profile_id or False
146 """
147 if context is None:
148 context = {}
149 user_obj = self.pool.get('res.users')
150 profile_obj = self.pool.get('account.statement.profile')
151 user = user_obj.browse(cr, uid, uid, context=context)
152 profile_ids = profile_obj.search(cr, uid, [('company_id', '=', user.company_id.id)], context=context)
153
154 return profile_ids[0] if profile_ids else False
155
138 _columns = {156 _columns = {
139 'profile_id': fields.many2one(157 'profile_id': fields.many2one(
140 'account.statement.profile',158 'account.statement.profile',
141 'Profil',159 'Bank Account Profile',
142 required=True,160 required=True,
143 readonly=True,
144 states={'draft': [('readonly', False)]}),161 states={'draft': [('readonly', False)]}),
145 'credit_partner_id': fields.related(162 'credit_partner_id': fields.related(
146 'profile_id',163 'profile_id',
@@ -175,6 +192,7 @@
175192
176 _defaults = {193 _defaults = {
177 'period_id': _default_period,194 'period_id': _default_period,
195 'profile_id': _default_profile,
178 }196 }
179197
180 def create(self, cr, uid, vals, context=None):198 def create(self, cr, uid, vals, context=None):
@@ -283,7 +301,7 @@
283 uid,301 uid,
284 st_line,302 st_line,
285 context=context)303 context=context)
286 # get the right partner according to the chosen profil304 # get the right partner according to the chosen profile
287 if st_line.statement_id.profile_id.force_partner_on_bank:305 if st_line.statement_id.profile_id.force_partner_on_bank:
288 bank_partner_id = st_line.statement_id.profile_id.partner_id.id306 bank_partner_id = st_line.statement_id.profile_id.partner_id.id
289 return bank_partner_id307 return bank_partner_id
290308
=== modified file 'account_statement_ext/statement_view.xml'
--- account_statement_ext/statement_view.xml 2013-02-13 08:21:48 +0000
+++ account_statement_ext/statement_view.xml 2013-09-12 09:00:19 +0000
@@ -99,51 +99,49 @@
99 <field name="arch" type="xml">99 <field name="arch" type="xml">
100100
101 <!-- Add before the group : profile and related infos -->101 <!-- Add before the group : profile and related infos -->
102 <xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">102 <field name="journal_id" position="attributes">
103 </xpath>103 <attribute name="invisible">True</attribute>
104 </field>
104105
105 <xpath expr="/form/sheet/group" position="after">106 <label for="name" position="before">
106 <group>107 <group>
107 <field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>108 <field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
108 <separator string="Profile Details" colspan="4"/>109 <field name="balance_check" invisible="1"/>
109 <field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" widget="selection"/>
110 <field name="credit_partner_id"/>
111 <field name="account_id" invisible="1"/>
112 <field name="balance_check" invisible="1"/>
113 </group>110 </group>
114 </xpath>111 </label>
115112
116 # Make balance visible or not depending on profile113 # Make balance visible or not depending on profile
117 <xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes">114 <field name="balance_start" position="attributes">
118 <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>115 <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
119 </xpath>116 </field>
120 <xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="attributes">117 <field name="balance_end_real" position="attributes">
121 <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>118 <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
122 </xpath>119 </field>
123 <xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="after">120 <field name="balance_end_real" position="after">
124 <field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>121 <field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
125 </xpath>122 </field>
126123
127 <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after">124 <xpath expr="//field[@name='line_ids']/tree/field[@name='sequence']" position="after">
128 <field name="id" readonly="1" />125 <field name="id" readonly="1" />
129 </xpath>126 </xpath>
130127
131 <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before">128 <xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before">
132 <field name="id" readonly="1" />129 <field name="id" readonly="1" />
133 </xpath>130 </xpath>
134 # Adapt onchange signature131 # Adapt onchange signature
135 <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='partner_id']" position="replace">132 <xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']" position="replace">
136 <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>133 <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
137 </xpath>134 </xpath>
138135
139 <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='partner_id']" position="replace">136 <xpath expr="//field[@name='line_ids']/form//field[@name='partner_id']" position="replace">
140 <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>137 <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
141 </xpath>138 </xpath>
142 <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='type']" position="replace">139 <xpath expr="//field[@name='line_ids']/form//field[@name='type']" position="replace">
143 <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>140 <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
144 </xpath>141 </xpath>
145 <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='type']" position="replace">142 # also set type hidden as it has no impact on reconciliation
146 <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>143 <xpath expr="//field[@name='line_ids']/tree/field[@name='type']" position="replace">
144 <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)" invisible="1"/>
147 </xpath>145 </xpath>
148146
149 </field>147 </field>

Subscribers

People subscribed via source and target branches