Skip to content

Commit

Permalink
[IMP] NEW FIELD QTY TOTAL
Browse files Browse the repository at this point in the history
  • Loading branch information
dhecar committed Jan 9, 2017
1 parent ed43efd commit 32a381b
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 18 deletions.
2 changes: 2 additions & 0 deletions sine_motoscoot_stock/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import product_motoscoot
import picking_extension
import stock_inventory

#import stock_fill_inventory_filter
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
7 changes: 5 additions & 2 deletions sine_motoscoot_stock/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"category": "Generic Modules/Others",
"website": "http://sinergiainformatica.net",
"description": "Extension.",
"depends": ["product", "stock_location", "stock", "sale"],
"update_xml": ["product_motoscoot_view.xml","picking_extension_view.xml"],
"depends": ["product", "stock_location", "stock", "sale"],
"update_xml": ["product_motoscoot_view.xml",
"picking_extension_view.xml",
"stock_inventory_form_view.xml",
],
"active": True,
"installable": True
}
Expand Down
9 changes: 5 additions & 4 deletions sine_motoscoot_stock/product_motoscoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ def StockByLocation(self, cr, uid, ids, name, args, context=None):
WHEN location_id='12' THEN 'G'
WHEN location_id='19' THEN 'B'
WHEN location_id='15' THEN 'P'
WHEN location_id='27' THEN 'T'
END AS LOC FROM stock_report_prodlots
WHERE (location_id ='12' OR location_id ='19' OR location_id='15')
WHERE (location_id ='12' OR location_id ='19' OR location_id='15' OR location_id='27')
AND product_id = '%s' ORDER BY location_id""" % i)
res[i] = cr.dictfetchall()

Expand Down Expand Up @@ -88,16 +89,16 @@ def compute_total_qty(self,cr, uid, ids, name, args, context=None):
res = {}
for i in ids:
cr.execute(""" SELECT sum(qty) as SUMA FROM stock_report_prodlots
WHERE (location_id ='12' OR location_id ='19' OR location_id='15')
WHERE (location_id ='12' OR location_id ='19' OR location_id='15' OR location_id='27')
AND product_id = '%s' """ % i)

for r in cr.fetchone():
res[i] = r
if res[i]:
return res
else:
return 0.0

res[i] = 0.0
return res


_columns = {
Expand Down
34 changes: 34 additions & 0 deletions sine_motoscoot_stock/stock_inventory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp.osv import fields, osv, orm


class stock_inventory_line(osv.osv):

_inherit = 'stock.inventory.line'

_columns = {

'inv':fields.boolean('Inventariado', help="Marcar para asegurar que el producto está inventariado"),
}

stock_inventory_line()
34 changes: 34 additions & 0 deletions sine_motoscoot_stock/stock_inventory_form_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_inventory_line_inherit" model="ir.ui.view">
<field name="name">stock.inventory.line.inh</field>
<field name="model">stock.inventory.line</field>
<field name="inherit_id" ref="stock.stock_inventory_line_tree"/>
<field name="arch" type="xml">
<field name="product_qty" position="after">
<field name="inv" />
</field>

<xpath expr="//tree[@string='Stock Inventory Lines']" position="attributes">
<attribute name="colors">#008000:inv == 'True';</attribute>
</xpath>
</field>
</record>



<record id="view_inventory_line_form_inherit" model="ir.ui.view">
<field name="name">stock.inventory.line.form.inh</field>
<field name="model">stock.inventory.line</field>
<field name="inherit_id" ref="stock.view_inventory_line_form"/>
<field name="arch" type="xml">
<field name="product_qty" position="after">
<field name="inv" />
</field>

</field>
</record>

</data>
</openerp>
26 changes: 14 additions & 12 deletions sine_wyomind_stock_update/wyomind_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ class WyomindStockSync(osv.TransientModel):
_description = 'Syncronize Stock'

def wyomind_sync(self, cr, uid, ids, context=None):
# Wyomind Config

#db_obj = self.pool['base.external.dbsource']

cr.execute(""" SELECT qty , product_id , location_id FROM stock_report_prodlots
WHERE (location_id ='12' OR location_id ='19' OR location_id='15')
ORDER BY location_id""")
ORDER BY location_id""")
## OR location_id='27')-->??

res = cr.dictfetchall()
result = {}
conf_obj = self.pool.get('wyomind.config')
Expand All @@ -78,12 +77,9 @@ def wyomind_sync(self, cr, uid, ids, context=None):
# If product is linked to magento
if mag_id is not None:

#if r['location_id'] == 12:
# ads = db_obj.get_stock(cr, SUPERUSER_ID, ids, r['product_id'], r['location_id'],
# context=context)

# q = r['qty'] - ads

# Si es ubicacion tienda, sumar stock ubicacion stock Girona + Ubicación stock tienda
#if r['location_id'] == 27:
# q = r[12] + r[27]
#else:

q = r['qty']
Expand All @@ -95,7 +91,9 @@ def wyomind_sync(self, cr, uid, ids, context=None):
}

location = 0
# Si ubicacion es girona o tienda, location Magento = 2
if r['location_id'] == 12:
##or r['location_id'] == 27:
location = 2
if r['location_id'] == 15:
location = 4
Expand Down Expand Up @@ -166,6 +164,8 @@ def action_done(self, cr, uid, ids, context=None):
location = 4
if move.location_id.id == 19:
location = 3
#if move.location_id.id == 27:
# location = 2

location2 = 0
if move.location_dest_id.id == 12:
Expand All @@ -174,13 +174,15 @@ def action_done(self, cr, uid, ids, context=None):
location2 = 4
if move.location_dest_id.id == 19:
location2 = 3
#if move.location_dest_id.id == 27:
# location2 = 2

""" Update dest stock location for partial in movements"""
# If product is linked to magento
if move.product_id.magento_bind_ids and move.location_dest_id.id not in (0, 22, 24, 25,27) and move.picking_id:
if move.product_id.magento_bind_ids and move.location_dest_id.id not in (0, 22, 24, 25) and move.picking_id:

# product stock
if move.location_dest_id.id in (12, 15, 19):
if move.location_dest_id.id in (12, 15, 19,27):
cr.execute("""SELECT qty FROM stock_report_prodlots WHERE
location_id =%s AND product_id = %s""" %
(move.location_dest_id.id, move.product_id.id))
Expand Down

0 comments on commit 32a381b

Please sign in to comment.