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
=== modified file 'account_anglo_saxon/invoice.py'
--- account_anglo_saxon/invoice.py 2011-01-14 00:11:01 +0000
+++ account_anglo_saxon/invoice.py 2011-05-11 05:53:30 +0000
@@ -25,7 +25,7 @@
2525
26class account_invoice_line(osv.osv):26class account_invoice_line(osv.osv):
27 _inherit = "account.invoice.line"27 _inherit = "account.invoice.line"
28 28
29 def move_line_get(self, cr, uid, invoice_id, context=None):29 def move_line_get(self, cr, uid, invoice_id, context=None):
30 res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context=context)30 res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context=context)
31 inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)31 inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
@@ -33,9 +33,9 @@
33 def get_price(cr, uid, inv, company_currency,i_line):33 def get_price(cr, uid, inv, company_currency,i_line):
34 cur_obj = self.pool.get('res.currency')34 cur_obj = self.pool.get('res.currency')
35 if inv.currency_id.id != company_currency:35 if inv.currency_id.id != company_currency:
36 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})36 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})
37 else:37 else:
38 price = i_line.product_id.product_tmpl_id.standard_price * i_line.quantity38 price = i_line.product_id.standard_price * i_line.quantity
39 return price39 return price
4040
41 if inv.type in ('out_invoice','out_refund'):41 if inv.type in ('out_invoice','out_refund'):
@@ -43,27 +43,27 @@
43 if i_line.product_id:43 if i_line.product_id:
44 if inv.type == 'out_invoice':44 if inv.type == 'out_invoice':
45 # debit account dacc will be the output account45 # debit account dacc will be the output account
46 # first check the product, if empty check the category 46 # first check the product, if empty check the category
47 dacc = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id47 dacc = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id
48 if not dacc:48 if not dacc:
49 dacc = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id49 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
50 else:50 else:
51 # = out_refund51 # = out_refund
52 # debit account dacc will be the input account52 # debit account dacc will be the input account
53 # first check the product, if empty check the category 53 # first check the product, if empty check the category
54 dacc = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id54 dacc = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id
55 if not dacc:55 if not dacc:
56 dacc = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id56 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
57 # in both cases the credit account cacc will be the expense account57 # in both cases the credit account cacc will be the expense account
58 # first check the product, if empty check the category 58 # first check the product, if empty check the category
59 cacc = i_line.product_id.product_tmpl_id.property_account_expense and i_line.product_id.product_tmpl_id.property_account_expense.id59 cacc = i_line.product_id.property_account_expense and i_line.product_id.property_account_expense.id
60 if not cacc:60 if not cacc:
61 cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id61 cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id
62 if dacc and cacc:62 if dacc and cacc:
63 res.append({63 res.append({
64 'type':'src',64 'type':'src',
65 'name': i_line.name[:64],65 'name': i_line.name[:64],
66 'price_unit':i_line.product_id.product_tmpl_id.standard_price,66 'price_unit':i_line.product_id.standard_price,
67 'quantity':i_line.quantity,67 'quantity':i_line.quantity,
68 'price':get_price(cr, uid, inv, company_currency, i_line),68 'price':get_price(cr, uid, inv, company_currency, i_line),
69 'account_id':dacc,69 'account_id':dacc,
@@ -72,11 +72,11 @@
72 'account_analytic_id':i_line.account_analytic_id.id,72 'account_analytic_id':i_line.account_analytic_id.id,
73 'taxes':i_line.invoice_line_tax_id,73 'taxes':i_line.invoice_line_tax_id,
74 })74 })
75 75
76 res.append({76 res.append({
77 'type':'src',77 'type':'src',
78 'name': i_line.name[:64],78 'name': i_line.name[:64],
79 'price_unit':i_line.product_id.product_tmpl_id.standard_price,79 'price_unit':i_line.product_id.standard_price,
80 'quantity':i_line.quantity,80 'quantity':i_line.quantity,
81 'price': -1 * get_price(cr, uid, inv, company_currency, i_line),81 'price': -1 * get_price(cr, uid, inv, company_currency, i_line),
82 'account_id':cacc,82 'account_id':cacc,
@@ -88,36 +88,36 @@
88 elif inv.type in ('in_invoice','in_refund'):88 elif inv.type in ('in_invoice','in_refund'):
89 for i_line in inv.invoice_line:89 for i_line in inv.invoice_line:
90 if i_line.product_id:90 if i_line.product_id:
91 if i_line.product_id.product_tmpl_id.type != 'service':91 if i_line.product_id.type != 'service':
92 # get the price difference account at the product 92 # get the price difference account at the product
93 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.id93 acc = i_line.product_id.property_account_creditor_price_difference and i_line.product_id.property_account_creditor_price_difference.id
94 if not acc:94 if not acc:
95 # if not found on the product get the price difference account at the category 95 # if not found on the product get the price difference account at the category
96 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.id96 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
97 a = None97 a = None
98 if inv.type == 'in_invoice':98 if inv.type == 'in_invoice':
99 # oa will be the stock input account99 # oa will be the stock input account
100 # first check the product, if empty check the category 100 # first check the product, if empty check the category
101 oa = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id101 oa = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id
102 if not oa:102 if not oa:
103 oa = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id103 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
104 else:104 else:
105 # = in_refund105 # = in_refund
106 # oa will be the stock output account106 # oa will be the stock output account
107 # first check the product, if empty check the category 107 # first check the product, if empty check the category
108 oa = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id108 oa = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id
109 if not oa:109 if not oa:
110 oa = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id110 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
111 if oa:111 if oa:
112 # get the fiscal position 112 # get the fiscal position
113 fpos = i_line.invoice_id.fiscal_position or False113 fpos = i_line.invoice_id.fiscal_position or False
114 a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)114 a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
115 diff_res = []115 diff_res = []
116 # calculate and write down the possible price difference between invoice price and product price 116 # calculate and write down the possible price difference between invoice price and product price
117 for line in res:117 for line in res:
118 if a == line['account_id'] and i_line.product_id.id == line['product_id']:118 if a == line['account_id'] and i_line.product_id.id == line['product_id']:
119 uom = i_line.product_id.uos_id or i_line.product_id.uom_id119 uom = i_line.product_id.uos_id or i_line.product_id.uom_id
120 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)120 standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uos_id.id)
121 if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc:121 if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc:
122 price_diff = i_line.price_unit - standard_price122 price_diff = i_line.price_unit - standard_price
123 line.update({'price':standard_price * line['quantity']})123 line.update({'price':standard_price * line['quantity']})
@@ -134,8 +134,8 @@
134 'taxes':line.get('taxes',[]),134 'taxes':line.get('taxes',[]),
135 })135 })
136 res += diff_res136 res += diff_res
137 return res 137 return res
138 138
139 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):139 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):
140 if not product:140 if not product:
141 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)141 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)
@@ -145,19 +145,19 @@
145 if type in ('in_invoice','in_refund'):145 if type in ('in_invoice','in_refund'):
146 product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context)146 product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context)
147 if type == 'in_invoice':147 if type == 'in_invoice':
148 oa = product_obj.product_tmpl_id.property_stock_account_input and product_obj.product_tmpl_id.property_stock_account_input.id148 oa = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id
149 if not oa:149 if not oa:
150 oa = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id150 oa = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id
151 else:151 else:
152 oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id152 oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id
153 if not oa:153 if not oa:
154 oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id154 oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
155 if oa:155 if oa:
156 fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False156 fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False
157 a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)157 a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
158 res['value'].update({'account_id':a}) 158 res['value'].update({'account_id':a})
159 return res159 return res
160 160
161account_invoice_line()161account_invoice_line()
162162
163class account_invoice(osv.osv):163class account_invoice(osv.osv):
@@ -170,7 +170,7 @@
170 if inv_obj.type == 'in_invoice':170 if inv_obj.type == 'in_invoice':
171 if line.get('product_id',False):171 if line.get('product_id',False):
172 product_obj = self.pool.get('product.product').browse(cr, uid, line['product_id'][0])172 product_obj = self.pool.get('product.product').browse(cr, uid, line['product_id'][0])
173 oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id173 oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id
174 if not oa:174 if not oa:
175 oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id175 oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
176 if oa:176 if oa:
@@ -180,6 +180,6 @@
180 line.update({'account_id': (account_data['id'],account_data['name'])})180 line.update({'account_id': (account_data['id'],account_data['name'])})
181 res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines)181 res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines)
182 return res182 return res
183 183
184account_invoice()184account_invoice()
185# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:185# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
186186
=== modified file 'account_anglo_saxon/product_view.xml'
--- account_anglo_saxon/product_view.xml 2011-01-14 00:11:01 +0000
+++ account_anglo_saxon/product_view.xml 2011-05-11 05:53:30 +0000
@@ -8,6 +8,7 @@
8 <field name="inherit_id" ref="account.product_normal_form_view"/>8 <field name="inherit_id" ref="account.product_normal_form_view"/>
9 <field name="arch" type="xml">9 <field name="arch" type="xml">
10 <xpath expr="/form/notebook/page/group/field[@name='property_account_expense']" position="after">10 <xpath expr="/form/notebook/page/group/field[@name='property_account_expense']" position="after">
11 <label string="" colspan="2"/>
11 <field name="property_account_creditor_price_difference" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />12 <field name="property_account_creditor_price_difference" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
12 <newline/>13 <newline/>
13 </xpath>14 </xpath>
@@ -36,7 +37,7 @@
36 <form position="inside">37 <form position="inside">
37 <group col="2" colspan="2">38 <group col="2" colspan="2">
38 <separator string=" Accounting Property" colspan="2"/>39 <separator string=" Accounting Property" colspan="2"/>
39 <field name="property_account_creditor_price_difference_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" /> 40 <field name="property_account_creditor_price_difference_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" />
40 </group>41 </group>
41 </form>42 </form>
42 </field>43 </field>
4344
=== modified file 'account_anglo_saxon/purchase.py'
--- account_anglo_saxon/purchase.py 2011-01-14 00:11:01 +0000
+++ account_anglo_saxon/purchase.py 2011-05-11 05:53:30 +0000
@@ -29,7 +29,7 @@
29 def inv_line_create(self, cr, uid, a, ol):29 def inv_line_create(self, cr, uid, a, ol):
30 line = super(purchase_order, self).inv_line_create(cr, uid, a, ol)30 line = super(purchase_order, self).inv_line_create(cr, uid, a, ol)
31 if ol.product_id:31 if ol.product_id:
32 oa = ol.product_id.product_tmpl_id.property_stock_account_input and ol.product_id.product_tmpl_id.property_stock_account_input.id32 oa = ol.product_id.property_stock_account_input and ol.product_id.property_stock_account_input.id
33 if not oa:33 if not oa:
34 oa = ol.product_id.categ_id.property_stock_account_input_categ and ol.product_id.categ_id.property_stock_account_input_categ.id34 oa = ol.product_id.categ_id.property_stock_account_input_categ and ol.product_id.categ_id.property_stock_account_input_categ.id
35 if oa:35 if oa:

Subscribers

People subscribed via source and target branches

to all changes: