跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 新手求助
  4. 新手问题,关于OE6.1rc中POS模块订单确认后对应产品库存没有变化的问题[已解决]

新手问题,关于OE6.1rc中POS模块订单确认后对应产品库存没有变化的问题[已解决]

已定时 已固定 已锁定 已移动 Odoo 新手求助
11 帖子 3 发布者 8.0k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • X 离线
    X 离线
    xuxudodo
    写于 最后由 编辑
    #2

    补充说明下: 6.1RC 是有这个问题的, 但6.1正式版已经修复.

    1 条回复 最后回复
    0
    • mrshellyM 离线
      mrshellyM 离线
      mrshelly
      写于 最后由 编辑
      #3

      Good, 谢谢分享,  建议在贴子里加上一些 tag 标签 以便检索...

      1 条回复 最后回复
      0
      • JoshuaJ 离线
        JoshuaJ 离线
        Joshua 管理员
        写于 最后由 编辑
        #4

        6.1的POS轻触屏界面还是比较简单的,要使用估计开发量不少

        【上海先安科技】(joshua AT openerp.cn),欢迎关注公众号:openerp_cn

        1 条回复 最后回复
        0
        • X 离线
          X 离线
          xuxudodo
          写于 最后由 编辑
          #5

          现附上解决办法, 如果你还在使用6.1RC1的话可以尝试, 6.1正式版已经解决了

          解决办法:
          第一步: 没有修改代码

          第二步: 加了触发器, 即判断当通过POS触摸屏下单后,自动触发生成相应的出入库记录,这样产品的库存数据就减少了.

          先看看相关表

          <br /><br />/*<br />pos触发器实现- 当pos触摸屏下单后,自动出库.<br />*/<br /><br />TABLE pos_order (<br />&nbsp; &nbsp; id integer NOT NULL,<br />&nbsp; &nbsp; create_uid integer,<br />&nbsp; &nbsp; create_date timestamp without time zone,<br />&nbsp; &nbsp; write_date timestamp without time zone,<br />&nbsp; &nbsp; write_uid integer,<br />&nbsp; &nbsp; sale_journal integer NOT NULL,<br />&nbsp; &nbsp; account_move integer,<br />&nbsp; &nbsp; date_order timestamp without time zone,<br />&nbsp; &nbsp; partner_id integer,<br />&nbsp; &nbsp; nb_print integer,<br />&nbsp; &nbsp; user_id integer,<br />&nbsp; &nbsp; name character varying(64) NOT NULL,<br />&nbsp; &nbsp; invoice_id integer,<br />&nbsp; &nbsp; company_id integer NOT NULL,<br />&nbsp; &nbsp; note text,<br />&nbsp; &nbsp; state character varying,<br />&nbsp; &nbsp; shop_id integer NOT NULL,<br />&nbsp; &nbsp; pricelist_id integer NOT NULL,<br />&nbsp; &nbsp; picking_id integer<br />);<br /><br /><br /><br />TABLE pos_order_line (<br />&nbsp; &nbsp; id integer NOT NULL,<br />&nbsp; &nbsp; create_uid integer,<br />&nbsp; &nbsp; create_date timestamp without time zone,<br />&nbsp; &nbsp; write_date timestamp without time zone,<br />&nbsp; &nbsp; write_uid integer,<br />&nbsp; &nbsp; notice character varying(128),<br />&nbsp; &nbsp; product_id integer NOT NULL,<br />&nbsp; &nbsp; order_id integer,<br />&nbsp; &nbsp; price_unit numeric,<br />&nbsp; &nbsp; price_subtotal numeric,<br />&nbsp; &nbsp; company_id integer NOT NULL,<br />&nbsp; &nbsp; price_subtotal_incl numeric,<br />&nbsp; &nbsp; qty numeric,<br />&nbsp; &nbsp; discount numeric,<br />&nbsp; &nbsp; name character varying(32) NOT NULL<br />);<br /><br />TABLE stock_picking (<br />&nbsp; &nbsp; id integer NOT NULL,<br />&nbsp; &nbsp; create_uid integer,<br />&nbsp; &nbsp; create_date timestamp without time zone,<br />&nbsp; &nbsp; write_date timestamp without time zone,<br />&nbsp; &nbsp; write_uid integer,<br />&nbsp; &nbsp; origin character varying(64),<br />&nbsp; &nbsp; address_id integer,<br />&nbsp; &nbsp; date_done timestamp without time zone,<br />&nbsp; &nbsp; min_date timestamp without time zone,<br />&nbsp; &nbsp; date timestamp without time zone,<br />&nbsp; &nbsp; location_id integer,<br />&nbsp; &nbsp; stock_journal_id integer,<br />&nbsp; &nbsp; backorder_id integer,<br />&nbsp; &nbsp; name character varying(64),<br />&nbsp; &nbsp; partner_id integer,<br />&nbsp; &nbsp; move_type character varying NOT NULL,<br />&nbsp; &nbsp; company_id integer NOT NULL,<br />&nbsp; &nbsp; invoice_state character varying NOT NULL,<br />&nbsp; &nbsp; note text,<br />&nbsp; &nbsp; state character varying,<br />&nbsp; &nbsp; location_dest_id integer,<br />&nbsp; &nbsp; max_date timestamp without time zone,<br />&nbsp; &nbsp; auto_picking boolean,<br />&nbsp; &nbsp; type character varying NOT NULL,<br />&nbsp; &nbsp; sale_id integer,<br />&nbsp; &nbsp; purchase_id integer<br />);<br /><br />TABLE stock_move (<br />&nbsp; &nbsp; id integer NOT NULL,<br />&nbsp; &nbsp; create_uid integer,<br />&nbsp; &nbsp; create_date timestamp without time zone,<br />&nbsp; &nbsp; write_date timestamp without time zone,<br />&nbsp; &nbsp; write_uid integer,<br />&nbsp; &nbsp; origin character varying(64),<br />&nbsp; &nbsp; product_uos_qty numeric,<br />&nbsp; &nbsp; address_id integer,<br />&nbsp; &nbsp; product_uom integer NOT NULL,<br />&nbsp; &nbsp; price_unit numeric,<br />&nbsp; &nbsp; date_expected timestamp without time zone NOT NULL,<br />&nbsp; &nbsp; date timestamp without time zone NOT NULL,<br />&nbsp; &nbsp; prodlot_id integer,<br />&nbsp; &nbsp; move_dest_id integer,<br />&nbsp; &nbsp; product_qty numeric NOT NULL,<br />&nbsp; &nbsp; product_uos integer,<br />&nbsp; &nbsp; location_id integer NOT NULL,<br />&nbsp; &nbsp; name character varying(250) NOT NULL,<br />&nbsp; &nbsp; note text,<br />&nbsp; &nbsp; product_id integer NOT NULL,<br />&nbsp; &nbsp; auto_validate boolean,<br />&nbsp; &nbsp; price_currency_id integer,<br />&nbsp; &nbsp; partner_id integer,<br />&nbsp; &nbsp; company_id integer NOT NULL,<br />&nbsp; &nbsp; picking_id integer,<br />&nbsp; &nbsp; priority character varying,<br />&nbsp; &nbsp; state character varying,<br />&nbsp; &nbsp; location_dest_id integer NOT NULL,<br />&nbsp; &nbsp; tracking_id integer,<br />&nbsp; &nbsp; product_packaging integer,<br />&nbsp; &nbsp; sale_line_id integer,<br />&nbsp; &nbsp; purchase_line_id integer,<br />&nbsp; &nbsp; production_id integer<br />);<br /><br />[code]<br /><br /><br />这是第二遍写,重新码字.
          
          1 条回复 最后回复
          0
          • X 离线
            X 离线
            xuxudodo
            写于 最后由 编辑
            #6

            触发器 建立在表 pos_order上

            会影响 表stock_picking ,插入相关记录

            create or replace function pos_order_auto_picking_for_touch() 
            returns trigger as 
                $pos_order_auto_picking_for_touch$ 
                DECLARE
                pos_order_id integer;
                pos_order_create_uid integer;
                pos_order_create_date timestamp;
                pos_order_name character varying(64);
                pos_order_company_id integer;
                pos_order_shop_id integer;
                rec record; 

               
                pos_order_stock_picking_picking_id integer; 
                pos_order_stock_picking_stock_journal_id integer;   
                pos_order_stock_picking_name character varying(64);
                pos_order_stock_picking_name_seq integer;
                BEGIN 
            --stock_picking

            IF (TG_OP = 'INSERT') THEN
            pos_order_id := NEW.id;
            pos_order_create_uid := NEW.create_uid;
            pos_order_create_date := NEW.create_date;
            pos_order_name := NEW.name;
            pos_order_company_id := NEW.company_id;
            pos_order_shop_id := NEW.shop_id;
            /
            length(pos_order_name) < 15  : pos backend
            length(pos_order_name) > 15  : pos
            /
            IF (length(pos_order_name) > 0) THEN
            BEGIN
            --pos_order_stock_picking_name
            SELECT nextval('ir_sequence_016') into pos_order_stock_picking_name_seq;
            select 'OUT/' || to_char( pos_order_stock_picking_name_seq ,'FM09999') into pos_order_stock_picking_name;

            --pos_order_stock_picking_stock_journal_id
            select id from stock_journal into pos_order_stock_picking_stock_journal_id where user_id = pos_order_company_id;

            update pos_order set note = pos_order_stock_picking_name where id = pos_order_id;
            --update pos_order_line set notice = pos_order_stock_picking_name where order_id = pos_order_id;


            INSERT INTO stock_picking (create_uid, create_date, write_date, write_uid, origin, address_id, date_done, min_date, date, location_id, stock_journal_id, backorder_id, name, partner_id, move_type, company_id, invoice_state, note, state, location_dest_id, max_date, auto_picking, type, sale_id, purchase_id)
            VALUES (pos_order_create_uid, pos_order_create_date, pos_order_create_date, pos_order_create_uid, pos_order_name, NULL, pos_order_create_date, pos_order_create_date, pos_order_create_date, NULL, pos_order_stock_picking_stock_journal_id, NULL, pos_order_stock_picking_name, NULL, 'direct', pos_order_company_id, 'none', '', 'done', NULL, pos_order_create_date, true, 'out', NULL, NULL);

            select id from stock_picking into pos_order_stock_picking_picking_id order by id desc limit 1;

            update pos_order set picking_id = pos_order_stock_picking_picking_id where id = pos_order_id;


            END;
            END IF;

            END IF;

            RETURN NULL;
            END; 
            $pos_order_auto_picking_for_touch$  LANGUAGE 'plpgsql' VOLATILE;

            --正式创建触发器trigger --INSERT
            create trigger pos_order_auto_picking_for_touch   
            AFTER insert or update
            on public.pos_order   
            for each row 
            execute procedure pos_order_auto_picking_for_touch();

            1 条回复 最后回复
            0
            • X 离线
              X 离线
              xuxudodo
              写于 最后由 编辑
              #7

              触发器二 建立在表pos_order_line上

              影响表pos_order ,stock_move,或更新或插入相关记录.

              create or replace function pos_order_line_auto_picking_for_touch() 
              returns trigger as 
                  $pos_order_line_auto_picking_for_touch$ 
                  DECLARE
                  pos_order_line_id integer;
                  pos_order_line_create_uid integer;
                  pos_order_line_create_date timestamp;   
                  pos_order_line_product_id integer;
                  pos_order_line_order_id integer;
                  pos_order_line_price_unit numeric;
                  pos_order_line_price_subtotal numeric;
                  pos_order_line_company_id integer ;
                  pos_order_line_price_subtotal_incl numeric;
                  pos_order_line_qty numeric;     
                  pos_order_line_name character varying(32);
                  rec record; 
                 
                  pos_order_line_pos_order_id_name character varying(64);
                  pos_order_line_pos_order_id_picking_id integer; 

                 
                  pos_order_line_product_id_product_uom_id integer; 
                  pos_order_line_product_id_location_id integer;
                  pos_order_line_product_id_location_dest_id integer;
                  pos_order_line_product_id_location_dest_id_tmp integer;
                  BEGIN 
              --stock_picking

              IF (TG_OP = 'INSERT') THEN
              pos_order_line_id := NEW.id;
              pos_order_line_create_uid := NEW.create_uid;
              pos_order_line_create_date := NEW.create_date;
              pos_order_line_product_id := NEW.product_id;
              pos_order_line_order_id := NEW.order_id;
              pos_order_line_price_unit := NEW.price_unit;
              pos_order_line_price_subtotal := NEW.price_subtotal;
              pos_order_line_company_id := NEW.company_id;
              pos_order_line_price_subtotal_incl := NEW.price_subtotal_incl;
              pos_order_line_qty := NEW.qty;
              pos_order_line_name := NEW.name;

              --pos_order_line_pos_order_id_name
              select name from pos_order into pos_order_line_pos_order_id_name where id = pos_order_line_order_id;

              IF (length(pos_order_line_pos_order_id_name) > 0) THEN
              BEGIN
              --pos_order_line_pos_order_id_picking_id
              select picking_id from pos_order into pos_order_line_pos_order_id_picking_id where id = pos_order_line_order_id limit 1;

              select uom_id from product_template into pos_order_line_product_id_product_uom_id where id = pos_order_line_product_id limit 1;
              --stock_warehouse
              select lot_stock_id from stock_warehouse into pos_order_line_product_id_location_id where company_id = pos_order_line_company_id limit 1;
              --stock_location
              select lot_output_id from stock_warehouse into pos_order_line_product_id_location_dest_id_tmp where company_id = pos_order_line_company_id limit 1;
              if(pos_order_line_product_id_location_dest_id_tmp is not null) then
              begin
                select chained_location_id from stock_location into pos_order_line_product_id_location_dest_id where id = pos_order_line_product_id_location_dest_id_tmp limit 1;
              end;
              end if;

              if(pos_order_line_product_id_location_dest_id is  null) then
              begin
                select id from stock_location into pos_order_line_product_id_location_dest_id where usage='customer'  limit 1;
              end;
              end if;


              INSERT INTO stock_move (create_uid,  create_date,  write_date,  write_uid,  origin,  product_uos_qty,  address_id,  product_uom,  price_unit,  date_expected ,  date ,  prodlot_id,  move_dest_id,  product_qty,    product_uos,  location_id,  name ,    note , product_id,  auto_validate,  price_currency_id,  partner_id,  company_id,  picking_id,  priority ,  state ,  location_dest_id,  tracking_id,  product_packaging,  sale_line_id,  purchase_line_id,  production_id)
              VALUES (pos_order_line_create_uid, pos_order_line_create_date, pos_order_line_create_date, pos_order_line_create_uid, pos_order_line_pos_order_id_name, pos_order_line_qty, NULL, pos_order_line_product_id_product_uom_id, NULL, pos_order_line_create_date, pos_order_line_create_date, NULL, NULL, pos_order_line_qty, pos_order_line_product_id_product_uom_id, pos_order_line_product_id_location_id, pos_order_line_name, NULL, pos_order_line_product_id, false, NULL, NULL, pos_order_line_company_id, pos_order_line_pos_order_id_picking_id, '1', 'done', pos_order_line_product_id_location_dest_id, NULL, NULL, NULL, NULL, NULL);



              END;
              END IF;

              END IF;

              RETURN NULL;
              END; 
              $pos_order_line_auto_picking_for_touch$  LANGUAGE 'plpgsql' VOLATILE;

              --正式创建触发器trigger --INSERT
              create trigger pos_order_line_auto_picking_for_touch   
              AFTER insert or update
              on public.pos_order_line 
              for each row 
              execute procedure pos_order_line_auto_picking_for_touch();

              1 条回复 最后回复
              0
              • X 离线
                X 离线
                xuxudodo
                写于 最后由 编辑
                #8

                如果再遇到类似的问题,或许这也是一种解决办法,仅供参考.

                1 条回复 最后回复
                0
                • mrshellyM 离线
                  mrshellyM 离线
                  mrshelly
                  写于 最后由 编辑
                  #9

                  嗯. 还是不推荐在数据库上面玩这些....  理论上, 应该可以二次开发, 修改  pos.order 的 create write 方法来实现...

                  1 条回复 最后回复
                  0
                  • X 离线
                    X 离线
                    xuxudodo
                    写于 最后由 编辑
                    #10

                    [quote author=mrshelly link=topic=2743.msg11297#msg11297 date=1338973067]
                    嗯. 还是不推荐在数据库上面玩这些....  理论上, 应该可以二次开发, 修改  pos.order 的 create write 方法来实现...
                    [/quote]

                    确实是这样, 主要当时为了解决这个问题,而又不想去改动代码, 感觉通过数据触发器实现就能解决.

                    所以官方不费吹灰之力,版本升级后就解决了.

                    现在是用不到了,这里只做个记录.

                    1 条回复 最后回复
                    0

                    • 登录

                    • 没有帐号? 注册

                    • 登录或注册以进行搜索。
                    • 第一个帖子
                      最后一个帖子
                    0
                    • 版块
                    • 标签
                    • 热门
                    • 用户
                    • 群组