|
@@ -0,0 +1,55 @@
|
|
|
+# 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 datetime import datetime, timedelta
|
|
|
+import time
|
|
|
+from openerp.osv import fields, osv
|
|
|
+from openerp.tools.translate import _
|
|
|
+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
|
|
+import openerp.addons.decimal_precision as dp
|
|
|
+from openerp import workflow
|
|
|
+
|
|
|
+# class product_product(osv.Model):
|
|
|
+ # _inherit = 'product.product'
|
|
|
+
|
|
|
+ # def _sales_count(self, cr, uid, ids, field_name, arg, context=None):
|
|
|
+ # SaleOrderLine = self.pool['sale.order.line']
|
|
|
+ # return {
|
|
|
+ # product_id: SaleOrderLine.search_count(cr,uid, [('product_id', '=', product_id)], context=context)
|
|
|
+ # for product_id in ids
|
|
|
+ # }
|
|
|
+
|
|
|
+ # _columns = {
|
|
|
+ # 'sales_count': fields.function(_sales_count, string='# Sales', type='integer'),
|
|
|
+
|
|
|
+ # }
|
|
|
+
|
|
|
+# class product_template(osv.Model):
|
|
|
+ # _inherit = 'product.template'
|
|
|
+
|
|
|
+ # def _sales_count(self, cr, uid, ids, field_name, arg, context=None):
|
|
|
+ # res = dict.fromkeys(ids, 0)
|
|
|
+ # for template in self.browse(cr, uid, ids, context=context):
|
|
|
+ # res[template.id] = sum([p.sales_count for p in template.product_variant_ids])
|
|
|
+ # return res
|
|
|
+
|
|
|
+ # def action_view_sales(self, cr, uid, ids, context=None):
|
|
|
+ # act_obj = self.pool.get('ir.actions.act_window')
|
|
|
+ # mod_obj = self.pool.get('ir.model.data')
|
|
|
+ # product_ids = []
|
|
|
+ # for template in self.browse(cr, uid, ids, context=context):
|
|
|
+ # product_ids += [x.id for x in template.product_variant_ids]
|
|
|
+ # result = mod_obj.xmlid_to_res_id(cr, uid, 'sale.action_order_line_product_tree',raise_if_not_found=True)
|
|
|
+ # result = act_obj.read(cr, uid, [result], context=context)[0]
|
|
|
+ # result['domain'] = "[('product_id','in',[" + ','.join(map(str, product_ids)) + "])]"
|
|
|
+ # return result
|
|
|
+
|
|
|
+
|
|
|
+ # _columns = {
|
|
|
+ # 'sales_count': fields.function(_sales_count, string='# Sales', type='integer'),
|
|
|
+
|
|
|
+ # }
|
|
|
+
|
|
|
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|