Merge lp:~vauxoo/addons-vauxoo/purchase_supplier-dev-yzk into lp:addons-vauxoo

Proposed by Isaac López Zúñiga
Status: Superseded
Proposed branch: lp:~vauxoo/addons-vauxoo/purchase_supplier-dev-yzk
Merge into: lp:addons-vauxoo
Diff against target: 143 lines (+128/-0)
3 files modified
purchase_supplier/__init__.py (+28/-0)
purchase_supplier/__openerp__.py (+47/-0)
purchase_supplier/purchase.py (+53/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/purchase_supplier-dev-yzk
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Pending
Nhomar - Vauxoo Pending
Review via email: mp+96806@code.launchpad.net

This proposal has been superseded by a proposal from 2012-03-09.

Description of the change

Module purchase_supplier added

To post a comment you must log in.
143. By Jose Antonio Morales Ponce(vauxoo) - - http://www.vauxoo.com

[IMP] Modified purchase.py to update seller_ids field in the product

Revision history for this message
Jose Antonio Morales Ponce(vauxoo) - - http://www.vauxoo.com (josemoralesp) wrote :

El modulo estaba creando el registro en el modelo, pero no estaba actualizando el campo seller_ids en el producto, hay 2 formas de resolver este problema:

1) Para hacer link a relaciones one2many o many2many es necesario crear una lista de tupla iniciadas con 6,0 y en en segundo debe colocarse una lista de ids, a los cuales se hara el enlace del campo, quedaria de la siguiente manera

product_obj = self.pool.get(product.product)

product_obj.write(cr,uid,[product_id],{'seller_ids':[(6,0,[record_id])]}).

Donde record_id es el id del nuevo registro creado en product.spplierinfo.

2) La segunda manera es mucho mas corta y en cierto punto sigue las misma premisa, para hacer link en las relaciones, solo que en este caso no es necesario crear el registro anteriormente, para luego ese id ser linkeado al modelo que necesitemos. Si deceamos crear un registro y a su vez crear el link a este nuevo registro se puede realizar con una lista de tuplas iniciada con 0,0 y en el segundo campo colocamos el diccionario con los datos del nuevo registro. Queda de la siguiente manera.

product_obj.write(cr,uid,[product_id],{'seller_ids':[(0,0,{'name': partner_id, 'min_qty': 1.0, 'delay': 1, 'sequence': 10, 'product_id': product_id, 'company_id': company_id, 'product_uom': line.product_id.uom_id.id })])

De esta manera realizamos las do2 cosas en una sola linea, esa fue la manera en que se realizo la correccion, ya fue realizado el push a este branch y podra ser revisado.

Saludos.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'purchase_supplier'
2=== added file 'purchase_supplier/__init__.py'
3--- purchase_supplier/__init__.py 1970-01-01 00:00:00 +0000
4+++ purchase_supplier/__init__.py 2012-03-09 20:13:17 +0000
5@@ -0,0 +1,28 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com/
11+# All Rights Reserved.
12+# info Vauxoo (info@vauxoo.com)
13+############################################################################
14+# Coded by: moylop260 (moylop260@vauxoo.com)
15+# Isaac Lopez (isaac@vauxoo.com)
16+############################################################################
17+#
18+# This program is free software: you can redistribute it and/or modify
19+# it under the terms of the GNU Affero General Public License as
20+# published by the Free Software Foundation, either version 3 of the
21+# License, or (at your option) any later version.
22+#
23+# This program is distributed in the hope that it will be useful,
24+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+# GNU Affero General Public License for more details.
27+#
28+# You should have received a copy of the GNU Affero General Public License
29+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30+#
31+##############################################################################
32+
33+import purchase
34
35=== added file 'purchase_supplier/__openerp__.py'
36--- purchase_supplier/__openerp__.py 1970-01-01 00:00:00 +0000
37+++ purchase_supplier/__openerp__.py 2012-03-09 20:13:17 +0000
38@@ -0,0 +1,47 @@
39+# -*- encoding: utf-8 -*-
40+###########################################################################
41+# Module Writen to OpenERP, Open Source Management Solution
42+#
43+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com/
44+# All Rights Reserved.
45+# info Vauxoo (info@vauxoo.com)
46+############################################################################
47+# Coded by: moylop260 (moylop260@vauxoo.com)
48+# Isaac Lopez (isaac@vauxoo.com)
49+############################################################################
50+#
51+# This program is free software: you can redistribute it and/or modify
52+# it under the terms of the GNU Affero General Public License as
53+# published by the Free Software Foundation, either version 3 of the
54+# License, or (at your option) any later version.
55+#
56+# This program is distributed in the hope that it will be useful,
57+# but WITHOUT ANY WARRANTY; without even the implied warranty of
58+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59+# GNU Affero General Public License for more details.
60+#
61+# You should have received a copy of the GNU Affero General Public License
62+# along with this program. If not, see <http://www.gnu.org/licenses/>.
63+#
64+##############################################################################
65+{
66+ 'name':'Purchase - supplier',
67+ 'version':'1.0',
68+ 'depends':["base","account","purchase"],
69+ 'author' : 'Vauxoo',
70+ "description": """Purchse supplier, whe you validate a purchase, the partner is converted in product supplier
71+ """,
72+ 'category' : 'Purchases',
73+ 'website': 'http://www.vauxoo.com',
74+ 'init_xml': [
75+ ],
76+ 'update_xml': [
77+ #~ 'partner_view.xml',
78+ #~ 'purchase_workflow.xml',
79+ ],
80+ 'demo_xml': [
81+
82+ ],
83+ 'installable': True,
84+ 'active': False,
85+}
86
87=== added file 'purchase_supplier/purchase.py'
88--- purchase_supplier/purchase.py 1970-01-01 00:00:00 +0000
89+++ purchase_supplier/purchase.py 2012-03-09 20:13:17 +0000
90@@ -0,0 +1,53 @@
91+# -*- encoding: utf-8 -*-
92+###########################################################################
93+# Module Writen to OpenERP, Open Source Management Solution
94+#
95+# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com/
96+# All Rights Reserved.
97+# info Vauxoo (info@vauxoo.com)
98+############################################################################
99+# Coded by: moylop260 (moylop260@vauxoo.com)
100+# Isaac Lopez (isaac@vauxoo.com)
101+############################################################################
102+#
103+# This program is free software: you can redistribute it and/or modify
104+# it under the terms of the GNU Affero General Public License as
105+# published by the Free Software Foundation, either version 3 of the
106+# License, or (at your option) any later version.
107+#
108+# This program is distributed in the hope that it will be useful,
109+# but WITHOUT ANY WARRANTY; without even the implied warranty of
110+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111+# GNU Affero General Public License for more details.
112+#
113+# You should have received a copy of the GNU Affero General Public License
114+# along with this program. If not, see <http://www.gnu.org/licenses/>.
115+#
116+##############################################################################
117+
118+import time
119+import netsvc
120+from osv import fields, osv
121+from mx import DateTime
122+from tools import config
123+from tools.translate import _
124+
125+class purchase_order(osv.osv):
126+ _inherit = "purchase.order"
127+
128+ def wkf_confirm_order(self, cr, uid, ids, context = None):
129+ product_supp_obj = self.pool.get('product.supplierinfo')
130+ company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
131+ product_obj = self.pool.get('product.product')
132+ if super(purchase_order, self).wkf_confirm_order(cr, uid, ids, context = context):
133+ for po in self.browse(cr, uid, ids, context = context):
134+ partner_id = po.partner_id.id
135+ for line in po.order_line:
136+ product_id = line.product_id.id
137+ if not product_supp_obj.search(cr, uid, [('product_id', '=', product_id), ('name', '=', partner_id)]):
138+ product_obj.write(cr,uid,[product_id],{'seller_ids':[(0,0,{'name': partner_id, 'min_qty': 1.0, 'delay': 1, 'sequence': 10, 'product_id': product_id, 'c ompany_id': company_id, 'product_uom': line.product_id.uom_id.id })]})
139+ return True
140+ else:
141+ return False
142+
143+purchase_order()