Переглянути джерело

NEW Smarticon de pos en producto

Sebas 7 роки тому
коміт
84c1d14c6b
7 змінених файлів з 200 додано та 0 видалено
  1. 27 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 45 0
      __openerp__.py
  4. 58 0
      pos.py
  5. BIN
      pos.pyc
  6. 70 0
      pos_view.xml
  7. BIN
      static/description/icon.png

+ 27 - 0
__init__.py

@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_brand for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    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/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product Brand is an Openobject module wich enable Brand management for products #
+###################################################################################
+from . import pos


+ 45 - 0
__openerp__.py

@@ -0,0 +1,45 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#    product_features for OpenERP                                                  #
+#    Copyright (C) 2009 NetAndCo (<http://www.netandco.net>).                   #
+#    Authors, Mathieu Lemercier, mathieu@netandco.net,                          #
+#             Franck Bret, franck@netandco.net                                  #
+#    Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>   #
+#                                                                               #
+#    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/>.      #
+#                                                                               #
+#################################################################################
+###################################################################################
+# Product features is an Openobject module wich enable features management for products #
+###################################################################################
+{
+    'name': 'Smarticon para Point of Sale/Product',
+    'version': '0.1',
+    'category': 'Point of Sale',
+    'description': """
+Smarticon para Point of Sale / Product
+========================================
+
+Smarticon para Point of Sale para que muestre la candidad de producto vendido
+
+    """,
+    'author': 'Eiru/Sebastian Penayo',
+    'website': '',
+	'depends': ['report','point_of_sale','base'],
+    'data': [
+		'pos_view.xml',
+    ],
+    'installable': True,
+}

+ 58 - 0
pos.py

@@ -0,0 +1,58 @@
+
+import math
+
+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
+
+class product_product(osv.Model):
+    _inherit = 'product.product'
+
+    def _pos_count(self, cr, uid, ids, field_name, arg, context=None):
+        r = dict.fromkeys(ids, 0)
+        domain = [
+            ('product_id', 'in', ids),
+        ]
+        for group in self.pool['report.pos.order'].read_group(cr, uid, domain, ['product_id','product_qty'], ['product_id'], context=context):
+            r[group['product_id'][0]] = group['product_qty']
+        return r
+
+    def action_view_pos(self, cr, uid, ids, context=None):
+        result = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'point_of_sale.action_pos_order_line', raise_if_not_found=True)
+        result = self.pool['ir.actions.act_window'].read(cr, uid, [result], context=context)[0]
+        result['domain'] = "[('product_id','in',[" + ','.join(map(str, ids)) + "])]"
+        return result
+
+    _columns = {
+        'pos_count': fields.function(_pos_count, string='# Pos', type='integer'),
+    }
+
+class product_template(osv.Model):
+    _inherit = 'product.template'
+
+    def _pos_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.pos_count for p in template.product_variant_ids])
+        return res
+
+    def action_view_pos(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, 'point_of_sale.action_pos_order_line',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 = {
+        'pos_count': fields.function(_pos_count, string='# Pos', type='integer'),
+
+    }
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:


+ 70 - 0
pos_view.xml

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+	  <!--<record id="act_res_partner_3_pos_order" model="ir.actions.act_window">
+            <field name="name">Pos</field>
+            <field name="res_model">pos.order.line</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="context">{'search_default_partner_id': active_id}</field>
+            <field name="groups_id" eval="[(4, ref('point_of_sale.group_pos_user'))]"/>
+            <field name="help" type="html">
+              <p class="oe_view_nocontent_create">
+                Click to create a quotation or pos order for this customer.
+              </p><p>
+                Odoo will help you efficiently handle the complete sale flow:
+                pos order, invoicing and
+                payment.
+              </p><p>
+                The social feature helps you organize discussions on each pos
+                order, and allow your customer to keep track of the evolution
+                of the pos order.
+              </p>
+            </field>
+        </record> -->
+
+
+
+        <record id="action_pos_line_product_tree" model="ir.actions.act_window">
+            <field name="context">{}</field><!-- force empty -->
+            <field name="name">Pos Order Lines</field>
+            <field name="res_model">pos.order.line</field>
+            <field name="view_id" ref="point_of_sale.view_pos_order_tree"/>
+            <field name="context">{'search_default_confirmed': 1}</field>
+        </record>
+
+        <record model="ir.ui.view" id="product_form_view_pos_order_button1">
+            <field name="name">product.product.pos.order1</field>
+            <field name="model">product.product</field>
+            <field name="inherit_id" ref="product.product_normal_form_view"/>
+        <!--    <field name="groups_id" eval="[(4, ref('base.group_sale_salesman'))]"/> -->
+            <field name="arch" type="xml">
+                <xpath expr="//div[@name='buttons']" position="inside">
+                    <button class="oe_inline oe_stat_button" name="action_view_pos"
+                        type="object" icon="fa-strikethrough">
+                        <field string="Pos" name="pos_count" widget="statinfo" />
+                    </button>
+                </xpath>
+            </field>
+        </record>
+
+      	<record model="ir.ui.view" id="product_template_form_view_pos_order_button1">
+            <field name="name">product.template.pos.order.button1</field>
+            <field name="model">product.template</field>
+            <field name="inherit_id" ref="product.product_template_only_form_view"/>
+          <!--    <field name="groups_id" eval="[(4, ref('base.group_sale_salesman'))]"/> -->
+            <field name="arch" type="xml">
+                <xpath expr="//div[@name='buttons']" position="inside">
+                    <button class="oe_inline oe_stat_button" name="action_view_pos"
+                        type="object" icon="fa-strikethrough">
+                        <field string="Pos" name="pos_count" widget="statinfo" />
+                    </button>
+                </xpath>
+            </field>
+        </record>
+
+
+
+    </data>
+</openerp>

BIN
static/description/icon.png