Merge lp:~akretion-team/openobject-addons/trunk-product-supplier-refactor into lp:openobject-addons
- trunk-product-supplier-refactor
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 7111 |
Proposed branch: | lp:~akretion-team/openobject-addons/trunk-product-supplier-refactor |
Merge into: | lp:openobject-addons |
Diff against target: |
435 lines (+78/-76) 4 files modified
mrp/mrp_demo.xml (+5/-5) product/product.py (+35/-33) product/product_demo.xml (+28/-28) purchase/purchase.py (+10/-10) |
To merge this branch: | bzr merge lp:~akretion-team/openobject-addons/trunk-product-supplier-refactor |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
qdp (OpenERP) | Pending | ||
Review via email: mp+114358@code.launchpad.net |
Commit message
Description of the change
Move field from template to variants.
The field seller_ids still stay on the product_template (so the original behaviour is still the same).
But we can move the seller_ids from the template to the variant easily in an extra module
qdp (OpenERP) (qdp) wrote : | # |
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote : | # |
Hello quentin, sorry for the delay.
The change done line 407 fix a bug. Indeed if you create a PO manually the name will be the product.name (+purchase description) and if you create a PO automatically the name will be the product.ref_partner (+purchase description).
There is no reason to have this difference.
Manual PO line : 908
name = product.name
if product.
name += '\n' + product.
automatic PO line : 1066
name = product.partner_ref
if product.
For the change of product_id into product_
It hardly recommanded. Indeed if we kept the name "product_id" developper think it's a product.product but in reality it a product.template. And when you install product_
Moreover when we install product variant multi we move the supplier from the template to the variant (price, ref... are always diferent per variant of product). So we will need to have a field call product_id linked to the product.product.
Thanks for you work. Just don't forget to fix the purchase line name, I start to work on product_template_id refactor.
Preview Diff
1 | === modified file 'mrp/mrp_demo.xml' |
2 | --- mrp/mrp_demo.xml 2012-06-28 12:18:20 +0000 |
3 | +++ mrp/mrp_demo.xml 2012-07-11 10:10:24 +0000 |
4 | @@ -930,7 +930,7 @@ |
5 | <field name="uom_po_id" ref="product.product_uom_kgm"/> |
6 | </record> |
7 | <record id="orange_supplier_asus" model="product.supplierinfo"> |
8 | - <field name="product_id" ref="product_orange"/> |
9 | + <field name="product_template_id" ref="product_orange"/> |
10 | <field name="name" ref="base.res_partner_asus"/> |
11 | <field name="min_qty">1.0</field> |
12 | <field name="product_uom" ref="product.product_uom_kgm"/> |
13 | @@ -945,7 +945,7 @@ |
14 | <field name="uom_po_id" ref="product.product_uom_kgm"/> |
15 | </record> |
16 | <record id="sugar_supplier_desertic" model="product.supplierinfo"> |
17 | - <field name="product_id" ref="product_sugar"/> |
18 | + <field name="product_template_id" ref="product_sugar"/> |
19 | <field name="name" ref="base.res_partner_desertic_hispafuentes"/> |
20 | <field name="product_uom" ref="product.product_uom_kgm"/> |
21 | <field name="min_qty">2.0</field> |
22 | @@ -960,7 +960,7 @@ |
23 | <field name="uom_po_id" ref="product_uom_litre"/> |
24 | </record> |
25 | <record id="water_supplier_agrolait" model="product.supplierinfo"> |
26 | - <field name="product_id" ref="product_water"/> |
27 | + <field name="product_template_id" ref="product_water"/> |
28 | <field name="name" ref="base.res_partner_agrolait"/> |
29 | <field name="product_uom" ref="product_uom_litre"/> |
30 | <field name="min_qty">2.0</field> |
31 | @@ -1050,7 +1050,7 @@ |
32 | <field name="uom_po_id" ref="product.product_uom_unit"/> |
33 | </record> |
34 | <record id="cloth_supplier_maxtor" model="product.supplierinfo"> |
35 | - <field name="product_id" ref="product_cloth"/> |
36 | + <field name="product_template_id" ref="product_cloth"/> |
37 | <field name="name" ref="base.res_partner_maxtor"/> |
38 | <field name="product_uom" ref="product.product_uom_unit"/> |
39 | <field name="min_qty">300.0</field> |
40 | @@ -1065,7 +1065,7 @@ |
41 | <field name="uom_po_id" ref="product.product_uom_unit"/> |
42 | </record> |
43 | <record id="buttons_supplier_asus" model="product.supplierinfo"> |
44 | - <field name="product_id" ref="product_buttons"/> |
45 | + <field name="product_template_id" ref="product_buttons"/> |
46 | <field name="name" ref="base.res_partner_asus"/> |
47 | <field name="product_uom" ref="product.product_uom_unit"/> |
48 | <field name="min_qty">100.0</field> |
49 | |
50 | === modified file 'product/product.py' |
51 | --- product/product.py 2012-06-05 17:12:31 +0000 |
52 | +++ product/product.py 2012-07-11 10:10:24 +0000 |
53 | @@ -258,32 +258,6 @@ |
54 | _name = "product.template" |
55 | _description = "Product Template" |
56 | |
57 | - def _get_main_product_supplier(self, cr, uid, product, context=None): |
58 | - """Determines the main (best) product supplier for ``product``, |
59 | - returning the corresponding ``supplierinfo`` record, or False |
60 | - if none were found. The default strategy is to select the |
61 | - supplier with the highest priority (i.e. smallest sequence). |
62 | - |
63 | - :param browse_record product: product to supply |
64 | - :rtype: product.supplierinfo browse_record or False |
65 | - """ |
66 | - sellers = [(seller_info.sequence, seller_info) |
67 | - for seller_info in product.seller_ids or [] |
68 | - if seller_info and isinstance(seller_info.sequence, (int, long))] |
69 | - return sellers and sellers[0][1] or False |
70 | - |
71 | - def _calc_seller(self, cr, uid, ids, fields, arg, context=None): |
72 | - result = {} |
73 | - for product in self.browse(cr, uid, ids, context=context): |
74 | - main_supplier = self._get_main_product_supplier(cr, uid, product, context=context) |
75 | - result[product.id] = { |
76 | - 'seller_info_id': main_supplier and main_supplier.id or False, |
77 | - 'seller_delay': main_supplier and main_supplier.delay or 1, |
78 | - 'seller_qty': main_supplier and main_supplier.qty or 0.0, |
79 | - 'seller_id': main_supplier and main_supplier.name.id or False |
80 | - } |
81 | - return result |
82 | - |
83 | _columns = { |
84 | 'name': fields.char('Name', size=128, required=True, translate=True, select=True), |
85 | 'product_manager': fields.many2one('res.users','Product Manager',help="This is use as task responsible"), |
86 | @@ -320,11 +294,7 @@ |
87 | help='Coefficient to convert Unit of Measure to UOS\n' |
88 | ' uos = uom * coeff'), |
89 | 'mes_type': fields.selection((('fixed', 'Fixed'), ('variable', 'Variable')), 'Measure Type', required=True), |
90 | - 'seller_info_id': fields.function(_calc_seller, type='many2one', relation="product.supplierinfo", multi="seller_info"), |
91 | - 'seller_delay': fields.function(_calc_seller, type='integer', string='Supplier Lead Time', multi="seller_info", help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."), |
92 | - 'seller_qty': fields.function(_calc_seller, type='float', string='Supplier Quantity', multi="seller_info", help="This is minimum quantity to purchase from Main Supplier."), |
93 | - 'seller_id': fields.function(_calc_seller, type='many2one', relation="res.partner", string='Main Supplier', help="Main Supplier who has highest priority in Supplier List.", multi="seller_info"), |
94 | - 'seller_ids': fields.one2many('product.supplierinfo', 'product_id', 'Partners'), |
95 | + 'seller_ids': fields.one2many('product.supplierinfo', 'product_template_id', 'Partners'), |
96 | 'loc_rack': fields.char('Rack', size=16), |
97 | 'loc_row': fields.char('Row', size=16), |
98 | 'loc_case': fields.char('Case', size=16), |
99 | @@ -491,6 +461,34 @@ |
100 | res[p.id] = (data['code'] and ('['+data['code']+'] ') or '') + \ |
101 | (data['name'] or '') + (data['variants'] and (' - '+data['variants']) or '') |
102 | return res |
103 | + |
104 | + |
105 | + def _get_main_product_supplier(self, cr, uid, product, context=None): |
106 | + """Determines the main (best) product supplier for ``product``, |
107 | + returning the corresponding ``supplierinfo`` record, or False |
108 | + if none were found. The default strategy is to select the |
109 | + supplier with the highest priority (i.e. smallest sequence). |
110 | + |
111 | + :param browse_record product: product to supply |
112 | + :rtype: product.supplierinfo browse_record or False |
113 | + """ |
114 | + sellers = [(seller_info.sequence, seller_info) |
115 | + for seller_info in product.seller_ids or [] |
116 | + if seller_info and isinstance(seller_info.sequence, (int, long))] |
117 | + return sellers and sellers[0][1] or False |
118 | + |
119 | + def _calc_seller(self, cr, uid, ids, fields, arg, context=None): |
120 | + result = {} |
121 | + for product in self.browse(cr, uid, ids, context=context): |
122 | + main_supplier = self._get_main_product_supplier(cr, uid, product, context=context) |
123 | + result[product.id] = { |
124 | + 'seller_info_id': main_supplier and main_supplier.id or False, |
125 | + 'seller_delay': main_supplier and main_supplier.delay or 1, |
126 | + 'seller_qty': main_supplier and main_supplier.qty or 0.0, |
127 | + 'seller_id': main_supplier and main_supplier.name.id or False |
128 | + } |
129 | + return result |
130 | + |
131 | |
132 | _defaults = { |
133 | 'active': lambda *a: 1, |
134 | @@ -526,6 +524,10 @@ |
135 | 'name_template': fields.related('product_tmpl_id', 'name', string="Name", type='char', size=128, store=True, select=True), |
136 | 'color': fields.integer('Color Index'), |
137 | 'product_image': fields.binary('Image'), |
138 | + 'seller_info_id': fields.function(_calc_seller, type='many2one', relation="product.supplierinfo", multi="seller_info"), |
139 | + 'seller_delay': fields.function(_calc_seller, type='integer', string='Supplier Lead Time', multi="seller_info", help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."), |
140 | + 'seller_qty': fields.function(_calc_seller, type='float', string='Supplier Quantity', multi="seller_info", help="This is minimum quantity to purchase from Main Supplier."), |
141 | + 'seller_id': fields.function(_calc_seller, type='many2one', relation="res.partner", string='Main Supplier', help="Main Supplier who has highest priority in Supplier List.", multi="seller_info"), |
142 | } |
143 | |
144 | def create(self, cr, uid, vals, context=None): |
145 | @@ -783,10 +785,10 @@ |
146 | 'product_name': fields.char('Supplier Product Name', size=128, help="This supplier's product name will be used when printing a request for quotation. Keep empty to use the internal one."), |
147 | 'product_code': fields.char('Supplier Product Code', size=64, help="This supplier's product code will be used when printing a request for quotation. Keep empty to use the internal one."), |
148 | 'sequence' : fields.integer('Sequence', help="Assigns the priority to the list of product supplier."), |
149 | - 'product_uom': fields.related('product_id', 'uom_po_id', type='many2one', relation='product.uom', string="Supplier Unit of Measure", readonly="1", help="This comes from the product form."), |
150 | + 'product_uom': fields.related('product_template_id', 'uom_po_id', type='many2one', relation='product.uom', string="Supplier Unit of Measure", readonly="1", help="This comes from the product form."), |
151 | 'min_qty': fields.float('Minimal Quantity', required=True, help="The minimal quantity to purchase to this supplier, expressed in the supplier Product Unit of Measure if not empty, in the default unit of measure of the product otherwise."), |
152 | 'qty': fields.function(_calc_qty, store=True, type='float', string='Quantity', multi="qty", help="This is a quantity which is converted into Default Unit of Measure."), |
153 | - 'product_id' : fields.many2one('product.template', 'Product', required=True, ondelete='cascade', select=True), |
154 | + 'product_template_id' : fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade', select=True), |
155 | 'delay' : fields.integer('Delivery Lead Time', required=True, help="Lead time in days between the confirmation of the purchase order and the reception of the products in your warehouse. Used by the scheduler for automatic computation of the purchase order planning."), |
156 | 'pricelist_ids': fields.one2many('pricelist.partnerinfo', 'suppinfo_id', 'Supplier Pricelist'), |
157 | 'company_id':fields.many2one('res.company','Company',select=1), |
158 | |
159 | === modified file 'product/product_demo.xml' |
160 | --- product/product_demo.xml 2012-01-31 13:36:57 +0000 |
161 | +++ product/product_demo.xml 2012-07-11 10:10:24 +0000 |
162 | @@ -693,112 +693,112 @@ |
163 | <field name="name" ref="base.res_partner_asus"/> |
164 | <field name="qty">10</field> |
165 | <field name="min_qty">1</field> |
166 | - <field name="product_id" ref="product_product_mb1"/> |
167 | + <field name="product_template_id" ref="product_product_mb1"/> |
168 | <field name="delay">5</field> |
169 | </record> |
170 | <record id="supplierinfo2" model="product.supplierinfo"> |
171 | <field name="name" ref="base.res_partner_asus"/> |
172 | <field name="qty">10</field> |
173 | <field name="min_qty">1</field> |
174 | - <field name="product_id" ref="product_product_mb2"/> |
175 | + <field name="product_template_id" ref="product_product_mb2"/> |
176 | <field name="delay">5</field> |
177 | </record> |
178 | <record id="supplierinfo3" model="product.supplierinfo"> |
179 | <field name="name" ref="base.res_partner_4"/> |
180 | <field name="qty">1</field> |
181 | <field name="min_qty">1</field> |
182 | - <field name="product_id" ref="product_product_mb1"/> |
183 | + <field name="product_template_id" ref="product_product_mb1"/> |
184 | <field name="delay">1</field> |
185 | </record> |
186 | <record id="supplierinfo4" model="product.supplierinfo"> |
187 | <field name="name" ref="base.res_partner_4"/> |
188 | <field name="qty">1</field> |
189 | <field name="min_qty">1</field> |
190 | - <field name="product_id" ref="product_product_mb2"/> |
191 | + <field name="product_template_id" ref="product_product_mb2"/> |
192 | <field name="delay">1</field> |
193 | </record> |
194 | <record id="supplierinfo5" model="product.supplierinfo"> |
195 | <field name="name" ref="base.res_partner_4"/> |
196 | <field name="qty">1</field> |
197 | <field name="min_qty">1</field> |
198 | - <field name="product_id" ref="product_product_pc1"/> |
199 | + <field name="product_template_id" ref="product_product_pc1"/> |
200 | <field name="delay">2</field> |
201 | </record> |
202 | <record id="supplierinfo6" model="product.supplierinfo"> |
203 | <field name="name" ref="base.res_partner_4"/> |
204 | <field name="qty">1</field> |
205 | <field name="min_qty">1</field> |
206 | - <field name="product_id" ref="product_product_pc2"/> |
207 | + <field name="product_template_id" ref="product_product_pc2"/> |
208 | <field name="delay">2</field> |
209 | </record> |
210 | <record id="supplierinfo7" model="product.supplierinfo"> |
211 | <field name="name" ref="base.res_partner_4"/> |
212 | <field name="qty">1</field> |
213 | <field name="min_qty">1</field> |
214 | - <field name="product_id" ref="product_product_pc3"/> |
215 | + <field name="product_template_id" ref="product_product_pc3"/> |
216 | <field name="delay">2</field> |
217 | </record> |
218 | <record id="supplierinfo8" model="product.supplierinfo"> |
219 | <field name="name" ref="base.res_partner_4"/> |
220 | <field name="qty">1</field> |
221 | <field name="min_qty">1</field> |
222 | - <field name="product_id" ref="product_product_pc4"/> |
223 | + <field name="product_template_id" ref="product_product_pc4"/> |
224 | <field name="delay">1</field> |
225 | </record> |
226 | <record id="supplierinfo9" model="product.supplierinfo"> |
227 | <field name="name" ref="base.res_partner_4"/> |
228 | <field name="qty">1</field> |
229 | <field name="min_qty">1</field> |
230 | - <field name="product_id" ref="product_product_cpu1"/> |
231 | + <field name="product_template_id" ref="product_product_cpu1"/> |
232 | <field name="delay">1</field> |
233 | </record> |
234 | <record id="supplierinfo10" model="product.supplierinfo"> |
235 | <field name="name" ref="base.res_partner_4"/> |
236 | <field name="qty">1</field> |
237 | <field name="min_qty">1</field> |
238 | - <field name="product_id" ref="product_product_cpu3"/> |
239 | + <field name="product_template_id" ref="product_product_cpu3"/> |
240 | <field name="delay">1</field> |
241 | </record> |
242 | <record id="supplierinfo11" model="product.supplierinfo"> |
243 | <field name="name" ref="base.res_partner_4"/> |
244 | <field name="qty">1</field> |
245 | <field name="min_qty">1</field> |
246 | - <field name="product_id" ref="product_product_hdd1"/> |
247 | + <field name="product_template_id" ref="product_product_hdd1"/> |
248 | <field name="delay">1</field> |
249 | </record> |
250 | <record id="supplierinfo12" model="product.supplierinfo"> |
251 | <field name="name" ref="base.res_partner_4"/> |
252 | <field name="qty">1</field> |
253 | <field name="min_qty">1</field> |
254 | - <field name="product_id" ref="product_product_hdd2"/> |
255 | + <field name="product_template_id" ref="product_product_hdd2"/> |
256 | <field name="delay">1</field> |
257 | </record> |
258 | <record id="supplierinfo13" model="product.supplierinfo"> |
259 | <field name="name" ref="base.res_partner_4"/> |
260 | <field name="qty">1</field> |
261 | <field name="min_qty">1</field> |
262 | - <field name="product_id" ref="product_product_hdd3"/> |
263 | + <field name="product_template_id" ref="product_product_hdd3"/> |
264 | <field name="delay">1</field> |
265 | </record> |
266 | <record id="supplierinfo14" model="product.supplierinfo"> |
267 | <field name="name" ref="base.res_partner_4"/> |
268 | <field name="qty">1</field> |
269 | <field name="min_qty">1</field> |
270 | - <field name="product_id" ref="product_product_20"/> |
271 | + <field name="product_template_id" ref="product_product_20"/> |
272 | <field name="delay">5</field> |
273 | </record> |
274 | <record id="supplierinfo15" model="product.supplierinfo"> |
275 | <field name="name" ref="base.res_partner_4"/> |
276 | <field name="qty">1</field> |
277 | <field name="min_qty">1</field> |
278 | - <field name="product_id" ref="product_product_21"/> |
279 | + <field name="product_template_id" ref="product_product_21"/> |
280 | <field name="delay">5</field> |
281 | </record> |
282 | <record id="supplierinfo16" model="product.supplierinfo"> |
283 | <field name="name" ref="base.res_partner_4"/> |
284 | <field name="qty">1</field> |
285 | <field name="min_qty">1</field> |
286 | - <field name="product_id" ref="product_product_22"/> |
287 | + <field name="product_template_id" ref="product_product_22"/> |
288 | <field name="delay">5</field> |
289 | </record> |
290 | <record id="supplierinfo17" model="product.supplierinfo"> |
291 | @@ -806,7 +806,7 @@ |
292 | <field name="qty">10</field> |
293 | <field name="min_qty">1</field> |
294 | <field name="sequence">5</field> |
295 | - <field name="product_id" ref="product_product_hdd1"/> |
296 | + <field name="product_template_id" ref="product_product_hdd1"/> |
297 | <field name="delay">5</field> |
298 | </record> |
299 | <record id="supplierinfo18" model="product.supplierinfo"> |
300 | @@ -814,7 +814,7 @@ |
301 | <field name="qty">10</field> |
302 | <field name="min_qty">1</field> |
303 | <field name="sequence">5</field> |
304 | - <field name="product_id" ref="product_product_hdd2"/> |
305 | + <field name="product_template_id" ref="product_product_hdd2"/> |
306 | <field name="delay">5</field> |
307 | </record> |
308 | <record id="supplierinfo19" model="product.supplierinfo"> |
309 | @@ -822,7 +822,7 @@ |
310 | <field name="qty">10</field> |
311 | <field name="min_qty">1</field> |
312 | <field name="sequence">5</field> |
313 | - <field name="product_id" ref="product_product_hdd3"/> |
314 | + <field name="product_template_id" ref="product_product_hdd3"/> |
315 | <field name="delay">5</field> |
316 | </record> |
317 | |
318 | @@ -831,7 +831,7 @@ |
319 | --> |
320 | |
321 | <record id="product_supplierinfo_0" model="product.supplierinfo"> |
322 | - <field name="product_id" ref="product_product_rearpanelarm0"/> |
323 | + <field name="product_template_id" ref="product_product_rearpanelarm0"/> |
324 | <field name="delay">5</field> |
325 | <field name="min_qty">1</field> |
326 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
327 | @@ -839,7 +839,7 @@ |
328 | |
329 | |
330 | <record id="product_supplierinfo_1" model="product.supplierinfo"> |
331 | - <field name="product_id" ref="product_product_rearpanelarm0"/> |
332 | + <field name="product_template_id" ref="product_product_rearpanelarm0"/> |
333 | <field name="delay">5</field> |
334 | <field name="min_qty">1</field> |
335 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
336 | @@ -847,7 +847,7 @@ |
337 | |
338 | |
339 | <record id="product_supplierinfo_2" model="product.supplierinfo"> |
340 | - <field name="product_id" ref="product_product_rearpanelarm1"/> |
341 | + <field name="product_template_id" ref="product_product_rearpanelarm1"/> |
342 | <field name="delay">5</field> |
343 | <field name="min_qty">1</field> |
344 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
345 | @@ -855,7 +855,7 @@ |
346 | |
347 | |
348 | <record id="product_supplierinfo_3" model="product.supplierinfo"> |
349 | - <field name="product_id" ref="product_product_sidepanel0"/> |
350 | + <field name="product_template_id" ref="product_product_sidepanel0"/> |
351 | <field name="delay">5</field> |
352 | <field name="min_qty">1</field> |
353 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
354 | @@ -863,7 +863,7 @@ |
355 | |
356 | |
357 | <record id="product_supplierinfo_4" model="product.supplierinfo"> |
358 | - <field name="product_id" ref="product_product_shelfofcm0"/> |
359 | + <field name="product_template_id" ref="product_product_shelfofcm0"/> |
360 | <field name="delay">5</field> |
361 | <field name="min_qty">1</field> |
362 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
363 | @@ -871,7 +871,7 @@ |
364 | |
365 | |
366 | <record id="product_supplierinfo_5" model="product.supplierinfo"> |
367 | - <field name="product_id" ref="product_product_shelfofcm1"/> |
368 | + <field name="product_template_id" ref="product_product_shelfofcm1"/> |
369 | <field name="delay">5</field> |
370 | <field name="min_qty">1</field> |
371 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
372 | @@ -879,7 +879,7 @@ |
373 | |
374 | |
375 | <record id="product_supplierinfo_6" model="product.supplierinfo"> |
376 | - <field name="product_id" ref="product_product_assemblysection0"/> |
377 | + <field name="product_template_id" ref="product_product_assemblysection0"/> |
378 | <field name="delay">2</field> |
379 | <field name="min_qty">1</field> |
380 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
381 | @@ -887,7 +887,7 @@ |
382 | |
383 | |
384 | <record id="product_supplierinfo_7" model="product.supplierinfo"> |
385 | - <field name="product_id" ref="product_product_woodlintelm0"/> |
386 | + <field name="product_template_id" ref="product_product_woodlintelm0"/> |
387 | <field name="delay">5</field> |
388 | <field name="min_qty">1</field> |
389 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
390 | @@ -895,7 +895,7 @@ |
391 | |
392 | |
393 | <record id="product_supplierinfo_8" model="product.supplierinfo"> |
394 | - <field name="product_id" ref="product_product_metalcleats0"/> |
395 | + <field name="product_template_id" ref="product_product_metalcleats0"/> |
396 | <field name="delay">5</field> |
397 | <field name="min_qty">1</field> |
398 | <field name="name" ref="base.res_partner_woodywoodpecker0"/> |
399 | |
400 | === modified file 'purchase/purchase.py' |
401 | --- purchase/purchase.py 2012-07-02 16:13:23 +0000 |
402 | +++ purchase/purchase.py 2012-07-11 10:10:24 +0000 |
403 | @@ -895,7 +895,7 @@ |
404 | lang = res_partner.browse(cr, uid, partner_id).lang |
405 | context_partner = {'lang': lang, 'partner_id': partner_id} |
406 | product = product_product.browse(cr, uid, product_id, context=context_partner) |
407 | - res['value'].update({'name': product.name, 'notes': notes or product.description_purchase}) |
408 | + res['value'].update({'name': product.partner_ref, 'notes': notes or product.description_purchase}) |
409 | |
410 | # - set a domain on product_uom |
411 | res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]} |
412 | @@ -917,15 +917,15 @@ |
413 | |
414 | qty = qty or 1.0 |
415 | supplierinfo = False |
416 | - supplierinfo_ids = product_supplierinfo.search(cr, uid, [('name','=',partner_id),('product_id','=',product.id)]) |
417 | - if supplierinfo_ids: |
418 | - supplierinfo = product_supplierinfo.browse(cr, uid, supplierinfo_ids[0], context=context) |
419 | - if supplierinfo.product_uom.id != uom_id: |
420 | - res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier only sells this product by %s') % supplierinfo.product_uom.name } |
421 | - min_qty = product_uom._compute_qty(cr, uid, supplierinfo.product_uom.id, supplierinfo.min_qty, to_uom_id=uom_id) |
422 | - if qty < min_qty: # If the supplier quantity is greater than entered from user, set minimal. |
423 | - res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier has a minimal quantity set to %s %s, you should not purchase less.') % (supplierinfo.min_qty, supplierinfo.product_uom.name)} |
424 | - qty = min_qty |
425 | + for supplier in product.seller_ids: |
426 | + if supplier.name.id == partner_id: |
427 | + supplierinfo = supplier |
428 | + if supplierinfo.product_uom.id != uom_id: |
429 | + res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier only sells this product by %s') % supplierinfo.product_uom.name } |
430 | + min_qty = product_uom._compute_qty(cr, uid, supplierinfo.product_uom.id, supplierinfo.min_qty, to_uom_id=uom_id) |
431 | + if qty < min_qty: # If the supplier quantity is greater than entered from user, set minimal. |
432 | + res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier has a minimal quantity set to %s %s, you should not purchase less.') % (supplierinfo.min_qty, supplierinfo.product_uom.name)} |
433 | + qty = min_qty |
434 | |
435 | dt = self._get_date_planned(cr, uid, supplierinfo, date_order, context=context).strftime(DEFAULT_SERVER_DATETIME_FORMAT) |
436 |
Hello Sébastien,
i don't remember the purpose of this change: ].update( {'name' : product.name, 'notes': notes or product. description_ purchase} ) ].update( {'name' : product. partner_ ref, 'notes': notes or product. description_ purchase} )
407 - res['value'
408 + res['value'
so as it was conflicting with latest changes in trunk, i didn't kept it.
also, i didn't kept the renaming of column product_id into product_template_id on supplierinfo, because i feel like it's dangereous and not fully tested: the runbot went red and, at least, it wasn't complete: see product/ pricelist. py pricelist. py 2012-07-25 16:24:46 +0000
categ_where = '(categ_id IS NULL)'
+++ product/
@@ -202,7 +202,7 @@
if partner:
partner_ where = 'base <> -2 OR %s IN (SELECT name FROM product_ supplierinfo WHERE product_id = %s) '
thanks for the contribution,
Quentin