Merge lp:~openerp-dev/openobject-addons/trunk-bug-778487-ara into lp:openobject-addons

Proposed by Ashvin Rathod (OpenERP)
Status: Merged
Merge reported by: Fabien (Open ERP)
Merged at revision: not available
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-778487-ara
Merge into: lp:openobject-addons
Diff against target: 207 lines (+34/-33)
3 files modified
account_anglo_saxon/invoice.py (+31/-31)
account_anglo_saxon/product_view.xml (+2/-1)
account_anglo_saxon/purchase.py (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-778487-ara
Reviewer Review Type Date Requested Status
Mustufa Rangwala (Open ERP) (community) Approve
qdp (OpenERP) Pending
Review via email: mp+60580@code.launchpad.net

Description of the change

Hello,

Fix: account_anglo_saxon - field positioning and code simplification

Thanks,
ara

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_anglo_saxon/invoice.py'
2--- account_anglo_saxon/invoice.py 2011-01-14 00:11:01 +0000
3+++ account_anglo_saxon/invoice.py 2011-05-11 05:53:30 +0000
4@@ -25,7 +25,7 @@
5
6 class account_invoice_line(osv.osv):
7 _inherit = "account.invoice.line"
8-
9+
10 def move_line_get(self, cr, uid, invoice_id, context=None):
11 res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context=context)
12 inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
13@@ -33,9 +33,9 @@
14 def get_price(cr, uid, inv, company_currency,i_line):
15 cur_obj = self.pool.get('res.currency')
16 if inv.currency_id.id != company_currency:
17- price = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, i_line.product_id.product_tmpl_id.standard_price * i_line.quantity, context={'date': inv.date_invoice})
18+ price = cur_obj.compute(cr, uid, company_currency, inv.currency_id.id, i_line.product_id.standard_price * i_line.quantity, context={'date': inv.date_invoice})
19 else:
20- price = i_line.product_id.product_tmpl_id.standard_price * i_line.quantity
21+ price = i_line.product_id.standard_price * i_line.quantity
22 return price
23
24 if inv.type in ('out_invoice','out_refund'):
25@@ -43,27 +43,27 @@
26 if i_line.product_id:
27 if inv.type == 'out_invoice':
28 # debit account dacc will be the output account
29- # first check the product, if empty check the category
30- dacc = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id
31+ # first check the product, if empty check the category
32+ dacc = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id
33 if not dacc:
34 dacc = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id
35 else:
36 # = out_refund
37 # debit account dacc will be the input account
38- # first check the product, if empty check the category
39- dacc = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id
40+ # first check the product, if empty check the category
41+ dacc = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id
42 if not dacc:
43 dacc = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id
44 # in both cases the credit account cacc will be the expense account
45- # first check the product, if empty check the category
46- cacc = i_line.product_id.product_tmpl_id.property_account_expense and i_line.product_id.product_tmpl_id.property_account_expense.id
47+ # first check the product, if empty check the category
48+ cacc = i_line.product_id.property_account_expense and i_line.product_id.property_account_expense.id
49 if not cacc:
50 cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id
51 if dacc and cacc:
52 res.append({
53 'type':'src',
54 'name': i_line.name[:64],
55- 'price_unit':i_line.product_id.product_tmpl_id.standard_price,
56+ 'price_unit':i_line.product_id.standard_price,
57 'quantity':i_line.quantity,
58 'price':get_price(cr, uid, inv, company_currency, i_line),
59 'account_id':dacc,
60@@ -72,11 +72,11 @@
61 'account_analytic_id':i_line.account_analytic_id.id,
62 'taxes':i_line.invoice_line_tax_id,
63 })
64-
65+
66 res.append({
67 'type':'src',
68 'name': i_line.name[:64],
69- 'price_unit':i_line.product_id.product_tmpl_id.standard_price,
70+ 'price_unit':i_line.product_id.standard_price,
71 'quantity':i_line.quantity,
72 'price': -1 * get_price(cr, uid, inv, company_currency, i_line),
73 'account_id':cacc,
74@@ -88,36 +88,36 @@
75 elif inv.type in ('in_invoice','in_refund'):
76 for i_line in inv.invoice_line:
77 if i_line.product_id:
78- if i_line.product_id.product_tmpl_id.type != 'service':
79- # get the price difference account at the product
80- acc = i_line.product_id.product_tmpl_id.property_account_creditor_price_difference and i_line.product_id.product_tmpl_id.property_account_creditor_price_difference.id
81+ if i_line.product_id.type != 'service':
82+ # get the price difference account at the product
83+ acc = i_line.product_id.property_account_creditor_price_difference and i_line.product_id.property_account_creditor_price_difference.id
84 if not acc:
85- # if not found on the product get the price difference account at the category
86+ # if not found on the product get the price difference account at the category
87 acc = i_line.product_id.categ_id.property_account_creditor_price_difference_categ and i_line.product_id.categ_id.property_account_creditor_price_difference_categ.id
88 a = None
89 if inv.type == 'in_invoice':
90 # oa will be the stock input account
91- # first check the product, if empty check the category
92- oa = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id
93+ # first check the product, if empty check the category
94+ oa = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id
95 if not oa:
96 oa = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id
97 else:
98 # = in_refund
99 # oa will be the stock output account
100- # first check the product, if empty check the category
101- oa = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id
102+ # first check the product, if empty check the category
103+ oa = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id
104 if not oa:
105 oa = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id
106 if oa:
107- # get the fiscal position
108+ # get the fiscal position
109 fpos = i_line.invoice_id.fiscal_position or False
110 a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
111 diff_res = []
112- # calculate and write down the possible price difference between invoice price and product price
113+ # calculate and write down the possible price difference between invoice price and product price
114 for line in res:
115 if a == line['account_id'] and i_line.product_id.id == line['product_id']:
116 uom = i_line.product_id.uos_id or i_line.product_id.uom_id
117- standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.product_tmpl_id.standard_price, i_line.uos_id.id)
118+ standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uos_id.id)
119 if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc:
120 price_diff = i_line.price_unit - standard_price
121 line.update({'price':standard_price * line['quantity']})
122@@ -134,8 +134,8 @@
123 'taxes':line.get('taxes',[]),
124 })
125 res += diff_res
126- return res
127-
128+ return res
129+
130 def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
131 if not product:
132 return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context)
133@@ -145,19 +145,19 @@
134 if type in ('in_invoice','in_refund'):
135 product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context)
136 if type == 'in_invoice':
137- oa = product_obj.product_tmpl_id.property_stock_account_input and product_obj.product_tmpl_id.property_stock_account_input.id
138+ oa = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id
139 if not oa:
140 oa = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id
141 else:
142- oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id
143+ oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id
144 if not oa:
145 oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
146 if oa:
147 fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False
148 a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
149- res['value'].update({'account_id':a})
150+ res['value'].update({'account_id':a})
151 return res
152-
153+
154 account_invoice_line()
155
156 class account_invoice(osv.osv):
157@@ -170,7 +170,7 @@
158 if inv_obj.type == 'in_invoice':
159 if line.get('product_id',False):
160 product_obj = self.pool.get('product.product').browse(cr, uid, line['product_id'][0])
161- oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id
162+ oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id
163 if not oa:
164 oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
165 if oa:
166@@ -180,6 +180,6 @@
167 line.update({'account_id': (account_data['id'],account_data['name'])})
168 res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines)
169 return res
170-
171+
172 account_invoice()
173 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
174
175=== modified file 'account_anglo_saxon/product_view.xml'
176--- account_anglo_saxon/product_view.xml 2011-01-14 00:11:01 +0000
177+++ account_anglo_saxon/product_view.xml 2011-05-11 05:53:30 +0000
178@@ -8,6 +8,7 @@
179 <field name="inherit_id" ref="account.product_normal_form_view"/>
180 <field name="arch" type="xml">
181 <xpath expr="/form/notebook/page/group/field[@name='property_account_expense']" position="after">
182+ <label string="" colspan="2"/>
183 <field name="property_account_creditor_price_difference" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
184 <newline/>
185 </xpath>
186@@ -36,7 +37,7 @@
187 <form position="inside">
188 <group col="2" colspan="2">
189 <separator string=" Accounting Property" colspan="2"/>
190- <field name="property_account_creditor_price_difference_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
191+ <field name="property_account_creditor_price_difference_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
192 </group>
193 </form>
194 </field>
195
196=== modified file 'account_anglo_saxon/purchase.py'
197--- account_anglo_saxon/purchase.py 2011-01-14 00:11:01 +0000
198+++ account_anglo_saxon/purchase.py 2011-05-11 05:53:30 +0000
199@@ -29,7 +29,7 @@
200 def inv_line_create(self, cr, uid, a, ol):
201 line = super(purchase_order, self).inv_line_create(cr, uid, a, ol)
202 if ol.product_id:
203- oa = ol.product_id.product_tmpl_id.property_stock_account_input and ol.product_id.product_tmpl_id.property_stock_account_input.id
204+ oa = ol.product_id.property_stock_account_input and ol.product_id.property_stock_account_input.id
205 if not oa:
206 oa = ol.product_id.categ_id.property_stock_account_input_categ and ol.product_id.categ_id.property_stock_account_input_categ.id
207 if oa:

Subscribers

People subscribed via source and target branches

to all changes: