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
1=== modified file 'account_statement_ext/statement.py'
2--- account_statement_ext/statement.py 2013-05-24 09:38:35 +0000
3+++ account_statement_ext/statement.py 2013-09-12 09:00:19 +0000
4@@ -38,7 +38,7 @@
5 stat_mod.account_bank_statement.write = fixed_write
6
7
8-class AccountStatementProfil(Model):
9+class AccountStatementProfile(Model):
10 """
11 A Profile will contain all infos related to the type of
12 bank statement, and related generated entries. It defines the
13@@ -47,10 +47,12 @@
14 _name = "account.statement.profile"
15 _inherit = ['mail.thread']
16
17- _description = "Statement Profil"
18+ _description = "Statement Profile"
19+ _order = 'sequence'
20
21 _columns = {
22 'name': fields.char('Name', required=True),
23+ 'sequence': fields.integer('Sequence', help="Gives a sequence in lists, the first profile will be used as default"),
24 'partner_id': fields.many2one(
25 'res.partner',
26 'Bank/Payment Office partner',
27@@ -135,12 +137,27 @@
28 periods = period_obj.find(cr, uid, dt=context.get('date'), context=context)
29 return periods and periods[0] or False
30
31+ def _default_profile(self, cr, uid, context=None):
32+ """
33+ Returns the default statement profile
34+ Default profile is the one with the lowest sequence of user's company
35+
36+ :return profile_id or False
37+ """
38+ if context is None:
39+ context = {}
40+ user_obj = self.pool.get('res.users')
41+ profile_obj = self.pool.get('account.statement.profile')
42+ user = user_obj.browse(cr, uid, uid, context=context)
43+ profile_ids = profile_obj.search(cr, uid, [('company_id', '=', user.company_id.id)], context=context)
44+
45+ return profile_ids[0] if profile_ids else False
46+
47 _columns = {
48 'profile_id': fields.many2one(
49 'account.statement.profile',
50- 'Profil',
51+ 'Bank Account Profile',
52 required=True,
53- readonly=True,
54 states={'draft': [('readonly', False)]}),
55 'credit_partner_id': fields.related(
56 'profile_id',
57@@ -175,6 +192,7 @@
58
59 _defaults = {
60 'period_id': _default_period,
61+ 'profile_id': _default_profile,
62 }
63
64 def create(self, cr, uid, vals, context=None):
65@@ -283,7 +301,7 @@
66 uid,
67 st_line,
68 context=context)
69- # get the right partner according to the chosen profil
70+ # get the right partner according to the chosen profile
71 if st_line.statement_id.profile_id.force_partner_on_bank:
72 bank_partner_id = st_line.statement_id.profile_id.partner_id.id
73 return bank_partner_id
74
75=== modified file 'account_statement_ext/statement_view.xml'
76--- account_statement_ext/statement_view.xml 2013-02-13 08:21:48 +0000
77+++ account_statement_ext/statement_view.xml 2013-09-12 09:00:19 +0000
78@@ -99,51 +99,49 @@
79 <field name="arch" type="xml">
80
81 <!-- Add before the group : profile and related infos -->
82- <xpath expr="/form/sheet/group/group/field[@name='journal_id']" position="replace">
83- </xpath>
84+ <field name="journal_id" position="attributes">
85+ <attribute name="invisible">True</attribute>
86+ </field>
87
88- <xpath expr="/form/sheet/group" position="after">
89+ <label for="name" position="before">
90 <group>
91 <field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
92- <separator string="Profile Details" colspan="4"/>
93- <field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" widget="selection"/>
94- <field name="credit_partner_id"/>
95- <field name="account_id" invisible="1"/>
96- <field name="balance_check" invisible="1"/>
97+ <field name="balance_check" invisible="1"/>
98 </group>
99- </xpath>
100+ </label>
101
102 # Make balance visible or not depending on profile
103- <xpath expr="/form/sheet/group/group/field[@name='balance_start']" position="attributes">
104- <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
105- </xpath>
106- <xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="attributes">
107- <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
108- </xpath>
109- <xpath expr="/form/sheet/group/group/field[@name='balance_end_real']" position="after">
110+ <field name="balance_start" position="attributes">
111+ <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
112+ </field>
113+ <field name="balance_end_real" position="attributes">
114+ <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
115+ </field>
116+ <field name="balance_end_real" position="after">
117 <field name="balance_end" widget="monetary" options='{"currency_field" : "currency"}' attrs="{'invisible':[('balance_check','=',False)]}"/>
118- </xpath>
119-
120- <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='sequence']" position="after">
121- <field name="id" readonly="1" />
122- </xpath>
123-
124- <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='date']" position="before">
125- <field name="id" readonly="1" />
126- </xpath>
127- # Adapt onchange signature
128- <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='partner_id']" position="replace">
129+ </field>
130+
131+ <xpath expr="//field[@name='line_ids']/tree/field[@name='sequence']" position="after">
132+ <field name="id" readonly="1" />
133+ </xpath>
134+
135+ <xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before">
136+ <field name="id" readonly="1" />
137+ </xpath>
138+ # Adapt onchange signature
139+ <xpath expr="//field[@name='line_ids']/tree/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)]"/>
141 </xpath>
142
143- <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='partner_id']" position="replace">
144+ <xpath expr="//field[@name='line_ids']/form//field[@name='partner_id']" position="replace">
145 <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
146 </xpath>
147- <xpath expr="/form/sheet/notebook/page/field/form/group/field[@name='type']" position="replace">
148+ <xpath expr="//field[@name='line_ids']/form//field[@name='type']" position="replace">
149 <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
150 </xpath>
151- <xpath expr="/form/sheet/notebook/page/field/tree/field[@name='type']" position="replace">
152- <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
153+ # also set type hidden as it has no impact on reconciliation
154+ <xpath expr="//field[@name='line_ids']/tree/field[@name='type']" position="replace">
155+ <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)" invisible="1"/>
156 </xpath>
157
158 </field>

Subscribers

People subscribed via source and target branches