Merge lp:~unifield-team/unifield-wm/utp-674 into lp:unifield-wm
- utp-674
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 1819 |
Proposed branch: | lp:~unifield-team/unifield-wm/utp-674 |
Merge into: | lp:unifield-wm |
Diff against target: |
385 lines (+164/-19) (has conflicts) 5 files modified
purchase_override/purchase.py (+92/-7) purchase_override/purchase_view.xml (+14/-2) purchase_override/report/rfq.rml (+7/-7) tender_flow/tender_flow.py (+43/-2) tender_flow/tender_flow_view.xml (+8/-1) Text conflict in tender_flow/tender_flow.py |
To merge this branch: | bzr merge lp:~unifield-team/unifield-wm/utp-674 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+191996@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'purchase_override/purchase.py' |
2 | --- purchase_override/purchase.py 2013-10-14 09:04:37 +0000 |
3 | +++ purchase_override/purchase.py 2013-10-21 14:37:05 +0000 |
4 | @@ -440,17 +440,19 @@ |
5 | # d['partner_id'] = [('partner_type', 'in', ['esc', 'external'])] |
6 | else: |
7 | v['invoice_method'] = 'picking' |
8 | + |
9 | + company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.partner_id.id |
10 | |
11 | - if order_type == 'direct' and dest_partner_id: |
12 | + if order_type == 'direct' and dest_partner_id and dest_partner_id != company_id: |
13 | cp_address_id = self.pool.get('res.partner').address_get(cr, uid, dest_partner_id, ['delivery'])['delivery'] |
14 | v.update({'dest_address_id': cp_address_id}) |
15 | # d.update({'dest_address_id': [('partner_id', '=', dest_partner_id)]}) |
16 | elif order_type == 'direct': |
17 | - v.update({'dest_address_id': False}) |
18 | + v.update({'dest_address_id': False, 'dest_partner_id': False}) |
19 | # d.update({'dest_address_id': [('partner_id', '=', self.pool.get('res.users').browse(cr, uid, uid).company_id.id)]}) |
20 | else: |
21 | - cp_address_id = self.pool.get('res.partner').address_get(cr, uid, self.pool.get('res.users').browse(cr, uid, uid).company_id.partner_id.id, ['delivery'])['delivery'] |
22 | - v.update({'dest_address_id': cp_address_id}) |
23 | + cp_address_id = self.pool.get('res.partner').address_get(cr, uid, company_id, ['delivery'])['delivery'] |
24 | + v.update({'dest_address_id': cp_address_id, 'dest_partner_id': company_id}) |
25 | # d.update({'dest_address_id': [('partner_id', '=', self.pool.get('res.users').browse(cr, uid, uid).company_id.id)]}) |
26 | |
27 | if partner_id and partner_id != local_market: |
28 | @@ -560,14 +562,15 @@ |
29 | |
30 | if not dest_partner_id: |
31 | v.update({'dest_address_id': False}) |
32 | - d.update({'dest_address_id': [('partner_id', '=', company_id)]}) |
33 | +# d.update({'dest_address_id': [('partner_id', '=', company_id)]}) |
34 | else: |
35 | - d.update({'dest_address_id': [('partner_id', '=', dest_partner_id)]}) |
36 | +# d.update({'dest_address_id': [('partner_id', '=', dest_partner_id)]}) |
37 | |
38 | delivery_addr = self.pool.get('res.partner').address_get(cr, uid, dest_partner_id, ['delivery']) |
39 | v.update({'dest_address_id': delivery_addr['delivery']}) |
40 | |
41 | - return {'value': v, 'domain': d} |
42 | +# return {'value': v, 'domain': d} |
43 | + return {'value': v} |
44 | |
45 | def change_currency(self, cr, uid, ids, context=None): |
46 | ''' |
47 | @@ -2596,4 +2599,86 @@ |
48 | |
49 | account_invoice() |
50 | |
51 | + |
52 | +class res_partner(osv.osv): |
53 | + _inherit = 'res.partner' |
54 | + |
55 | + def address_multiple_get(self, cr, uid, ids, adr_pref=['default']): |
56 | + address_obj = self.pool.get('res.partner.address') |
57 | + address_ids = address_obj.search(cr, uid, [('partner_id', '=', ids)]) |
58 | + address_rec = address_obj.read(cr, uid, address_ids, ['type']) |
59 | + res= {} |
60 | + for addr in address_rec: |
61 | + res.setdefault(addr['type'], []) |
62 | + res[addr['type']].append(addr['id']) |
63 | + if res: |
64 | + default_address = res.get('default', False) |
65 | + else: |
66 | + default_address = False |
67 | + result = {} |
68 | + for a in adr_pref: |
69 | + result[a] = res.get(a, default_address) |
70 | + |
71 | + return result |
72 | + |
73 | +res_partner() |
74 | + |
75 | + |
76 | +class res_partner_address(osv.osv): |
77 | + _inherit = 'res.partner.address' |
78 | + |
79 | + def _get_dummy(self, cr, uid, ids, field_name, args, context=None): |
80 | + res = {} |
81 | + for id in ids: |
82 | + res[id] = True |
83 | + |
84 | + return res |
85 | + |
86 | + def _src_address(self, cr, uid, obj, name, args, context=None): |
87 | + ''' |
88 | + Returns all the destination addresses of a partner or all default |
89 | + addresses if he hasn't destination addresses |
90 | + ''' |
91 | + addr_obj = self.pool.get('res.partner.address') |
92 | + partner_obj = self.pool.get('res.partner') |
93 | + user_obj = self.pool.get('res.users') |
94 | + res = [] |
95 | + |
96 | + for arg in args: |
97 | + if arg[0] == 'dest_address': |
98 | + addr_type = 'delivery' |
99 | + elif arg[0] == 'inv_address': |
100 | + addr_type = 'invoice' |
101 | + |
102 | + if arg[2]: |
103 | + partner_id = arg[2] |
104 | + else: |
105 | + partner_id = user_obj.browse(cr, uid, uid, context=context).company_id.partner_id.id |
106 | + if arg[1] == 'in': |
107 | + partner_id = [partner_id] |
108 | + |
109 | + addr_ids = [] |
110 | + if isinstance(partner_id, list): |
111 | + for partner in partner_id: |
112 | + if not partner: |
113 | + continue |
114 | + addr_ids.extend(partner_obj.address_multiple_get(cr, uid, partner, [addr_type])[addr_type]) |
115 | + |
116 | + else: |
117 | + addr_ids = partner_obj.address_multiple_get(cr, uid, partner_id, [addr_type])[addr_type] |
118 | + |
119 | + res.append(('id', 'in', list(id for id in addr_ids if id))) |
120 | + |
121 | + return res |
122 | + |
123 | + _columns = { |
124 | + 'dest_address': fields.function(_get_dummy, fnct_search=_src_address, method=True, |
125 | + type='boolean', string='Dest. Address', store=False), |
126 | + 'inv_address': fields.function(_get_dummy, fnct_search=_src_address, method=True, |
127 | + type='boolean', string='Invoice Address', store=False), |
128 | + } |
129 | + |
130 | + |
131 | +res_partner_address() |
132 | + |
133 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
134 | |
135 | === modified file 'purchase_override/purchase_view.xml' |
136 | --- purchase_override/purchase_view.xml 2013-10-08 08:56:01 +0000 |
137 | +++ purchase_override/purchase_view.xml 2013-10-21 14:37:05 +0000 |
138 | @@ -87,11 +87,11 @@ |
139 | <xpath expr="/form/notebook//field[@name='dest_address_id']" position="replace"> |
140 | <field name="dest_partner_id" attrs="{'invisible': [('order_type', '!=', 'direct')], 'required': [('order_type', '=', 'direct')], 'readonly': [('state', 'not in', ['draft', 'confirmed'])]}" |
141 | on_change="on_change_dest_partner_id(dest_partner_id)" /> |
142 | - <field name="dest_address_id" domain="[('partner_id', '=', dest_partner_id)]" attrs="{'required': [('order_type', '=', 'direct')], 'readonly': [('state', 'not in', ['draft', 'confirmed'])]}" /> |
143 | + <field name="dest_address_id" domain="[('dest_address', '=', dest_partner_id)]" attrs="{'required': [('order_type', '=', 'direct')], 'readonly': [('state', 'not in', ['draft', 'confirmed'])]}" /> |
144 | </xpath> |
145 | <xpath expr="/form/notebook//field[@name='fiscal_position']" position="after"> |
146 | <field name="invoice_address_id" |
147 | - domain="[('partner_id', 'in', [dest_partner_id, company_id])]" |
148 | + domain="[('inv_address', 'in', [company_id])]" |
149 | context="contact_display='partner_address'" |
150 | attrs="{'required': [('order_type', '=', 'direct')], 'readonly': [('state', 'not in', ['draft', 'confirmed'])]}" |
151 | /> |
152 | @@ -251,6 +251,18 @@ |
153 | name="Address Book" |
154 | parent="purchase.menu_purchase_config_purchase" /> |
155 | |
156 | + <record id="res_partner_address_list_view" model="ir.ui.view"> |
157 | + <field name="name">res.partner.address.list.view</field> |
158 | + <field name="model">res.partner.address</field> |
159 | + <field name="type">tree</field> |
160 | + <field name="inherit_id" ref="base.view_partner_address_tree" /> |
161 | + <field name="arch" type="xml"> |
162 | + <xpath expr="/tree//field[@name='name']" position="after"> |
163 | + <field name="street" /> |
164 | + </xpath> |
165 | + </field> |
166 | + </record> |
167 | + |
168 | <record id="action_supplier_address_form" model="ir.actions.act_window"> |
169 | <field name="name">Addresses</field> |
170 | <field name="type">ir.actions.act_window</field> |
171 | |
172 | === modified file 'purchase_override/report/rfq.rml' |
173 | --- purchase_override/report/rfq.rml 2013-08-20 09:01:06 +0000 |
174 | +++ purchase_override/report/rfq.rml 2013-10-21 14:37:05 +0000 |
175 | @@ -170,7 +170,7 @@ |
176 | <para style="TextInformation"> </para> |
177 | </td> |
178 | <td> |
179 | - <para style="TextInformation">[[ objects[0].dest_address_id.name or objects[0].partner_id.name ]]</para> |
180 | + <para style="TextInformation">[[ objects[0].rfq_delivery_address and objects[0].rfq_delivery_address.partner_id and objects[0].rfq_delivery_address.partner_id.name or '' ]]</para> |
181 | </td> |
182 | <td> |
183 | <para style="TextInformation"> </para> |
184 | @@ -199,7 +199,7 @@ |
185 | <para style="TextInformation"> </para> |
186 | </td> |
187 | <td> |
188 | - <para style="TextInformation">[[ objects[0].dest_address_id.street ]]</para> |
189 | + <para style="TextInformation">[[ objects[0].rfq_delivery_address and objects[0].rfq_delivery_address.street ]]</para> |
190 | </td> |
191 | <td> |
192 | <para style="TextInformation"> </para> |
193 | @@ -228,7 +228,7 @@ |
194 | <para style="TextInformation"> </para> |
195 | </td> |
196 | <td> |
197 | - <para style="TextInformation">[[ objects[0].dest_address_id.street2 ]]</para> |
198 | + <para style="TextInformation">[[ objects[0].rfq_delivery_address and objects[0].rfq_delivery_address.street2 ]]</para> |
199 | </td> |
200 | <td> |
201 | <para style="TextInformation"> </para> |
202 | @@ -257,7 +257,7 @@ |
203 | <para style="TextInformation"> </para> |
204 | </td> |
205 | <td> |
206 | - <para style="TextInformation">[[ objects[0].dest_address_id.zip ]] [[ objects[0].dest_address_id.city ]]</para> |
207 | + <para style="TextInformation">[[ objects[0].rfq_delivery_address and '%s %s' % (objects[0].rfq_delivery_address.zip objects[0].rfq_delivery_address.city) or '' ]]</para> |
208 | </td> |
209 | <td> |
210 | <para style="TextInformation"> </para> |
211 | @@ -286,7 +286,7 @@ |
212 | <para style="TextInformation"> </para> |
213 | </td> |
214 | <td> |
215 | - <para style="TextInformation">[[ objects[0].dest_address_id.country_id and objects[0].dest_address_id.country_id.name or '' ]]</para> |
216 | + <para style="TextInformation">[[ objects[0].rfq_delivery_address and objects[0].rfq_delivery_address.country_id and objects[0].rfq_delivery_address.country_id.name or '' ]]</para> |
217 | </td> |
218 | <td> |
219 | <para style="TextInformation"> </para> |
220 | @@ -315,7 +315,7 @@ |
221 | <para style="TextInformation"> </para> |
222 | </td> |
223 | <td> |
224 | - <para style="TextInformation">[[ objects[0].dest_address_id.phone ]]</para> |
225 | + <para style="TextInformation">[[ objects[0].rfq_delivery_address and objects[0].rfq_delivery_address.phone ]]</para> |
226 | </td> |
227 | <td> |
228 | <para style="TextInformation"> </para> |
229 | @@ -344,7 +344,7 @@ |
230 | <para style="TextInformation"> </para> |
231 | </td> |
232 | <td> |
233 | - <para style="TextInformation">[[ objects[0].dest_address_id.email ]]</para> |
234 | + <para style="TextInformation">[[ objects[0].rfq_delivery_address and objects[0].rfq_delivery_address.email ]]</para> |
235 | </td> |
236 | <td> |
237 | <para style="TextInformation"> </para> |
238 | |
239 | === modified file 'tender_flow/tender_flow.py' |
240 | --- tender_flow/tender_flow.py 2013-10-14 12:58:21 +0000 |
241 | +++ tender_flow/tender_flow.py 2013-10-21 14:37:05 +0000 |
242 | @@ -111,6 +111,7 @@ |
243 | 'internal_state': fields.selection([('draft', 'Draft'),('updated', 'Rfq Updated'), ], string="Internal State", readonly=True), |
244 | 'rfq_name_list': fields.function(_vals_get, method=True, string='RfQs Ref', type='char', readonly=True, store=False, multi='get_vals',), |
245 | 'product_id': fields.related('tender_line_ids', 'product_id', type='many2one', relation='product.product', string='Product'), |
246 | + 'delivery_address': fields.many2one('res.partner.address', string='Delivery address', required=True), |
247 | 'tender_from_fo': fields.function(_is_tender_from_fo, method=True, type='boolean', string='Is tender from FO ?',), |
248 | } |
249 | |
250 | @@ -127,6 +128,7 @@ |
251 | |
252 | _order = 'name desc' |
253 | |
254 | +<<<<<<< TREE |
255 | def _check_restriction_line(self, cr, uid, ids, context=None): |
256 | ''' |
257 | Check if there is no restrictive products in lines |
258 | @@ -142,6 +144,24 @@ |
259 | |
260 | return res |
261 | |
262 | +======= |
263 | + def default_get(self, cr, uid, fields, context=None): |
264 | + ''' |
265 | + Set default data |
266 | + ''' |
267 | + # Object declaration |
268 | + partner_obj = self.pool.get('res.partner') |
269 | + user_obj = self.pool.get('res.users') |
270 | + |
271 | + res = super(tender, self).default_get(cr, uid, fields, context=context) |
272 | + |
273 | + # Get the delivery address |
274 | + company = user_obj.browse(cr, uid, uid, context=context).company_id |
275 | + res['delivery_address'] = partner_obj.address_get(cr, uid, company.partner_id.id, ['delivery'])['delivery'] |
276 | + |
277 | + return res |
278 | + |
279 | +>>>>>>> MERGE-SOURCE |
280 | def _check_tender_from_fo(self, cr, uid, ids, context=None): |
281 | if not context: |
282 | context = {} |
283 | @@ -273,7 +293,7 @@ |
284 | raise osv.except_osv(_('Warning !'), _('You must select at least one product!')) |
285 | for supplier in tender.supplier_ids: |
286 | # create a purchase order for each supplier |
287 | - address_id = partner_obj.address_get(cr, uid, [supplier.id], ['delivery'])['delivery'] |
288 | + address_id = partner_obj.address_get(cr, uid, [supplier.id], ['default'])['default'] |
289 | if not address_id: |
290 | raise osv.except_osv(_('Warning !'), _('The supplier "%s" has no address defined!')%(supplier.name,)) |
291 | pricelist_id = supplier.property_product_pricelist_purchase.id |
292 | @@ -291,6 +311,7 @@ |
293 | 'priority': tender.priority, |
294 | 'details': tender.details, |
295 | 'delivery_requested_date': tender.requested_date, |
296 | + 'rfq_delivery_address': tender.delivery_address and tender.delivery_address.id or False, |
297 | } |
298 | # create the rfq - dic is udpated for default partner_address_id at purchase.order level |
299 | po_id = po_obj.create(cr, uid, values, context=dict(context, partner_id=supplier.id, rfq_ok=True)) |
300 | @@ -511,7 +532,7 @@ |
301 | })) |
302 | |
303 | # fill data corresponding to po creation |
304 | - address_id = partner_obj.address_get(cr, uid, [line.supplier_id.id], ['delivery'])['delivery'] |
305 | + address_id = partner_obj.address_get(cr, uid, [line.supplier_id.id], ['default'])['default'] |
306 | pricelist = line.supplier_id.property_product_pricelist_purchase.id, |
307 | if line.currency_id: |
308 | price_ids = self.pool.get('product.pricelist').search(cr, uid, [('type', '=', 'purchase'), ('currency_id', '=', line.currency_id.id)], context=context) |
309 | @@ -531,6 +552,7 @@ |
310 | 'warehouse_id': tender.warehouse_id.id, |
311 | 'details': tender.details, |
312 | 'delivery_requested_date': tender.requested_date, |
313 | + 'dest_address_id': tender.delivery_address.id, |
314 | } |
315 | data[line.supplier_id.id].update(po_values) |
316 | |
317 | @@ -881,6 +903,8 @@ |
318 | values = super(procurement_order, self).po_values_hook(cr, uid, ids, context=context, *args, **kwargs) |
319 | procurement = kwargs['procurement'] |
320 | |
321 | + values['partner_address_id'] = self.pool.get('res.partner').address_get(cr, uid, [values['partner_id']], ['default'])['default'] |
322 | + |
323 | # set tender link in purchase order |
324 | if procurement.tender_id: |
325 | values['origin_tender_id'] = procurement.tender_id.id |
326 | @@ -918,6 +942,7 @@ |
327 | return False |
328 | return True |
329 | _columns = {'tender_id': fields.many2one('tender', string="Tender", readonly=True), |
330 | + 'rfq_delivery_address': fields.many2one('res.partner.address', string='Delivery address'), |
331 | 'origin_tender_id': fields.many2one('tender', string='Tender', readonly=True), |
332 | 'rfq_ok': fields.boolean(string='Is RfQ ?'), |
333 | 'state': fields.selection(PURCHASE_ORDER_STATE_SELECTION, 'State', readonly=True, help="The state of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' state. Then the order has to be confirmed by the user, the state switch to 'Confirmed'. Then the supplier must confirm the order to change the state to 'Approved'. When the purchase order is paid and received, the state becomes 'Closed'. If a cancel action occurs in the invoice or in the reception of goods, the state becomes in exception.", select=True), |
334 | @@ -934,6 +959,22 @@ |
335 | 'You must specify a Valid Till date.', |
336 | ['valid_till']),] |
337 | |
338 | + def default_get(self, cr, uid, fields, context=None): |
339 | + ''' |
340 | + Set default data |
341 | + ''' |
342 | + # Object declaration |
343 | + partner_obj = self.pool.get('res.partner') |
344 | + user_obj = self.pool.get('res.users') |
345 | + |
346 | + res = super(purchase_order, self).default_get(cr, uid, fields, context=context) |
347 | + |
348 | + # Get the delivery address |
349 | + company = user_obj.browse(cr, uid, uid, context=context).company_id |
350 | + res['rfq_delivery_address'] = partner_obj.address_get(cr, uid, company.partner_id.id, ['delivery'])['delivery'] |
351 | + |
352 | + return res |
353 | + |
354 | def create(self, cr, uid, vals, context=None): |
355 | ''' |
356 | Set the reference at this step |
357 | |
358 | === modified file 'tender_flow/tender_flow_view.xml' |
359 | --- tender_flow/tender_flow_view.xml 2013-08-30 14:16:23 +0000 |
360 | +++ tender_flow/tender_flow_view.xml 2013-10-21 14:37:05 +0000 |
361 | @@ -20,6 +20,7 @@ |
362 | <field name="categ" attrs="{'readonly': [('state', '!=', 'draft')]}" |
363 | on_change="onchange_categ(categ)"/> |
364 | <field name="priority" attrs="{'readonly': [('state', '!=', 'draft')]}" /> |
365 | + <field name="delivery_address" colspan="4" attrs="{'readonly': [('state', '!=', 'draft')]}" domain="[('dest_address', '=', company_id)]"/> |
366 | <field name="details" /> |
367 | </group> |
368 | <notebook colspan="5"> |
369 | @@ -184,9 +185,15 @@ |
370 | <field name="arch" type="xml"> |
371 | <data> |
372 | <field name="details" position="after"> |
373 | + <newline /> |
374 | + <field name="valid_till" attrs="{'invisible': [('rfq_ok', '=', False)],'readonly': [('state', 'in', ['sourced', 'split', 'rfq_updated', 'draft', 'done', 'cancel', 'confirmed', 'approved', 'except_picking', 'except_invoice'])]}" /> |
375 | <field name="tender_id" attrs="{'invisible': [('rfq_ok', '=', False)],'readonly': [('state', 'in', ['sourced', 'split', 'rfq_updated', 'done', 'cancel', 'confirmed', 'approved', 'except_picking', 'except_invoice'])]}" /> |
376 | - <field name="valid_till" attrs="{'invisible': [('rfq_ok', '=', False)],'readonly': [('state', 'in', ['sourced', 'split', 'rfq_updated', 'draft', 'done', 'cancel', 'confirmed', 'approved', 'except_picking', 'except_invoice'])]}" /> |
377 | <field name="rfq_ok" invisible="1" /> |
378 | + <field |
379 | + name="rfq_delivery_address" |
380 | + colspan="4" |
381 | + domain="[('dest_address', '=', company_id)]" |
382 | + attrs="{'invisible': [('rfq_ok', '=', False)], 'readonly': ['|', ('tender_id', '!=', False), ('state', 'in', ['sourced', 'split', 'rfq_updated', 'done', 'cancel', 'confirmed', 'approved', 'except_picking', 'except_invoice'])]}" /> |
383 | </field> |
384 | |
385 | <xpath expr="/form/notebook//page[@string='Delivery & Invoicing']" position="attributes"> |