Merge lp:~openerp-dev/openobject-addons/trunk-bug-778487-ara into lp:openobject-addons
- trunk-bug-778487-ara
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mustufa Rangwala (Open ERP) (community) | Approve | ||
qdp (OpenERP) | Pending | ||
Review via email: mp+60580@code.launchpad.net |
Commit message
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 | 25 | 25 | ||
6 | 26 | class account_invoice_line(osv.osv): | 26 | class account_invoice_line(osv.osv): |
7 | 27 | _inherit = "account.invoice.line" | 27 | _inherit = "account.invoice.line" |
9 | 28 | 28 | ||
10 | 29 | def move_line_get(self, cr, uid, invoice_id, context=None): | 29 | def move_line_get(self, cr, uid, invoice_id, context=None): |
11 | 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) |
12 | 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) |
13 | @@ -33,9 +33,9 @@ | |||
14 | 33 | def get_price(cr, uid, inv, company_currency,i_line): | 33 | def get_price(cr, uid, inv, company_currency,i_line): |
15 | 34 | cur_obj = self.pool.get('res.currency') | 34 | cur_obj = self.pool.get('res.currency') |
16 | 35 | if inv.currency_id.id != company_currency: | 35 | if inv.currency_id.id != company_currency: |
18 | 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}) |
19 | 37 | else: | 37 | else: |
21 | 38 | price = i_line.product_id.product_tmpl_id.standard_price * i_line.quantity | 38 | price = i_line.product_id.standard_price * i_line.quantity |
22 | 39 | return price | 39 | return price |
23 | 40 | 40 | ||
24 | 41 | if inv.type in ('out_invoice','out_refund'): | 41 | if inv.type in ('out_invoice','out_refund'): |
25 | @@ -43,27 +43,27 @@ | |||
26 | 43 | if i_line.product_id: | 43 | if i_line.product_id: |
27 | 44 | if inv.type == 'out_invoice': | 44 | if inv.type == 'out_invoice': |
28 | 45 | # debit account dacc will be the output account | 45 | # debit account dacc will be the output account |
31 | 46 | # first check the product, if empty check the category | 46 | # first check the product, if empty check the category |
32 | 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.id | 47 | dacc = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id |
33 | 48 | if not dacc: | 48 | if not dacc: |
34 | 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.id | 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.id |
35 | 50 | else: | 50 | else: |
36 | 51 | # = out_refund | 51 | # = out_refund |
37 | 52 | # debit account dacc will be the input account | 52 | # debit account dacc will be the input account |
40 | 53 | # first check the product, if empty check the category | 53 | # first check the product, if empty check the category |
41 | 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.id | 54 | dacc = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id |
42 | 55 | if not dacc: | 55 | if not dacc: |
43 | 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.id | 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.id |
44 | 57 | # in both cases the credit account cacc will be the expense account | 57 | # in both cases the credit account cacc will be the expense account |
47 | 58 | # first check the product, if empty check the category | 58 | # first check the product, if empty check the category |
48 | 59 | cacc = i_line.product_id.product_tmpl_id.property_account_expense and i_line.product_id.product_tmpl_id.property_account_expense.id | 59 | cacc = i_line.product_id.property_account_expense and i_line.product_id.property_account_expense.id |
49 | 60 | if not cacc: | 60 | if not cacc: |
50 | 61 | cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id | 61 | cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id |
51 | 62 | if dacc and cacc: | 62 | if dacc and cacc: |
52 | 63 | res.append({ | 63 | res.append({ |
53 | 64 | 'type':'src', | 64 | 'type':'src', |
54 | 65 | 'name': i_line.name[:64], | 65 | 'name': i_line.name[:64], |
56 | 66 | 'price_unit':i_line.product_id.product_tmpl_id.standard_price, | 66 | 'price_unit':i_line.product_id.standard_price, |
57 | 67 | 'quantity':i_line.quantity, | 67 | 'quantity':i_line.quantity, |
58 | 68 | 'price':get_price(cr, uid, inv, company_currency, i_line), | 68 | 'price':get_price(cr, uid, inv, company_currency, i_line), |
59 | 69 | 'account_id':dacc, | 69 | 'account_id':dacc, |
60 | @@ -72,11 +72,11 @@ | |||
61 | 72 | 'account_analytic_id':i_line.account_analytic_id.id, | 72 | 'account_analytic_id':i_line.account_analytic_id.id, |
62 | 73 | 'taxes':i_line.invoice_line_tax_id, | 73 | 'taxes':i_line.invoice_line_tax_id, |
63 | 74 | }) | 74 | }) |
65 | 75 | 75 | ||
66 | 76 | res.append({ | 76 | res.append({ |
67 | 77 | 'type':'src', | 77 | 'type':'src', |
68 | 78 | 'name': i_line.name[:64], | 78 | 'name': i_line.name[:64], |
70 | 79 | 'price_unit':i_line.product_id.product_tmpl_id.standard_price, | 79 | 'price_unit':i_line.product_id.standard_price, |
71 | 80 | 'quantity':i_line.quantity, | 80 | 'quantity':i_line.quantity, |
72 | 81 | 'price': -1 * get_price(cr, uid, inv, company_currency, i_line), | 81 | 'price': -1 * get_price(cr, uid, inv, company_currency, i_line), |
73 | 82 | 'account_id':cacc, | 82 | 'account_id':cacc, |
74 | @@ -88,36 +88,36 @@ | |||
75 | 88 | elif inv.type in ('in_invoice','in_refund'): | 88 | elif inv.type in ('in_invoice','in_refund'): |
76 | 89 | for i_line in inv.invoice_line: | 89 | for i_line in inv.invoice_line: |
77 | 90 | if i_line.product_id: | 90 | if i_line.product_id: |
81 | 91 | if i_line.product_id.product_tmpl_id.type != 'service': | 91 | if i_line.product_id.type != 'service': |
82 | 92 | # get the price difference account at the product | 92 | # get the price difference account at the product |
83 | 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.id | 93 | acc = i_line.product_id.property_account_creditor_price_difference and i_line.product_id.property_account_creditor_price_difference.id |
84 | 94 | if not acc: | 94 | if not acc: |
86 | 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 |
87 | 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.id | 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.id |
88 | 97 | a = None | 97 | a = None |
89 | 98 | if inv.type == 'in_invoice': | 98 | if inv.type == 'in_invoice': |
90 | 99 | # oa will be the stock input account | 99 | # oa will be the stock input account |
93 | 100 | # first check the product, if empty check the category | 100 | # first check the product, if empty check the category |
94 | 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.id | 101 | oa = i_line.product_id.property_stock_account_input and i_line.product_id.property_stock_account_input.id |
95 | 102 | if not oa: | 102 | if not oa: |
96 | 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.id | 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.id |
97 | 104 | else: | 104 | else: |
98 | 105 | # = in_refund | 105 | # = in_refund |
99 | 106 | # oa will be the stock output account | 106 | # oa will be the stock output account |
102 | 107 | # first check the product, if empty check the category | 107 | # first check the product, if empty check the category |
103 | 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.id | 108 | oa = i_line.product_id.property_stock_account_output and i_line.product_id.property_stock_account_output.id |
104 | 109 | if not oa: | 109 | if not oa: |
105 | 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.id | 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.id |
106 | 111 | if oa: | 111 | if oa: |
108 | 112 | # get the fiscal position | 112 | # get the fiscal position |
109 | 113 | fpos = i_line.invoice_id.fiscal_position or False | 113 | fpos = i_line.invoice_id.fiscal_position or False |
110 | 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) |
111 | 115 | diff_res = [] | 115 | diff_res = [] |
113 | 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 |
114 | 117 | for line in res: | 117 | for line in res: |
115 | 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']: |
116 | 119 | uom = i_line.product_id.uos_id or i_line.product_id.uom_id | 119 | uom = i_line.product_id.uos_id or i_line.product_id.uom_id |
118 | 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) |
119 | 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: |
120 | 122 | price_diff = i_line.price_unit - standard_price | 122 | price_diff = i_line.price_unit - standard_price |
121 | 123 | line.update({'price':standard_price * line['quantity']}) | 123 | line.update({'price':standard_price * line['quantity']}) |
122 | @@ -134,8 +134,8 @@ | |||
123 | 134 | 'taxes':line.get('taxes',[]), | 134 | 'taxes':line.get('taxes',[]), |
124 | 135 | }) | 135 | }) |
125 | 136 | res += diff_res | 136 | res += diff_res |
128 | 137 | return res | 137 | return res |
129 | 138 | 138 | ||
130 | 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): |
131 | 140 | if not product: | 140 | if not product: |
132 | 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) |
133 | @@ -145,19 +145,19 @@ | |||
134 | 145 | if type in ('in_invoice','in_refund'): | 145 | if type in ('in_invoice','in_refund'): |
135 | 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) |
136 | 147 | if type == 'in_invoice': | 147 | if type == 'in_invoice': |
138 | 148 | oa = product_obj.product_tmpl_id.property_stock_account_input and product_obj.product_tmpl_id.property_stock_account_input.id | 148 | oa = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id |
139 | 149 | if not oa: | 149 | if not oa: |
140 | 150 | oa = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id | 150 | oa = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id |
141 | 151 | else: | 151 | else: |
143 | 152 | oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id | 152 | oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id |
144 | 153 | if not oa: | 153 | if not oa: |
145 | 154 | oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id | 154 | oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id |
146 | 155 | if oa: | 155 | if oa: |
147 | 156 | fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False | 156 | fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False |
148 | 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) |
150 | 158 | res['value'].update({'account_id':a}) | 158 | res['value'].update({'account_id':a}) |
151 | 159 | return res | 159 | return res |
153 | 160 | 160 | ||
154 | 161 | account_invoice_line() | 161 | account_invoice_line() |
155 | 162 | 162 | ||
156 | 163 | class account_invoice(osv.osv): | 163 | class account_invoice(osv.osv): |
157 | @@ -170,7 +170,7 @@ | |||
158 | 170 | if inv_obj.type == 'in_invoice': | 170 | if inv_obj.type == 'in_invoice': |
159 | 171 | if line.get('product_id',False): | 171 | if line.get('product_id',False): |
160 | 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]) |
162 | 173 | oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id | 173 | oa = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id |
163 | 174 | if not oa: | 174 | if not oa: |
164 | 175 | oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id | 175 | oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id |
165 | 176 | if oa: | 176 | if oa: |
166 | @@ -180,6 +180,6 @@ | |||
167 | 180 | line.update({'account_id': (account_data['id'],account_data['name'])}) | 180 | line.update({'account_id': (account_data['id'],account_data['name'])}) |
168 | 181 | res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines) | 181 | res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines) |
169 | 182 | return res | 182 | return res |
171 | 183 | 183 | ||
172 | 184 | account_invoice() | 184 | account_invoice() |
173 | 185 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 185 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
174 | 186 | 186 | ||
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 | 8 | <field name="inherit_id" ref="account.product_normal_form_view"/> | 8 | <field name="inherit_id" ref="account.product_normal_form_view"/> |
180 | 9 | <field name="arch" type="xml"> | 9 | <field name="arch" type="xml"> |
181 | 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"> |
182 | 11 | <label string="" colspan="2"/> | ||
183 | 11 | <field name="property_account_creditor_price_difference" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" /> | 12 | <field name="property_account_creditor_price_difference" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" /> |
184 | 12 | <newline/> | 13 | <newline/> |
185 | 13 | </xpath> | 14 | </xpath> |
186 | @@ -36,7 +37,7 @@ | |||
187 | 36 | <form position="inside"> | 37 | <form position="inside"> |
188 | 37 | <group col="2" colspan="2"> | 38 | <group col="2" colspan="2"> |
189 | 38 | <separator string=" Accounting Property" colspan="2"/> | 39 | <separator string=" Accounting Property" colspan="2"/> |
191 | 39 | <field name="property_account_creditor_price_difference_categ" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" /> | 40 | <field name="property_account_creditor_price_difference_categ" domain="[('type','<>','view'),('type','<>','consolidation')]" attrs="{'readonly':[('purchase_ok','=',0)]}" /> |
192 | 40 | </group> | 41 | </group> |
193 | 41 | </form> | 42 | </form> |
194 | 42 | </field> | 43 | </field> |
195 | 43 | 44 | ||
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 | 29 | def inv_line_create(self, cr, uid, a, ol): | 29 | def inv_line_create(self, cr, uid, a, ol): |
201 | 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) |
202 | 31 | if ol.product_id: | 31 | if ol.product_id: |
204 | 32 | oa = ol.product_id.product_tmpl_id.property_stock_account_input and ol.product_id.product_tmpl_id.property_stock_account_input.id | 32 | oa = ol.product_id.property_stock_account_input and ol.product_id.property_stock_account_input.id |
205 | 33 | if not oa: | 33 | if not oa: |
206 | 34 | oa = ol.product_id.categ_id.property_stock_account_input_categ and ol.product_id.categ_id.property_stock_account_input_categ.id | 34 | oa = ol.product_id.categ_id.property_stock_account_input_categ and ol.product_id.categ_id.property_stock_account_input_categ.id |
207 | 35 | if oa: | 35 | if oa: |