Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

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



  • 如题所述,在测试OE6.1rc版的POS模块时, 发现:
    1) 在OE 触摸屏 选择商品界面形成的POS单, 下单付款后,对应的产品库存数量没有看到减少;
    2) 在POS后台的订单界面下单付款后,对应的产品库存数量也没有减少.

    我的疑问:
    OE是出于怎样的考虑实现这个模块的;
    另外是否有模式可以选择,当pos订单确认并付款后,对应产品的库存数量也发生变化.

    之前测试过OE5.x的POS模块,没有上述的问题.

    经过初步的分析和测试,通过修改point_of_sale.py中的
    删除
    create_picking中的 下面代码后,可以解决 第二种情况,订单确认付款后,自动形成出库单,产品库存相应减少
    if not order.state=='draft':
                    continue

    请帮忙看看,谢谢!



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



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


  • 管理员

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



  • 现附上解决办法, 如果你还在使用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 />这是第二遍写,重新码字.
    


  • 触发器 建立在表 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();



  • 触发器二 建立在表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();



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



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



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

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

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

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


Log in to reply