瀏覽代碼

commit inicial

Rodney Elpidio Enciso Arias 7 年之前
當前提交
6f9a5156a8
共有 7 個文件被更改,包括 113 次插入0 次删除
  1. 1 0
      __init__.py
  2. 二進制
      __init__.pyc
  3. 19 0
      __openerp__.py
  4. 1 0
      models/__init__.py
  5. 二進制
      models/__init__.pyc
  6. 92 0
      models/pos_order.py
  7. 二進制
      models/pos_order.pyc

+ 1 - 0
__init__.py

@@ -0,0 +1 @@
+from . import models

二進制
__init__.pyc


+ 19 - 0
__openerp__.py

@@ -0,0 +1,19 @@
+{
+    'name': 'Product Pack POS for IngAdhoc',
+    'summary': 'Product packs on POS',
+    'description': """
+This module is extension for INGADHOC's module product_pack that will
+Process product_pack pickings from POS sales.
+     """,
+    'version': '8.0.0.1',
+    'category': 'Point of Sale',
+    'author': 'DVIT.me',
+    'website': 'http://dvit.me',
+    'license': 'AGPL-3',
+    'depends': ['product_pack', 'point_of_sale'],
+    'data': [],
+    'demo': [],
+    'installable': True,
+    'auto_install': True,
+    'application': False,
+}

+ 1 - 0
models/__init__.py

@@ -0,0 +1 @@
+import pos_order

二進制
models/__init__.pyc


+ 92 - 0
models/pos_order.py

@@ -0,0 +1,92 @@
+from openerp import models, fields, api
+from openerp.osv import osv
+from openerp.tools.translate import _
+
+
+class pos_order(models.Model):
+    _inherit = "pos.order"
+
+    def create_picking(self, cr, uid, ids, context=None):
+        ''' Below code will create another picking for packs'''
+        picking_obj = self.pool['stock.picking']
+        partner_obj = self.pool['res.partner']
+        move_obj = self.pool['stock.move']
+        packs_exist = False
+
+        for order in self.browse(cr, uid, ids, context=context):
+            for line in order.lines:
+                if line.product_id.pack:
+                    packs_exist = True
+
+            addr = order.partner_id and partner_obj.address_get(
+                cr, uid, [order.partner_id.id],
+                ['delivery']) or {}
+            picking_type = order.picking_type_id
+            picking_id = False
+            if picking_type and packs_exist:
+                picking_id = picking_obj.create(cr, uid, {
+                    'origin': order.name,
+                    'partner_id': addr.get('delivery', False),
+                    'date_done': order.date_order,
+                    'picking_type_id': picking_type.id,
+                    'company_id': order.company_id.id,
+                    'move_type': 'direct',
+                    'note': order.note or "",
+                    'invoice_state': 'none',
+                }, context=context)
+                self.write(cr, uid, [order.id], {
+                           'picking_id': picking_id}, context=context)
+            location_id = order.location_id.id
+            if order.partner_id:
+                destination_id = order.partner_id.property_stock_customer.id
+            elif picking_type:
+                if not picking_type.default_location_dest_id:
+                    raise osv.except_osv(_('Error!'), _(
+                        'Missing source or destination location for picking type %s. Please configure those fields and try again.' % (picking_type.name,)))
+                destination_id = picking_type.default_location_dest_id.id
+            else:
+                destination_id = partner_obj.default_get(
+                    cr, uid, ['property_stock_customer'],
+                    context=context)['property_stock_customer']
+
+            if packs_exist:
+                for line in order.lines:
+                    if line.product_id.pack:
+                        for pack_line in line.product_id.pack_line_ids:
+
+                            move_list = []
+
+                            move_list.append(move_obj.create(cr, uid, {
+                                'name': pack_line.product_id.name,
+                                'product_uom': pack_line.product_id.uom_id.id,
+                                'product_uos': pack_line.product_id.uom_id.id,
+                                'picking_id': picking_id,
+                                'picking_type_id': picking_type.id,
+                                'product_id': pack_line.product_id.id,
+                                'product_uos_qty': abs(pack_line.quantity * line.qty),
+                                'product_uom_qty': abs(pack_line.quantity * line.qty),
+                                'state': 'draft',
+                                'location_id': location_id if line.qty >= 0 else destination_id,
+                                'location_dest_id': destination_id if line.qty >= 0 else location_id,
+                            }, context=context))
+
+                            if picking_id:
+                                picking_obj.action_confirm(
+                                    cr, uid, [picking_id], context=context)
+                                picking_obj.force_assign(
+                                    cr, uid, [picking_id], context=context)
+                                picking_obj.action_done(
+                                    cr, uid, [picking_id], context=context)
+                            elif move_list:
+                                move_obj.action_confirm(
+                                    cr, uid, move_list, context=context)
+                                move_obj.force_assign(
+                                    cr, uid, move_list, context=context)
+                                move_obj.action_done(
+                                    cr, uid, move_list, context=context)
+
+        '''this call will create pickings for normal products'''
+        super(pos_order, self).create_picking(
+            cr, uid, ids, context=context)
+
+        return True

二進制
models/pos_order.pyc